How to create a mean relative abundance barplot for a grouping factor.

My query relates to the use of feature-table group prior to creating a barplot.
If I use --p-mode sum (or mean-ceiling) all sample frequencies in a group are aggregated.

If I have features with low prevalence but high frequencies (perhaps in samples with large numbers of total reads) and the feature table is not normalized, simply summing or averaging the frequencies will skew the group proportions in the barplot.

What I want is to convert the feature table to relative abundance and then apply the mean-ceiling to this table. Unfortunately, a relative abundance table is not compatible with feature-table group.


Hi @D629497,

Welcome to the :qiime2: forum!

A couple of thoughts and observations. First, it's relatively rare that I see a super low abundance (below 1/(my rarefaction depth)) with high prevalence. So, prevelence filtering is often suffecient. That said, there's a brand new filter-features-conditionally function in q2-feature-table that filters features based on abundance and prevalence and might sit your needs.

A second thing to consider is whether you truly need to present all your data as a stacked barchart. I sit firmly in the "no" camp and experience no small measure of frustration that QIIME doesn't support this easily. The average non-colorblind adult human can distinguish between about 8 and 16 colors and 16 is really pushing it. Happily or coincidently, in many microbiome analyses, you can often threshold at 1% or 5% average relative abundance overall and find the exact same thing. (Milage may vary based on environment type, but like - mouth, gut, vaginal of adults). I dont know that you can do that filtering automagically :sparkles: in QIIME, but it's a note for... somewhere.

I think the fact that you can't collapse on the relative abundance semantic type is sort of weird; maybe @thermokarst can address that decision, or maybe we should open an issue.


1 Like

Great question, @jwdebelius!

The feature-table collapse method predates our machinery for "matching" output types to input types (via TypeMap and TypeMatch) - at this point it is just a matter of updating the signature of the method to use TypeMatch, and then we are all set.


1 Like

Cool @thermokarst, I’ll open an issue on GitHub:

1 Like

@jwdebelius thanks for pointing out the filter-features-conditionally function and posting on github.

Also, sometimes, for instance constructing heat maps, i’d like to restrict to the top 100 species based on relative abundance.

Best Wishes

Hi @D629497,

You can want to look at our pretty extensive filtering tutorial. It doesn’t cover conditional filtering or all the cases, but it may get you started.



This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.