ecological-agent-skills 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/AGENT_CONTEXT.md +191 -0
  2. package/CATALOG.md +329 -0
  3. package/LICENSE +692 -0
  4. package/README.md +347 -0
  5. package/bin/install.mjs +168 -0
  6. package/docs/comparison-with-alternatives.md +38 -0
  7. package/docs/global-examples-index.md +103 -0
  8. package/docs/repository-statistics.md +101 -0
  9. package/docs/theoretical-foundations.md +188 -0
  10. package/environment.yaml +106 -0
  11. package/examples/community/arctic_tundra_vegetation_example.md +247 -0
  12. package/examples/community/bird_landuse_example.md +63 -0
  13. package/examples/community/phytoplankton_reservoir_example.md +60 -0
  14. package/examples/community/reef_fish_indopacific_example.md +221 -0
  15. package/examples/impact/baci_road_example.md +57 -0
  16. package/examples/impact/ecosystem_services_atlantic_forest.md +83 -0
  17. package/examples/impact/forest_loss_borneo_timeseries_example.md +225 -0
  18. package/examples/occupancy/puma_camera_example.md +61 -0
  19. package/examples/occupancy/snow_leopard_himalayas_example.md +204 -0
  20. package/examples/reproducible/whittaker_biome_sdm_example.md +406 -0
  21. package/examples/sdm/anteater_cerrado_example.md +69 -0
  22. package/examples/sdm/jaguar_amazon_example.md +80 -0
  23. package/examples/sdm/koala_climate_change_example.md +170 -0
  24. package/examples/sdm/wolf_recolonization_europe_example.md +193 -0
  25. package/package.json +43 -0
  26. package/renv.lock +194 -0
  27. package/skills/SKILL_INDEX.json +1020 -0
  28. package/skills/acoustic-monitoring/SKILL.md +163 -0
  29. package/skills/acoustic-monitoring/examples/example-prompts.md +100 -0
  30. package/skills/acoustic-monitoring/examples/temperate_forest_birds_example.md +285 -0
  31. package/skills/acoustic-monitoring/resources/acoustic-indices-reference.md +93 -0
  32. package/skills/acoustic-monitoring/resources/soundscape-ecology-guide.md +90 -0
  33. package/skills/acoustic-monitoring/resources/species-id-tools-comparison.md +89 -0
  34. package/skills/acoustic-monitoring/scripts/batch_species_detection.py +360 -0
  35. package/skills/acoustic-monitoring/scripts/compute_acoustic_indices.R +235 -0
  36. package/skills/acoustic-monitoring/scripts/compute_acoustic_indices.py +374 -0
  37. package/skills/biostatistics-workbench/SKILL.md +140 -0
  38. package/skills/biostatistics-workbench/examples/example-prompts.md +39 -0
  39. package/skills/biostatistics-workbench/resources/effect-size-reference.md +81 -0
  40. package/skills/biostatistics-workbench/resources/glm-family-link-reference.md +47 -0
  41. package/skills/biostatistics-workbench/resources/test-selection-guide.md +93 -0
  42. package/skills/biostatistics-workbench/scripts/glm_pipeline.R +78 -0
  43. package/skills/biostatistics-workbench/scripts/glm_pipeline.py +210 -0
  44. package/skills/camera-trap-processing/SKILL.md +159 -0
  45. package/skills/camera-trap-processing/examples/example-prompts.md +103 -0
  46. package/skills/camera-trap-processing/examples/leopard_serengeti_example.md +231 -0
  47. package/skills/camera-trap-processing/resources/activity-patterns-reference.md +113 -0
  48. package/skills/camera-trap-processing/resources/camtrapR-workflow-guide.md +130 -0
  49. package/skills/camera-trap-processing/resources/detection-event-definition-guide.md +89 -0
  50. package/skills/camera-trap-processing/scripts/estimate_activity.R +169 -0
  51. package/skills/camera-trap-processing/scripts/process_camtrap_data.R +179 -0
  52. package/skills/camera-trap-processing/scripts/process_camtrap_data.py +192 -0
  53. package/skills/community-ecology-ordination/SKILL.md +133 -0
  54. package/skills/community-ecology-ordination/examples/example-prompts.md +35 -0
  55. package/skills/community-ecology-ordination/resources/dissimilarity-metric-guide.md +53 -0
  56. package/skills/community-ecology-ordination/resources/nmds-interpretation-guide.md +104 -0
  57. package/skills/community-ecology-ordination/scripts/__pycache__/community_analysis.cpython-311.pyc +0 -0
  58. package/skills/community-ecology-ordination/scripts/community_analysis.R +143 -0
  59. package/skills/community-ecology-ordination/scripts/community_analysis.py +231 -0
  60. package/skills/ecological-data-foundation/SKILL.md +129 -0
  61. package/skills/ecological-data-foundation/examples/example-prompts.md +40 -0
  62. package/skills/ecological-data-foundation/resources/coordinate-cleaning-flags.md +66 -0
  63. package/skills/ecological-data-foundation/resources/darwin-core-glossary.md +91 -0
  64. package/skills/ecological-data-foundation/resources/data-citation-guide.md +265 -0
  65. package/skills/ecological-data-foundation/resources/gbif-data-citation-guide.md +193 -0
  66. package/skills/ecological-data-foundation/resources/qa-checklist.md +83 -0
  67. package/skills/ecological-data-foundation/scripts/__pycache__/clean_occurrences.cpython-311.pyc +0 -0
  68. package/skills/ecological-data-foundation/scripts/__pycache__/download_from_ebird.cpython-311.pyc +0 -0
  69. package/skills/ecological-data-foundation/scripts/__pycache__/download_from_inat.cpython-311.pyc +0 -0
  70. package/skills/ecological-data-foundation/scripts/__pycache__/download_from_iucn.cpython-311.pyc +0 -0
  71. package/skills/ecological-data-foundation/scripts/__pycache__/download_from_obis.cpython-311.pyc +0 -0
  72. package/skills/ecological-data-foundation/scripts/clean_occurrences.R +230 -0
  73. package/skills/ecological-data-foundation/scripts/clean_occurrences.py +268 -0
  74. package/skills/ecological-data-foundation/scripts/download_from_ebird.R +251 -0
  75. package/skills/ecological-data-foundation/scripts/download_from_ebird.py +364 -0
  76. package/skills/ecological-data-foundation/scripts/download_from_gbif.R +315 -0
  77. package/skills/ecological-data-foundation/scripts/download_from_gbif.py +407 -0
  78. package/skills/ecological-data-foundation/scripts/download_from_inat.R +238 -0
  79. package/skills/ecological-data-foundation/scripts/download_from_inat.py +304 -0
  80. package/skills/ecological-data-foundation/scripts/download_from_iucn.R +273 -0
  81. package/skills/ecological-data-foundation/scripts/download_from_iucn.py +344 -0
  82. package/skills/ecological-data-foundation/scripts/download_from_obis.R +248 -0
  83. package/skills/ecological-data-foundation/scripts/download_from_obis.py +318 -0
  84. package/skills/ecological-impact-assessment/SKILL.md +123 -0
  85. package/skills/ecological-impact-assessment/examples/example-prompts.md +32 -0
  86. package/skills/ecological-impact-assessment/resources/baci-design-guide.md +55 -0
  87. package/skills/ecological-impact-assessment/resources/fragmentation-metrics-reference.md +86 -0
  88. package/skills/ecological-impact-assessment/resources/pressure-index-template.md +78 -0
  89. package/skills/ecological-impact-assessment/resources/study-design-guide.md +168 -0
  90. package/skills/ecological-impact-assessment/scripts/baci_analysis.R +161 -0
  91. package/skills/ecological-impact-assessment/scripts/fragmentation_analysis.py +141 -0
  92. package/skills/ecological-impact-assessment/scripts/power_analysis_baci.R +274 -0
  93. package/skills/ecosystem-services-assessment/SKILL.md +125 -0
  94. package/skills/ecosystem-services-assessment/examples/example-prompts.md +24 -0
  95. package/skills/ecosystem-services-assessment/resources/es-indicator-reference.md +45 -0
  96. package/skills/ecosystem-services-assessment/resources/invest-parameter-guide.md +86 -0
  97. package/skills/ecosystem-services-assessment/resources/rusle-coefficients.md +88 -0
  98. package/skills/ecosystem-services-assessment/scripts/__pycache__/compute_es.cpython-311.pyc +0 -0
  99. package/skills/ecosystem-services-assessment/scripts/compute_es.py +189 -0
  100. package/skills/ecosystem-services-assessment/scripts/tradeoff_analysis.R +161 -0
  101. package/skills/environmental-time-series/SKILL.md +125 -0
  102. package/skills/environmental-time-series/examples/example-prompts.md +33 -0
  103. package/skills/environmental-time-series/resources/anomaly-indices-reference.md +88 -0
  104. package/skills/environmental-time-series/resources/bfast-parameter-guide.md +69 -0
  105. package/skills/environmental-time-series/scripts/__pycache__/recovery_trajectory.cpython-311.pyc +0 -0
  106. package/skills/environmental-time-series/scripts/__pycache__/trend_analysis.cpython-311.pyc +0 -0
  107. package/skills/environmental-time-series/scripts/recovery_trajectory.R +305 -0
  108. package/skills/environmental-time-series/scripts/recovery_trajectory.py +178 -0
  109. package/skills/environmental-time-series/scripts/trend_analysis.R +192 -0
  110. package/skills/environmental-time-series/scripts/trend_analysis.py +184 -0
  111. package/skills/geoprocessing-for-ecology/SKILL.md +123 -0
  112. package/skills/geoprocessing-for-ecology/examples/example-prompts.md +32 -0
  113. package/skills/geoprocessing-for-ecology/resources/crs-reference.md +62 -0
  114. package/skills/geoprocessing-for-ecology/resources/global-predictor-sources.md +331 -0
  115. package/skills/geoprocessing-for-ecology/resources/resampling-methods.md +57 -0
  116. package/skills/geoprocessing-for-ecology/scripts/__pycache__/download_predictors.cpython-311.pyc +0 -0
  117. package/skills/geoprocessing-for-ecology/scripts/download_predictors.R +239 -0
  118. package/skills/geoprocessing-for-ecology/scripts/download_predictors.py +379 -0
  119. package/skills/geoprocessing-for-ecology/scripts/stack_and_extract.R +224 -0
  120. package/skills/geoprocessing-for-ecology/scripts/stack_and_extract.py +172 -0
  121. package/skills/landscape-connectivity/SKILL.md +170 -0
  122. package/skills/landscape-connectivity/examples/example-prompts.md +96 -0
  123. package/skills/landscape-connectivity/examples/jaguar_mesoamerica_corridor_example.md +271 -0
  124. package/skills/landscape-connectivity/resources/circuitscape-parameter-guide.md +155 -0
  125. package/skills/landscape-connectivity/resources/graph-theory-for-ecology.md +134 -0
  126. package/skills/landscape-connectivity/resources/resistance-surface-guide.md +141 -0
  127. package/skills/landscape-connectivity/scripts/connectivity_analysis.py +387 -0
  128. package/skills/landscape-connectivity/scripts/connectivity_metrics.R +274 -0
  129. package/skills/landscape-connectivity/scripts/resistance_surface.R +239 -0
  130. package/skills/model-validation-and-uncertainty/SKILL.md +131 -0
  131. package/skills/model-validation-and-uncertainty/examples/example-prompts.md +30 -0
  132. package/skills/model-validation-and-uncertainty/resources/extrapolation-risk-guide.md +236 -0
  133. package/skills/model-validation-and-uncertainty/resources/metric-selection-guide.md +52 -0
  134. package/skills/model-validation-and-uncertainty/resources/threshold-selection-guide.md +64 -0
  135. package/skills/model-validation-and-uncertainty/scripts/__pycache__/validate_model.cpython-311.pyc +0 -0
  136. package/skills/model-validation-and-uncertainty/scripts/extrapolation_risk.R +315 -0
  137. package/skills/model-validation-and-uncertainty/scripts/validate_model.py +226 -0
  138. package/skills/model-validation-and-uncertainty/scripts/validate_sdm.R +162 -0
  139. package/skills/occupancy-and-detection/SKILL.md +126 -0
  140. package/skills/occupancy-and-detection/examples/example-prompts.md +33 -0
  141. package/skills/occupancy-and-detection/resources/detection-history-format.md +100 -0
  142. package/skills/occupancy-and-detection/resources/occupancy-study-design.md +47 -0
  143. package/skills/occupancy-and-detection/scripts/__pycache__/occupancy_analysis.cpython-311.pyc +0 -0
  144. package/skills/occupancy-and-detection/scripts/occupancy_analysis.R +160 -0
  145. package/skills/occupancy-and-detection/scripts/occupancy_analysis.py +159 -0
  146. package/skills/population-viability-analysis/SKILL.md +161 -0
  147. package/skills/population-viability-analysis/examples/african_elephant_pva_example.md +266 -0
  148. package/skills/population-viability-analysis/examples/example-prompts.md +95 -0
  149. package/skills/population-viability-analysis/resources/extinction-risk-thresholds.md +128 -0
  150. package/skills/population-viability-analysis/resources/matrix-model-guide.md +139 -0
  151. package/skills/population-viability-analysis/resources/sensitivity-elasticity-reference.md +182 -0
  152. package/skills/population-viability-analysis/scripts/matrix_pva.R +258 -0
  153. package/skills/population-viability-analysis/scripts/pva_analysis.py +442 -0
  154. package/skills/population-viability-analysis/scripts/stochastic_pva.R +353 -0
  155. package/skills/predictive-modeling-best-practices/SKILL.md +136 -0
  156. package/skills/predictive-modeling-best-practices/examples/example-prompts.md +58 -0
  157. package/skills/predictive-modeling-best-practices/resources/collinearity-decision-tree.md +65 -0
  158. package/skills/predictive-modeling-best-practices/resources/sampling-bias-correction.md +267 -0
  159. package/skills/predictive-modeling-best-practices/resources/spatial-cv-guide.md +73 -0
  160. package/skills/predictive-modeling-best-practices/scripts/__pycache__/spatial_cv.cpython-311.pyc +0 -0
  161. package/skills/predictive-modeling-best-practices/scripts/collinearity_check.R +112 -0
  162. package/skills/predictive-modeling-best-practices/scripts/spatial_cv.py +182 -0
  163. package/skills/reproducible-ecology-pipeline/SKILL.md +139 -0
  164. package/skills/reproducible-ecology-pipeline/examples/example-prompts.md +35 -0
  165. package/skills/reproducible-ecology-pipeline/resources/directory-structure-template.md +94 -0
  166. package/skills/reproducible-ecology-pipeline/resources/params-yaml-template.yaml +84 -0
  167. package/skills/reproducible-ecology-pipeline/resources/reproducibility-checklist-template.md +66 -0
  168. package/skills/reproducible-ecology-pipeline/scripts/generate_file_manifest.py +110 -0
  169. package/skills/reproducible-ecology-pipeline/scripts/init_project.sh +53 -0
  170. package/skills/spatial-prioritization/SKILL.md +162 -0
  171. package/skills/spatial-prioritization/examples/biodiversity_hotspot_prioritization_example.md +289 -0
  172. package/skills/spatial-prioritization/examples/example-prompts.md +93 -0
  173. package/skills/spatial-prioritization/resources/cost-surface-reference.md +130 -0
  174. package/skills/spatial-prioritization/resources/marxan-vs-prioritizr-comparison.md +125 -0
  175. package/skills/spatial-prioritization/resources/prioritizr-formulation-guide.md +188 -0
  176. package/skills/spatial-prioritization/resources/representation-targets-guide.md +186 -0
  177. package/skills/spatial-prioritization/scripts/prioritization_sensitivity.R +320 -0
  178. package/skills/spatial-prioritization/scripts/run_prioritization.R +336 -0
  179. package/skills/species-distribution-modeling/SKILL.md +139 -0
  180. package/skills/species-distribution-modeling/examples/example-prompts.md +36 -0
  181. package/skills/species-distribution-modeling/resources/algorithm-comparison.md +25 -0
  182. package/skills/species-distribution-modeling/resources/calibration-area-guide.md +71 -0
  183. package/skills/species-distribution-modeling/resources/climate-scenario-preparation.md +170 -0
  184. package/skills/species-distribution-modeling/resources/maxent-calibration-guide.md +211 -0
  185. package/skills/species-distribution-modeling/resources/sdm-checklist.md +37 -0
  186. package/skills/species-distribution-modeling/scripts/predict_distribution.R +236 -0
  187. package/skills/species-distribution-modeling/scripts/predict_distribution.py +286 -0
  188. package/skills/species-distribution-modeling/scripts/prepare_future_layers.R +351 -0
  189. package/skills/species-distribution-modeling/scripts/project_scenarios.R +220 -0
  190. package/skills/species-distribution-modeling/scripts/run_ensemble_sdm.R +99 -0
  191. package/skills/species-distribution-modeling/scripts/sdm_pipeline.py +318 -0
  192. package/skills/species-distribution-modeling/scripts/tune_maxnet.R +344 -0
  193. package/templates/SKILL_TEMPLATE.md +225 -0
  194. package/templates/checklists/data-submission-checklist.md +38 -0
  195. package/templates/checklists/post-analysis-checklist.md +55 -0
  196. package/templates/checklists/pre-analysis-checklist.md +31 -0
  197. package/templates/prompts/debug-skill.md +47 -0
  198. package/templates/prompts/invoke-skill.md +34 -0
  199. package/templates/prompts/invoke-workflow.md +45 -0
  200. package/templates/reports/technical-report-template.md +80 -0
  201. package/templates/scripts/logger_setup.R +79 -0
  202. package/templates/scripts/logger_setup.py +119 -0
  203. package/templates/scripts/params_loader.R +28 -0
  204. package/templates/scripts/params_loader.py +38 -0
  205. package/workflows/analyze-community-structure/WORKFLOW.md +72 -0
  206. package/workflows/analyze-environmental-change/WORKFLOW.md +73 -0
  207. package/workflows/assess-ecological-impact/WORKFLOW.md +75 -0
  208. package/workflows/assess-ecosystem-services/WORKFLOW.md +68 -0
  209. package/workflows/assess-landscape-connectivity/WORKFLOW.md +84 -0
  210. package/workflows/build-fire-risk-map/WORKFLOW.md +79 -0
  211. package/workflows/produce-technical-report/WORKFLOW.md +113 -0
  212. package/workflows/run-camera-trap-occupancy/WORKFLOW.md +87 -0
  213. package/workflows/run-conservation-prioritization/WORKFLOW.md +89 -0
  214. package/workflows/run-multispecies-screening/WORKFLOW.md +197 -0
  215. package/workflows/run-occupancy-analysis/WORKFLOW.md +74 -0
  216. package/workflows/run-population-viability/WORKFLOW.md +90 -0
  217. package/workflows/run-sdm-study/WORKFLOW.md +99 -0
@@ -0,0 +1,63 @@
1
+ # Worked Example: Bird Community Structure Across Land Uses
2
+
3
+ **Workflow:** analyze-community-structure
4
+ **System:** Birds, Atlantic Forest
5
+ **Sites:** 90 sites across 3 land use types (30 each)
6
+ **Species matrix:** 90 sites × 127 species (point counts, 5 min, 25m radius)
7
+
8
+ ---
9
+
10
+ ## Alpha Diversity
11
+
12
+ | Land use | S (richness) | H' (Shannon) | 1−D (Simpson) |
13
+ |----------|-------------|-------------|--------------|
14
+ | Old-growth forest | 42.3 ± 4.1 | 3.41 ± 0.18 | 0.96 ± 0.01 |
15
+ | Secondary forest | 28.7 ± 5.2 | 2.89 ± 0.24 | 0.92 ± 0.02 |
16
+ | Pasture | 14.2 ± 3.8 | 2.01 ± 0.31 | 0.81 ± 0.04 |
17
+
18
+ Kruskal-Wallis (richness): H = 47.3, p < 0.001
19
+ Post-hoc Dunn: all pairs significantly different (p_adj < 0.01)
20
+
21
+ ## NMDS
22
+
23
+ - Stress = 0.13 (acceptable)
24
+ - 20 random starts; converged solution confirmed
25
+
26
+ ## PERMANOVA
27
+
28
+ ```
29
+ adonis2(bray_dist ~ land_use, permutations = 999)
30
+
31
+ Df SumOfSqs R2 F Pr(>F)
32
+ land_use 2 4.218 0.421 29.1 0.001 ***
33
+ Residual 87 6.299 0.579
34
+ Total 89 10.517 1.000
35
+ ```
36
+
37
+ ## PERMDISP (Homogeneity of Dispersions)
38
+
39
+ ```
40
+ F = 3.42, p = 0.038 (significant)
41
+ ```
42
+
43
+ **Note:** Significant dispersion differences detected. PERMANOVA result reflects both centroid differences AND variation in dispersion. Old-growth forest sites are more homogeneous (lower dispersion) than pasture sites. Both centroid and dispersion effects are ecologically meaningful.
44
+
45
+ ## Top SIMPER Species (Old-growth vs Pasture)
46
+
47
+ | Species | Contribution (%) | Mean abund OG | Mean abund Pasture |
48
+ |---------|----------------|--------------|-------------------|
49
+ | Thamnophilus caerulescens | 4.2 | 3.1 | 0.1 |
50
+ | Dysithamnus mentalis | 3.8 | 2.8 | 0.0 |
51
+ | Myrmotherula axillaris | 3.5 | 2.6 | 0.0 |
52
+ | Volatinia jacarina | 3.1 | 0.2 | 4.7 |
53
+ | Sporophila caerulescens | 2.9 | 0.1 | 3.8 |
54
+
55
+ ## Beta Diversity Partitioning
56
+
57
+ | Component | Total beta |
58
+ |-----------|-----------|
59
+ | Bray-Curtis total | 0.623 |
60
+ | Turnover | 0.481 (77.2%) |
61
+ | Nestedness | 0.142 (22.8%) |
62
+
63
+ **Interpretation:** Community differences are dominated by species turnover (replacement), not nestedness. This suggests true compositional differentiation between habitats rather than simple species loss.
@@ -0,0 +1,60 @@
1
+ # Worked Example: Phytoplankton Community — Amazon Reservoirs
2
+
3
+ **Workflow:** analyze-community-structure
4
+ **System:** Phytoplankton assemblages in hydroelectric reservoirs
5
+ **Sites:** 24 sampling stations across 3 reservoirs (Tucuruí, Balbina, Samuel)
6
+ **Survey:** Quarterly sampling, 2018–2022 (6 campaigns × 24 stations = 144 samples)
7
+ **Matrix:** 144 samples × 63 genera (cell density, cells/mL)
8
+
9
+ ---
10
+
11
+ ## Data Preparation
12
+
13
+ - Hellinger transformation applied (sqrt of relative abundance) to reduce effect of dominant taxa
14
+ - Rare genera (< 5 samples, < 10 cells/mL peak density) removed: 63 → 51 genera retained
15
+ - Seasonal grouping: wet season (Nov–Mar) / dry season (Apr–Oct)
16
+
17
+ ## Alpha Diversity by Reservoir and Season
18
+
19
+ | Reservoir | Season | Richness | Shannon H' | Simpson 1−D |
20
+ |-----------|--------|---------|-----------|------------|
21
+ | Tucuruí | Wet | 31.2 ± 4.1 | 2.91 ± 0.31 | 0.91 |
22
+ | Tucuruí | Dry | 22.4 ± 3.7 | 2.44 ± 0.28 | 0.87 |
23
+ | Balbina | Wet | 18.7 ± 5.2 | 2.21 ± 0.41 | 0.83 |
24
+ | Balbina | Dry | 14.1 ± 4.0 | 1.87 ± 0.38 | 0.76 |
25
+ | Samuel | Wet | 26.3 ± 3.9 | 2.73 ± 0.29 | 0.89 |
26
+ | Samuel | Dry | 19.8 ± 3.4 | 2.38 ± 0.25 | 0.86 |
27
+
28
+ Tucuruí showed significantly higher richness (KW: H = 18.4, p < 0.001), associated with larger surface area and longer water residence time.
29
+
30
+ ## NMDS — Stress = 0.11 (good)
31
+
32
+ Environmental fitting (envfit, 999 permutations):
33
+
34
+ | Variable | r² | p |
35
+ |---------|----|----|
36
+ | Total phosphorus | 0.61 | 0.001 |
37
+ | Water temperature | 0.54 | 0.001 |
38
+ | Season | 0.48 | 0.001 |
39
+ | Reservoir | 0.42 | 0.001 |
40
+ | Turbidity | 0.31 | 0.004 |
41
+
42
+ ## PERMANOVA
43
+
44
+ ```
45
+ adonis2(bray_dist ~ reservoir * season, permutations = 999)
46
+
47
+ Df SumOfSqs R² F p
48
+ reservoir 2 3.412 0.312 28.1 0.001
49
+ season 1 1.847 0.169 30.4 0.001
50
+ reservoir:season 2 0.934 0.085 7.7 0.001
51
+ Residual 138 4.200 0.384
52
+ Total 143 10.939 1.000
53
+ ```
54
+
55
+ ## Key Findings
56
+
57
+ - Community composition differed strongly between reservoirs (R² = 0.31) and seasons (R² = 0.17)
58
+ - Cyanobacteria (Microcystis, Cylindrospermopsis) dominated Balbina dry season — consistent with known eutrophication issues
59
+ - Diatoms (Aulacoseira, Cyclotella) dominated Tucuruí wet season — associated with higher turbulence and silica availability
60
+ - Temporal beta diversity was dominated by species turnover (77%), not nestedness, suggesting true seasonal succession rather than simple impoverishment
@@ -0,0 +1,221 @@
1
+ # Worked Example: Reef Fish Community — Indo-Pacific Coral Reefs
2
+
3
+ **Workflow:** analyze-community-structure
4
+ **System:** Reef fish assemblages, Indo-Pacific coral reefs (Great Barrier Reef to Coral Triangle)
5
+ **Sites:** 3,214 transects across 8 countries (Australia, Indonesia, Philippines, Papua New Guinea, Fiji, Solomon Islands, Malaysia, Timor-Leste)
6
+ **Survey:** Reef Life Survey — diver visual census, 50 m x 5 m belt transects, 2008--2023
7
+ **Matrix:** 3,214 transects x 987 species (abundance counts)
8
+
9
+ ---
10
+
11
+ ## Step 1 — Data Sources
12
+
13
+ | Item | Detail |
14
+ |------|--------|
15
+ | Database | Reef Life Survey (RLS), open-access |
16
+ | Citation | Edgar & Stuart-Smith 2014 (doi:10.1038/sdata.2014.7) |
17
+ | Raw scope | ~14,200 transects across 8 countries, all marine habitats |
18
+ | Geographic filter | Indo-Pacific coral reefs only (100--180 E, 0--30 S) |
19
+ | Temporal range | 2008--2023 |
20
+ | Post-filter | 3,847 transects, 1,126 species |
21
+ | Taxonomic scope | Actinopterygii (bony reef fishes) |
22
+
23
+ ## Step 2 — QA and Filtering
24
+
25
+ | Filter | Criterion | Records removed | Remaining |
26
+ |--------|-----------|----------------|-----------|
27
+ | Survey method | Remove cryptic survey method (M2) | 214 transects | 3,633 |
28
+ | Depth | Remove transects > 30 m | 97 transects | 3,536 |
29
+ | Species poverty | Remove transects with < 5 species | 183 transects | 3,353 |
30
+ | Taxonomic standardization | Synonyms resolved via WoRMS | 139 names merged | 987 species |
31
+ | Outlier screening | Abundance values > 99.9th percentile winsorized | 41 records adjusted | 3,353 |
32
+ | Spatial thinning | Max 3 transects per site per year to reduce pseudoreplication | 139 transects | 3,214 |
33
+ | **Final matrix** | | | **3,214 transects x 987 species** |
34
+
35
+ Data transformation: square-root of abundance applied before ordination and dissimilarity calculations to down-weight numerically dominant schooling species.
36
+
37
+ ---
38
+
39
+ ## Alpha Diversity
40
+
41
+ ### By Depth Zone
42
+
43
+ | Depth zone | n transects | Richness (S) | Shannon H' | Simpson 1-D |
44
+ |------------|------------|-------------|-----------|------------|
45
+ | Shallow (0--5 m) | 874 | 48.3 +/- 11.2 | 2.97 +/- 0.34 | 0.92 +/- 0.03 |
46
+ | Mid (5--15 m) | 1,487 | 61.7 +/- 13.8 | 3.28 +/- 0.29 | 0.95 +/- 0.02 |
47
+ | Deep (15--30 m) | 853 | 39.1 +/- 10.4 | 2.74 +/- 0.37 | 0.89 +/- 0.04 |
48
+
49
+ Kruskal-Wallis (richness ~ depth zone): H = 214.7, df = 2, p < 0.001
50
+ Post-hoc Dunn: all pairwise comparisons p_adj < 0.001
51
+ Mid-depth zone harbours peak richness, consistent with the mid-domain effect and maximum coral structural complexity at 5--15 m.
52
+
53
+ ### By Latitude Band
54
+
55
+ | Latitude band | n transects | Richness (S) | Shannon H' | Simpson 1-D |
56
+ |---------------|------------|-------------|-----------|------------|
57
+ | 0--10 S (Coral Triangle core) | 1,241 | 68.4 +/- 14.1 | 3.42 +/- 0.27 | 0.96 +/- 0.01 |
58
+ | 10--20 S (central GBR, Melanesia) | 1,108 | 52.1 +/- 12.6 | 3.11 +/- 0.31 | 0.93 +/- 0.02 |
59
+ | 20--30 S (southern GBR, subtropical) | 865 | 34.7 +/- 9.8 | 2.68 +/- 0.35 | 0.88 +/- 0.03 |
60
+
61
+ Kruskal-Wallis (richness ~ latitude band): H = 387.2, df = 2, p < 0.001
62
+ Post-hoc Dunn: all pairwise comparisons p_adj < 0.001
63
+ Richness declines approximately 50% from the equatorial Coral Triangle to subtropical reefs, consistent with the marine latitudinal diversity gradient.
64
+
65
+ ---
66
+
67
+ ## Beta Diversity
68
+
69
+ ### Bray-Curtis Dissimilarity
70
+
71
+ | Comparison | Mean dissimilarity +/- SD |
72
+ |-----------|--------------------------|
73
+ | Within shallow | 0.54 +/- 0.11 |
74
+ | Within mid | 0.48 +/- 0.09 |
75
+ | Within deep | 0.57 +/- 0.12 |
76
+ | Between shallow--mid | 0.63 +/- 0.10 |
77
+ | Between mid--deep | 0.66 +/- 0.11 |
78
+ | Between shallow--deep | 0.72 +/- 0.10 |
79
+ | Within 0--10 S | 0.46 +/- 0.10 |
80
+ | Within 10--20 S | 0.52 +/- 0.11 |
81
+ | Within 20--30 S | 0.58 +/- 0.13 |
82
+ | Between 0--10 S and 20--30 S | 0.78 +/- 0.08 |
83
+
84
+ ### Turnover vs Nestedness Decomposition (betapart)
85
+
86
+ | Component | Sorensen-based | % of total |
87
+ |-----------|---------------|-----------|
88
+ | Total beta (beta.sor) | 0.71 | 100% |
89
+ | Turnover (beta.sim) | 0.51 | 71.8% |
90
+ | Nestedness-resultant (beta.sne) | 0.20 | 28.2% |
91
+
92
+ Turnover dominates total beta diversity (~72%), indicating that compositional change across depth zones and latitude bands reflects species replacement rather than progressive impoverishment of a nested subset.
93
+
94
+ ---
95
+
96
+ ## NMDS
97
+
98
+ - Distance: Bray-Curtis on square-root transformed abundances
99
+ - Dimensions: 2
100
+ - Random starts: 50
101
+ - **Stress = 0.14** (acceptable; < 0.20 threshold)
102
+ - Convergence reached after 50 iterations in best solution
103
+
104
+ Ordination reveals clear separation along NMDS1 by latitude band (Coral Triangle vs subtropical) and along NMDS2 by depth zone. Shallow and deep assemblages occupy distinct ordination space with mid-depth transects intermediate. Coral Triangle transects cluster tightly relative to the more dispersed subtropical group.
105
+
106
+ Environmental fitting (envfit, 999 permutations):
107
+
108
+ | Variable | r2 | p |
109
+ |---------|-----|------|
110
+ | Latitude | 0.68 | 0.001 |
111
+ | Depth (m) | 0.54 | 0.001 |
112
+ | Sea surface temperature | 0.51 | 0.001 |
113
+ | Live coral cover (%) | 0.47 | 0.001 |
114
+ | Structural complexity (rugosity) | 0.39 | 0.001 |
115
+ | Distance to shelf edge (km) | 0.22 | 0.003 |
116
+
117
+ ---
118
+
119
+ ## PERMANOVA
120
+
121
+ ```
122
+ adonis2(bray_dist ~ depth_zone * region, data = env, permutations = 999)
123
+
124
+ Df SumOfSqs R2 F Pr(>F)
125
+ depth_zone 2 48.71 0.182 112.4 0.001 ***
126
+ region 7 82.94 0.310 54.7 0.001 ***
127
+ depth_zone:region 14 16.05 0.060 5.3 0.001 ***
128
+ Residual 3190 119.82 0.448
129
+ Total 3213 267.52 1.000
130
+ ```
131
+
132
+ Region explains the largest fraction of community variance (R2 = 0.31), followed by depth zone (R2 = 0.18). The significant interaction (R2 = 0.06) indicates that depth zonation patterns differ among regions -- for example, shallow assemblages in the Coral Triangle are compositionally distinct from shallow assemblages on the southern Great Barrier Reef.
133
+
134
+ ---
135
+
136
+ ## PERMDISP (Homogeneity of Multivariate Dispersions)
137
+
138
+ ### By Depth Zone
139
+
140
+ ```
141
+ betadisper(bray_dist, group = depth_zone)
142
+ F = 14.87, df1 = 2, df2 = 3211, p = 0.001
143
+ ```
144
+
145
+ | Depth zone | Mean distance to centroid |
146
+ |------------|-------------------------|
147
+ | Shallow (0--5 m) | 0.442 +/- 0.061 |
148
+ | Mid (5--15 m) | 0.401 +/- 0.054 |
149
+ | Deep (15--30 m) | 0.459 +/- 0.068 |
150
+
151
+ ### By Region
152
+
153
+ ```
154
+ betadisper(bray_dist, group = region)
155
+ F = 9.31, df1 = 7, df2 = 3206, p = 0.001
156
+ ```
157
+
158
+ **Note:** Significant heterogeneity of dispersions detected for both factors. Deep and shallow transects show greater multivariate dispersion than mid-depth transects, and subtropical regions are more dispersed than Coral Triangle sites. The PERMANOVA result therefore reflects a combination of centroid shifts and dispersion differences. Both effects are ecologically interpretable: greater dispersion in deep and subtropical assemblages reflects higher environmental heterogeneity in those settings.
159
+
160
+ ---
161
+
162
+ ## SIMPER — Top Contributors to Between-Depth-Zone Differences
163
+
164
+ ### Shallow vs Deep
165
+
166
+ | Species | Contribution (%) | Mean abund shallow | Mean abund deep | Functional group |
167
+ |---------|------------------|--------------------|-----------------|-----------------|
168
+ | *Pomacentrus moluccensis* | 3.7 | 12.4 | 1.2 | Planktivore, coral-associated |
169
+ | *Chromis viridis* | 3.4 | 18.7 | 2.1 | Schooling planktivore |
170
+ | *Pseudanthias squamipinnis* | 2.9 | 0.8 | 9.6 | Schooling planktivore, deep reef |
171
+ | *Acanthurus lineatus* | 2.6 | 7.3 | 0.4 | Territorial herbivore, reef crest |
172
+ | *Cephalopholis miniata* | 2.3 | 0.3 | 3.8 | Mesopredator, deep reef |
173
+
174
+ Shallow assemblages are characterised by coral-associated damselfishes and herbivores adapted to high-energy, light-saturated reef crests. Deep assemblages shift toward planktivorous anthiines and mesopredators associated with walls and overhangs.
175
+
176
+ ### Coral Triangle vs Subtropical (20--30 S)
177
+
178
+ | Species | Contribution (%) | Mean abund Coral Triangle | Mean abund subtropical | Functional group |
179
+ |---------|------------------|--------------------------|----------------------|-----------------|
180
+ | *Chromis ternatensis* | 2.8 | 8.9 | 0.1 | Schooling planktivore |
181
+ | *Halichoeres melanurus* | 2.5 | 5.4 | 0.3 | Invertivore wrasse |
182
+ | *Chaetodon trifascialis* | 2.2 | 3.7 | 0.0 | Obligate corallivore |
183
+ | *Abudefduf vaigiensis* | 1.9 | 1.2 | 6.1 | Generalist omnivore |
184
+ | *Notolabrus gymnogenis* | 1.7 | 0.0 | 4.3 | Temperate-affinity wrasse |
185
+
186
+ ---
187
+
188
+ ## Ecological Interpretation
189
+
190
+ 1. **Latitudinal diversity gradient.** Richness declines approximately 50% from equatorial Coral Triangle reefs to subtropical reefs at 20--30 S. This gradient is consistent with the marine species-area relationship, higher sea surface temperatures supporting greater metabolic scope, and the Coral Triangle functioning as both an evolutionary centre of origin and an overlap zone for Indian and Pacific Ocean faunas.
191
+
192
+ 2. **Depth zonation driven by environmental filtering.** The three depth zones harbour distinct assemblages structured by light attenuation, wave energy, and coral morphological transitions. Branching *Acropora*-dominated shallows support a different functional guild than plating and massive coral communities at depth. The significant depth x region interaction indicates these vertical zonation patterns are not uniform across the Indo-Pacific.
193
+
194
+ 3. **Turnover dominates beta diversity.** The high turnover component (~72%) indicates that communities at different depths and latitudes are not nested subsets of one another but rather comprise distinct species pools shaped by environmental filtering. This contrasts with a simple impoverishment model and implies that conservation of Indo-Pacific reef fish diversity requires protecting reefs across the full depth and latitudinal gradient.
195
+
196
+ 4. **Dispersion patterns are ecologically informative.** Greater multivariate dispersion in deep and subtropical assemblages reflects higher among-site environmental heterogeneity (variable reef geomorphology at depth; mixing of tropical and temperate faunas at subtropical margins). Conservation planning should account for this higher beta diversity in marginal reef environments.
197
+
198
+ 5. **Functional turnover.** SIMPER results show that depth-zone differences are driven by shifts in functional groups (coral-associated planktivores replaced by deep-reef mesopredators), not simply by abundance fluctuations within the same guild. This reinforces the hypothesis that environmental filtering acts on functional traits.
199
+
200
+ ---
201
+
202
+ ## Data Sources and References
203
+
204
+ | Reference | DOI |
205
+ |-----------|-----|
206
+ | Edgar, G.J. & Stuart-Smith, R.D. (2014). Systematic global assessment of reef fish communities by the Reef Life Survey program. *Scientific Data*, 1, 140007. | doi:10.1038/sdata.2014.7 |
207
+ | Bellwood, D.R., Hughes, T.P., Connolly, S.R. & Tanner, J. (2005). Environmental and geometric constraints on Indo-Pacific coral reef biodiversity. *Ecology Letters*, 8, 643--651. | doi:10.1111/j.1461-0248.2005.00820.x |
208
+ | Baselga, A. (2010). Partitioning the turnover and nestedness components of beta diversity. *Global Ecology and Biogeography*, 19, 134--143. | doi:10.1111/j.1466-8238.2009.00490.x |
209
+ | Roberts, C.M. et al. (2002). Marine biodiversity hotspots and conservation priorities for tropical reefs. *Science*, 295, 1280--1284. | doi:10.1126/science.1067728 |
210
+ | Anderson, M.J. (2001). A new method for non-parametric multivariate analysis of variance. *Austral Ecology*, 26, 32--46. | doi:10.1111/j.1442-9993.2001.01070.pp.x |
211
+ | Clarke, K.R. (1993). Non-parametric multivariate analyses of changes in community structure. *Australian Journal of Ecology*, 18, 117--143. | doi:10.1111/j.1442-9993.1993.tb00438.x |
212
+
213
+ ### R Packages Used
214
+
215
+ | Package | Purpose |
216
+ |---------|---------|
217
+ | `vegan` | NMDS, PERMANOVA (adonis2), SIMPER, envfit, betadisper |
218
+ | `betapart` | Turnover--nestedness decomposition |
219
+ | `worrms` | Taxonomic standardization via WoRMS API |
220
+ | `dplyr`, `tidyr` | Data wrangling and filtering |
221
+ | `ggplot2` | Ordination and diversity visualizations |
@@ -0,0 +1,57 @@
1
+ # Worked Example: BACI — Road Impact on Bird Richness
2
+
3
+ **Workflow:** assess-ecological-impact
4
+ **System:** Birds (Atlantic Forest fragment)
5
+ **Disturbance:** Federal highway expansion (construction 2018–2019)
6
+ **Control sites:** 8 forest sites > 10 km from road, comparable habitat
7
+ **Impact sites:** 8 forest sites within 2 km of road
8
+
9
+ ---
10
+
11
+ ## Study Design
12
+
13
+ | Period | Surveys | Dates |
14
+ |--------|---------|-------|
15
+ | Before | 3 (Jan 2016, Jan 2017, Jan 2018) | 3 annual surveys |
16
+ | After | 3 (Jan 2020, Jan 2021, Jan 2022) | 3 annual surveys post-construction |
17
+
18
+ ## Model
19
+
20
+ ```r
21
+ richness ~ period * treatment + (1|site), family = nbinom2()
22
+ ```
23
+
24
+ ## Results
25
+
26
+ | Term | Estimate | SE | z | p |
27
+ |------|---------|----|----|---|
28
+ | Intercept | 3.21 | 0.12 | 26.7 | < 0.001 |
29
+ | period_after | 0.04 | 0.09 | 0.44 | 0.66 |
30
+ | treatment_impact | -0.11 | 0.16 | -0.69 | 0.49 |
31
+ | **period_after:treatment_impact** | **-0.31** | **0.12** | **-2.58** | **0.010** |
32
+
33
+ ## Interpretation
34
+
35
+ The BACI interaction (β = −0.31, SE = 0.12, p = 0.010) indicates a significant negative effect of road construction on bird richness at impact sites relative to control sites.
36
+
37
+ On the original scale: exp(−0.31) = 0.73, meaning impact sites showed approximately **27% lower bird richness** after road construction compared to what would be expected based on control site trends.
38
+
39
+ 95% CI for the multiplicative effect: [0.58, 0.93]
40
+
41
+ ## Fragmentation Results
42
+
43
+ | Metric | Pre-road (2015) | Post-road (2022) | Change |
44
+ |--------|----------------|-----------------|--------|
45
+ | Forest area (ha) | 12,450 | 10,890 | −12.5% |
46
+ | Patch count | 23 | 31 | +34.8% |
47
+ | Mean patch size (ha) | 541 | 351 | −35.1% |
48
+ | Edge density (m/ha) | 87 | 124 | +42.5% |
49
+ | MESH (ha) | 3,210 | 1,870 | −41.7% |
50
+
51
+ ## Impact Classification
52
+
53
+ **Overall impact: MAJOR**
54
+
55
+ - Significant bird richness decline (−27%, BACI p = 0.010)
56
+ - Severe fragmentation increase (MESH −42%)
57
+ - High edge density (edge effects affecting interior species)
@@ -0,0 +1,83 @@
1
+ # Worked Example: Ecosystem Services — Atlantic Forest Remnants (São Paulo)
2
+
3
+ **Workflow:** assess-ecosystem-services
4
+ **System:** Atlantic Forest remnants in São Paulo state
5
+ **Study area:** ~248,000 km² (state of São Paulo)
6
+ **Land cover:** MapBiomas Collection 8, 2022
7
+ **Services assessed:** Carbon storage, erosion control, pollination habitat
8
+
9
+ ---
10
+
11
+ ## Land Cover Summary (São Paulo, 2022)
12
+
13
+ | Class | Area (Mha) | % of state |
14
+ |-------|-----------|-----------|
15
+ | Native forest (dense) | 2.41 | 9.7% |
16
+ | Secondary forest | 1.18 | 4.8% |
17
+ | Savanna / Cerrado | 0.43 | 1.7% |
18
+ | Planted pasture | 6.82 | 27.5% |
19
+ | Sugarcane | 5.14 | 20.7% |
20
+ | Soy / corn | 3.67 | 14.8% |
21
+ | Urban | 2.89 | 11.7% |
22
+ | Other | 1.89 | 7.6% |
23
+
24
+ ---
25
+
26
+ ## Carbon Storage Results
27
+
28
+ | Land cover | C stock (MgC/ha) | Total C (MtC) | % of state total |
29
+ |-----------|-----------------|--------------|-----------------|
30
+ | Dense forest | 178.2 | 429.5 | 61.3% |
31
+ | Secondary forest | 68.4 | 80.7 | 11.5% |
32
+ | Cerrado | 52.1 | 22.4 | 3.2% |
33
+ | Pasture | 18.3 | 124.8 | 17.8% |
34
+ | Sugarcane | 12.1 | 62.2 | 8.9% |
35
+
36
+ Dense forest stores 10× more carbon per hectare than pasture.
37
+
38
+ ---
39
+
40
+ ## Erosion Control (RUSLE C-factor approach)
41
+
42
+ | Land cover | C-factor | Avoided erosion (t/ha/yr) | % erosion service |
43
+ |-----------|---------|--------------------------|------------------|
44
+ | Dense forest | 0.0001 | 18.4 | 38.2% |
45
+ | Secondary forest | 0.005 | 17.9 | 18.6% |
46
+ | Cerrado | 0.01 | 17.4 | 6.7% |
47
+ | Pasture | 0.15 | 16.2 | 28.4% |
48
+
49
+ ---
50
+
51
+ ## Pollination Habitat Index
52
+
53
+ | Land cover | Pollination index | Total area × index |
54
+ |-----------|----------------|--------------------|
55
+ | Dense forest | 1.00 | 24,100 km² |
56
+ | Secondary forest | 0.85 | 10,030 km² |
57
+ | Cerrado | 0.75 | 3,225 km² |
58
+ | Pasture | 0.20 | 13,640 km² |
59
+ | Sugarcane | 0.10 | 5,140 km² |
60
+
61
+ ---
62
+
63
+ ## Trade-off Analysis (Spearman correlations, class-level)
64
+
65
+ | Service pair | ρ | Relationship |
66
+ |-------------|---|-------------|
67
+ | Carbon × Erosion control | 0.92 | **Strong synergy** |
68
+ | Carbon × Pollination | 0.89 | **Strong synergy** |
69
+ | Erosion × Pollination | 0.84 | **Synergy** |
70
+ | Forest × Agricultural productivity | -0.78 | **Trade-off** |
71
+
72
+ All three services are strongly synergistic — native vegetation provides carbon, erosion control, AND pollination habitat simultaneously, with no trade-offs among these services.
73
+
74
+ ---
75
+
76
+ ## Key Recommendation
77
+
78
+ Restoring 500,000 ha of secondary forest in the highest-priority areas (currently degraded pasture adjacent to forest remnants) would generate an estimated:
79
+ - +34.2 MtC additional carbon stock
80
+ - +8.95 million t/yr erosion avoided
81
+ - +425,000 km² (weighted) additional pollination habitat
82
+
83
+ At a 3% social discount rate, the net present value of these services exceeds the opportunity cost of land conversion in 78% of priority parcels.