pangenome / pggb

the pangenome graph builder
https://doi.org/10.1101/2023.04.05.535718
MIT License
344 stars 38 forks source link

the parameters to build pangenome for metagenomes #337

Open Wenhai-Zhang opened 9 months ago

Wenhai-Zhang commented 9 months ago

Hi, I ran pggb to build pangenomes for 10 bacterial genomes (Ecoli). The command is pggb -i merged.fa.gz -o 10n95p -t 20 -p 95 -n 10 -S -m and it can work well. But i have some confused with the parameters though i have seen the examples in github.

  1. I think -p is important for me to build pangenomes. I would like to share my simple understanding and i don't know whether it is right. If I set the -p parameter to 95, and two segments are aligned with a percent identity of 98, which is higer than 95, does this mean that in this region, one of the segments is randomly retained as the unique segment? I would like to understand how it actually work.

  2. In metagenomes, ANI 95 is used by default to distinguish different species, and ANI 99.9 is used to distinguish different strains. If my previous understand is right, when I build pangenomes for strains in the same species, I want to retain more information, should I set stricter parameter? For example, -p 98 or -p 99.

  3. Is my command set suitable to build the pangenome for the same species?

  4. By the way, have you tried to build pangenomes for a few thousands of bacterial genomes? I would like to know how long it will take approximately?

Perhaps my questions are a bit annoying, but I really need your help. Thank you in advance.

subwaystation commented 9 months ago

Hi @Wenhai-Zhang,

let me try to answer some of your questions, the rest I leave to @AndreaGuarracino.

  1. It really depends on the species you have. Runnig mash triangle will give you a rough indication of how to set parameter p.
  2. You should rather ask the question: Is my command suitable for the given data? Some E. coli are close to each other, some are not so close to each other. You left the default segment length, which I also did with E. coli. Maybe you even to to try -p 90. If you go -p 98 while having a divergent set of sequences, you will get underalignments.
  3. I did indeed build a graph from 2146 E. coli. While I will present this in 2 days, you can already take a look at https://docs.google.com/presentation/d/13kOe67brYH4XcsnnuFajdN0g4_vtZCGCk2Xj7DoDclA/edit#slide=id.g28a5cec7b4e_0_34.
Wenhai-Zhang commented 9 months ago

@subwaystation Thank you for quick response and I'm sorry to have time to reply to you now. And thank you for your correct and I'm learning how to express myself better in English.

Runnig mash triangle will give you a rough indication of how to set parameter p.

image I ran the command mash triangle and get the result. Actually the distance between 10 genomes of all E. coli is no more than 0.03, but due to the merging of genomic sequences, some plasmids and contigs are considered separate sequences (paths), which seems to affect distance. This raises a new question, whether it will affect the build of pangenomes, perhaps because I need to try more lenient parameters for this question?

Some E. coli are close to each other, some are not so close to each other.

I know, but as mentioned above, in metagenomes, the ANI of strains from the same specie (such as E.coli) is must greater than 95. That's why I initially set - p 95 for my command. In the next step, I am going to try to map the reads to the pangenome. In order to retain more information and reduce errors, that's why I want to know if I should set stricter parameters.

While I will present this in 2 days, you can already take a look at ...

Thank you very much for sharing the file. This seems not friendly for general server setups. And I have seen that 2146 genomes with plasmids only have 2146 paths, this make me realize that I prabably don not process genomic data correctly. Because I have 10 genomes but I have 17 paths, some plasmids and contigs are considered separate sequences (paths). These is my processing command. Could you share the details of how to handle it?

ls *.fna.gz | while read f; do
    sample_name=$(echo $f | cut -f 1,2 -d '_');
    echo ${sample_name}
    # 'cut -f 1' to trim the headers
    fastix -p "${sample_name}#1#" <(zcat $f | cut -f 1) | bgzip -@ 4 -c > ${sample_name}.fa.gz
done

file_list=$(find /home/wenhai/Desktop/test/pggb_test -name "*.fa.gz" -exec echo -n "{} " \;)
zcat $file_list | bgzip -c -@ 16 > merged.fa.gz
samtools faidx merged.fa.gz