Skip to contents

Inverse Simpson alpha diversity metric.

Usage

inv_simpson(counts, cpus = n_cpus())

Arguments

counts

An OTU abundance matrix where each column is a sample, and each row is an OTU. Any object coercible with as.matrix() can be given here, as well as phyloseq, rbiom, SummarizedExperiment, and TreeSummarizedExperiment objects.

cpus

How many parallel processing threads should be used. The default, n_cpus(), will use all logical CPU cores.

Value

A numeric vector.

Details

The Inverse Simpson index is another way to present the information from the Simpson index, but in a more intuitive format. While the standard Simpson index calculates the probability of two randomly selected individuals belonging to the same species (where a lower value means more diversity), the Inverse Simpson index is the reciprocal of that value (1/D). This simple transformation makes the index easier to interpret: the value increases as diversity increases.

The primary advantage of the Inverse Simpson index is that its value can be understood as the "effective number of species". This means a community with an Inverse Simpson index of 10 has a diversity that is equivalent to a community composed of 10 equally abundant species. This provides a more direct and biologically meaningful interpretation compared to more abstract indices. Like the standard Simpson index, it is more heavily weighted by the most abundant species and is less sensitive to sampling depth than richness metrics like Observed Features or Chao1.

Calculation

Pre-transformation: drop all OTUs with zero abundance.

In the formulas below, \(x\) is a single column (sample) from counts. \(p\) are the relative abundances.

$$p_{i} = \displaystyle \frac{x_i}{\sum x}$$ $$D = \displaystyle 1 / \sum_{i = 1}^{n} p_{i}\times\ln(p_{i})$$

  x <- c(4, 0, 3, 2, 6)[-2]
  p <- x / sum(x)
  1 / sum(p * log(p))
  #>  -0.7636352

References

Simpson EH 1949. Measurement of diversity. Nature, 163. doi:10.1038/163688a0

See also

Other alpha_diversity: alpha_div(), beta_div(), chao1(), faith(), observed(), shannon(), simpson()

Examples

    # Example counts matrix
    ex_counts
#>                   Saliva Gums Nose Stool
#> Streptococcus        162  793   22     1
#> Bacteroides            2    4    2   611
#> Corynebacterium        0    0  498     1
#> Haemophilus          180   87    2     1
#> Propionibacterium      1    1  251     0
#> Staphylococcus         0    1  236     1
    
    # Inverse Simpson diversity values
    inv_simpson(ex_counts)
#>   Saliva     Gums     Nose    Stool 
#> 2.029446 1.233425 2.783607 1.013125 
    
    # Low diversity
    inv_simpson(c(100, 1, 1, 1, 1)) # 1.08
#> [1] 1.081168
    
    # High diversity
    inv_simpson(c(20, 20, 20, 20, 20)) # 5
#> [1] 5
    
    # Low richness
    inv_simpson(1:3) # 2.57
#> [1] 2.571429
    
    # High richness
    inv_simpson(1:100) # 75.37
#> [1] 75.37313