跳到正文
cccskills
免费在 GitHub 公开

bio-ecological-genomics-biodiversity-metrics

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).

中文简介正在准备中。当前显示原文说明。

实测评分 未实测

查看安装方法

包含的文件(4)

  • SKILL.md9.0 KB
  • examples/beta_partitioning.R4.0 KB
  • examples/inext_diversity.R2.8 KB
  • usage-guide.md4.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Version Compatibility

Reference examples tested with: ggplot2 3.5+, vegan 2.6+

Before using code patterns, verify installed versions match. If versions differ:

  • R: packageVersion('<pkg>') then ?function_name to verify parameters

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

Biodiversity Metrics

"Calculate species diversity for my ecological samples" → Compute Hill number diversity (richness, Shannon, Simpson) with coverage-based rarefaction/extrapolation using iNEXT, and partition beta diversity into turnover and nestedness components with betapart.

  • R: iNEXT::iNEXT() for coverage-based rarefaction and extrapolation
  • R: betapart::beta.multi() for beta diversity partitioning

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)NameSensitivityEquivalent Index
q = 0Species richnessRare species onlyS (species count)
q = 1Shannon diversityEqual weight allexp(H') Shannon exponential
q = 2Simpson diversityDominant species1/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

Goal: Compare diversity across assemblages standardized by sampling completeness rather than sample size.

Approach: Run iNEXT coverage-based rarefaction/extrapolation for Hill numbers q=0,1,2 and visualize with ggiNEXT.

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: named list of species abundance vectors per site
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(200, 10, 5, 2, 1, 1, 1)
)

# q=c(0,1,2): compute all three Hill numbers
# datatype='abundance': raw counts (use 'incidence_freq' for detection/non-detection)
# nboot=200: bootstrap replicates for confidence intervals
result <- iNEXT(abundance_data, q = c(0, 1, 2), datatype = 'abundance', nboot = 200)

# Rarefaction/extrapolation curves
ggiNEXT(result, type = 1) + theme_bw()

# Sample completeness profiles (coverage vs sample size)
ggiNEXT(result, type = 2) + theme_bw()

# Coverage-based rarefaction curves (diversity vs coverage)
ggiNEXT(result, type = 3) + theme_bw()

Point Estimates at Standardized Coverage

Goal: Estimate diversity at a common coverage level for fair cross-site comparison.

Approach: Use estimateD with a target coverage of 0.95 to produce standardized Hill number estimates.

# Estimate diversity at a common coverage level
# coverage=0.95: typical target for adequate sampling
# 0.95 means 95% of individuals in the community belong to detected species
est <- estimateD(abundance_data, datatype = 'abundance',
                 base = 'coverage', level = 0.95)
est

Asymptotic Diversity Estimation

Goal: Estimate true community diversity if sampling were complete.

Approach: Extract asymptotic estimates (Chao1, Chao-Shannon, Chao-Simpson) from iNEXT output.

# Chao1 (q=0), Chao-Shannon (q=1), Chao-Simpson (q=2)
# Asymptotic = estimated true diversity if sampling were complete
asymptotic <- iNEXT(abundance_data, q = c(0, 1, 2), datatype = 'abundance')
asymptotic$AsyEst

iNEXT.3D: Taxonomic, Phylogenetic, and Functional Diversity

Goal: Compute diversity across three dimensions: taxonomic, phylogenetic (Faith's PD generalized), and functional (trait space).

Approach: Use iNEXT3D with appropriate diversity facet and supplementary data (phylogenetic tree or trait distance matrix).

library(iNEXT.3D)

# Taxonomic diversity (TD) - standard Hill numbers
td <- iNEXT3D(abundance_data, diversity = 'TD', q = c(0, 1, 2), datatype = 'abundance')

# Phylogenetic diversity (PD) - requires ultrametric tree
# PD generalizes Faith's PD via Hill numbers on branch lengths
pd <- iNEXT3D(abundance_data, diversity = 'PD', q = c(0, 1, 2),
              datatype = 'abundance', PDtree = phylo_tree)

# Functional diversity (FD) - requires species distance matrix
# FD captures trait space coverage via Hill numbers
fd <- iNEXT3D(abundance_data, diversity = 'FD', q = c(0, 1, 2),
              datatype = 'abundance', FDdistM = trait_dist_matrix, FDtype = 'AUC')

Classic Diversity with vegan

Goal: Calculate standard alpha diversity indices and rarefaction curves from a community matrix.

Approach: Compute Shannon, Simpson, and inverse Simpson indices with vegan::diversity, then rarefy to the minimum sample size.

library(vegan)

# community_matrix: sites (rows) x species (columns)
richness <- specnumber(community_matrix)
shannon <- diversity(community_matrix, index = 'shannon')
simpson <- diversity(community_matrix, index = 'simpson')
invsimpson <- diversity(community_matrix, index = 'invsimpson')

# Classic rarefaction to minimum sample size
# Rarefies to the smallest sample, discarding extra reads
raremin <- min(rowSums(community_matrix))
rarecurve(community_matrix, step = 20, sample = raremin)
rare_richness <- rarefy(community_matrix, sample = raremin)

Beta Diversity Partitioning with betapart

Goal: Decompose total beta diversity into turnover (species replacement) and nestedness (richness difference) components.

Approach: Apply betapart pairwise and multi-site decomposition on presence/absence and abundance matrices using Sorensen, Jaccard, and Bray-Curtis families.

Decomposes total beta diversity (Sorensen or Jaccard) into turnover (species replacement) and nestedness (richness difference) components:

library(betapart)

# Presence/absence matrix required
pa_matrix <- ifelse(community_matrix > 0, 1, 0)

# --- Pairwise decomposition ---
# Sorensen family: beta.sim (turnover) + beta.sne (nestedness) = beta.sor (total)
pair_sor <- beta.pair(pa_matrix, index.family = 'sorensen')
pair_sor$beta.sim   # turnover component
pair_sor$beta.sne   # nestedness component
pair_sor$beta.sor   # total beta diversity

# Jaccard family: beta.jtu (turnover) + beta.jne (nestedness) = beta.jac (total)
pair_jac <- beta.pair(pa_matrix, index.family = 'jaccard')

# --- Multi-site decomposition ---
multi <- beta.multi(pa_matrix, index.family = 'sorensen')
multi$beta.SIM   # multi-site turnover
multi$beta.SNE   # multi-site nestedness
multi$beta.SOR   # multi-site total

# --- Abundance-based beta diversity ---
pair_abund <- beta.pair.abund(community_matrix, index.family = 'bray')
pair_abund$beta.bray.bal   # balanced variation (analogous to turnover)
pair_abund$beta.bray.gra   # abundance gradient (analogous to nestedness)

Interpreting Beta Diversity Components

DominanceEcological Meaning
Turnover >> NestednessSpecies replacement along gradients; distinct communities
Nestedness >> TurnoverPoor sites are subsets of rich sites; nested pattern
Both similarMixed processes driving community differences

Visualization

Goal: Visualize the relative contribution of turnover vs nestedness to total beta diversity.

Approach: Plot turnover proportion against total beta diversity for each site pair using ggplot2.

library(ggplot2)

# Beta diversity triangle plot (turnover vs nestedness proportions)
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

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Workflow for read alignment, sorting, indexing, mapping statistics, and downstream-ready alignment artifacts.

中文简介正在准备中。当前显示原文说明。

BioTender-max/awesome-bio-agent-skills2042026年7月2日 更新

alphafold

免费

Validate protein designs using AlphaFold2 structure prediction. Use this skill when: (1) Validating designed sequences fold correctly, (2) Predicting binder-target complex structures, (3) Calculating confidence metrics (pLDDT, pTM, ipTM), (4) Self-consistency validation of designs, (5) Multi-chain complex prediction with AlphaFold-Multimer. For faster single-chain prediction, use esm. For QC thresholds, use protein-qc.

中文简介正在准备中。当前显示原文说明。

BioTender-max/awesome-bio-agent-skills2042026年7月2日 更新

AlphaFold2 / AlphaFold-Multimer structure prediction for validation and confidence scoring. Use this skill when: (1) Validating designed sequences fold correctly, (2) Predicting binder-target complex structures, (3) Calculating confidence metrics (pLDDT, pTM, ipTM), (4) Self-consistency validation of designs, (5) Multi-chain complex prediction with AlphaFold-Multimer. For faster single-chain prediction, use esm2-sequence-scoring. For QC thresholds, use protein-design-qc.

中文简介正在准备中。当前显示原文说明。

BioTender-max/awesome-bio-agent-skills2042026年7月2日 更新

Workflow for event-level and isoform-level splicing analysis with sashimi-ready outputs and splice QC.

中文简介正在准备中。当前显示原文说明。

BioTender-max/awesome-bio-agent-skills2042026年7月2日 更新

atac-seq

免费

ATAC-seq processing with assay QC, MACS3 peak calling, consensus peak matrices, differential accessibility, and motif or footprint follow-up.

中文简介正在准备中。当前显示原文说明。

BioTender-max/awesome-bio-agent-skills2042026年7月2日 更新

bindcraft

免费

End-to-end binder design using BindCraft hallucination. Use this skill when: (1) Designing protein binders with built-in AF2 validation, (2) Running production-quality binder campaigns, (3) Using different design protocols (fast, default, slow), (4) Need joint backbone and sequence optimization, (5) Want high experimental success rate. For backbone-only generation, use rfdiffusion. For QC thresholds, use protein-qc. For tool selection guidance, use binder-design.

中文简介正在准备中。当前显示原文说明。

BioTender-max/awesome-bio-agent-skills2042026年7月2日 更新

查看 BioTender-max 的全部技能

报告此技能的问题