R code for analyses in "Stoichiometric responses of detritivores vs carnivores across Brazil"
Authors/Creators
Description
This Zenodo record contains all R scripts and workflow files used to reproduce the analyses presented in the manuscript “Stoichiometric responses of detritivores vs carnivores across Brazil.” The scripts implement the full analytical pipeline, including data preparation, stoichiometric trait modeling, multivariate niche analyses, and community- and richness-level summaries.
The code is designed to be used together with the associated Dryad data package (survey_invertebrates.csv and survey_autotrophs.csv), available at DRYAD: DOI: 10.5061/dryad.rjdfn2zrd.
Together, the Zenodo code archive and Dryad data archive enable full reproducibility of all analyses and figures.
Contents
The archive includes the following scripts:
-
Lat_env_model_regressions.R — Multivariate compositional (ALR) models of elemental composition (C, N, P) along latitude, temperature, and algal N:P, including prediction, back-transformation, and coefficient extraction.
-
Ellipses_2D.R — Generation of 2D stoichiometric niche ellipses (N–P, N–C, P–C) along environmental gradients using multivariate normal models.
-
Hypervolume_niche_volume.R — Estimation of stoichiometric niche volume (generalized variance of ALR covariance matrices) along latitude, temperature, and algal N:P.
-
Trophic_boxplots_CV_means.R — Tests and boxplots comparing elemental means and coefficients of variation between carnivores and detritivores at the site level.
-
Community_composition_PERMANOVA.R — Bray–Curtis PERMANOVAs for family- and morphospecies-level community composition for detritivores and carnivores.
-
Richness_vs_environment_stoich_subset.R — Morphospecies richness vs. latitude, MAT, and algal N:P using the stoichiometry-filtered subset.
-
Summary_effects_plots.R — Compact effect-summary figures synthesizing model outputs for latitude, temperature, and algal N:P across all stoichiometric traits.
A README PDF is included summarizing the purpose, inputs, workflow, and outputs of each script.
Software Requirements
All analyses require R (version ≥ 4.2) and the following packages:
-
gamlss2 (from GitHub: gamlss-dev/gamlss2)
-
bamlss
-
ggplot2, patchwork, dplyr, tidyr, purrr, tibble, scales
-
Matrix, MASS, vegan, car, cowplot, ragg
The workflow assumes the data files (from Dryad) are placed in the working directory alongside the scripts.
Reproducibility
Running the scripts in numerical order (starting with Lat_env_model_regressions.R) fully reproduces all figures, tables, and summary statistics reported in the manuscript. No manual preprocessing is required beyond placing the CSV data files in the working directory.
Files
README_Code_Stoichiometric responses of detritivores vs carnivores across Brazil.pdf
Files
(502.9 kB)
| Name | Size | Download all |
|---|---|---|
|
md5:c2652d2f03645803a7b33a2e49ffc268
|
13.3 kB | Download |
|
md5:08ec88cfaf7c5557edbaf36e3200db78
|
29.7 kB | Download |
|
md5:c655841839a0813f5b59ff488e44bc98
|
35.1 kB | Download |
|
md5:7f8dd0e03a467a6f2b03dfbc50a01c76
|
34.2 kB | Download |
|
md5:ac59098edfe782afa606ecfe012a1a39
|
359.3 kB | Preview Download |
|
md5:775c06cc441b56627cdd42435a256fa1
|
7.4 kB | Download |
|
md5:3ac93ff01a419fd43bcc047954d09007
|
9.4 kB | Download |
|
md5:f25ed236e8b35d0874884cff30e4ee28
|
14.5 kB | Download |
Additional details
Dates
- Submitted
-
2025-11-19