Continuous within-rural settlement intensity and household exposures are associated with gut microbiota composition in young children in western Kenya
# Analysis code: Settlement intensity and child gut microbiota composition in rural Kenya
**Coley et al. (2026)** — *BMC Microbiome* (under review)
This repository contains the R analysis code for the manuscript examining associations
between the within-rural settlement intensity gradient and gut microbiota alpha and
beta diversity in 85 children aged 2–5 years from a rural Kenyan cohort.
---
## Repository structure
```
code/ R analysis scripts (run in the order listed below)
data/ Place OSF data files here before running (see data/README.md)
output/ Created automatically at run time; receives all CSV and figure outputs
```
---
## Data
All data files are archived on OSF: **
osf.io
Raw sequencing reads are deposited at NCBI SRA: BioProject accession PRJNA1207554
See `data/README.md` for a full description of each file and download instructions.
---
## How to reproduce
### 1. Requirements
- R ≥ 4.2
- Key packages: `phyloseq`, `vegan`, `ALDEx2`, `maaslin3`, `zCompositions`,
`picante`, `phytools`, `mediation`, `broom`, `car`, `tidyverse`, `ggrepel`,
`cowplot`, `officer`, `flextable`
Install from Bioconductor where needed:
```r
BiocManager::install(c("phyloseq", "ALDEx2", "maaslin3"))
```
### 2. Configure paths
Open `code/sgma1_1_data-prep.R` and `code/sgma1_1_landscape.R` and set
`proj_dir` to the root of this repository (the folder containing `code/` and `data/`).
Also set `qiime_dir` and `seq_path` to wherever you have placed the QIIME2 output files.
### 3. Run scripts in order
```
code/sgma1_1_landscape.R # primary landscape and alpha/beta diversity analyses
code/sgma1_1_household.R # household predictor analyses and variance partitioning
code/sgma1_1_antibiotic.R # antibiotic use analysis and mediation
code/sgma1_1_targeted_DA_landscape.R # differential abundance vs. settlement intensity
code/sgma1_1_targeted_DA_ecoli.R # differential abundance vs. drinking water …