Skip to content

About

Rotavirus transmission model using SickMix contact data

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

SickMix-Rota

Model code for:

Chen D, Shapiro A, Ibiebele J, Donald JL, Schmidt MA, Jenness SM, Lopman BA, Shioda K. How dynamic social contacts influence transmission and non-pharmaceutical intervention effectiveness for rotavirus. Manuscript under review.

The paper asks how changes in social contact during acute infection affect the parameters of a transmission model and the estimated impact of non-pharmaceutical interventions (NPIs), using rotavirus as the example. This repository holds the R code for the transmission model, its calibration, and the NPI scenarios. The input data are not included (see Data). The paper is under review, so the code may change during revision.

The model

The model is an age-structured, deterministic compartmental model of rotavirus transmission, written in R with deSolve. It has six age groups (0 to 11, 12 to 23, 24 to 35, 36 to 47, and 48 to 59 months, and 5 years and older), maternal immunity, up to three successive infections with waning immunity between them, and an early (3 days) and a late infectious phase for both symptomatic and asymptomatic infections. The population has the size and age structure of Portland, Oregon (649,072 people), held constant with births equal to deaths, and transmission follows a sinusoidal seasonal pattern. The equations are in Appendix Section 1 of the paper.

Contacts come from SickMix, a longitudinal survey of the social contacts of people seeking care for acute gastroenteritis or respiratory infection, as 2x2 matrices (under 5 and 5 and older) for cases on the day they felt most sick (the index day), one week later, and two weeks later. Contacts with children under 5 are split equally across the model's five one-year age groups. Two versions of the model are compared:

  • Behavior-naive (model_type=naive): every infectious phase uses the same contact matrix, from two weeks after enrollment.
  • Behavior-dynamic (model_type=driven in the code): early symptomatic infection uses the index-day matrix, late symptomatic infection the one-week matrix, and asymptomatic infection the two-week matrix.

Four parameters are estimated by maximum likelihood: the per-contact transmissibility beta_0, the timing (phi) and amplitude of seasonality, and the dispersion of a negative binomial likelihood. The calibration target is the monthly rate of rotavirus gastroenteritis (RVGE) hospitalizations per 10,000 person-years in children under 5, by year of age, from July 2001 to June 2006, before rotavirus vaccine was introduced in the United States (a centered three-month rolling mean). The model runs for 30 years and its last 60 months are compared with the data. The 95% confidence interval (CI) for beta_0 comes from its profile likelihood, with the other three parameters refit at each value.

The fitted models are then used to simulate three NPIs, each starting 14 days before the modeled peak of daily hospitalizations in children under 5 and lasting 29 days:

  1. quarantine and isolation of all infected children under 5, whose contacts are reduced to household contacts at home on the index day;
  2. isolation of symptomatic children under 5 only;
  3. a 50% reduction in the infectiousness of symptomatic infections at all ages.

Each is compared with no intervention, at the point estimate and at both ends of the beta_0 CI.

Setup

The code was run with R 4.6.1. Package versions are pinned with renv: open SickMix-Rota.Rproj, or start R in the repository root, and run once

renv::restore()

Every step is a single-threaded Rscript call. One likelihood evaluation of the 30-year model takes about 15 seconds on one Apple M1 core, so one maximum likelihood fit takes hours and the full profile likelihood takes hundreds of CPU-hours. The paper's runs were done on a SLURM cluster (see Running on a cluster).

Data

The data are not in this repository: the hospitalization series are derived from the MarketScan Commercial Database, which is licensed, and the contact matrices are derived from SickMix study data. The only data file included is the table of fixed parameters, which are literature values. The scripts expect these files under data/input/:

  • incidence/in_rvge_0_ts_separate.Rds to in_rvge_4_ts_separate.Rds: monthly RVGE hospitalization rates in children under 5, one file per year of age. Each is a data frame with date (first day of each month) and roll_unvax (three-month rolling mean of the monthly rate per 10,000 person-years). From MarketScan, as analyzed in Baker et al. (2019).
  • contact_matrices/marketscan_bootstrap_2x2/: the four 2x2 contact matrices used in the paper (CM_SET=bootstrap), cases (rows) by contacts (columns), under 5 and 5 and older. The files are cases_<matrix>_marketscan.Rds, where <matrix> is index (the index day), 1wk_follow_up and 2wk_follow_up (one and two weeks later), or index_hh (household members at home on the index day, used for the quarantine and isolation NPIs). Each is a data frame with a label column and one column per contact age group. From SickMix, weighted to the MarketScan population.
  • contact_matrices/marketscan_weighted_2x2/: an earlier estimate of the same four matrices, with the same file names (CM_SET=weighted, the default). From SickMix.
  • population/age_sex_pop_2018_portland.csv: population of Portland, Oregon, by single year of age, from IPUMS USA, American Community Survey 2018 (online frequency table of age by sex, weighted by perwt, filtered to city 5530). R/load_parameters.R reads rows 107 to 199 of the export.
  • parameters/parameters_SickMix_dc.xlsx: fixed parameters, with descriptions and sources (Table S1 of the paper). Included in this repository.

The age labels of the 2x2 matrices are read by name (read_cm_2x2() in R/functions/contact_matrices.R), so either <5 and >=5 or Less than 5 years and 5+ years work, in either order. data-raw/marketscan_incidence.R is the original analysis script from Baker et al. (2019), kept to document how the hospitalization series were built; it is not part of the pipeline and runs only on the MarketScan extracts, with its original file paths.

Running the analysis

All scripts run from the repository root and take their settings from environment variables, so the same command works on a laptop and on a cluster. Outputs go to data/run/<run_date>/, and every output file name carries the contact matrix set (bootstrap_corrected for the matrices used in the paper).

A quick check

This run uses 6 simulated years and 20 optimizer steps, so its estimates mean nothing, but it goes through the fitting, the selection of the best fit, the NPIs, and the summary in about five minutes, which shows that the inputs are in place:

export run_date=test start_yr=0 end_yr=6 CM_SET=bootstrap
model_type=naive  START_ID=1 MLE_MAXIT=20 Rscript R/01-fit_mle.R
model_type=driven START_ID=1 MLE_MAXIT=20 Rscript R/01-fit_mle.R
Rscript R/01b-select_mle.R
model_type=naive  EST_SOURCE=mle Rscript R/03-npi_scenarios.R
model_type=driven EST_SOURCE=mle Rscript R/03-npi_scenarios.R
Rscript R/05-summarize_mle_npi.R

01b-select_mle.R lists the starting values and contact matrix sets it did not find, which is expected here. The summary tables and fit plots are written to data/run/test/summary/.

The paper's analysis

The paper uses the bootstrap contact matrices, a 30-year horizon, six starting values per model, and a profile likelihood grid of 71 values of beta_0. Run serially, the steps are:

export run_date=paper start_yr=0 end_yr=30 CM_SET=bootstrap
export BETA_GRID_POINTS=71 BETA_LOG_HALF_WIDTH=0.35

# 1. Maximum likelihood fit from each starting value, then keep the best fit per model
for m in naive driven; do
  for s in 1 2 3 4 5 6; do model_type=$m START_ID=$s Rscript R/01-fit_mle.R; done
done
Rscript R/01b-select_mle.R

# 2. Profile likelihood for beta_0, one fit per grid value, then the point estimate and 95% CI
for m in naive driven; do
  for i in $(seq 1 71); do model_type=$m SLURM_ARRAY_TASK_ID=$i Rscript R/02-profile_likelihood.R profile; done
  model_type=$m Rscript R/02-profile_likelihood.R merge
done

# 3. NPI scenarios at the point estimate and both ends of the CI
for m in naive driven; do
  for e in point_est left right; do model_type=$m est_type=$e Rscript R/03-npi_scenarios.R; done
done

# 4. Tables and figures
Rscript R/04-report.R report

Each call inside the loops is independent of the others in the same loop, which is how they were run on the cluster, as array jobs. The report writes to data/run/paper/report/:

File Contents
beta0_estimates_bootstrap_corrected.csv point estimate and 95% CI of beta_0, with the other three parameters, for each model
npi_under5_bootstrap_corrected.{png,csv} percent reduction in RVGE hospitalizations in children under 5, by NPI and model (Figure 3)
npi_age5plus_bootstrap_corrected.{png,csv} the same for ages 5 and older (Figure S3)
fit_ci_bootstrap_corrected.png observed and modeled monthly hospitalization rates by year of age, with bands for the beta_0 CI (Figure S2)
npi_case_counts_point_bootstrap_corrected.csv hospitalizations during the NPI window by scenario, model, and age group, at the point estimate

Along the way, mle/mle_starts_<run_date>.csv lists every starting value with its estimates and negative log-likelihood, and profiles/ holds each model's profile.

Settings

Variable Used by Values
run_date all name of the run; outputs go to data/run/<run_date>/
start_yr, end_yr all (01b and 02 merge read only end_yr) simulated years: 0 and 30 in the paper; shorter horizons are for tests only
model_type 01, 02, 03 naive or driven (behavior-dynamic)
CM_SET 01 to 04 bootstrap (the paper) or weighted (default)
CM_EXPANSION 01 to 04 corrected (default) or old, an earlier expansion of the 2x2 matrices that divided the under-5 rows by 5 once too often, kept to compare with earlier runs (weighted matrices only)
START_ID 01 row of the starting values in R/mle_starts.R, 1 to 6 (default 1)
MLE_MAXIT 01 maximum function evaluations per Nelder-Mead call (default 3000; lower it only for tests)
START_MLE_FILE 01 optional: start from the estimates in an earlier MLE output file
ROUND_SIM 01, 02 FALSE (default): the likelihood rounds only the observed rates; TRUE also rounds the simulated rates, as an earlier version did
SLURM_ARRAY_TASK_ID 02 profile the grid value to fit, 1 to BETA_GRID_POINTS
BETA_GRID_POINTS, BETA_LOG_HALF_WIDTH 02 number of grid values and their half-width in log units around the MLE (defaults 61 and 1.05; the paper used 71 and 0.35)
PROFILE_CI_DF 02 merge degrees of freedom of the chi-square cutoff for the 95% CI: 1 (default, one profiled parameter) or 4
EST_SOURCE 03 profile (default): estimates from the profile likelihood; mle: the MLE point estimate, without a profile
est_type 03 point_est, left, or right (the ends of the CI, with EST_SOURCE=profile only)
NPI_TIMING 03 peak (default): start NPI_DAYS_BEFORE_PEAK days before the modeled peak in children under 5; july: start on July 1 of the model year
NPI_DAYS_BEFORE_PEAK 03 default 14
NPI_WINDOW_DAYS 03 days of hospitalizations counted from the NPI start (default 29 with peak)

Running on a cluster

The paper's runs used slurmworkflow on the Rollins School of Public Health cluster at Emory University, in two workflows:

  • R/hpc/workflow-mle_npi.R: the maximum likelihood fits for both models and three contact matrix sets (bootstrap, weighted, and weighted with the earlier expansion) from all six starting values, the selection of the best fits, NPIs at the MLE, and the summary (R/05-summarize_mle_npi.R).
  • R/hpc/workflow-profile_npi.R: the profile likelihood for both models with the bootstrap matrices, the merge, and the NPIs at the profile estimates, reading the MLEs from the first workflow's run folder.

The report (R/04-report.R) was then run locally. deploy-mle_npi.sh and deploy-profile_npi.sh build, ship, and start each workflow and are meant to be run line by line. The cluster-specific settings (R module, partitions, notification email) are in R/hpc/hpc_configs.R, and renv.lock.hpc pins the packages the cluster jobs restore. The step scripts themselves contain nothing cluster-specific, so they can be run with any scheduler that sets the environment variables above.

Repository layout

R/
  functions/               model, likelihood, NPI, profile likelihood, and plotting functions
    load_functions.R       sources the files above; every step calls it
  load_parameters.R        fixed parameters, initial state, contact matrices, calibration target
  mle_starts.R             the six starting values for the maximum likelihood fit
  01-fit_mle.R             maximum likelihood fit for one model, contact matrix set, and starting value
  01b-select_mle.R         keeps the best fit for each model and contact matrix set
  02-profile_likelihood.R  profile likelihood for beta_0 ("profile") and its point estimate and 95% CI ("merge")
  03-npi_scenarios.R       NPI scenarios at the profile estimates or at the MLE
  04-report.R              tables and figures from the profile and NPI results
  05-summarize_mle_npi.R   summary of a run without a profile: estimates, NPI reductions, fit plots, equilibrium check
  hpc/                     slurmworkflow settings and workflow builders
  archive/                 functions from the original code that the pipeline does not call
data-raw/                  script that built the hospitalization series (not part of the pipeline)
data/input/parameters/     fixed parameter table; all other data are not tracked
deploy-mle_npi.sh          cluster deploy, maximum likelihood workflow
deploy-profile_npi.sh      cluster deploy, profile likelihood workflow
renv.lock, renv.lock.hpc   package versions, local and cluster

License

GPL-3.0. See LICENSE.

About

Rotavirus transmission model using SickMix contact data

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages