How phac-nml-phrsd/ern works
Project type and purpose
• This is an R package (“ern”) whose purpose is to estimate the time‐varying effective reproduction number (Rₜ) of pathogens using either clinical testing data or wastewater surveillance data. It provides data‐processing pipelines, statistical inference (including a JAGS‐based MCMC implementation), plotting utilities, vignettes for users, and integration with CRAN.
File structure
• Top‐level files: DESCRIPTION, NAMESPACE, LICENSE, README.md (package metadata)
• R/: core R code modules, each file encapsulates specific functionality (data ingestion, deconvolution, smoothing, estimation, plotting, diagnostics)
• data-raw/: scripts that generate raw data for inclusion in data/
• data/: packaged datasets (cl.data, ww.data) used for examples and testing
• inst/: citation and other miscellaneous install‐time files
• man-roxygen/ & man/: roxygen source and generated Rd documentation
• tests/: testthat suite with helper scripts and reference test data
• vignettes/: user guides and reproducible examples
• .github/workflows/: CI config for test/coverage on GitHub Actions
README for additional insights
• Describes two inference methods (“renewal” via JAGS and “linear” interpolation)
• Notes external dependency on JAGS (rjags) for Bayesian inference
• Mentions vignettes as interactive tutorials
• Outlines developer workflow for CRAN submission
a. Main components
• External Inputs:
– Clinical incidence data (user‐provided)
– Wastewater surveillance data (user‐provided)
• Data Ingestion & Preprocessing: scripts in R/data-raw and R/data.R
• Distribution Library: R/distributions.R, parameter modules (incubation, serial interval, shedding)
• Deconvolution & Interpolation Engines:
– Renewal‐method using JAGS (R/deconvolution_RL.R, R/mcmcdiag.R)
– Linear‐interpolation method (R/linear_int_daily.R)
• Rₜ Estimation Functions: R/estimate_R_cl*, R/estimate_R_ww*
• Results Summarization & Plots: R/summary_postsamples.R, R/plot.R
• Documentation & Examples: man-roxygen, man/, vignettes/
• Packaging & Tests:
– Package metadata (DESCRIPTION, NAMESPACE)
– Unit tests (tests/)
– CI/CD pipeline (GitHub Actions in .github/)
• External Services: JAGS executable (invoked via rjags), CRAN build farm
b. Relationships and data flows
– User data → Data Ingestion → Distribution Library → Deconvolution/Interpolation → Rₜ Estimation → Summarization & Plots → User output
– Vignettes reference core functions and packaged data
– CI pipeline runs tests and builds package for CRAN
c. Architectural patterns & design principles
– Modular: each R script provides a focused responsibility
– Data‐Centric: raw data → cleaned data → model input → model output
– Pipeline: chaining functions in a well‐defined order
– Test‐Driven: extensive test suite for each function
– Documentation‐First: roxygen to Rd to README to vignettes
d. Key technologies & libraries
– R (language)
– rjags / JAGS (Bayesian inference engine)
– testthat (unit testing)
– roxygen2 (documentation)
– GitHub Actions (CI/CD)