Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
sweepLink documentation
Light Logo Dark Logo

Getting Started

  • Installation
  • Tutorial
    • Step 1: Preparing the Input
    • Step 2: Inference
    • Step 3: Results
    • Step 4: Refining
  • Using your own data

User Manual

  • How it works
  • sweepLink tasks
    • Inference
    • Simulation
    • Likelihood surfaces
  • Companion scripts
    • sweeplink-vcf2input
    • sweeplink-extract
    • sweeplink-plot
    • sweeplink-plot-posteriors
  • File formats
  • FAQ
Back to top

sweeplink-plot¶

The two-panel figure of the selection signal along the genome.

$ sweeplink-plot --prefix doc

Writes doc_selection.png. Nothing else is needed — the run’s settings come from doc.parameters.

Panel A, evidence. One dot per locus at -log10(1 - P), where P is the posterior probability that the sign of s is as inferred. Dots are coloured only by chromosome, alternating grey and blue; the red dashed line is the selection threshold. A locus is under selection by being above it, exactly as in a Manhattan plot.

Panel B, effect size. The posterior mean of |s| along the genome as a shaded area, with the loci that passed the threshold marked in red.

Note

The evidence axis is -log10(1 - P) rather than P because the posterior saturates: with 100,000 samples nothing can exceed 100000/100001, so on a plain 0–1 axis every strong locus is crushed into the top sliver.

Input¶

--prefix / --dirs + --run-name

The run(s) to plot. See combining several runs. All runs must share the same iterations, since one threshold line is drawn for all of them, and a locus may not appear twice.

--round2-prefix / --round2-dirs + --round2-run-name

A second, refined round to overlay. Its estimates appear as filled red markers, the first round’s as hollow ones, joined by a line so the shift of each locus is visible.

--counts <file>, --iterations <n>, --round2-iterations <n>

Override what is recorded in the .parameters files. Valid only with a single prefix.

Output¶

--out <file>

Where to write. Default <prefix>_selection.png. The extension picks the format — .png, .pdf or .svg.

--dpi <n>

Resolution for raster output. Default 200. Raise it for print — --dpi 300 or --dpi 600.

Tip

Which format depends on how many loci you are plotting. A vector file stores one element per locus, so it grows with the data, while a PNG is the same size whatever it plots:

Loci

PNG

SVG

413

139 KB

109 KB

4,000

105 KB

591 KB

For a few thousand loci — the tutorial, a --region zoom, the --compare scatter — vector wins on both size and quality, which is why the figures in these docs are SVG.

Past roughly ten thousand loci that reverses. The growth is about 138 bytes per locus, so a chromosome with 500,000 loci would make an SVG of around 69 MB: slow to open, and awkward in a repository or a manuscript. There, use --dpi 300 for a print-quality PNG at a fraction of the size.

--show

Open the figure in matplotlib’s own interactive window (pan, rubber-band zoom, save) instead of writing a file. With --out as well, both happen. Needs a local display, so it will not work over a plain SSH session.

Appearance¶

--theme <light|dark>

Colours for a light or a dark page. Default light.

--title <text>

Replaces the default title.

--markers <dot|triangle>

Marker shape in panel B. triangle additionally encodes direction — up for positive, down for negative. Default dot; the direction is in _selected.txt either way.

--region <chr[:start-end]>

Zoom both panels to one chromosome or a stretch of it, e.g. 2 or 2:10000-60000. Either side of the range may be left open (2:10000-). This is a data filter, so it works with or without --show.

The chromosome is named exactly as it appears in the first column of the counts file. In the tutorial’s data that is 2, so --region chr2 matches nothing; if your own file uses chr2, then chr2 is what to pass.

Annotating peaks¶

--labels <file>

A tab-separated file with chr, pos and label columns, plus an optional label_bottom — see file formats. The two panels say two different things about the same locus:

Column

Panel

Style

label

A, evidence

italic, rotated, above the panel with a leader line down to the peak

label_bottom

B, |s|

bold, horizontal, just to the right of the marker

chr	pos	label	label_bottom
2	50001	true sweep	2:50001

Without a label_bottom column, panel B falls back to the locus’s own chr:pos — which for the row above is 2:50001 anyway, so the column is only needed when you want different text there. Either label may be left empty to annotate just one panel.

Keep the annotation short: it has to share the figure with the data, and a short label is far less likely to collide with a neighbour. Room above panel A is made automatically from the measured size of the text, so long labels do not overrun the axis — but many labels packed into one narrow region will still overlap, simply because there is no space.

The threshold¶

The same three forms as sweeplink-extract, and they mean the same thing — pass at most one, and pass the same value you extracted with so the line matches the shortlist:

--max-samples-against <n> · --min-posterior <p> · --min-evidence <e>

Comparing the two rounds¶

--compare

Only with a second round. Writes an additional figure, <out-stem>_comparison.png: a scatter of every paired locus’s |s| in round 1 against round 2, with the line where the two would agree. The quickest way to see that removing the linkage model shifts estimates up, and by how much.

$ sweeplink-plot --prefix doc --round2-prefix doc_r2 --compare
Next
sweeplink-plot-posteriors
Previous
sweeplink-extract
Copyright © 2024, Ekaterina Noskova
Made with Sphinx and @pradyunsg's Furo
On this page
  • sweeplink-plot
    • Input
    • Output
    • Appearance
    • Annotating peaks
    • The threshold
    • Comparing the two rounds