sweeplink-extract¶
Reads a finished run, decides which loci are under selection, and writes the input files for a focused second round on just those loci.
$ sweeplink-extract --prefix doc --out-prefix doc_r2
Read 413 loci from 'doc_s_statePosteriors.txt' (100000 MCMC samples each;
selecting where at most 0 disagree, posterior >= 0.99999).
Selected 45 of 413 loci (18 positive, 27 negative).
doc_r2_alleleCounts.txt
doc_r2_meta.txt
doc_r2_selected.txt
Second round: N fixed at the estimate of the first run, linkage off.
Pop1: N = 82899 (from 10000 pooled samples)
sweeplink infer \
--counts doc_r2_alleleCounts.txt \
--meta doc_r2_meta.txt \
--mu_a_A 1e-8 \
--N 82899 --log10N.update false \
--linkage false \
--out doc_r2
It prints the exact command for the second round, with the population size already filled in — copy it and run it.
Input and output¶
--prefix/--dirs+--run-nameThe run(s) to read. See combining several runs. Each run is thresholded on its own and the selected loci concatenated, so runs of different lengths may be combined — but their meta files and
mu_a_Amust match.--out-prefix <prefix>Required. Prefix for the three files written:
File
Contents
<prefix>_alleleCounts.txtCounts for the selected loci only.
<prefix>_meta.txtCopied from the input run.
<prefix>_selected.txtThe shortlist with direction,
mean_sand support — see file formats.--counts <file>,--meta <file>,--iterations <n>Override what is recorded in
<prefix>.parameters. Valid only with a single--prefix;--iterationsis only needed for runs made by versions that did not record it.
Choosing what counts as “under selection”¶
The criterion is how many of the MCMC samples agree on the sign of s. The
default is the strictest possible: every sample must agree.
The same threshold can be expressed three ways. Pass at most one:
--max-samples-against <n>How many samples may disagree. Default 0. The plainest of the three — an ordinary small integer with no risk of misreading the direction.
--min-posterior <p>The same threshold as a probability, on the smoothed scale that is plotted and reported.
--min-evidence <e>The same threshold as
-log10(1 - posterior)— the units of the y-axis ofsweeplink-plot’s evidence panel. Bigger is stricter, but written as an ordinary small number instead of a string of 9s.
On the tutorial’s run these three select the same 85 loci:
$ sweeplink-extract --prefix doc --out-prefix loose --max-samples-against 5000
$ sweeplink-extract --prefix doc --out-prefix loose --min-posterior 0.95
$ sweeplink-extract --prefix doc --out-prefix loose --min-evidence 1.3
Warning
--min-posterior’s useful range is always extremely close to 1 (like
0.99999). A value near 0, such as 1e-6, reads as if it means “almost nothing
required” — and it does exactly that, accepting nearly every locus. If you want
a strict threshold written as a small number, use --min-evidence.
--min-posterior 1.0 selects nothing and says so: with the neutral pseudo-count
nothing can reach exactly 1, the ceiling being iterations/(iterations+1). Use
--max-samples-against 0 for the strictest threshold.
--direction <both|positive|negative>Keep only one direction of selection. Default
both.
The population size for round 2¶
The printed N is 10^mean(log10N) over the run’s MCMC samples — not the
mean of N, which sits far out in the right tail. With several runs the raw
log10N samples are pooled across all of them; see
combining several runs.
Using it to rank a shortlist¶
sweeplink-extract computes a signed mean_s for every locus it is given, so
pointing it at a second-round run with a threshold loose enough to keep
everything turns it into a ranking tool:
$ sweeplink-extract --prefix doc_r2 --out-prefix doc_r2_ranked --max-samples-against 100000
$ tail -n +2 doc_r2_ranked_selected.txt | sort -t$'\t' -k4,4 -g -r | head