The purpose of this analysis is to use the MixSIAR package to implement a Bayesian hierarchical mixing model to estimate the mixing proportion of two species of co-dominant marsh plants, Schoenoplectus americanus and Spartina patens. As it is currently written, we estimate the mixing proportions using one fixed effect, environmental treatment, with four levels: high_sal/high_elev, high_sal/low_elev, low_sal/high_elev, low_sal/low_elev. We also include a continuous effect of seed year determined by 210Pb dating of sediment layers.
Files are organized and named in the order to be run sequentially (0-4).
0_data_assembly.R: This script cleans the raw biomass and isotope data and formats each- Inputs:
Belowground_Biomass.csvBiomass spreadsheet from HSK ThesisBlueGenes2023_Belowground_Biomass - BG2023.csvBiomass spreadsheet from summer 2023 weighing effortCompiled_Traits.csvTrait data from HSK Thesis220729_JPM.xls - CN sum.csvSmithsonian lab isotope data220801_JPM.xls - CN sum.csvSmithsonian lab isotope data220519_JPM.xls - CN sum.csvSmithsonian lab isotope dataCEST_Sample_Runs.csvCEST lab isotope data - all runs, not including replicate testingTrial_Carbon_Data_unedited.csvCEST lab isotope data - replicate trialsCorr_Trial_COMP.csvCEST lab isotope data - replicate trialsMilled_replicates.csvCEST lab isotope data - replicate trials
- Outputs:
marsh_source_all.csvraw source isotopes formatted to MixSIAR specs, 151 observations of 2 variablesCompiled_Traits_appended.csvtraits with added weights and root-shoot-ratios, 672 observations of 35 variablestraining.csvmixture distribution for training MixSIAR model, 274 observations of 17 variablesbgb_biomass.csvall weights across each layer, 1692 observations of 11 variablesholdout_DONOTTOUCH.csvholdout data, 49 observations of 36 variables
- Inputs:
1_run_model.R: Describing model inputs and running model, adjust "run" in run_model for MCMC parameters- Inputs:
training.csvmarsh_source_all.csvmarsh-discrnull trophic enrichment factors
- Output
jags.Env.rdssave full jags model run as RDS objectfigs/isospace_env_plotd13C plotprior_env_plotuniform uninformative distributiondiagnostics.pdfpdf for trace, density, and running means plot for each parameterdiagnostics.txttext file containing Gelman-Rubin, Geweke, and Heidelberger-Welch diagnosticssummary_statistics.txtabbreviated file for main model output, group estimates, and DICMixSIAR_modeltext file with model descriptionposterior_density_high_salfolder containing posterior density plots for group characteristicsposterior_density_low_salfolder containing posterior density plots for group characteristics
- Inputs:
2_biomass_calc.R: Calculate mixing proportion and weight densities, some plotting- Inputs:
training.csvjags.1.rdsbgb_biomass.csv
- Outputs:
bgb_biomass_mod.rdsmodified to include mixing proportions and weight density
- Inputs:
3_model_validationtemporary file holding space until model validation is pursued- Outputs: none
4_graphing.R: Basic plotting functions for factors- Inputs:
bgb_biomass.rdsCompiled_Traits_appended.csv
- Outputs: none
- Inputs:
├── data # raw biomass and isotope data
│ ├── Biomass # Biomass weights from two efforts
│ ├── Holdout # Folder to place holdout
│ └── Isotope # Isotope data from CEST and ND
├── figs # folder for produced figures
├── output # intermediary files created during analysis
│ ├── data # modified data products
│ ├── posterior_density_high_salinity # Empty folder to hold mixsiar outputs
│ ├── posterior_density_high_salinity # Empty folder to hold mixsiar outputs
│ └── jags.normal.rds # JAGS product used in analysis, takes a decently long time to run so provided here
├── src # supporting functions
└── README.md
All code was run in R version 4.4.0 (2024-04-24). Necessary packages to run script are identified at the top of each script.
dplyrv1.1.4ggplot2v3.5.1tidyversev2.0.0MixSIARv3.1.12