"Cohorts of immature Pteropus bats show interannual variation in Hendra virus serology
收藏资源简介:
LUMINEX Wildlife Disease Analysis Pipeline Overview Bayesian analysis pipeline for "Cohorts of immature Pteropus bats show interannual variation in Hendra virus serology" Summary Prerequisites Software Requirements - R (≥ 4.0.0) - Stan (≥ 2.21) Required R Packages # Core packages install.packages(c("rstan", "tidyverse", "here", "loo", "bayesplot")) # Additional packages install.packages(c("RColorBrewer", "cowplot", "boot", "see", "factoextra", "bestNormalize", "LaplacesDemon", "ggpubr", "plyr", "see", "pscl")) # Core utility functions (CRITICAL DEPENDENCY) source(here("R", "useful_functions.R")) # Bayesian analysis functions source(here("R", "paper_theme.R")) # Plotting themes Hardware Requirements - Storage: ≥5GB free space - CPU: Multi-core processor recommended Data Requirements /raw_sharable folder Execution Workflow ⚠️ CRITICAL: Execute in This Order Phase 1: Core Data Processing 1. Initial Data Cleaning source("R/create_datasets_for_stan_part_1.R") - Runtime: ~5-10 minutes - Outputs: data_for_cohort_model.csv, luminex_igg_igm.csv 2. Serology Classification rmarkdown::render("R/mixture_model_final.R") - Runtime: ~30-60 minutes (Stan model fitting) - Outputs: serology_prob.csv 3. Age/Cohort Assignment rmarkdown::render("R/cohort_model_2025_05_12.Rmd") - Runtime: ~1-3 hours (complex Stan models) - Outputs: age_predictions.csv & a species comparison analysis 4. Dataset Integration source("R/create_datasets_for_stan_part_2_06_30_24.R") - Runtime: ~10-15 minutes - Outputs: All analysis-ready datasets with time-alive variables Phase 2: Primary Analyses 5. Prevalence Smoothing Analysis rmarkdown::render("R/gaussian_smooth_prevalence_06_30_24.Rmd") - Runtime: ~10+ hours (multiple Stan models) - Key outputs: Prevalence curves, model comparisons - Additional outputs: -Basic prevalence smoothing (4 pathogens × 4 cohorts) -Site-specific analysis (8-cohort models) -Sex-stratified analysis -Stringent cohort cutoff analysis -Multiple cutoff threshold testing (5 different cutoffs) -Date-based modeling -Batch effect testing -Adult vs juvenile comparisons 6. Logistic Regression Analysis source("R/logistic_models_fig_3.R") source("R/logistic_models_fig_2.R") - Runtime: ~30-60 minutes - Outputs: Figure 2 & 3 plots Phase 3: Supporting Analyses (Optional) 7. Additional Analyses (run as needed): - adult_prevalence_curves.Rmd - Adult dynamics - PCA_new_analysis.R - Multivariate analysis - additional_figures.R - Supplementary figures Key Functions (useful_functions.R) - fit_4cohort_model() - Bayesian 4-cohort prevalence model - compile_stan_results() - Extract and format Stan results - create_time_sequence() - Generate prediction timepoints - compute_loo_cv() - Leave-one-out cross-validation - plot_parameter_diagnostics() - Model diagnostic plots Troubleshooting Common Issues Stan compilation errors: # Recompile Stan models rstan_options(auto_write = TRUE) options(mc.cores = parallel::detectCores()) Memory issues: - Reduce Stan iterations: ITER = 1000 instead of ITER = 2000 - Run analyses sequentially, not in parallel Missing dependencies: # Load all utility functions source(here("R", "useful_functions.R")) source(here("R", "paper_theme.R")) Resume from Saved Results Many scripts save intermediate results: # Check for existing model fits if(file.exists("model_results.RData")) { load("model_results.RData") } else { # Run full analysis } Output Structure Luminex_figs/r_figs/ # All generated figures Data_for_publication/ # Final analysis datasets stan/ # Stan model files R/ # Analysis scripts Expected Runtime Full pipeline: 10-20 hours on modern hardware



