How can I get lefse output for a single taxonomy level (e.g. species) only?

Hi dc-
You can also run something like:
for MetaPhlAn3 output on the command line

$  grep -E "s__|clade" merged_abundance_table.txt | sed 's/^.*s__//g' | cut -f1,3-8 | sed -e 's/clade_name/body_site/g' > merged_abundance_table_species.txt

or
For MetaPhlAn2 output

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

To produce feature tables that only have the species level results. Both commands are from the MetaPhlAn tutorials: https://github.com/biobakery/biobakery/wiki/metaphlan2; https://github.com/biobakery/biobakery/wiki/metaphlan3 - this will give you more information on what exactly those commands are doing.

1 Like