| name | bio-ecological-genomics-biodiversity-metrics |
| description | Calculates species richness, diversity, and turnover using the Hill number framework with iNEXT coverage-based rarefaction/extrapolation, asymptotic diversity estimation, and beta diversity partitioning (betapart turnover vs nestedness). Compares assemblages using coverage-standardized rather than size-standardized rarefaction. Use when quantifying biodiversity from species abundance or incidence data, comparing diversity across sites, or constructing rarefaction curves. Not for clinical 16S microbiome alpha/beta diversity (see microbiome/diversity-analysis). |
| tool_type | r |
| primary_tool | iNEXT |
Biodiversity Metrics
Calculates alpha diversity using Hill numbers, coverage-based rarefaction/extrapolation, and beta diversity partitioning into turnover and nestedness components.
Hill Numbers Framework
Hill numbers unify diversity indices into a single parametric family controlled by order q:
| Order (q) | Name | Sensitivity | Equivalent Index |
|---|
| q = 0 | Species richness | Rare species only | S (species count) |
| q = 1 | Shannon diversity | Equal weight all | exp(H') Shannon exponential |
| q = 2 | Simpson diversity | Dominant species | 1/D Simpson inverse |
Higher q values downweight rare species. q = 1 weights species by frequency and is the most balanced measure.
iNEXT Coverage-Based Rarefaction
Coverage-based rarefaction standardizes by completeness rather than sample size, enabling fair comparison of assemblages sampled with different effort (Chao & Jost 2012).
library(iNEXT)
abundance_data <- list(
site_A = c(100, 45, 23, 12, 8, 5, 3, 2, 1, 1),
site_B = c(80, 60, 40, 30, 20, 15, 10, 8, 5, 3, 2, 1),
site_C = c
result iNEXTabundance_data q datatype nboot
ggiNEXTresult type theme_bw
ggiNEXTresult type theme_bw
ggiNEXTresult type theme_bw
Point Estimates at Standardized Coverage
est <- estimateD(abundance_data, datatype = 'abundance',
base = 'coverage', level = 0.95)
est
Asymptotic Diversity Estimation
asymptotic <- iNEXT(abundance_data, q = c(0, 1, 2), datatype = 'abundance')
asymptotic$AsyEst
iNEXT.3D: Taxonomic, Phylogenetic, and Functional Diversity
library(iNEXT.3D)
td <- iNEXT3D(abundance_data, diversity = 'TD', q = c(0, 1, 2), datatype = 'abundance')
pd <- iNEXT3D(abundance_data, diversity = 'PD', q = c(0, 1, 2),
datatype = 'abundance', PDtree = phylo_tree)
fd <- iNEXT3D(abundance_data, diversity = 'FD', q
datatype FDdistM trait_dist_matrix FDtype
Classic Diversity with vegan
library(vegan)
richness <- specnumber(community_matrix)
shannon <- diversity(community_matrix, index = 'shannon')
simpson <- diversity(community_matrix, index = 'simpson')
invsimpson <- diversity(community_matrix, index = 'invsimpson')
raremin <- min(rowSums(community_matrix))
rarecurve(community_matrix, step = 20, sample = raremin)
rare_richness <- rarefy(community_matrix, sample = raremin)
Beta Diversity Partitioning with betapart
Decomposes total beta diversity (Sorensen or Jaccard) into turnover (species replacement) and nestedness (richness difference) components:
library(betapart)
pa_matrix <- ifelse(community_matrix > 0, 1, 0)
pair_sor <- beta.pair(pa_matrix, index.family = 'sorensen')
pair_sor$beta.sim
pair_sor$beta.sne
pair_sor$beta.sor
pair_jac <- beta.pair(pa_matrix, index.family = 'jaccard')
multi <- beta.multi(pa_matrix, index.family = 'sorensen')
multi$beta.SIM
multi$beta.SNE
multi$beta.SOR
pair_abund <- beta.pair.abundcommunity_matrix index.family
pair_abundbeta.bray.bal
pair_abundbeta.bray.gra
Interpreting Beta Diversity Components
| Dominance | Ecological Meaning |
|---|
| Turnover >> Nestedness | Species replacement along gradients; distinct communities |
| Nestedness >> Turnover | Poor sites are subsets of rich sites; nested pattern |
| Both similar | Mixed processes driving community differences |
Visualization
library(ggplot2)
beta_df <- data.frame(
turnover = as.vector(pair_sor$beta.sim),
nestedness = as.vector(pair_sor$beta.sne),
total = as.vector(pair_sor$beta.sor)
)
beta_df$turn_prop <- beta_df$turnover / beta_df$total
ggplot(beta_df, aes(x = total, y = turn_prop)) +
geom_point(alpha = 0.5) +
geom_hline(yintercept = 0.5, linetype = 'dashed') +
labs(x = 'Total beta diversity (Sorensen)',
y = 'Turnover proportion'
theme_bw
Related Skills
- edna-metabarcoding - Generate species tables from eDNA data
- community-ecology - Constrained ordination of assemblages
- microbiome/diversity-analysis - 16S microbiome diversity metrics
- data-visualization/ggplot2-fundamentals - Customize diversity plots