Selection scans (Drosophila DGRP)
The tutorials target the JBrowse v5 beta, and the v4.3.0 release
on the download page lacks some of what they show. To install the
beta of JBrowse Web, run npm install -g @jbrowse/cli@next, then
jbrowse create jbrowse2 --branch v5.0.0-beta.20. Desktop beta builds for Linux and
macOS are on the releases page;
the Windows build waits on code signing.
In Drosophila melanogaster, a selective sweep at the insecticide-resistance
gene Cyp6g1 (Daborn et al. 2002)
and the In(2L)t inversion on chromosome 2L each leave a mark in windowed
population-genetic statistics. π (diversity within a group) dips at the sweep
and Tajima's D falls below zero there, while Fst (the distance between two
groups' allele frequencies) rises across the inversion. The inversion flips a
stretch of 2L end to end and suppresses recombination between the inverted and
standard arrangements in a heterozygote
(Corbett-Detig & Hartl 2012).
Starting from a multi-sample VCF of inbred lines and vcftools' windowed
statistics, packed into bigWigs, we:
- load the Fst bigWig as a quantitative track on dm6 beside the genes
- add Tajima's D, π and called-variant tracks at Cyp6g1 and highlight the sweep
- open all six arms with the inversion's extent over Fst
- stack π for each arrangement in a multi-wiggle track, then color a log2 ratio track with a threshold scale
- facet a one-record inversion VCF into karyotype sections from a sample sheet
Prerequisites
- a JBrowse to open them in: Desktop takes a local file by path, Web through Add track
curlnode, for the JBrowse CLI- vcftools, for the windowed statistics
- bcftools, to read the VCF header and sample list
- htslib (
bgzip,tabix), to index the VCF built in the per-sample section bedGraphToBigWig, to pack a bedGraph into a bigWig
# Debian/Ubuntu
sudo apt install samtools bcftools tabix vcftools nodejs
# or conda, which has every tool above
conda install -c bioconda -c conda-forge samtools bcftools htslib vcftools \
nodejs ucsc-bedgraphtobigwig
# or Linux x86_64 binaries for the tools apt lacks
wget -P ~/.local/bin \
https://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/bedGraphToBigWig
chmod +x ~/.local/bin/bedGraphToBigWig
# any platform
npm install -g @jbrowse/cli@nextThe data
The Drosophila Genetic Reference Panel (DGRP) has 205 inbred lines (Mackay et al. 2012), lifted to dm6. You don't need these files to follow the page: the track configs below read the hosted results. The build script fetches them to rebuild those results. The vcftools steps take your own VCF and two sample lists.
| What it is | File |
|---|---|
| The DGRP freeze-2 genotype calls | DGRP2.source_NCSU.dm6.final.SNPs_only.vcf.gz |
The In(2L)t inversion karyotype for each line, from DGRPool's phenotype record | download |
Building Fst, π and Tajima's D bigWigs with vcftools
DGRPool records each line's In(2L)t arrangement
(Gardeux et al. 2023), harmonizing the
typing of Huang et al. 2015: 0 for
standard homozygotes, 2 for inverted and 1 for heterozygotes.
build_dgrp_popgen.sh
drops the heterozygotes and writes the two sample lists, one name per line, that
vcftools takes for --weir-fst-pop and --keep.
It also renames DGRPool's DGRP_021 to the VCF's DGRP-021. DGRPool types
In(3R)Payne too, so the same grouping on that phenotype scans 3R.
Each scan is a vcftools run, an awk step that turns its table into a bedGraph,
and a bedGraphToBigWig pack. Fst uses the Weir & Cockerham estimator1
(Weir & Cockerham 1984):
# chrom.sizes from the VCF header, so it uses the contig names of the scans
bcftools view -h dgrp2.vcf.gz |
awk -F'[=,>]' '/^##contig/{print $3"\t"$5}' > dm6.chrom.sizes
# window equal to step, so windows tile the genome
vcftools --gzvcf dgrp2.vcf.gz \
--weir-fst-pop In2Lt_INV.txt --weir-fst-pop In2Lt_STD.txt \
--fst-window-size 2000 --fst-window-step 2000 --out fst_In2Lt
# BIN_START is 1-based here, hence -1
# negative Fst is an estimator artifact at low-differentiation sites; floor at 0
# $5 is WEIGHTED_FST, the ratio of summed variance components
# $6, MEAN_FST, averages per-site ratios and swings on a few uninformative sites
# BIN_END is the nominal window end, so the last window of a contig passes its
# end; clamp it, or bedGraphToBigWig refuses the whole file
awk -F'\t' 'NR==FNR{len[$1]=$2; next}
FNR>1 && $5!="nan" && $5!="-nan" {
v=$5+0; if (v<0) v=0
end=$3; if (end>len[$1]) end=len[$1]
if (end>$2-1) print $1"\t"($2-1)"\t"end"\t"v
}' dm6.chrom.sizes fst_In2Lt.windowed.weir.fst |
sort -k1,1 -k2,2n > fst_In2Lt.bedgraph
bedGraphToBigWig fst_In2Lt.bedgraph dm6.chrom.sizes fst_In2Lt.bwDiversity is the same three steps with --window-pi 2000, reading $5 of
pi_all.windowed.pi, with --keep restricting it to one arrangement:
vcftools --gzvcf dgrp2.vcf.gz --window-pi 2000 --out pi_all
vcftools --gzvcf dgrp2.vcf.gz --keep In2Lt_INV.txt --window-pi 2000 --out pi_INV$4 of the same table is the called-variant count the figure below stacks under
π, packed into a bigWig by the same awk and bedGraphToBigWig pair.
Tajima's D (Tajima 1989) reports
BIN_START 0-based, so there is no -1 shift, and has no BIN_END, so the
awk builds the window end before the clamp:
vcftools --gzvcf dgrp2.vcf.gz --TajimaD 2000 --out tajimad_all
# BIN_START is already 0-based, and there is no BIN_END
# build the end here and clamp it to the contig length
awk -F'\t' 'NR==FNR{len[$1]=$2; next}
FNR>1 && $4!="nan" && $4!="-nan" {
end=$2+2000; if (end>len[$1]) end=len[$1]
if (end>$2) print $1"\t"$2"\t"end"\t"$4
}' dm6.chrom.sizes tajimad_all.Tajima.D |
sort -k1,1 -k2,2n > tajimad_all.bedgraph
bedGraphToBigWig tajimad_all.bedgraph dm6.chrom.sizes tajimad_all.bw2 kb windows resolve a single-gene sweep like Cyp6g1; widen toward 5-10 kb for genome-wide overviews.
The bigWigs take contig names from the VCF header (2L, 2R, X, FlyBase
style) while UCSC dm6 writes chr2L, and
refname aliasing maps one to the
other. A mismatch with no alias draws an empty track and raises no error.
The DGRP VCF holds variant sites only, so --window-pi counts every position
missing from the file as invariant and callable, and a window that lost sites to
filtering shows low diversity.2 Filtering also shifts the whole baseline
of Tajima's D, since it removes the rare alleles D is most sensitive to, and
vcftools counts two chromosomes where an inbred line contributes one. Read D at
a locus against the genome-wide background of all the lines.
Loading the scans in JBrowse
We load dm6 from UCSC, whose reference names the arms chr2L. The alias file
maps them to the bare 2L the scans use:
Goes in the assemblies array of config.json. See Assemblies.
{
"name": "dm6",
"aliases": ["BDGP6"],
"sequence": {
"adapter": {
"type": "TwoBitAdapter",
"uri": "https://hgdownload.soe.ucsc.edu/goldenPath/dm6/bigZips/dm6.2bit"
}
},
"refNameAliases": {
"uri": "https://hgdownload.soe.ucsc.edu/goldenPath/dm6/bigZips/dm6.chromAlias.txt"
}
}jbrowse add-assembly https://hgdownload.soe.ucsc.edu/goldenPath/dm6/bigZips/dm6.2bit \
--name dm6 \
--alias BDGP6 \
--refNameAliases https://hgdownload.soe.ucsc.edu/goldenPath/dm6/bigZips/dm6.chromAlias.txtThe gene track is UCSC's curated RefSeq annotation of dm6:
Goes in the tracks array of config.json. See Tracks.
{
"type": "FeatureTrack",
"trackId": "dm6-ncbiRefSeqCurated",
"name": "NCBI RefSeq - RefSeq Curated",
"assemblyNames": ["dm6"],
"adapter": {
"type": "Gff3TabixAdapter",
"gffGzLocation": {
"uri": "https://jbrowse.org/ucsc/dm6/ncbiRefSeqCurated.gff.gz"
},
"index": {
"indexType": "CSI",
"location": {
"uri": "https://jbrowse.org/ucsc/dm6/ncbiRefSeqCurated.gff.gz.csi"
}
}
}
}jbrowse add-track-json '{
"type": "FeatureTrack",
"trackId": "dm6-ncbiRefSeqCurated",
"name": "NCBI RefSeq - RefSeq Curated",
"assemblyNames": ["dm6"],
"adapter": {
"type": "Gff3TabixAdapter",
"gffGzLocation": {
"uri": "https://jbrowse.org/ucsc/dm6/ncbiRefSeqCurated.gff.gz"
},
"index": {
"indexType": "CSI",
"location": {
"uri": "https://jbrowse.org/ucsc/dm6/ncbiRefSeqCurated.gff.gz.csi"
}
}
}
}'In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track..., choose Add track from pasted JSON, and paste:
{
"type": "FeatureTrack",
"trackId": "dm6-ncbiRefSeqCurated",
"name": "NCBI RefSeq - RefSeq Curated",
"assemblyNames": ["dm6"],
"adapter": {
"type": "Gff3TabixAdapter",
"gffGzLocation": {
"uri": "https://jbrowse.org/ucsc/dm6/ncbiRefSeqCurated.gff.gz"
},
"index": {
"indexType": "CSI",
"location": {
"uri": "https://jbrowse.org/ucsc/dm6/ncbiRefSeqCurated.gff.gz.csi"
}
}
}
}Each scan is a quantitative track over its bigWig. To load your own, swap uri
for the bigWig your build wrote, whose contig names must match the assembly or
its aliases.
Goes in the tracks array of config.json. See Tracks.
{
"type": "QuantitativeTrack",
"trackId": "fst_in2lt",
"name": "Fst (In(2L)t vs standard, 2kb windows)",
"assemblyNames": ["dm6"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/fst_In2Lt.bw"
}
}jbrowse add-track https://jbrowse.org/demos/popgen/fst_In2Lt.bw \
--trackId fst_in2lt \
--name "Fst (In(2L)t vs standard, 2kb windows)" \
--assemblyNames dm6In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track... and, in Add a track from file or URL, enter:
- Main file:
https://jbrowse.org/demos/popgen/fst_In2Lt.bw
Click Next. JBrowse reads the adapter and track type off the file name. Then fill in:
- Track name:
Fst (In(2L)t vs standard, 2kb windows) - Assembly:
dm6
Click Add.
Reading the Cyp6g1 sweep in Tajima's D and π
Search Cyp6g1 in the location box and add three QuantitativeTracks shaped
like the Fst track above, each over all the lines: Tajima's D, π, and the
called-variant count per window (column 4 of the table π comes from).
Goes in the tracks array of config.json. See Tracks.
{
"type": "QuantitativeTrack",
"trackId": "tajd_all",
"name": "Tajima's D (whole panel)",
"assemblyNames": ["dm6"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/tajimad_all.bw"
}
}jbrowse add-track https://jbrowse.org/demos/popgen/tajimad_all.bw \
--trackId tajd_all \
--name "Tajima's D (whole panel)" \
--assemblyNames dm6In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track... and, in Add a track from file or URL, enter:
- Main file:
https://jbrowse.org/demos/popgen/tajimad_all.bw
Click Next. JBrowse reads the adapter and track type off the file name. Then fill in:
- Track name:
Tajima's D (whole panel) - Assembly:
dm6
Click Add.
Open this track in JBrowse Web ↗
Needs JBrowse Desktop 5.0 or newer. If nothing opens, copy the link and paste it into Desktop's Open JBrowse Web link..., on the start screen or under File → Session.
https://jbrowse.org/code/jb2/main/?config=https%3A%2F%2Fjbrowse.org%2Fucsc%2Fdm6%2Fconfig.json&session=spec-%7B%22sessionTracks%22%3A%5B%7B%22type%22%3A%22QuantitativeTrack%22%2C%22trackId%22%3A%22tajd_all%22%2C%22name%22%3A%22Tajima%27s+D+%28whole+panel%29%22%2C%22assemblyNames%22%3A%5B%22dm6%22%5D%2C%22adapter%22%3A%7B%22type%22%3A%22BigWigAdapter%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Ftajimad_all.bw%22%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22dm6%22%2C%22loc%22%3A%22chr2R%3A12%2C000%2C000-12%2C400%2C000%22%2C%22tracks%22%3A%5B%22tajd_all%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+Tajima%27s+D+%28whole+panel%29Goes in the tracks array of config.json. See Tracks.
{
"type": "QuantitativeTrack",
"trackId": "pi_all",
"name": "π (whole panel)",
"assemblyNames": ["dm6"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/pi_all.bw"
}
}jbrowse add-track https://jbrowse.org/demos/popgen/pi_all.bw \
--trackId pi_all \
--name "π (whole panel)" \
--assemblyNames dm6In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track... and, in Add a track from file or URL, enter:
- Main file:
https://jbrowse.org/demos/popgen/pi_all.bw
Click Next. JBrowse reads the adapter and track type off the file name. Then fill in:
- Track name:
π (whole panel) - Assembly:
dm6
Click Add.
Open this track in JBrowse Web ↗
Needs JBrowse Desktop 5.0 or newer. If nothing opens, copy the link and paste it into Desktop's Open JBrowse Web link..., on the start screen or under File → Session.
https://jbrowse.org/code/jb2/main/?config=https%3A%2F%2Fjbrowse.org%2Fucsc%2Fdm6%2Fconfig.json&session=spec-%7B%22sessionTracks%22%3A%5B%7B%22type%22%3A%22QuantitativeTrack%22%2C%22trackId%22%3A%22pi_all%22%2C%22name%22%3A%22%CF%80+%28whole+panel%29%22%2C%22assemblyNames%22%3A%5B%22dm6%22%5D%2C%22adapter%22%3A%7B%22type%22%3A%22BigWigAdapter%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Fpi_all.bw%22%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22dm6%22%2C%22loc%22%3A%22chr2R%3A12%2C000%2C000-12%2C400%2C000%22%2C%22tracks%22%3A%5B%22pi_all%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+%CF%80+%28whole+panel%29Goes in the tracks array of config.json. See Tracks.
{
"type": "QuantitativeTrack",
"trackId": "sites_all",
"name": "Called variants per window",
"assemblyNames": ["dm6"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/sites_all.bw"
}
}jbrowse add-track https://jbrowse.org/demos/popgen/sites_all.bw \
--trackId sites_all \
--name "Called variants per window" \
--assemblyNames dm6In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track... and, in Add a track from file or URL, enter:
- Main file:
https://jbrowse.org/demos/popgen/sites_all.bw
Click Next. JBrowse reads the adapter and track type off the file name. Then fill in:
- Track name:
Called variants per window - Assembly:
dm6
Click Add.
Open this track in JBrowse Web ↗
Needs JBrowse Desktop 5.0 or newer. If nothing opens, copy the link and paste it into Desktop's Open JBrowse Web link..., on the start screen or under File → Session.
https://jbrowse.org/code/jb2/main/?config=https%3A%2F%2Fjbrowse.org%2Fucsc%2Fdm6%2Fconfig.json&session=spec-%7B%22sessionTracks%22%3A%5B%7B%22type%22%3A%22QuantitativeTrack%22%2C%22trackId%22%3A%22sites_all%22%2C%22name%22%3A%22Called+variants+per+window%22%2C%22assemblyNames%22%3A%5B%22dm6%22%5D%2C%22adapter%22%3A%7B%22type%22%3A%22BigWigAdapter%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Fsites_all.bw%22%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22dm6%22%2C%22loc%22%3A%22chr2R%3A12%2C000%2C000-12%2C400%2C000%22%2C%22tracks%22%3A%5B%22sites_all%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+Called+variants+per+windowTo band the swept window, drag across chr2R:12,130,000-12,200,000 on the
scalebar and pick Highlight region.
Called variants fall under the sweep because a duplication of Cyp6g1 segregates alongside the resistance allele (Schmidt et al. 2010), and the duplicated sequence lowers the number of sites called in the window.
The In(2L)t inversion, genome-wide and within each arrangement
Open the assembly with no location to lay the six arms out side by side, with
the In(2L)t Fst track across all of them. A track above Fst marks the
published extent of the inversion with one inline feature:
Goes in the tracks array of config.json. See Tracks.
{
"type": "FeatureTrack",
"trackId": "in2lt_inversion",
"name": "In(2L)t inversion",
"assemblyNames": ["dm6"],
"adapter": {
"type": "FromConfigAdapter",
"features": [
{
"uniqueId": "in2lt",
"refName": "chr2L",
"start": 2225744,
"end": 13154180,
"name": "In(2L)t"
}
]
}
}jbrowse add-track-json '{
"type": "FeatureTrack",
"trackId": "in2lt_inversion",
"name": "In(2L)t inversion",
"assemblyNames": ["dm6"],
"adapter": {
"type": "FromConfigAdapter",
"features": [
{
"uniqueId": "in2lt",
"refName": "chr2L",
"start": 2225744,
"end": 13154180,
"name": "In(2L)t"
}
]
}
}'In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track..., choose Add track from pasted JSON, and paste:
{
"type": "FeatureTrack",
"trackId": "in2lt_inversion",
"name": "In(2L)t inversion",
"assemblyNames": ["dm6"],
"adapter": {
"type": "FromConfigAdapter",
"features": [
{
"uniqueId": "in2lt",
"refName": "chr2L",
"start": 2225744,
"end": 13154180,
"name": "In(2L)t"
}
]
}
}Fst and π are on different scales, so each gets a track and a y-axis. A multi-wiggle track shares one axis across rows, which suits one statistic across groups, so the π bigWig of each arrangement loads as one row of a single track:
Goes in the tracks array of config.json. See Tracks.
{
"type": "MultiQuantitativeTrack",
"trackId": "pi_by_arrangement",
"name": "π by In(2L)t arrangement",
"assemblyNames": ["dm6"],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "π In(2L)t",
"uri": "https://jbrowse.org/demos/popgen/pi_INV.bw"
},
{
"type": "BigWigAdapter",
"source": "π standard",
"uri": "https://jbrowse.org/demos/popgen/pi_STD.bw"
}
]
}
}jbrowse add-track-json '{
"type": "MultiQuantitativeTrack",
"trackId": "pi_by_arrangement",
"name": "π by In(2L)t arrangement",
"assemblyNames": ["dm6"],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "π In(2L)t",
"uri": "https://jbrowse.org/demos/popgen/pi_INV.bw"
},
{
"type": "BigWigAdapter",
"source": "π standard",
"uri": "https://jbrowse.org/demos/popgen/pi_STD.bw"
}
]
}
}'In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track..., choose Add track from pasted JSON, and paste:
{
"type": "MultiQuantitativeTrack",
"trackId": "pi_by_arrangement",
"name": "π by In(2L)t arrangement",
"assemblyNames": ["dm6"],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "π In(2L)t",
"uri": "https://jbrowse.org/demos/popgen/pi_INV.bw"
},
{
"type": "BigWigAdapter",
"source": "π standard",
"uri": "https://jbrowse.org/demos/popgen/pi_STD.bw"
}
]
}
}Each arrangement's π swings several fold between 2 kb windows, far more than the
two arrangements differ, so the two rows look alike. Pool into 250 kb bins and
take log2 of inverted over standard to get one track that sits at zero where the
arrangements have equal diversity. An awk step writes it from the two π
bedGraphs:
# B: bin width; each bin's pi is the length-weighted mean of its 2 kb windows
awk -F'\t' -v OFS='\t' -v B=250000 '
NR==FNR { len[$1]=$2; next }
FNR==1 { g++ }
{ k=$1 SUBSEP int($2/B); w=$3-$2; s[g,k]+=$4*w; n[g,k]+=w; seen[k] }
END {
for (k in seen) if (s[1,k]>0 && s[2,k]>0) {
split(k, a, SUBSEP); end=(a[2]+1)*B; if (end>len[a[1]]) end=len[a[1]]
print a[1], a[2]*B, end, log((s[1,k]/n[1,k])/(s[2,k]/n[2,k]))/log(2)
}
}' dm6.chrom.sizes pi_INV.bedgraph pi_STD.bedgraph |
sort -k1,1 -k2,2n > pi_ratio_In2Lt.bedgraph
bedGraphToBigWig pi_ratio_In2Lt.bedgraph dm6.chrom.sizes pi_ratio_In2Lt.bwIn grammar-of-graphics terms,
encoding.color is a color scale: the score mapped through scale.domain to a
scale.range of colors. Here a threshold scale colors each bin by its side of
zero, and encoding.y pins the y scale to ±1.5:
Goes in the tracks array of config.json. See Tracks.
{
"type": "QuantitativeTrack",
"trackId": "pi_ratio_in2lt",
"name": "π, In(2L)t over standard (log2, 250 kb bins)",
"assemblyNames": ["dm6"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/pi_ratio_In2Lt.bw"
},
"displayDefaults": {
"encoding": {
"y": {
"scale": { "domainMin": -1.5, "domainMax": 1.5 },
"axis": { "title": "log2 ratio" }
},
"color": {
"scale": {
"type": "threshold",
"domain": [0],
"range": ["#e66100", "#1f78b4"],
"names": ["inverted lower", "inverted higher"]
},
"legend": { "title": "π, In(2L)t vs standard" }
}
}
}
}jbrowse add-track https://jbrowse.org/demos/popgen/pi_ratio_In2Lt.bw \
--trackId pi_ratio_in2lt \
--name "π, In(2L)t over standard (log2, 250 kb bins)" \
--assemblyNames dm6 \
--displayDefaults '{"encoding":{"y":{"scale":{"domainMin":-1.5,"domainMax":1.5},"axis":{"title":"log2 ratio"}},"color":{"scale":{"type":"threshold","domain":[0],"range":["#e66100","#1f78b4"],"names":["inverted lower","inverted higher"]},"legend":{"title":"π, In(2L)t vs standard"}}}}'In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track..., choose Add track from pasted JSON, and paste:
{
"type": "QuantitativeTrack",
"trackId": "pi_ratio_in2lt",
"name": "π, In(2L)t over standard (log2, 250 kb bins)",
"assemblyNames": ["dm6"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/pi_ratio_In2Lt.bw"
},
"displayDefaults": {
"encoding": {
"y": {
"scale": { "domainMin": -1.5, "domainMax": 1.5 },
"axis": { "title": "log2 ratio" }
},
"color": {
"scale": {
"type": "threshold",
"domain": [0],
"range": ["#e66100", "#1f78b4"],
"names": ["inverted lower", "inverted higher"]
},
"legend": { "title": "π, In(2L)t vs standard" }
}
}
}
}Advanced → Edit plot... in the track menu shows encoding, the y and color
scales included, as text and applies edits live.
Open chr2L alone, with the π ratio track under Fst:
The inverted lines have less diversity than the standard ones across the inverted region, most near the breakpoints, where the suppressed recombination is strongest. Toward the centromere past the inversion, where the arrangements recombine freely, the ratio sits at zero. Differentiation decays gradually outside the breakpoints (Corbett-Detig & Hartl).
Genotyping the inversion in each line
The karyotype that split the lines into two groups also loads as a track, one
row per line. The inversion is one <INV> record spanning the published
breakpoints, genotyped 1/1 in the inverted lines and 0/0 in the standard
ones, with the far breakpoint in END:
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT DGRP-026 DGRP-032
2L 2225744 In2Lt N <INV> . PASS SVTYPE=INV;END=13154180 GT 1/1 0/0The samples TSV pairs each line with its karyotype (standard or inverted).
facet splits the display into sections, one per karyotype value,
facet.sort orders them, and rows.color is a color scale on each row's label
bar:
Goes in the tracks array of config.json. See Tracks.
{
"type": "VariantTrack",
"trackId": "dgrp_In2Lt_sv",
"name": "In(2L)t inversion genotyped across DGRP lines",
"assemblyNames": ["dm6"],
"adapter": {
"type": "VcfTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/dgrp_In2Lt_sv.vcf.gz",
"samplesTsvLocation": {
"uri": "https://jbrowse.org/demos/popgen/dgrp_In2Lt_samples.tsv"
}
},
"displays": [
{
"type": "LinearVariantDisplay",
"facet": { "field": "karyotype", "sort": ["Standard", "In(2L)t"] },
"rows": { "color": "karyotype" }
}
]
}jbrowse add-track-json '{
"type": "VariantTrack",
"trackId": "dgrp_In2Lt_sv",
"name": "In(2L)t inversion genotyped across DGRP lines",
"assemblyNames": ["dm6"],
"adapter": {
"type": "VcfTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/dgrp_In2Lt_sv.vcf.gz",
"samplesTsvLocation": {
"uri": "https://jbrowse.org/demos/popgen/dgrp_In2Lt_samples.tsv"
}
},
"displays": [
{
"type": "LinearVariantDisplay",
"facet": { "field": "karyotype", "sort": ["Standard", "In(2L)t"] },
"rows": { "color": "karyotype" }
}
]
}'In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track..., choose Add track from pasted JSON, and paste:
{
"type": "VariantTrack",
"trackId": "dgrp_In2Lt_sv",
"name": "In(2L)t inversion genotyped across DGRP lines",
"assemblyNames": ["dm6"],
"adapter": {
"type": "VcfTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/dgrp_In2Lt_sv.vcf.gz",
"samplesTsvLocation": {
"uri": "https://jbrowse.org/demos/popgen/dgrp_In2Lt_samples.tsv"
}
},
"displays": [
{
"type": "LinearVariantDisplay",
"facet": { "field": "karyotype", "sort": ["Standard", "In(2L)t"] },
"rows": { "color": "karyotype" }
}
]
}With a sample sheet of your own, name any of its columns in facet to split the
rows by it. Grouping and ordering
shows this track under the Fst scan.
Reproduce it end to end
build_dgrp_popgen.sh
wraps every step above. The script:
- Downloads the DGRP2 dm6 SNP VCF and the
In(2L)tkaryotypes. - Splits the lines into inverted and standard groups, and writes Fst, π, their inverted-over-standard ratio and Tajima's D as bigWigs over windows with vcftools.
- Builds the one-record inversion VCF that genotypes every line.
- Downloads JBrowse and writes a
config.jsonwith dm6 and every track, opening onIn(2L)t.
curl -fO https://raw.githubusercontent.com/GMOD/jbrowse-components/main/scripts/build_dgrp_popgen.sh
bash build_dgrp_popgen.sh # builds ./dgrp_popgen_build/jbrowse2
npx --yes serve dgrp_popgen_build/jbrowse2 # then open the printed URLThe config opens on In(2L)t across arm 2L. The .bw and .vcf.gz files are
written next to it, to host elsewhere or
open as local track files in
JBrowse Desktop.
See also
- Tutorial: LD at a selective sweep (human)
- Tutorial: LD across an inversion (mosquitoes)
- Tutorial: A selected haplotype (Dog10K)
- User guide: Quantitative track
- User guide: Variant sample rows
- User guide: GWAS / Manhattan track
- Config guide: Assemblies
- Config guide: Grouping and lane order
- Docs: jbrowse-anywidget
External links
- Selection scans (Drosophila DGRP) in R, the same analysis written for ggjbrowse
Citations
- Bhatia et al. (2013). Estimating and interpreting FST: the impact of rare variants
- Corbett-Detig & Hartl (2012). Population genomics of inversion polymorphisms in Drosophila melanogaster
- Daborn et al. (2002). A single P450 allele associated with insecticide resistance in Drosophila
- Danecek et al. (2011). The variant call format and VCFtools
- Gardeux et al. (2023). DGRPool: A web tool leveraging harmonized Drosophila Genetic Reference Panel phenotyping data
- Huang et al. (2015). Linkage disequilibrium and inversion-typing of the Drosophila melanogaster Genome Reference Panel
- Korunes & Samuk (2021). pixy: Unbiased estimation of nucleotide diversity and divergence in the presence of missing data
- Mackay et al. (2012). The Drosophila melanogaster Genetic Reference Panel
- Schmidt et al. (2010). Copy number variation and transposable elements feature in recent, ongoing adaptation at the Cyp6g1 locus
- Tajima (1989). Statistical method for testing the neutral mutation hypothesis by DNA polymorphism
- Weir & Cockerham (1984). Estimating F-statistics for the analysis of population structure
Notes
-
The inverted and standard groups are very unequal in size, since the inverted arrangement is the rarer one. Hudson's estimator is the usual recommendation where groups differ this much (Bhatia et al. 2013); A selected haplotype (Dog10K) scans with that one. ↩
-
pixy (Korunes & Samuk 2021) takes an allSites VCF and reports π, dxy and Fst per window without that bias, and its output packs into a bigWig the same way. ↩
Feedback on this tutorial is welcome: contact us.