Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GlobalDietaryDiversity

Repo for all code related to the paper 'Plant DNA distinguishes the sources of dietary diversity across the nutrition transition' by Neubert et al. 2026

System requirements

Hardware requirements

Designed to run on a standard laptop or desktop computer capable of typical data-analysis workflows. No special hardware is required.

Software requirements

OS Requirements

The notebooks should work on most modern operating systems. This repo has been tested specifically on macOS 15.1.

Tools needed

Three command-line tools (RAxML, MAFFT, and phylocom) are required only for the phylogeny notebooks (Code/01_pipeline/02_ and 03_). The figure, supporting, and sensitivity notebooks do not need them and the repository ships the finished trees under Data/phylogeny/, so you can skip this section unless you intend to rebuild the phylogeny from scratch.

  1. R (4.1.x recommended; validated on 4.1.1)
  2. An IDE such as RStudio (or any equivalent R IDE/editor)
  3. RAxML 8.2.12
  4. MAFFT v7.526
  5. phylocom 4.2

R package dependencies

Install the following packages before running the notebooks:

  • ape 5.6.2
  • Biostrings 2.62.0
  • broom 1.0.1
  • broom.mixed 0.2.9.6
  • coin 1.4.5
  • dplyr 1.0.10
  • dunn.test 1.3.5
  • forcats 0.5.2
  • GGally 2.1.2
  • ggeffects 2.3.2
  • ggplot2 3.5.1
  • ggpubfigs 0.0.1
  • ggridges 0.5.4
  • ggtree 3.2.1
  • here 1.0.1
  • ips 0.0.13
  • lme4 1.1.34
  • lmerTest 3.1.3
  • lmtest 0.9.40
  • logistf 1.26.1
  • microbiome 1.16.0
  • multcompView 0.1.8
  • parameters 0.28.2
  • patchwork 1.3.0
  • phylocomr 0.3.4
  • phyloseq 1.38.0
  • phytools 1.2.0
  • purrr 1.2.0
  • RColorBrewer 1.1.3
  • readr 2.1.3
  • readxl 1.4.1
  • reshape2 1.4.4
  • scales 1.3.0
  • stringr 1.4.1
  • tibble 3.1.8
  • tidyr 1.2.1
  • tidyverse 1.3.2
  • vegan 2.6.4

Installation guide

Typical install time for all tools and dependencies is <30 minutes on a normal desktop computer.

  1. Install the tools listed above.

  2. Get the repository: download the ZIP or git clone the repo, then open GlobalDietaryDiversity.Rproj to launch it in RStudio. Opening the .Rproj sets the working directory to the repository root, which all notebooks rely on, and running them with a different working directory causes file-not-found errors partway through.

  3. Install required R packages: install the packages listed in the R package dependencies section (e.g., via install.packages() in R).

  4. Run the notebooks: open the notebooks under Code/ and run them in the order described below. Restart the R session and clear objects from the workspace between each notebook to ensure proper package and variable loading. Note that the economic data supporting this study come from the International Comparison Program (ICP) of The World Bank. Access to unpublished ICP data is restricted under a confidentiality agreement and cannot be shared or disseminated by the authors, so Data/pppData.csv is not included in this repository (it is listed in .gitignore). Two analyses read it and will fail without it: Code/03_supporting/04_diet_cost.Rmd, and the diet-cost section of Code/04_sensitivity/01_rarefaction.Rmd. Every other notebook runs on the included data. Data may be available from the ICP Global Office on request, subject to their data access and confidentiality policies.

Demo & Instructions for use

Instructions to run on the included data

  1. Open GlobalDietaryDiversity.Rproj.
  2. Install the packages listed in System Requirements.
  3. Run order: Notebooks are numbered by stage and are intended to run in that order. Restart R and clear the workspace between notebooks. a. 01_pipeline/01_preprocess_phyloseq.Rmd — run this first. It builds the phyloseq objects every other notebook reads. b. 02_main_figures/02_fig2_dietary_patterns.Rmd is a pipeline stage, not just a figure. It computes the global PCA and writes *_withPCs.rds and pc2Loadings.rds, which eight downstream notebooks depend on. Running 03_fig3, 04_fig4, most of 03_supporting/, or the sensitivity analyses before it produces missing-file errors. c. Everything else in 02_main_figures/, 03_supporting/, and 04_sensitivity/ can be run in any order once steps a and b are done.
  4. Rebuilding the phylogeny from scratch (not required as the trees are included) is circular, because the phylogeny needs a preprocessed phyloseq object and preprocessing needs the finished tree. The order is: 01_preprocess chunks through the "Save the objects" block → 02_build_phylogeny_dated.Rmd → 03_build_phylogeny_ml.Rmd → back to 01_preprocess for the tree-attachment chunks. If you rebuild the phylogeny, note that two steps run outside R. 02_build_phylogeny_dated.Rmd and 03_build_phylogeny_ml.Rmd each pause after the alignment section and require using a RAxML command in a terminal from the analysis output directory; 02_build_phylogeny_dated.Rmd pauses again later and will require use of a BLADJ command to run from inside bladj_workspace/. Resume the notebook at the next chunk once each finishes.

Expected output

  • Figures/ - one PDF per figure panel. Main-figure panels are named by figure and panel (Fig1A.pdf, Fig2BCDE.pdf); Extended Data figures use analysisName_EF.pdf. Each notebook's ggsave() calls name its own outputs.
  • Results/ — summary tables as CSV, one per sensitivity analysis plus the self-report and food-extraction comparisons.
  • Data/ — intermediate phyloseq objects written by 01_preprocess_phyloseq.Rmd and 02_fig2_dietary_patterns.Rmd, reused by later notebooks.

Manuscript figures were spaced and lightly formatted in Illustrator; underlying data and results are identical.

Expected run time

Approximate run time, on a recent laptop, is 1.5-2 hours without a phylogeny rebuild:

  • Preprocessing and main figure notebooks: ~10 minutes total
  • Supporting notebooks, except 06_ordination_metrics.Rmd: ~10 minutes
  • 03_supporting/06_ordination_metrics.Rmd: ~1 hour
  • Sensitivity analyses: ~10 minutes total
  • Phylogeny rebuild (optional): ~2-3 hours

Instructions for use on your own data

  1. Provide a compatible FoodSeq phyloseq object with otu_table, tax_table, and sample_data columns used in the notebooks. Save it in Data/ (e.g., Data/my_cohort_ps_glommed.rds) and update any file-name/path references in the code chunks.
  2. Adjust cohort-specific variables as needed. Some notebooks reference fields and logic tailored to the study cohorts (e.g., country labels, covariates, inclusion filters). You may need to rename columns, relevel factors, or edit model formulas to reflect your dataset.
  3. Run all code chunks in the relevant notebooks to generate figures for your dataset.

This codebase is designed to reproduce analyses for the specific cohorts in the paper; it is not a fully general-purpose package. While you can adapt it to other FoodSeq datasets by supplying a compatible phyloseq object and updating paths/variables, expect to adjust column names, factor levels, and some model formulas to match your context.

Reproduction instructions (paper results)

  1. Open GlobalDietaryDiversity.Rproj, then run the notebooks in the order given under Instructions to run on the included data above, using the precomputed objects and mapping files in Data/.
  2. The PDFs written to Figures/ correspond to the figures reported in the manuscript. (Manuscript versions were spaced and lightly formatted in Illustrator; underlying data and results are identical.)

About

Repo for all code related to the paper 'Increasing plant diversity of global diets' by Neubert et al. 2025

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages