Decide which cases to sequence next, under a fixed laboratory budget.
Genomic surveillance programs can sequence only a fraction of reported cases. Which fraction you pick determines what you can see. BeyondBaseline takes a line list, a population, and a weekly budget, and returns a ranked list of cases to sequence — balancing demographic representativeness against visibility of transmission structure.
It runs in two modes:
| mode | for | needs |
|---|---|---|
| Operational | a health department choosing this week's samples | a real line list + population table |
| Research | evaluating sampling strategies against known truth | simulated data with ground truth |
The operational mode needs no simulation, no digital twin, and no agent-based model. It works on the data a surveillance program already has.
pip install -e .Verify:
python scripts/scenarios_simulation/verify_cli_entrypoints.pyOne command, one week, one decision.
beyond-baseline \
-l linelist.csv \
-p population.txt \
-b 400 \
--current-date 2021-07-12 \
--target "LL,P" \
--time-budget 4 \
--algorithm SURS \
--outdir week28/| flag | meaning |
|---|---|
-l, --linelist |
reported cases: one row per case, with a date and demographics |
-p, --population |
the population you are sampling from (census or synthetic) |
-b, --batch-size |
how many sequences you can run this week |
--current-date |
Monday of the week being decided |
--target |
what to match: LL line list, P population, LL,P blended |
--time-budget |
rolling pool window, in weeks |
--algorithm |
one of the strategies below |
-g, --already-sequenced |
last week's output, so cases are not re-picked |
outdir/
├── samples_new_scen99_SURS.csv the recommendation: which cases to sequence
├── history_updated_scen99_SURS.csv cumulative record, feeds next week's -g
├── history_combined_all.csv same, across all algorithms run
└── weekly_summary.txt human-readable report
and on stdout:
Target: LL,P → 4S-4(LL,P)
pool_window=4, decision_window=4, blend_alpha=0.5
SURS | pool= 1870 | batch= 400 | sampled= 400 | KL=0.120586 | 0.01s
Combined history: week28/history_combined_all.csv (400 rows)
Next week: --already-sequenced week28/history_combined_all.csv
The KL figure is divergence between your chosen samples and the target distribution — lower is more representative.
Feed the previous week's history back in, so the sampler knows what has already been sequenced and does not pick it again:
# week 28
beyond-baseline -l linelist.csv -p population.txt -b 400 \
--current-date 2021-07-12 --target "LL,P" --algorithm SURS --outdir week28/
# week 29
beyond-baseline -l linelist.csv -p population.txt -b 400 \
--current-date 2021-07-19 --target "LL,P" --algorithm SURS \
-g week28/history_combined_all.csv --no-replacement --outdir week29/--target |
matches | use when |
|---|---|---|
LL |
the recent line list | you want samples to mirror who is actually being reported |
P |
the underlying population | you want to correct for ascertainment bias |
LL,P |
a blend (--blend-alpha, default 0.5) |
the usual compromise |
| name | shorthand | behaviour |
|---|---|---|
SURS |
surs |
simple uniform random sampling — the common baseline |
Stratified |
rigid demographic quotas | |
Uniform Random |
uniform with a minimum per group | |
Greedy |
greedy KL minimisation against the target | |
LASSO-Stratified |
ls |
sparse risk modelling, then stratified |
LASSO-Greedy |
lg |
sparse risk modelling, then greedy |
RL |
Gittins/UCB bandit (experimental) |
--algorithm is repeatable, so several can be compared in one run.
That trade-off between demographic equity and topological visibility is what this software exists to navigate.
Evaluates many strategies across many scenarios against simulated data, where the true transmission network is known.
beyond-baseline-sweep \
--linelist replicate_0/linelist.csv.xz \
--population va_persontrait_epihiper.txt \
--infections replicate_0/linelist_allevents.csv.xz \
--outdir runs/ \
--batch-size 400 --no-replacement --seed 42 --save-samples \
--algorithms surs stratified lasso_greedy lasso_stratified \
--stratifiers age race county sexOutputs KL_series.csv, AUC_rankings.csv and, with --save-samples, the
selected cases per scenario and algorithm.
--algorithms accepts registry names (LASSO-Greedy), the aliases listed in
--help, or the recipe slug (lasso_greedy, uniform_random). The slug is
the cross-repo spelling: it is what PhyloGAS passes from sampling.algorithms.
A recipe is one scenario (stride, pool window, target) plus one algorithm,
and is what downstream tools name. Its id is <scenario>__<algorithm slug>,
and --save-samples writes <recipe id>_samples.csv.xz:
4S-4_LL-P__lasso_greedy_samples.csv.xz # 4-week stride, 4-week pool, LL,P target
4S__surs_samples.csv.xz # SURS: stride only
SURS ignores the target and pool window, so all scenarios sharing a stride
draw the same sample. Those collapse to one recipe per stride (1S__surs,
4S__surs) rather than writing identical files under different names — 38
recipes in all. Old ids such as 4S-4_LL-P__surs still resolve, as aliases.
scenarios-recipes # print every recipe id, its scenarios, and its sample fileSURS sampling is seeded from --seed (per algorithm, per week), so several
draws on one line list differ and sampling replicates are meaningful. Before
this fix SURS was a pure function of the line list — its samples are not
bit-identical to those from earlier releases.
Multiple replicates:
beyond-baseline-replicates --replicates-dir data/replicates --population pop.txt
beyond-baseline-aggregate --input-dir replicate_results --outdir replicate_resultsMetrics that require agent-based-model ground truth — mugration cosine similarity, topological F1 — moved to PhyloGAS, so that BeyondBaseline stays runnable on a real line list with no simulation attached.
beyond-baseline-sweep ... --save-samples --outdir runs/
phylogas benchmark mugration --truth <abm.json> \
--samples 'runs/*_samples.csv.xz' --infections <allevents.csv.xz>See cste_instructions.txt for the full before/after
mapping.
| command | purpose |
|---|---|
beyond-baseline |
operational — one week, one decision |
beyond-baseline-sweep |
research — many scenarios × algorithms |
beyond-baseline-replicates |
research — drive multiple replicates |
beyond-baseline-aggregate |
research — aggregate across replicates |
beyond-baseline-lasso-greedy |
LASSO-Greedy group-size sweep |
beyond-baseline-lasso-stratified |
LASSO-Stratified group-size sweep |
scenarios-recipes |
print the recipe index (ids and sample filenames) |
Older names remain available and behave identically, so existing sbatch scripts keep working:
| deprecated | use instead |
|---|---|
scenarios-weekly |
beyond-baseline |
scenarios-runner |
beyond-baseline-sweep |
scenarios-replicates |
beyond-baseline-replicates |
scenarios-aggregate |
beyond-baseline-aggregate |
scenarios-lasso-greedy |
beyond-baseline-lasso-greedy |
scenarios-lasso-stratified |
beyond-baseline-lasso-stratified |
Running the scripts directly (python3 run_all_scenarios.py ...) also still
works.
Line list — one row per reported case:
| column | notes |
|---|---|
date |
report or collection date (--date-field to rename) |
age_group, sex, smh_race, county |
whichever you pass to --stratifiers |
alias_pid |
case identifier |
alias_contact |
infector, if known — enables coverage metrics |
Population — the sampling frame, in EpiHiper persontrait format: a JSON
schema line, then a header with pid, gender, county, smh_race,
age_group.
--stratifiers accepts the short names age, race, county, sex, ses,
which map onto age_group, smh_race, county, sex, ses_category.
county is the county name, present in both the line list and the
persontrait file; county_fips exists only in TwinSampler line lists and so
cannot be matched against the population.
Three independent axes:
- Demographic representativeness — KL divergence of the sample against census, line list, or blended targets.
- Variant accuracy — absolute error in estimated variant prevalence.
- Transmission topology — Mean Reciprocal Distance for tree coverage (cumulative, by tree size, over an 8-week window, and per age group), component coverage, and cosine similarity and topological F1 for geographic flow.
Only the first axis is computed here, as kl_targets in AUC_rankings.csv.
The other two need the simulation's ground truth -- true variant counts and
the transmission graph -- which a real line list does not carry, so PhyloGAS
computes them (phylogas benchmark truth, phylogas benchmark mugration).
This keeps the sweep runnable by a health department on its own data.
Supports sliding windows, multi-week strides (4S-4), no-replacement pooling,
and SLURM array submission for large sweeps.
| file | role |
|---|---|
run_weekly_sampling.py |
operational mode |
run_all_scenarios.py |
research sweeps |
sampling_algorithms.py |
the strategies, including proportional backfill and LASSO macro-bucketing |
scenarios_config.py |
scenario definitions and defaults |
aggregate_results.py |
cross-replicate aggregation; median Z-scores and AUC rankings |
submit_*.sbatch |
SLURM array templates |
- TwinSampler — generates the ascertainment-biased line lists used in research mode
- PhyloGAS — the benchmarking framework that consumes BeyondBaseline's selections and scores them against ground truth