Skip to content

SimonAB/Apodemus_vaccines

Repository files navigation

Environmental Drivers of Low Vaccine Responsiveness in a Lab-to-Wild Rodent Model

A comprehensive Julia-based analysis pipeline for investigating vaccine responsiveness in wild vs laboratory populations of wood mice (Apodemus sylvaticus).

Overview

This repository contains the complete data analysis pipeline for the research project examining how environmental factors affect vaccine responsiveness, comparing laboratory-reared and wild wood mice populations. The study investigates the role of habitat, diet, and parasite burden on vaccine-specific antibody responses.

Key Research Questions

  • How do environmental factors affect vaccine responsiveness between wild and laboratory populations?
  • What role do diet and nutritional stress play in vaccine efficacy?
  • How do helminth infections influence vaccine-specific antibody production?
  • Can we develop causally-explicit models to quantify these relationships?

Repository Structure

Core Analysis Scripts (src/)

The analysis pipeline consists of several sequential Julia scripts:

  • 0_Data_Checks.jl - Exploratory data analysis and data validation
  • 1_Multilevel_Models.jl - Multilevel Bayesian models for vaccine response analysis
  • 2_SCM_validation.jl - Directed Acyclic Graph (DAG) validation for causal inference
  • 3_SCM_identification.jl - Structural Causal Model (SCM) identification of causal effects
  • 4_SCM_intervention.jl - SCM intervention analysis for causal effect estimation
  • 4prime_SCM_intervention.jl - Extended SCM analysis with interaction effects
  • compute_cohens_d_main_effects.jl - Effect size calculations for main effects

Utility Modules

  • DataWrangler.jl - Data processing, cleaning, and encoding functions
  • TuringUtils.jl - Utility functions for Bayesian models using Turing.jl
  • TuringPlots.jl - Plotting functions for model outputs and diagnostics
  • PlottingUtils.jl - Additional plotting utilities for data visualisation

Supplementary Figure Generation (figures/)

Scripts for generating supplementary figures:

  • generate_temporal_dynamics.jl - Temporal dynamics of vaccine response
  • generate_parasite_analysis.jl - Parasite burden zero-inflation analysis
  • generate_sensitivity_analysis.jl - Model sensitivity and robustness testing
  • generate_supplementary_figures.jl - Master script for all supplementary figures

Run from the figures/ directory:

cd figures
julia generate_supplementary_figures.jl

Figures are saved to: ../../Apodemus_vaccines_manuscript/Figures/plots/

Data (data/)

  • clean_data.csv - Processed dataset ready for analysis
  • joint_dataset_4analysis_checked.csv - Main analysis dataset with validated entries
  • dag_df.csv - Data formatted for causal analysis
  • readme_column_key.csv - Data dictionary explaining variable definitions

Setup and Installation

Prerequisites

  • Julia 1.11+ (recommended for optimal performance)
  • R (for RCall integration)

Installation Steps

  1. Clone the repository:

    git clone https://github.com/SimonAB/Apodemus_vaccines.git
    cd Apodemus_vaccines
  2. Open the project in VSCode or your preferred IDE

  3. Launch Julia and activate the project environment:

    # Start Julia REPL (⌘⇧P then "Start Julia REPL" in VSCode)
    ]  # Enter Pkg mode
    activate .
    instantiate
    precompile  # Optional but recommended
  4. Exit Pkg mode and verify installation:

Usage

Individual Analysis Steps

Execute the analysis pipeline sequentially:

# Data exploration and validation
include("src/0_Data_Checks.jl")

# Multilevel models
include("src/1_Multilevel_Models.jl")

# Causal inference
include("src/2_SCM_validation.jl")
include("src/3_SCM_identification_optimized.jl")
include("src/4_SCM_intervention.jl")

Generate Supplementary Figures

To generate all supplementary figures:

cd figures
julia generate_supplementary_figures.jl

Or generate individual figures:

julia generate_temporal_dynamics.jl
julia generate_parasite_analysis.jl
julia generate_sensitivity_analysis.jl

Custom Analysis

For custom analyses, load the utility modules:

include("src/DataWrangler.jl")
include("src/TuringUtils.jl")
include("src/PlottingUtils.jl")

Output Locations

Analysis figures are automatically saved to the manuscript repository:

  • Main figures: ../../Apodemus_vaccines_manuscript/Figures/plots/
  • Generated by scripts in src/ and figures/ directories
  • Requires the manuscript repository to be located at ../../Apodemus_vaccines_manuscript/

Key Dependencies

The project utilises several key Julia packages:

  • Turing.jl - Bayesian modelling and inference
  • DataFrames.jl - Data manipulation and analysis
  • CairoMakie.jl - High-quality plotting and visualisation
  • MixedModels.jl - Mixed-effects modelling
  • AlgebraOfGraphics.jl - Grammar of graphics implementation
  • GLM.jl - Generalised linear models
  • MCMCChains.jl - MCMC chain analysis and diagnostics

Analysis Approach

The project employs a comprehensive causal inference framework:

  1. Multilevel Modelling - Account for hierarchical data structure (individuals nested within populations)
  2. Directed Acyclic Graphs (DAGs) - Explicit causal assumptions and confounding relationships
  3. Structural Causal Models - Quantify causal effects of environmental factors
  4. Bayesian Inference - Uncertainty quantification and robust statistical inference

Citation

If you use this code or data, please cite:

Babayan, S.A., Venkatesan, S., Hall, J.L., Smith, E., Sweeny, A., & Pedersen, A.B. "Environmental drivers of low vaccine responsiveness in a lab-to-wild rodent model." [Journal] (in preparation).

Contributing

This research code is provided for reproducibility and transparency. For questions or collaboration inquiries, please contact:

License

This project is licensed under the terms specified in the LICENSE file.

Acknowledgments

  • University of Glasgow, School of Biodiversity, One Health & Veterinary Medicine
  • University of Edinburgh, Institute of Ecology and Evolution
  • Julia Computing Community for excellent package ecosystem

About

Why do individuals vary in their response to immunisation?

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages