Discrepancies in Shannon Index Calculations Between QIIME2 and vegan R Package

Hi QIIME2 Team,

I've encountered some discrepancies when calculating the Shannon index using two different methods: QIIME2 and the diversity function from the R package vegan. I followed the "Moving Pictures" tutorial to compute the Shannon index in QIIME2 with the following command:

qiime diversity alpha-group-significance \
  --i-alpha-diversity shannon_vector.qza \
  --m-metadata-file metadata.txt \
  --o-visualization shannon-group-significance.qzv

This was done after applying the core-metrics-phylogenetic method. However, when I attempted to calculate the Shannon index using the vegan package in R, I found that the results were different, and the significance between groups was inconsistent.

I understand that the two methods might use different bases for their calculations, such as base 2 for QIIME2 and base e for vegan. Even after converting the results to a common base, the discrepancy remains unclear.

Additionally, I've noticed that the values for corresponding samples are significantly different. For instance, QIIME2 yielded values of 7.02, 7.68, and 6.96, while vegan provided 3.60, 5.07, and 4.77.

I also considered the downsampling performed in the core-metrics-phylogenetic method and tried the following command:

qiime diversity alpha \
  --i-table table.qza \
  --p-metric shannon \
  --o-alpha-diversity shannon_vector.qza

Unfortunately, this did not resolve the issue.

I'm curious to know what might be causing these differences and how I can reconcile the results.

Best,
Bella

Hello @Bella,

What version of qiime2 are you using? Which R function did you use? Were the input tables to each method the same?

Hello @colinvwood,

I'm using QIIME2 version q2cli 2024.5.0 and have computed the Shannon index using the diversity() function from the vegan package. Upon verification, I've confirmed that the input tables for both diversity() and qiime diversity alpha are indeed the same.

Hello @Bella,

Using a QIIME2 2024.5 amplicon environment and running qiime diversity alpha with --p-metric shannon and vegan::diversity with base = 2 on the feature table from the moving pictures tutorial yield the same per-sample vector of diversity indices for me. Perhaps you could retrace your steps and see if you overlooked something?

1 Like