Calculating diversity from relative abundance

I’m analyzing shotgun metagenomics data and have read-based relative abundance table (by tools like kraken-braken, metaphlan2 etc). I was wondering if I can use qiime2 to calculate diversity based on relative-abundance table. It seems that some metrics can be calculated from relative abundance (observed OTU, shannon index, Jaccard distance).
Do you know if it should work properly?
Any other suggestions from community members on how to approach it?

Good afternoon,

Yes, this should work fine. The alpha diversity metrics like Shannon and beta diversity metrics like Jaccard will work on any feature-abundance table (regardless if it’s relative abundance, and regardless if it’s amplicon).

Some of the metrics are phylogenetic, namely Faith’s PD and UniFrac. In this case, each feature will have to be placed somewhere on a phylogenetic tree, which is harder for shotgun metagenomics than amplicons, but not impossible.


1 Like

One slight hiccup is the types are currently over-specific. So qiime diversity alpha/beta will want a FeatureTable[Frequency] since that is a “lowest common denominator” for all of the different measures/metrics.

@ChrisKeefe is currently working on cleaning this up by separating each into their own method so that we can have a more refined notion of the available types. In the meanwhile you would need to lie about the type which I don’t strongly recommend, but a deadline is a deadline sometimes.


Have you made any progress on this? We have MetaPhlAn2 data that we would like to calculate alpha diversity.

Thanks, Sarah Highlander TGen North

Hi @shighlander!
q2-diversity-lib will not be officially released until January 2020, but even in its current form it should allow you to calculate common alpha diversity indices from relative frequency data. (FaithPD, Pielou’s Evenness, Shannon’s Entropy, and Observed Features)

The underlying algorithms are the same as those currently used in q2-diversity. q2-diversity-lib just provides a more robust system of semantic type constraints, slightly improved protections against user error, and method-by-method citations.

If you want to give it a shot, you should probably create a fresh QIIME 2 environment named div-lib or something like that. Once you’ve activated the conda environment you want to use, this should install the package for you:

pip install git+

qiime diversity-lib --help will give you a list of available Actions, and qiime diversity-lib [action-name] --help will tell you how to use them.

Good luck, and please let me know if you run into any issues along the way!


Thanks, I’ll give it a try!



Hello, I would like to perform the same calculations, would it be possible to share the commands you used with the q2-diversity plugin to calculate diversity from metaphlan frequency table ?
Thanks a lot

Hi @Francis29029!
q2-diversity does not currently allow the use of relative-frequency data in calculating alpha/beta diversity. Check out my response to shighlander above for instructions on downloading, installing, and getting command-specific help for q2-diversity-lib.

Please note: although I believe all of the tools available in the in-development plugin mentioned above are sound, it has not been officially released yet. Please post to the forum and @mention me if you run into any unexpected issues.



Just an FYI, @shighlander, @Francis29029 - it should now be possible to calculate observed_features, jaccard, and shannon from a FeatureTable[RelativeFrequency] using q2_diversity.alpha.

1 Like