knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.width = 7, fig.height = 4, dev = "png" )
Pathogen genomic surveillance is the backbone of pandemic preparedness. By sequencing positive samples and tracking lineage frequencies over time, public health agencies can detect emerging variants early and monitor their spread.
However, real-world surveillance systems have a fundamental bias problem: sequencing rates are highly unequal across regions and institutions. A well-resourced capital city might sequence 15% of positive cases, while a rural area sequences only 0.5%. If you simply count uploaded sequences to estimate "what fraction is variant X?", the answer is dominated by high-sequencing regions — regardless of what is actually circulating elsewhere.
On top of this, there is a reporting delay problem. From sample collection to sequence upload, 1–4 weeks can pass. This means the most recent weeks of data are always incomplete, and naive trend estimates systematically undercount the latest period.
survinger addresses both problems in a unified framework.
The package provides three core capabilities:
Resource allocation: Given limited sequencing capacity, how should sequences be distributed across regions and sources to maximize surveillance value?
Design-weighted estimation: Given that sequencing rates differ, how do we estimate lineage prevalence correctly?
Delay-adjusted nowcasting: Given that recent data is incomplete, what is the true current trend?
library(survinger) # Load example data (simulated, 5 regions, 26 weeks) data(sarscov2_surveillance) sim <- sarscov2_surveillance # Create a surveillance design object design <- surv_design( data = sim$sequences, strata = ~ region, sequencing_rate = sim$population[c("region", "seq_rate")], population = sim$population, source_type = "source_type" ) print(design)
The design object captures the stratification structure and computes inverse-probability weights automatically.
The core value proposition: design-weighted estimates correct for sequencing inequality.
weighted <- surv_lineage_prevalence(design, "BA.2.86", method = "hajek") naive <- surv_naive_prevalence(design, "BA.2.86") surv_compare_estimates(weighted, naive)
The gap between the two lines shows the bias introduced by ignoring unequal sequencing rates.
If you have 500 sequencing slots this week, how should you distribute them?
alloc <- surv_optimize_allocation(design, "min_mse", total_capacity = 500) print(alloc)
Compare with alternative strategies:
surv_compare_allocations(design, total_capacity = 500)
Estimate the reporting delay distribution and nowcast recent counts:
delay_fit <- surv_estimate_delay(design) print(delay_fit) nowcast <- surv_nowcast_lineage(design, delay_fit, "BA.2.86") plot(nowcast)
The main inference function applies both design weighting and delay correction simultaneously:
adjusted <- surv_adjusted_prevalence(design, delay_fit, "BA.2.86") print(adjusted)
How likely is the current system to detect a variant at 1% prevalence?
det <- surv_detection_probability(design, true_prevalence = 0.01) cat("Weekly detection probability:", round(det$overall, 3), "\n") cat("Required sequences for 95% detection:", surv_required_sequences(0.01), "\n")
The phylosamp package provides sample size calculations for variant surveillance — it answers "how many sequences do I need in total?"
survinger answers the next question: "Given my fixed capacity, how do I allocate it optimally, and how do I correct the resulting estimates for the biases my design introduces?"
The two packages are complementary, not competing.
vignette("allocation-optimization") — deep dive into allocationvignette("delay-correction") — delay estimation and nowcastingAny scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.