科研 Skill
生态多样性群落分析
ecological-diversity-analysis
Computes community-ecology diversity metrics and ordination: Shannon/Simpson indices, rarefaction, NMDS/PCoA, PERMANOVA. Use when analyzing species-by-site community composition data.
SKILL.md
Ecological Diversity and Community Analysis
Purpose
Covers the standard quantitative-ecology workflow for analyzing a
species-by-site (or species-by-sample) community matrix: computing
alpha-diversity indices, comparing diversity across sites with
rarefaction, ordinating community composition to visualize
similarity between samples, and testing whether groups of samples
differ statistically (PERMANOVA/ANOSIM). This is the standard
toolkit behind community ecology, conservation biology, and
environmental monitoring studies (e.g., comparing biodiversity across
habitats, before/after a disturbance, or along an environmental
gradient) — a gap in a skill set that otherwise only covers
species-occurrence download and distribution modeling (see
gbif-biodiversity), not the follow-on community-level statistics.
Use when a dataset already has site x species abundance or presence/absence counts and the next step is quantifying and comparing biodiversity patterns, not downloading new occurrence records.
When to Use
- Have a sites x species abundance/count matrix and need diversity indices, rarefaction curves, or richness estimates.
- Need to test whether community composition differs between treatments, habitats, or time points (PERMANOVA, ANOSIM).
- Need to visualize similarity/dissimilarity between samples via ordination (NMDS, PCoA) rather than raw high-dimensional species tables.
- Comparing biodiversity across unevenly sampled sites (different numbers of individuals or samples) — this requires rarefaction, not a direct richness comparison.
Prerequisites
- A tidy site x species matrix (rows = sites/samples, columns = species, values = abundance or presence/absence).
- Python:
scikit-bio,pandas,numpy,scipy; for ordination and PERMANOVA,scikit-bio'sdiversity,stats.distancemodules, or Python port equivalents of R'svegan. R: theveganpackage is the field-standard reference implementation (install.packages("vegan")) and is recommended when exact parity with published ecology methods matters.
Workflow
1. Compute alpha diversity (within-sample)
from skbio.diversity import alpha_diversity
import pandas as pd
counts = site_species_df.values # rows = sites, cols = species
sample_ids = site_species_df.index
shannon = alpha_diversity("shannon", counts, ids=sample_ids)
simpson = alpha_diversity("simpson", counts, ids=sample_ids)
richness = alpha_diversity("observed_otus", counts, ids=sample_ids)
- Richness (number of species observed) is highly sensitive to sampling effort — never compare raw richness across sites with different total abundance/sample sizes without rarefying first.
- Shannon (
H') weights by both richness and evenness; Simpson (1 - D) is more weighted toward dominant species and less sensitive to rare species than Shannon — report which index is used and why, since they can rank sites differently. - Pielou's evenness =
H' / log(richness), useful to separate "many species but one dominant" from "many species, evenly abundant" communities with similar Shannon values.
2. Rarefaction for fair comparison across sampling effort
from skbio.diversity.alpha import sobs
import numpy as np
def rarefy(counts_row, depth, n_iter=100, seed=0):
rng = np.random.default_rng(seed)
results = []
total = counts_row.sum()
species_idx = np.repeat(np.arange(len(counts_row)), counts_row)
for _ in range(n_iter):
sample = rng.choice(species_idx, size=depth, replace=False)
results.append(len(np.unique(sample)))
return np.mean(results), np.std(results)
- Rarefy all sites to the same depth (the smallest total count across sites, or a chosen common depth) before comparing richness; report both the rarefied mean and its variability across iterations.
- For presence/absence or detection data with repeat visits,
consider accumulation curves / Chao estimators
(
skbio.diversity.alpha.chao1) instead, which estimate asymptotic richness rather than observed-at-a-given-depth richness. - In R,
vegan::rarefy()andvegan::specaccum()are the standard, well-tested implementations — prefer them over a custom reimplementation when R is available, since subtle bugs in resampling-without-replacement logic are easy to introduce.
3. Ordination (beta diversity visualization)
from skbio.diversity import beta_diversity
from skbio.stats.ordination import pcoa
bc_dm = beta_diversity("braycurtis", counts, ids=sample_ids)
ordination = pcoa(bc_dm)
coords = ordination.samples[["PC1", "PC2"]]
- Bray-Curtis dissimilarity is the standard choice for abundance data; Jaccard for presence/absence data.
- PCoA (principal coordinates analysis) gives an eigenvalue-based
ordination directly from a distance matrix; NMDS
(non-metric multidimensional scaling,
vegan::metaMDSin R, orsklearn.manifold.MDSwithmetric=Falseas an approximation in Python) better preserves rank-order dissimilarity for noisy ecological data and reports a stress value — stress above ~0.2 indicates the chosen number of dimensions does not represent the data well and should be increased or the result interpreted cautiously. - Always report the dissimilarity metric used and, for NMDS, the final stress value alongside the ordination plot.
4. Test group differences (PERMANOVA / ANOSIM)
from skbio.stats.distance import permanova
result = permanova(bc_dm, grouping=site_metadata["treatment"],
permutations=999)
- PERMANOVA (permutational multivariate ANOVA) tests whether group
centroids differ in multivariate space; it is sensitive to
differences in within-group dispersion (heterogeneity), not just
location — run
betadisper/PERMDISP(viavegan::betadisperin R) first to check whether a significant PERMANOVA result reflects a true compositional difference or merely unequal variance between groups. - Use enough permutations (999 is a common default; more for small p-values near a significance threshold) and report the exact p-value and permutation count, not just "p < 0.05."
- ANOSIM is an older alternative with similar logic but is more sensitive to unequal sample sizes between groups; PERMANOVA is generally preferred in current ecological practice.
5. Report conventions
- State the index/metric choices (which alpha-diversity index, which dissimilarity metric) and why, since different metrics can lead to different conclusions about the same data.
- Report rarefaction depth and number of resampling iterations.
- For ordination plots, report the method, distance metric, percent variance explained (PCoA) or stress (NMDS), and sample size per group.
Limitations
- Assumes a clean site x species count/abundance matrix already
exists; taxonomic identification, data cleaning, and occurrence
download are out of scope (pair with
gbif-biodiversityfor sourcing raw occurrence records, or a project's own survey data pipeline). veganin R remains the most complete, field-validated reference implementation for these methods; the Python (scikit-bio) equivalents cover the core methods shown here but have a smaller feature surface (e.g., fewer built-in diversity indices and ordination methods) — for a methods section that must match established ecological literature exactly, cross-check againstvegan.- Does not cover phylogenetic diversity metrics (e.g., Faith's PD, UniFrac) which require a phylogenetic tree as additional input, or functional-trait diversity, which requires a trait matrix.
- PERMANOVA/NMDS results depend on the chosen dissimilarity metric and data transformation (e.g., Hellinger or log transforms for abundance data with many zeros); these choices should be justified, not defaulted blindly.
Quality Checklist
- Alpha-diversity comparisons across sites use rarefied values (or an asymptotic estimator), not raw counts, when sampling effort differs.
- Dissimilarity metric (Bray-Curtis, Jaccard, etc.) stated and appropriate for the data type (abundance vs. presence/absence).
- NMDS stress value (if used) reported and checked against conventional thresholds (<0.2 acceptable, <0.1 good).
- PERMANOVA accompanied by a dispersion check (betadisper/ PERMDISP) before interpreting group differences as compositional.
- Permutation count and exact p-values reported.
示例提示词
我有样方物种计数矩阵,帮我算多样性指数并做NMDS排序和PERMANOVA检验。
所属插件
安装该插件会一并获得同领域的 18 个 Skill / MCP。
同插件的其他科研 Skill
- OpenAQ空气质量分析Accesses OpenAQ air quality data (PM2.5, O3, NO2), runs spatial interpolation, health exposure indices, city comparisons. Use for air pollution monitoring and exposure analysis.
- Copernicus气候数据下载Downloads climate/weather data from the Copernicus Climate Data Store (ERA5, seasonal forecasts) via cdsapi, covering API setup and request splitting. Use for any CDS/ECMWF download.
- 气候趋势检验分析Runs climate trend analysis: Mann-Kendall test, Sen’s slope, extreme indices (RX1day, R10mm), percentile thresholds, IPCC-style figures. Use to detect and visualize climate trends.
- ERA5再分析气候数据Downloads and analyzes ERA5 reanalysis data via the Copernicus CDS API: anomalies, trends, publication-quality climate maps. Use for ERA5-specific climate analysis end to end.
- GBIF物种分布建模Queries GBIF occurrence records, applies spatial thinning, and fits species distribution models (MaxEnt, BRT) with pygbif/geopandas/elapid. Use for occurrence and habitat-suitability analysis.
- 综合地理空间科学分析Covers broad geospatial workflows: satellite imagery, vector/raster GIS, spatial ML, point clouds, cloud-native formats (STAC, COG). Use as a general entry point for remote sensing or GIS tasks.
- GeoPandas矢量GIS分析Performs vector GIS analysis with GeoPandas: spatial joins, overlays, buffer/dissolve, choropleth maps, rasterio integration. Use for vector spatial analysis and raster-vector workflows.
- DEM水文地貌分析Runs DEM-based hydrological analysis with pysheds: watershed delineation, flow direction/accumulation, stream networks, runoff estimation. Use for terrain-driven hydrology modeling.
- 海洋碳酸盐化学Computes seawater carbonate chemistry with PyCO2SYS: pH, pCO2, aragonite/calcite saturation, air-sea CO2 flux. Use for ocean carbon-cycle and acidification analysis.
- MetPy大气探空分析Performs atmospheric analysis with MetPy/Siphon: downloads NWP data, plots skew-T log-P diagrams, computes CAPE/CIN, builds synoptic composites. Use for weather-sounding meteorology analysis.
- 地震波形数据处理Analyzes seismological data with ObsPy: waveform download, filtering, P/S phase picking, moment magnitude, spectral analysis. Use for earthquake and seismic-waveform analysis.
- 海洋再分析数据分析Downloads and analyzes oceanographic data from Copernicus Marine Service and Argo floats with gsw/xarray: mixed layer depth, eddy kinetic energy, T-S diagrams. Use for physical oceanography.
- 物理海洋学论文绘图绘制物理海洋学论文图:区域/全球/极地地图、多面板、垂向剖面、Hovmöller图、cmocean配色与期刊版式。投稿级海洋学图件排版和配色时使用。
- 种群动态建模Models population dynamics with logistic/exponential growth, Lotka-Volterra, matrix population models, mark-recapture abundance estimation. Use for quantitative population ecology.
- QGIS自动化地理处理Drives QGIS (PyQGIS, processing, GDAL) for GIS/remote sensing tasks: raster/vector ops, spectral indices, reprojection, zonal statistics, map layouts. Use for any QGIS-based geospatial task.
- 多光谱遥感影像处理Reads, reprojects, and analyzes multispectral GeoTIFF imagery with rioxarray/rasterio: NDVI/EVI, cloud masking, mosaicking, Cloud-Optimized GeoTIFF export. Use for raster remote-sensing processing.
- Google Earth Engine卫星分析Runs Google Earth Engine satellite analysis with geemap/ee: NDVI time series, land-cover classification, change detection, GeoTIFF export. Use for cloud-based large-scale satellite analysis.
常见问题
生态多样性群落分析能做什么?
Computes community-ecology diversity metrics and ordination: Shannon/Simpson indices, rarefaction, NMDS/PCoA, PERMANOVA. Use when analyzing species-by-site community composition data。
如何安装生态多样性群落分析?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「生态多样性群落分析」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
生态多样性群落分析需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
生态多样性群落分析经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。