I want to make a barplot using the library fantaxtic (top taxa: Phylum and nested taxa Genus). The problem is that I want to filter Genus by abundance > 2% and the rest of phyla I want to group them in the category Others. Is it posible? Can library Fantaxtic filter by abundance?
I found an answer in this forum suggesting something like that
get_top_taxa(glom_genus, 0.98*nrow(glom_genus@otu_table))
but it is not working for me. I read that get_top_taxa is deprecated.
I'm the author of the package, and I have to disappoint you:
top_taxaonly returns the top N taxa by some metric. This is by design: a plot with too many taxa in it simply becomes unintelligible, and tight control over the number of taxa is therefore required.Luckily, you can apply your own manual filtering and use
fantaxtic::collapse_taxato then create a phyloseq object where all taxa <2% are merged. See the code below for a full example.Note: you need to decide how 2% is calculated: is this a minimum abundance of 2%, a mean abundance of 2%, a summed abundance of 2%, etc. In the example below I used the maximum, and set the cutoff to 10% to prevent overplotting.
In the future, feel free to create an issue in the fantaxtic repository on GitHub; this will ensure that I can quickly and accurately answer your question.
Created on 2023-07-12 by the reprex package (v2.0.1)