I have a few large OTU tables of bacterial and viral datasets. The samples are across different sites and times.

I would like to visualise the community 'diversity' across the times for which I have data. For example it would be interesting to see if community diversity peaks in the summer months and falls in the winter months- in a repeating pattern. 

I have not come across much advice or literature which looks at looking at diversity for large OTU datasets. Considering the OTUs are essentially arbitrary and that there are thousands of them, what is the best way to calculate and visualise the each samples diversity?

With the vegan package on R it is quite easy to calculate the Shannon/Simpsons diversity index for an OTU table. Can you simply use this on a 'raw' table of OTUs?

  • $\begingroup$ There are no best way I think. Those indices are different definitions of diversity. I don't think there has been much argument of whether one is of greater of interest for, say conservation purposes or whatever. I think you'll just have to pick one you like! The fact that OTU is a rather arbitrary grouping concept won't change much to the discussion. Note that there are many other indices of diversity (have a look at this answer for a list of measures of diversity) $\endgroup$
    – Remi.b
    Jul 25, 2017 at 21:35
  • $\begingroup$ I don't know much though on this topic and it might be worth having a look at the book Measuring Biological Diversity from Magurran $\endgroup$
    – Remi.b
    Jul 25, 2017 at 21:38

2 Answers 2


I mostly concur with @Nathan's answer, and in particular with the references he provided.

As Shannon & Simpson indices can be hard to interpret and can be non-intuitive, I prefer using Hill diversities as suggested by Nathan (the Jost 2006 and 2007 refs are great to read up on this). The main argument is that Hill diversities give effective number of species that are comparable between samples and follow the duplication principle.

Hill diversities rely on a unified formula (see this wikipedia article) with one parameter, q. Increasing values for q correspond to increasing weighting of taxa abundances in the diversity calculation:

  • D with q=0 does not account for taxon abundance, so is just the number of taxa, or richness
  • D with q=1 is not defined, but asymptotically approximated by e^H where H is the Shannon entropy. D_q1 is the effective number of species with abundance weights.
  • D with q=2 corresponds to the Inverse Simpson index (1/D_Simpson). D_q2 weighs more abundant taxa even more strongly.

One can choose any value for q (with q=1 with the limit e^H), and comparing diversity estimates for varying q can give you an idea of sample evenness. Setting q=∞ gives the Berger-Parker index (the fraction of individuals in the sample belonging to the most abundant species).

Importantly, for alpha div analyses on (16S/18S-based) OTUs, I would always generate rarefaction curves first, and then generate diversity estimates at a common, rarefied number of reads per sample.

You can do most of this using the R package vegan. The phyloseq package provides various alpha div estimates in one command, but no Hill diversities. I've written a few simple functions to perform rarefaction and calculate (rarefied or non-rarefied) Hill diversities from an OTU count table matrix:




The vegan package is suitable for your needs, but you may find you need to use others or code your own functions.

Due to sequencing biases, you shouldn't trust the 'raw' counts of your OTUs (unless you have a good reason to do so—I'm not sure how your OTUs were obtained). Rather, you may consider relativizing your site-by-species matrix. You can do so using the decostand() function.

Then, you can use the diversity() functions to analyze diversity; but you may also consider looking into other approaches to assess local diversity, such as rarefaction and sampling-based approaches, species equivalents and Hill numbers (Hill 1973, Gotelli and Colwell 2001, Jost 2006, 2007). The books by Magurran and McGill (2011) and Legendre and Legendre (2012) are extremely helpful.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .