This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to create heatmap for Genus in Metaphlan2?

Hi, I have the following problem:

I have in my hands the file 'merged_abundance_table.txt' and I want to create a heatmap of relative abundance for Genus. How should I rearrange the comand below?

linux@ubuntu:~$ grep -E "(s__)|(^ID)" merged_abundance_table.txt | grep -v "t__" | sed 's/^.*s__//g' > merged_abundance_table_species.txt

Can you help me please?

Thanks

metaphlan2 genome sequencing next-gen

Can you show the first few lines of merged_abundance_table.txt ? ..also, an example of the format you want to produce would help a great deal.

Thanks! Kevin

1 answer

HI Kevin, thanks for the reply. But I had already solved the question. Knowing that it had multiple '.fna', I was able to resolve the issue with the following command sequence:

linux@ubuntu:~$ for f in *.fna; do metaphlan2.py $f --input_type fasta --nproc 4 --tax_lev g > ${f%.fasta.gz}_profile.txt; done

linux@ubuntu:~$ merge_metaphlan_tables.py *_profile.txt > merged_abundance_table.txt

linux@ubuntu:~$ grep -E "(g__)|(^ID)" merged_abundance_table.txt | grep -v "t__" | sed 's/^.*g__//g' > merged_abundance_table_genus.txt

linux@ubuntu:~$ hclust2.py -i merged_abundance_table_genus.txt -o abundance_heatmap_genus.png --ftop 25 --f_dist_f braycurtis --s_dist_f braycurtis --cell_aspect_ratio 0.5 -l --flabel_size 6 --slabel_size 6 --max_flabel_len 100 --max_slabel_len 100 --minv 0.1 --dpi 300

Thank you very much anyway !! :)

Glad that you got it solved.

Best of luck!

Log in to answer this question.