Simulation

The simulate task generates time-series allele count data under sweepLink’s own model.

$ ./sweeplink simulate --numLoci 500 --numPop 1 --mu_a_A 1e-8 --out sim

Note

For a proper benchmark, use SLiM instead. Simulating under the same model you then fit tells you that the implementation is self-consistent, not that it works on real data — and SLiM’s simulations are considerably more realistic. This task is the quickest way to get test data in the right format: for checking a pipeline end to end, exploring how a setting behaves, or producing a small example. Use it for that, and reach for SLiM when the answer has to hold up.

The model arguments are the same as for infer — the grids, --deltaT, the priors, --linkage, --numStatesAbsS, and so on — since data are simulated under exactly that model. What follows are the arguments specific to simulating.

What to simulate

--numLoci <n>

Number of loci. Default 100.

--times <t1,t2,...>

The sampled time points, in generations. Default 1,10,50,100,500,1000.

--numPop <n>

Number of populations, each sampled at every time point. Default 2.

--meta <file>

Instead of --times and --numPop, take the design from a meta file. Use this when you need a ragged design — populations sampled at different times — which the two flags above cannot express.

--chunks <n1,n2,...>

Split the loci into independent chunks, e.g. chromosomes. The values must sum to --numLoci. Default: one chunk containing everything.

Distances between loci

These set the physical spacing that the spatial layer’s transition probabilities depend on.

--rateDistances <lambda>

Distances are drawn from a Poisson with this rate. Default 100.

--fixedDistances <d>

Use the same distance d between every pair of consecutive loci instead of drawing them.

Sampling depth

--binomialN <n1,n2,...>

The number of chromosomes sampled per population — one value per population.

--fractionBinomialN <f>

If --binomialN is not given, sample this fraction of each population’s N. Default 0.1, and must lie in [0, 1].

Starting allele frequencies

Pass at most one; the default is the model’s own prior.

--initUniformX

Draw the starting frequency uniformly on [0, 1].

--initBetaX (with --alphaX, --betaX, both default 0.7)

Draw it from a Beta distribution. The default shape puts most mass near 0 and 1, as a neutral site-frequency spectrum does.

--initialX <x1,x2,...>

Fix the starting frequencies explicitly.

How to simulate

--simulateWF

Simulate under the true discrete Wright-Fisher model rather than the diffusion approximation. Slower, and the more honest check of the two — if inference recovers the truth under this, the diffusion approximation is not doing the work.

--simulateForward

Simulate using the forward operator.

Without either, the diffusion is used.

Output

The counts and meta files are written with the --out prefix, in exactly the format infer reads, so a simulation can be fed straight back in. The true parameter values are written alongside, which is what makes this useful for checking recovery.

--writeAlleleFreq [<prefix>]

Also write the underlying allele frequency trajectories — the X values that the counts were sampled from, and which you never observe in real data. One file per locus.

--writeSummaryAlleleFreq [<prefix>]

Write a single summary of the allele frequencies across loci instead of one file each.