Pipeline scripts (called by the Snakefile). Run any with --help for arguments, defaults, and examples.
hapmap_low_rec_mask.py— per-chromosome BED of the bottom--rec-fractionof HapMap recombination-rate intervals. Chromosome names are matched symmetrically across the two common conventions:1,chr1,chr_1andChr-1all resolve to each other in either direction, and a pipeline base-name prefix (combined.1,amaranth.16) is stripped from the query first. An exact match always wins, and a file holding two spellings of the same chromosome is an error rather than a coin flip.find_low_access_regions.py— BED of low-accessibility windows, computed from a tree sequence's inferred mutation map.mutload_summary.py— interactive HTML diagnostic for the mutload step: per-individual residual load after window-level pruning (ASCII bar chart, red highlight on individuals still outside the cutoff band, lineage table of flagged counts).mutload_masks.py— outlier and mutation-masked BED files for one tree sequence (pipeline step 3).combine_remove_masks.py— merge the step 1–3 BED masks into a single combined BED per chromosome.trim_regions_single.py— the pipeline step-4 command; apply a BED mask to one tree sequence while preserving the original coordinate system and embedding the resolved mutation map.trim_samples.py— remove individuals genome-wide (--individuals) or over BED intervals (--remove). See Sample ID matching for the exact sample-ID matching rules.filter_min_samples.py— drop intervals whose local trees retain fewer than--min-samplesnon-isolated sample nodes, viadelete_intervals(coordinates preserved); updateskept_intervalsmetadata and writes a diagnostic BED. Optional pipeline step 5b, driven bymin_samples.validation_plots_from_ts.py— SINGER-style QC plots (mutational load, diversity, Tajima's D, folded/unfolded SFS) across TS replicates; optional observed-vs-simulated overlays. Also dumps the plotted values towindows.tsv/samples.tsv/sfs.tsv, one table per plot axis, with adatasetcolumn so a--comparerun keeps both series in the same file.genomewide_expected_vs_observed.py— pool the per-chromosomewindows.tsvfiles into one expected-vs-observed scatter per statistic (π and Tajima's D), coloured by each window's length-weighted mean recombination rate. Pass--all-chromsto have each figure state how much of the genome it actually covers; it prints a warning and titles the plotPARTIAL GENOMEwhen chromosomes are missing. Windows the map does not cover are drawn grey rather than as zero-rate; when the positive rates span more than a decade the colour axis is log-scaled and zero-rate windows are clipped to the smallest positive rate (stated on the colourbar).merge_treefiles_by_replicate.py— concatenate chromosome-specific tree-sequence files by replicate; embedded mutation-rate ratemaps are merged and carried forward.export_vcf.py— export a.vcf/.vcf.gzfrom a (filtered) tree sequence: variable sites only, ploidy-aware genotypes, and samples pruned bytrim_sampleswritten as missing (.) viaisolated_as_missing. Driven byemit_vcf; see VCF export.pipeline_summary.py— self-contained HTML report of genome retention, per-individual outlier counts, the genome-wide expected-vs-observed panels from step 6b, and the embedded per-chromosome validation plots. Requires--filtered-ts(the final per-chromosome tree sequences, in the<chrom>/<rep>.<suffix>layout produced by steps 5/5b), which it loads to measure retained sequence directly from each ARG.--run-configtakes therun_config.jsonthe Snakefile writes; every setting in it is shown, including keys the script does not list explicitly. The "Inputs and fallbacks" table is built from the step logs (logs/step1–step3) and the final ARGs'mu_sourcemetadata, and a red banner at the top lists any fallback.
Scripts not called by the Snakemake pipeline. Run any with --help for its full
argument list, defaults, and examples.
coalescence_ne_plots_from_ts.py— pair-coalescence and Ne plots from TS replicates. Choose the time grid with one of--time-bins-file(explicit edges),--num-quantiles N(equal-coalescence-event bins derived frompair_coalescence_quantilesaveraged over post-burnin replicates), or--num-bins N(uniform log-spaced bins across the observed coalescence-time range). Note that--num-binsmeant equal-coalescence-event bins up to v1.8; that mode is now--num-quantiles, so pre-v1.9 commands need renaming to reproduce their old time grid. Optional Demes-based coalescent simulations (--sim N) produce window-stat and SFS TSVs for observed-vs-sim density plots invalidation_plots_from_ts.py. Full option list and outputs: coalescence_ne_plots.md.compare_trees_html.py— render one tree index from each of two tree sequences side-by-side into a single HTML file.locate_tree.py— find the local tree at a(chromosome, position)in a merged tree sequence, using thechrom_offsetsmetadata to map the within-chromosome coordinate to the concatenated axis. See Locating a tree by chromosome and position.trees_gallery_html.py— scrollable HTML gallery of all trees from two tree sequences, useful for quick before/after inspection.simulate_two_bottleneck_demography.py— simulate replicate ARGs under a fixed two-bottleneck demography (35 ka + 9 ka bottlenecks, present-day expansion) for known-truth pipeline tests.make_realistic_example.py— generate a realistic synthetic example dataset (ARGs from the two-bottleneck model + three injected flaws: contaminated individuals, per-window sample pruning, and amut_rate.paccessibility mask) for end-to-end pipeline testing. Emits aground_truth.jsonfor scoring the pipeline's masks. See realistic_example.md for details, CLI options, and the ground-truth schema.
- Tree-sequence files: scripts accept
.ts,.trees, and.tszfiles. Loading/writing.tszrequirestszipto be installed; scripts will raise a clear error iftszipis missing when a.tszis used. - BED files: expected as whitespace-separated lines
chrom start end [name].startandendare numeric (half-open intervals[start, end)). If a fourth columnnameis present it may list one or more comma-separated sample IDs; if omitted the BED filename stem is used as the sample name. Lines starting with#and blank lines are ignored. - HapMap recombination maps: when required (e.g.
hapmap_low_rec_mask.py), the script expects the HapMap format used bymsprime.RateMap.read_hapmap. - Glob
--pattern: arguments named--patternaccept shell-style glob patterns (for example "*.tsz") and are matched against filenames in the supplied directory. - Defaults & output locations: many scripts write to a
results/directory or to an output directory under the input tree-directory when--out/--out-dirare not provided. Examples:trim_samples.py: default output is<ts_parent>/trimmed/<ts_stem>_trimmed.tszwhen--outis not given.mutload_summary.pywritesresults/<name>.htmlandlogs/<name>.log; no BED files are written (usemutload_masks.pyfor BED output).- Several plotting scripts write PNG files into
results/by default; most have--outor--out-dirflags to override this.
- Logging & errors: Snakemake captures each rule's stdout/stderr under
logs/slurm/when using the supplied SLURM profile. These scheduler/job logs are distinct from optional per-script summary logs written via a script's--logor--out-diroption. A script exception is therefore diagnosed first from its Snakemake job log; a summary log records completed-script results and is not guaranteed to exist after an early failure. Common failures include missingtszipfor.tszI/O and malformed BED records; BED parsing requires finite numeric coordinates,start < end, and rows within the sequence bounds.
scripts/argtest_common.py contains shared tree-sequence helpers used by multiple scripts:
- TS I/O (
load_ts,dump_ts) - mutational load / stat helpers
- trimming and masking helpers
Use this module for internal script imports rather than duplicating the helpers.
trim_samples.py matches sample/individual IDs exactly against the tree sequence's internal individual names as produced by argtest_common.get_individual_name() (prefers individual.metadata['id'] when present, otherwise a synthetic ind<id> name).
- Matching is exact and case-sensitive.
--name-substring-to-remove(default"") is removed via global string replacement before matching; provide names that match the normalized individual names. Despite replacing the former--suffix-to-stripoption, the operation is not suffix-specific: every occurrence is removed.
Per-individual analyses may pool multiple sample nodes for one individual (for example, two nodes for a diploid). Uniform ploidy is assessed only among represented individuals; individual-table rows with no sample nodes are ignored. The stricter uniform-ploidy and leaf-sample contract remains audit/evidence-gated until it has been checked on the real input corpus.