Analyzes how environmental gradients structure species communities using constrained ordination (CCA for unimodal responses, RDA on Hellinger-transformed data for linear responses, db-RDA for arbitrary distances), variance partitioning with adjusted R-squared (Peres-Neto 2006), indicator species analysis with the group-size-equalized IndVal.g form (De Caceres & Legendre 2009), PERMANOVA paired MANDATORILY with PERMDISP dispersion testing since the two confound each other (Anderson & Walsh 2013), Joint Species Distribution Models (HMSC, sjSDM, gjam) with explicit acknowledgement that residual covariance is NOT pure biotic interaction, phylogenetic community ecology with explicit null-model justification (Webb 2002), trait-environment via RLQ + fourth-corner with the corrected modeltype=6 permutation (Dray 2014), bipartite network metrics with Strona 2014 curveball null randomization, and Mantel test replacements (db-RDA conditioned on spatial PCNM eigenvectors, GDM) per Legendre & Fortin 2010.
install.packages('vegan'))install.packages('indicspecies'))install.packages('Hmsc'))install.packages('sjSDM'))install.packages('picante'))install.packages('ade4'))install.packages('adespatial'))install.packages('ggplot2'))Tell your AI agent what you want to do:
"I have a species-by-site abundance matrix and environmental variables. Check DCA axis-1 gradient length first; if > 3 SD use CCA, if < 3 SD use Hellinger-RDA. Apply forward selection, check VIF, and produce a triplot."
"Test community composition differences across my four habitat types with PERMANOVA (adonis2). MANDATORY: also run betadisper to test dispersion heterogeneity. If betadisper is significant, the PERMANOVA conclusion must be qualified (Anderson & Walsh 2013)."
"I have community distances and environmental distances. Don't run Mantel; replace with dbRDA using spatial PCNM eigenvectors as Condition() (Legendre & Fortin 2010). Test marginal environmental effect after partialling out space."
"Fit HMSC for my 200-species community with environmental predictors, traits, phylogeny, and spatial random effect. Report variance partitioning into fixed effects, random effects, traits, and phylogeny. Explicitly disclaim that residual covariance is not pure biotic interaction (Pollock 2014; Poggiato 2021)."
"I have a 2000-ASV community matrix from metabarcoding. HMSC is too slow at this S; use sjSDM with elastic-net regularization (Pichler & Hartig 2021)."
"Find indicator species for each of my four habitat types using
multipattwithfunc='IndVal.g'(NOT 'IndVal' which is biased by group size). Use 999 permutations and report results sorted by p-value."
"Compute SES_MPD and SES_MNTD across my communities with the
taxa.labelsnull model. Then test whether traits track phylogeny with Blomberg's K and Pagel's lambda before interpreting clustering as environmental filtering; cite Mayfield & Levine 2010."
"Test how species traits respond to environmental gradients using RLQ ordination followed by the fourth-corner permutation test with
modeltype=6(Dray 2014). Defaultmodeltype=2/4gives inflated Type I error."
adonis2 (NOT the deprecated adonis) with by='margin' for unbalanced designsbetadisper + permutest alongside PERMANOVA; explicitly report when the location conclusion is confounded by dispersion heterogeneityfunc='IndVal.g' (group-size-corrected) for indicator species; never the basic 'IndVal'modeltype=6 for trait-environment hypothesesadonis2() is the modern PERMANOVA; adonis() was deprecated in vegan 2.6, so tutorials citing adonis() are outdatedby = 'margin' in adonis2 gives the marginal-SS PERMANOVA appropriate for unbalanced designs; by = 'terms' gives sequential SS (the default) which is order-dependentpairwiseAdonis::pairwise.adonis2 with FDR correctionconvertToCodaObject(m) and Gelman-Rubin diagnosticsdevice='cpu' (slower but works)IndVal.g is the group-equalized indicator value; basic IndVal is biased toward larger groups; do not use 'IndVal' for unbalanced designstaxa.labels randomizes which species are in samples (holds richness constant); independentswap preserves both row and column sums; richness randomizes within samples; the choice answers different ecological questionsr2dtable/quasiswap; vegan/bipartite adopted as default circa 2020modeltype=6 (Dray 2014); modeltype=2/4 alone gives inflated Type I error