LD at a selective sweep (human)
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.21. Desktop beta builds for Linux and
macOS are on the releases page;
the Windows build waits on code signing.
Selection for lactase persistence in Europe swept one haplotype around the lactase gene LCT to high frequency, and the variants on it are still inherited together as one long block of linkage disequilibrium (LD). PLINK correlates the phased genotypes of the 1000 Genomes samples, and JBrowse draws the correlation of every pair of variants as a triangle. Across the LCT block on chr2, we:
- load PLINK's r² table for the European samples as an LD track
- add Fst, a deCODE recombination map and a second LD track over the pooled release, and read the block's edges against them
- cluster a variant track of the haplotypes with Clustering → Cluster rows by genotype...
- draw each population's allele frequency at the lactase-persistence variant as a row of a multi-wiggle track
Prerequisites
- a JBrowse to paste the tracks into (Web or Desktop)
bcftoolsbuilt with libcurl- htslib (
tabix) curlpython3node, for the JBrowse CLIbedGraphToBigWig, for the Fst track- PLINK 1.9 for the r² tables and PLINK 2.0 for the Fst track and the frequency filter1
# Debian/Ubuntu
sudo apt install bcftools tabix nodejs
# or conda, which has every tool above
conda install -c bioconda -c conda-forge bcftools htslib nodejs \
ucsc-bedgraphtobigwig plink plink2
# 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
1000 Genomes 30x high-coverage from NYGC (Byrska-Bishop et al. 2022), called natively on GRCh38.
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 cutting, PLINK and plink2 steps take your own phased VCF in place of the 1000 Genomes slice.
| What it is | File |
|---|---|
| Phased chromosome 2 | 1kGP_high_coverage_Illumina.chr2.filtered.SNV_INDEL_SV_phased_panel.vcf.gz |
The release's own unrelated set, whose SAMPLE_NAME column is unrelated.samples |
1000G_2504_high_coverage.sequence.index |
Populations and superpopulations, narrowed to that unrelated set for panel.samples (EUR) and rest.samples (everything else) |
20130606_g1k_3202_samples_ped_population.txt |
Loading the hg38 assembly
The tables, the Fst track and the haplotypes all use GRCh38 coordinates on chr2, so the tracks below go on that assembly.
Goes in the assemblies array of config.json. See Assemblies.
{
"name": "hg38",
"uri": "https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz",
"refNameAliases": {
"uri": "https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/hg38_aliases.txt"
},
"cytobands": "https://jbrowse.org/genomes/GRCh38/cytoBand.txt"
}Edits config.json in the current folder, creating it if there is none. See JBrowse CLI with Desktop.
jbrowse add-assembly https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz \
--name hg38 \
--refNameAliases https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/hg38_aliases.txt \
--config '{"cytobands":"https://jbrowse.org/genomes/GRCh38/cytoBand.txt"}'hg38 is one of the genomes JBrowse Desktop hosts, with gene tracks already set up: on the start screen click Browse hosted genomes and pick it. To load the files of this config instead:
In JBrowse Desktop, Open your own genome on the start screen (or File → Open genome... in a session), then Open from a URL and paste, one per line:
https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz
https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz.fai
https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz.gziJBrowse reads the format off the file name. Then fill in:
- Genome name:
hg38 - refName aliases (under More options):
https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/hg38_aliases.txt - cytobands (under More options):
https://jbrowse.org/genomes/GRCh38/cytoBand.txt
Cutting the LCT region out of the 1000 Genomes VCF
Cut the region twice: over the whole release, and over its European samples (the
panel, where the sweep happened). *.samples files list one ID per line.
# -r fetches the 3.4 Mb region by range request from the 2.5 GB chromosome file
# -e drops symbolic SV records, which are spans; the display correlates
# allele indicators
bcftools view -r chr2:133800000-137200000 -S unrelated.samples \
-e 'ALT[0]~"<"' -Oz -o pooled.vcf.gz \
https://ftp.1000genomes.ebi.ac.uk/vol1/ftp/data_collections/1000G_2504_high_coverage/working/20220422_3202_phased_SNV_INDEL_SV/1kGP_high_coverage_Illumina.chr2.filtered.SNV_INDEL_SV_phased_panel.vcf.gz
tabix -f -C -p vcf pooled.vcf.gz
bcftools view -S panel.samples -Oz -o panel.vcf.gz pooled.vcf.gz
tabix -f -C -p vcf panel.vcf.gzCorrelating the LCT variants with PLINK
PLINK correlates allele indicators, so we first reduce each slice to biallelic SNVs, one record per position, with the IDs dropped:
bcftools view -m2 -M2 -v snps panel.vcf.gz | bcftools norm -d both |
bcftools annotate -x ID -Oz -o panel.snvs.vcf.gzThen we pick common variants per cohort and correlate every pair. PLINK's table
has one row per pair, so a minor allele frequency (MAF) floor keeps it small
enough for a browser to draw. The same reduction on pooled.vcf.gz gives
pooled.snvs.vcf.gz for the pooled table.
# 0.35 is a high MAF floor, to keep the variants that tag the block
plink2 --vcf panel.snvs.vcf.gz --double-id --allow-extra-chr --output-chr chrM \
--set-missing-var-ids @:# --maf 0.35 --chr chr2 --write-snplist --out sel
# dprime adds D' beside r2
# --ld-window-r2 0 keeps the uncorrelated pairs, drawn as white cells
# raise both --ld-window and --ld-window-kb, or the defaults clip this block at
# 10 variants or 1 Mb
plink --vcf panel.snvs.vcf.gz --double-id --allow-extra-chr --output-chr chrM \
--set-missing-var-ids @:# --extract sel.snplist \
--r2 dprime --ld-window 999999 --ld-window-kb 4000 --ld-window-r2 0 \
--out lct_1kg38_chr2_eur
# tabix needs tab-separated columns and a commented header; plink pads with
# spaces
awk 'NR==1{$1=$1; print "#" $0; next} {$1=$1; print}' OFS='\t' \
lct_1kg38_chr2_eur.ld | bgzip > lct_1kg38_chr2_eur.ld.gz
tabix -C -s 1 -b 2 -e 2 -f lct_1kg38_chr2_eur.ld.gzDrawing the LCT LD triangle from a PLINK table
In the triangle, red means two variants are inherited together and white means independent. The triangle is a matrix turned on its corner, so the vertical axis is the distance between the two variants.
Point an LDTrack at the r² table (squared correlation
per variant pair) PLINK wrote:
Goes in the tracks array of config.json. See Tracks.
{
"type": "LDTrack",
"trackId": "kgp_lct_ld",
"name": "LCT lactase-persistence LD, 1000G European panel (r²)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_eur.ld.gz",
"csi": true
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": { "show": true },
"height": 360
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "LDTrack",
"trackId": "kgp_lct_ld",
"name": "LCT lactase-persistence LD, 1000G European panel (r²)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_eur.ld.gz",
"csi": true
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": { "show": true },
"height": 360
}
}'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": "LDTrack",
"trackId": "kgp_lct_ld",
"name": "LCT lactase-persistence LD, 1000G European panel (r²)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_eur.ld.gz",
"csi": true
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": { "show": true },
"height": 360
}
}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%2Fhg38%2Fconfig.json&session=spec-%7B%22sessionTracks%22%3A%5B%7B%22type%22%3A%22LDTrack%22%2C%22trackId%22%3A%22kgp_lct_ld%22%2C%22name%22%3A%22LCT+lactase-persistence+LD%2C+1000G+European+panel+%28r%C2%B2%29%22%2C%22assemblyNames%22%3A%5B%22hg38%22%5D%2C%22adapter%22%3A%7B%22type%22%3A%22PlinkLDTabixAdapter%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Flct_1kg38_chr2_eur.ld.gz%22%2C%22csi%22%3Atrue%7D%2C%22displayDefaults%22%3A%7B%22variantLayout%22%3A%22genomic%22%2C%22legend%22%3A%7B%22show%22%3Atrue%7D%2C%22height%22%3A360%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22hg38%22%2C%22loc%22%3A%22chr2%3A134%2C400%2C000-136%2C900%2C000%22%2C%22tracks%22%3A%5B%22kgp_lct_ld%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+LCT+lactase-persistence+LD%2C+1000G+European+panel+%28r%C2%B2%29This view in a notebook, with jbrowse-anywidget. Swap a track's uri for your file.
from jbrowse_anywidget import JBrowseApp, fetch_hub
config = fetch_hub("https://jbrowse.org/ucsc/hg38/config.json")
app = JBrowseApp(
assemblies=config["assemblies"],
tracks=config.get("tracks", []) + [
{
"type": "LDTrack",
"trackId": "kgp_lct_ld",
"name": "LCT lactase-persistence LD, 1000G European panel (r²)",
"assemblyNames": [
"hg38"
],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_eur.ld.gz",
"csi": True
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": {
"show": True
},
"height": 360
}
}
],
views=[
{
"type": "LinearGenomeView",
"assembly": "hg38",
"loc": "chr2:134,400,000-136,900,000",
"tracks": [
"kgp_lct_ld"
]
}
],
)
app # display the widgetThis view in your React 19 app, with @jbrowse/react-app2 and @jbrowse/core. Add your own files to tracks.
import { use } from 'react'
import { JBrowse } from '@jbrowse/react-app2'
import '@jbrowse/react-app2/styles.css'
import { addRelativeUris } from '@jbrowse/core/util/addRelativeUris'
const configUrl = "https://jbrowse.org/ucsc/hg38/config.json"
const configPromise = fetch(configUrl)
.then(res => res.json())
.then(config => {
addRelativeUris(config, new URL(configUrl))
return config
})
export default function Figure() {
const config = use(configPromise)
return (
<JBrowse
assemblies={config.assemblies}
tracks={[...(config.tracks ?? []), ...[
{
"type": "LDTrack",
"trackId": "kgp_lct_ld",
"name": "LCT lactase-persistence LD, 1000G European panel (r²)",
"assemblyNames": [
"hg38"
],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_eur.ld.gz",
"csi": true
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": {
"show": true
},
"height": 360
}
}
]]}
aggregateTextSearchAdapters={config.aggregateTextSearchAdapters}
configuration={config.configuration}
views={[
{
"type": "LinearGenomeView",
"assembly": "hg38",
"loc": "chr2:134,400,000-136,900,000",
"tracks": [
"kgp_lct_ld"
]
}
]}
/>
)
}jbrowse-img draws this view as an SVG, no browser needed. Swap --config or a track for your own.
cat > tracks.json <<'JSON'
[
{
"type": "LDTrack",
"trackId": "kgp_lct_ld",
"name": "LCT lactase-persistence LD, 1000G European panel (r²)",
"assemblyNames": [
"hg38"
],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_eur.ld.gz",
"csi": true
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": {
"show": true
},
"height": 360
}
}
]
JSON
npx @jbrowse/img --config https://jbrowse.org/ucsc/hg38/config.json \
--trackConfigs tracks.json \
--assembly hg38 --loc chr2:134,400,000-136,900,000 \
--track kgp_lct_ld \
--out figure.svgFor a PNG, --out figure.png (needs rsvg-convert: apt install librsvg2-bin, brew install librsvg).
In grammar-of-graphics terms,
encoding.color is a color scale, and
encoding.color.field sets its input to r²
or D' (a second LD measure), and this table has both. For your own table, swap
uri for the .ld.gz that tabix indexed, with its .csi beside it.
Computing Fst per variant with plink2
Fst, how far apart two groups' allele frequencies sit, comes from plink2 --fst
over panel.samples and rest.samples, as a bigWig for a
quantitative track:
# plink2 takes the two panels as one categorical phenotype, with FID beside IID
{ printf '#FID\tIID\tPOP\n'
awk '{print $1"\t"$1"\tPANEL"}' panel.samples
awk '{print $1"\t"$1"\tREST"}' rest.samples; } > fst_pops.txt
# method=wc is Weir and Cockerham; the plink2 default, Hudson, gives a
# different number
# --output-chr chrM writes the chromosome as chr2, matching the file
plink2 --vcf pooled.vcf.gz --double-id --output-chr chrM --pheno fst_pops.txt \
--fst POP method=wc report-variants vcols=chrom,pos,fst --out fst_site
# 1-based site to bedGraph interval, dropping sites scored nan
awk 'NR>1 && $4!="nan" {printf "%s\t%d\t%d\t%.5f\n",$1,$2-1,$2,$4}' \
fst_site.PANEL.REST.fst.var | sort -k1,1 -k2,2n > fst_site.bedgraph
printf 'chr2\t242193529\n' > hg38.chrom.sizes
bedGraphToBigWig fst_site.bedgraph hg38.chrom.sizes fst.bwThe Fst track config sets a lower resolutionMultiplier on the adapter. Zoomed
out, a bigWig serves summary bins, and averaging a bin hides the few
differentiated variants among the many around them:
Goes in the tracks array of config.json. See Tracks.
{
"type": "QuantitativeTrack",
"trackId": "kgp_lct_fst",
"name": "Fst, European panel vs the other 1000 Genomes samples (Weir & Cockerham)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_fst_eur_vs_rest.bw",
"resolutionMultiplier": 0.001
},
"displayDefaults": {
"mark": { "type": "point", "extent": "none" },
"encoding": {
"size": 2,
"y": {
"field": "maxScore",
"scale": { "domainMin": 0.1, "domainMax": 0.5 }
},
"color": { "value": "#0068d1" }
}
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "QuantitativeTrack",
"trackId": "kgp_lct_fst",
"name": "Fst, European panel vs the other 1000 Genomes samples (Weir & Cockerham)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_fst_eur_vs_rest.bw",
"resolutionMultiplier": 0.001
},
"displayDefaults": {
"mark": { "type": "point", "extent": "none" },
"encoding": {
"size": 2,
"y": {
"field": "maxScore",
"scale": { "domainMin": 0.1, "domainMax": 0.5 }
},
"color": { "value": "#0068d1" }
}
}
}'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": "kgp_lct_fst",
"name": "Fst, European panel vs the other 1000 Genomes samples (Weir & Cockerham)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_fst_eur_vs_rest.bw",
"resolutionMultiplier": 0.001
},
"displayDefaults": {
"mark": { "type": "point", "extent": "none" },
"encoding": {
"size": 2,
"y": {
"field": "maxScore",
"scale": { "domainMin": 0.1, "domainMax": 0.5 }
},
"color": { "value": "#0068d1" }
}
}
}Running the Fst step over 40 Mb of chr2, as
build_lct_fst_scan.sh does, gives a wide scan that
loads the same way:
Goes in the tracks array of config.json. See Tracks.
{
"type": "QuantitativeTrack",
"trackId": "kgp_lct_fst_scan",
"name": "Fst, European panel vs the other 1000 Genomes samples, across 40 Mb of chr2",
"assemblyNames": ["hg38"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_fst_eur_vs_rest_scan.bw",
"resolutionMultiplier": 0.001
},
"displayDefaults": {
"mark": { "type": "point", "extent": "none" },
"encoding": {
"size": 2,
"y": {
"field": "maxScore",
"scale": { "domainMin": 0.1, "domainMax": 0.5 }
},
"color": { "value": "#0068d1" }
}
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "QuantitativeTrack",
"trackId": "kgp_lct_fst_scan",
"name": "Fst, European panel vs the other 1000 Genomes samples, across 40 Mb of chr2",
"assemblyNames": ["hg38"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_fst_eur_vs_rest_scan.bw",
"resolutionMultiplier": 0.001
},
"displayDefaults": {
"mark": { "type": "point", "extent": "none" },
"encoding": {
"size": 2,
"y": {
"field": "maxScore",
"scale": { "domainMin": 0.1, "domainMax": 0.5 }
},
"color": { "value": "#0068d1" }
}
}
}'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": "kgp_lct_fst_scan",
"name": "Fst, European panel vs the other 1000 Genomes samples, across 40 Mb of chr2",
"assemblyNames": ["hg38"],
"adapter": {
"type": "BigWigAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_fst_eur_vs_rest_scan.bw",
"resolutionMultiplier": 0.001
},
"displayDefaults": {
"mark": { "type": "point", "extent": "none" },
"encoding": {
"size": 2,
"y": {
"field": "maxScore",
"scale": { "domainMin": 0.1, "domainMax": 0.5 }
},
"color": { "value": "#0068d1" }
}
}
}The LCT block against Fst and the deCODE map
We'll compare the triangle with two maps it does not depend on. The first is the gene track, NCBI's curated RefSeq models as UCSC serves them:
Goes in the tracks array of config.json. See Tracks.
{
"type": "FeatureTrack",
"trackId": "hg38-ncbiRefSeqCurated",
"name": "NCBI RefSeq - RefSeq Curated",
"assemblyNames": ["hg38"],
"adapter": {
"type": "Gff3TabixAdapter",
"gffGzLocation": {
"uri": "https://jbrowse.org/ucsc/hg38/ncbiRefSeqCurated.gff.gz"
},
"index": {
"indexType": "CSI",
"location": {
"uri": "https://jbrowse.org/ucsc/hg38/ncbiRefSeqCurated.gff.gz.csi"
}
}
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "FeatureTrack",
"trackId": "hg38-ncbiRefSeqCurated",
"name": "NCBI RefSeq - RefSeq Curated",
"assemblyNames": ["hg38"],
"adapter": {
"type": "Gff3TabixAdapter",
"gffGzLocation": {
"uri": "https://jbrowse.org/ucsc/hg38/ncbiRefSeqCurated.gff.gz"
},
"index": {
"indexType": "CSI",
"location": {
"uri": "https://jbrowse.org/ucsc/hg38/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": "hg38-ncbiRefSeqCurated",
"name": "NCBI RefSeq - RefSeq Curated",
"assemblyNames": ["hg38"],
"adapter": {
"type": "Gff3TabixAdapter",
"gffGzLocation": {
"uri": "https://jbrowse.org/ucsc/hg38/ncbiRefSeqCurated.gff.gz"
},
"index": {
"indexType": "CSI",
"location": {
"uri": "https://jbrowse.org/ucsc/hg38/ncbiRefSeqCurated.gff.gz.csi"
}
}
}
}The second is deCODE's recombination rate, counted off crossovers in sequenced families:
Goes in the tracks array of config.json. See Tracks.
{
"trackId": "decode_recomb",
"name": "deCODE recombination rate (cM/Mb, pedigree)",
"uri": "https://hgdownload.soe.ucsc.edu/gbdb/hg38/recombRate/recombAvg.bw",
"assemblyNames": ["hg38"],
"displayDefaults": {
"encoding": { "y": { "scale": { "domainMin": 0, "domainMax": 100 } } }
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track https://hgdownload.soe.ucsc.edu/gbdb/hg38/recombRate/recombAvg.bw \
--trackId decode_recomb \
--name "deCODE recombination rate (cM/Mb, pedigree)" \
--assemblyNames hg38 \
--displayDefaults '{"encoding":{"y":{"scale":{"domainMin":0,"domainMax":100}}}}'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:
{
"trackId": "decode_recomb",
"name": "deCODE recombination rate (cM/Mb, pedigree)",
"uri": "https://hgdownload.soe.ucsc.edu/gbdb/hg38/recombRate/recombAvg.bw",
"assemblyNames": ["hg38"],
"displayDefaults": {
"encoding": { "y": { "scale": { "domainMin": 0, "domainMax": 100 } } }
}
}The pooled triangle is a second LDTrack over the table PLINK wrote for
pooled.snvs.vcf.gz:
Goes in the tracks array of config.json. See Tracks.
{
"type": "LDTrack",
"trackId": "kgp_lct_pooled",
"name": "All 1000 Genomes populations pooled (r²)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_pooled.ld.gz",
"csi": true
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": { "show": true },
"height": 360
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "LDTrack",
"trackId": "kgp_lct_pooled",
"name": "All 1000 Genomes populations pooled (r²)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_pooled.ld.gz",
"csi": true
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": { "show": true },
"height": 360
}
}'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": "LDTrack",
"trackId": "kgp_lct_pooled",
"name": "All 1000 Genomes populations pooled (r²)",
"assemblyNames": ["hg38"],
"adapter": {
"type": "PlinkLDTabixAdapter",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_pooled.ld.gz",
"csi": true
},
"displayDefaults": {
"variantLayout": "genomic",
"legend": { "show": true },
"height": 360
}
}Open the region the slice covers with the gene, Fst and deCODE tracks and both triangles:
- In the Fst track at the top, the sites with the highest Fst in the window sit inside the block.
- The block fills the flat span of the deCODE map. The map counts crossovers in sequenced families, so it is a check on the triangle that is independent of LD. The HapMap and 1000 Genomes recombination maps in the UCSC hg38 hub are estimated from LD, so they are not independent of LD.
- Pooling the swept European samples with populations the sweep never reached lightens the pooled triangle.
Clustering LCT haplotypes into the block the triangle draws
The triangle summarises haplotypes, the variants on each chromosome along the block. A track over the multi-population VCF draws them below it in equal-width columns, one row per chromosome:
Goes in the tracks array of config.json. See Tracks.
{
"type": "VariantTrack",
"trackId": "kgp_lct_haplotypes",
"name": "1000 Genomes haplotypes across LCT (one row per haplotype)",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_6pop.vcf.gz",
"csi": true,
"displays": [
{
"type": "LinearVariantDisplay",
"variantLayout": "columns",
"rows": "haplotype",
"filter": [{ "field": "minorAlleleFrequency", "gte": 0.35 }],
"forceLoad": true,
"height": 700
}
]
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "VariantTrack",
"trackId": "kgp_lct_haplotypes",
"name": "1000 Genomes haplotypes across LCT (one row per haplotype)",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_6pop.vcf.gz",
"csi": true,
"displays": [
{
"type": "LinearVariantDisplay",
"variantLayout": "columns",
"rows": "haplotype",
"filter": [{ "field": "minorAlleleFrequency", "gte": 0.35 }],
"forceLoad": true,
"height": 700
}
]
}'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": "kgp_lct_haplotypes",
"name": "1000 Genomes haplotypes across LCT (one row per haplotype)",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_6pop.vcf.gz",
"csi": true,
"displays": [
{
"type": "LinearVariantDisplay",
"variantLayout": "columns",
"rows": "haplotype",
"filter": [{ "field": "minorAlleleFrequency", "gte": 0.35 }],
"forceLoad": true,
"height": 700
}
]
}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%2Fhg38%2Fconfig.json&session=spec-%7B%22sessionTracks%22%3A%5B%7B%22type%22%3A%22VariantTrack%22%2C%22trackId%22%3A%22kgp_lct_haplotypes%22%2C%22name%22%3A%221000+Genomes+haplotypes+across+LCT+%28one+row+per+haplotype%29%22%2C%22assemblyNames%22%3A%5B%22hg38%22%5D%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Flct_1kg38_chr2_6pop.vcf.gz%22%2C%22csi%22%3Atrue%2C%22displays%22%3A%5B%7B%22type%22%3A%22LinearVariantDisplay%22%2C%22variantLayout%22%3A%22columns%22%2C%22rows%22%3A%22haplotype%22%2C%22filter%22%3A%5B%7B%22field%22%3A%22minorAlleleFrequency%22%2C%22gte%22%3A0.35%7D%5D%2C%22forceLoad%22%3Atrue%2C%22height%22%3A700%7D%5D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22hg38%22%2C%22loc%22%3A%22chr2%3A134%2C400%2C000-136%2C900%2C000%22%2C%22tracks%22%3A%5B%22kgp_lct_haplotypes%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+1000+Genomes+haplotypes+across+LCT+%28one+row+per+haplotype%29This view in a notebook, with jbrowse-anywidget. Swap a track's uri for your file.
from jbrowse_anywidget import JBrowseApp, fetch_hub
config = fetch_hub("https://jbrowse.org/ucsc/hg38/config.json")
app = JBrowseApp(
assemblies=config["assemblies"],
tracks=config.get("tracks", []) + [
{
"type": "VariantTrack",
"trackId": "kgp_lct_haplotypes",
"name": "1000 Genomes haplotypes across LCT (one row per haplotype)",
"assemblyNames": [
"hg38"
],
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_6pop.vcf.gz",
"csi": True,
"displays": [
{
"type": "LinearVariantDisplay",
"variantLayout": "columns",
"rows": "haplotype",
"filter": [
{
"field": "minorAlleleFrequency",
"gte": 0.35
}
],
"forceLoad": True,
"height": 700
}
]
}
],
views=[
{
"type": "LinearGenomeView",
"assembly": "hg38",
"loc": "chr2:134,400,000-136,900,000",
"tracks": [
"kgp_lct_haplotypes"
]
}
],
)
app # display the widgetThis view in your React 19 app, with @jbrowse/react-app2 and @jbrowse/core. Add your own files to tracks.
import { use } from 'react'
import { JBrowse } from '@jbrowse/react-app2'
import '@jbrowse/react-app2/styles.css'
import { addRelativeUris } from '@jbrowse/core/util/addRelativeUris'
const configUrl = "https://jbrowse.org/ucsc/hg38/config.json"
const configPromise = fetch(configUrl)
.then(res => res.json())
.then(config => {
addRelativeUris(config, new URL(configUrl))
return config
})
export default function Figure() {
const config = use(configPromise)
return (
<JBrowse
assemblies={config.assemblies}
tracks={[...(config.tracks ?? []), ...[
{
"type": "VariantTrack",
"trackId": "kgp_lct_haplotypes",
"name": "1000 Genomes haplotypes across LCT (one row per haplotype)",
"assemblyNames": [
"hg38"
],
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_6pop.vcf.gz",
"csi": true,
"displays": [
{
"type": "LinearVariantDisplay",
"variantLayout": "columns",
"rows": "haplotype",
"filter": [
{
"field": "minorAlleleFrequency",
"gte": 0.35
}
],
"forceLoad": true,
"height": 700
}
]
}
]]}
aggregateTextSearchAdapters={config.aggregateTextSearchAdapters}
configuration={config.configuration}
views={[
{
"type": "LinearGenomeView",
"assembly": "hg38",
"loc": "chr2:134,400,000-136,900,000",
"tracks": [
"kgp_lct_haplotypes"
]
}
]}
/>
)
}jbrowse-img draws this view as an SVG, no browser needed. Swap --config or a track for your own.
cat > tracks.json <<'JSON'
[
{
"type": "VariantTrack",
"trackId": "kgp_lct_haplotypes",
"name": "1000 Genomes haplotypes across LCT (one row per haplotype)",
"assemblyNames": [
"hg38"
],
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_6pop.vcf.gz",
"csi": true,
"displays": [
{
"type": "LinearVariantDisplay",
"variantLayout": "columns",
"rows": "haplotype",
"filter": [
{
"field": "minorAlleleFrequency",
"gte": 0.35
}
],
"forceLoad": true,
"height": 700
}
]
}
]
JSON
npx @jbrowse/img --config https://jbrowse.org/ucsc/hg38/config.json \
--trackConfigs tracks.json \
--assembly hg38 --loc chr2:134,400,000-136,900,000 \
--track kgp_lct_haplotypes \
--out figure.svgFor a PNG, --out figure.png (needs rsvg-convert: apt install librsvg2-bin, brew install librsvg).
The lactase-persistence variant, rs4988235, falls below the matrix's frequency
floor, so the figure marks it with UCSC's ClinVar track, filtered to that
record:
Goes in the tracks array of config.json. See Tracks.
{
"trackId": "hg38-clinvarMain",
"name": "ClinVar Variants - ClinVar SNVs",
"uri": "https://hgdownload.soe.ucsc.edu/gbdb/hg38/bbi/clinvar/clinvarMain.bb",
"assemblyNames": ["hg38"],
"displayDefaults": {
"filter": ["jexl:feature.phenotypeList=='LACTASE PERSISTENCE'"]
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track https://hgdownload.soe.ucsc.edu/gbdb/hg38/bbi/clinvar/clinvarMain.bb \
--trackId hg38-clinvarMain \
--name "ClinVar Variants - ClinVar SNVs" \
--assemblyNames hg38 \
--displayDefaults "{\"filter\":[\"jexl:feature.phenotypeList=='LACTASE PERSISTENCE'\"]}"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:
{
"trackId": "hg38-clinvarMain",
"name": "ClinVar Variants - ClinVar SNVs",
"uri": "https://hgdownload.soe.ucsc.edu/gbdb/hg38/bbi/clinvar/clinvarMain.bb",
"assemblyNames": ["hg38"],
"displayDefaults": {
"filter": ["jexl:feature.phenotypeList=='LACTASE PERSISTENCE'"]
}
}Cluster the rows by genotype two ways:
- from the track menu, Clustering → Cluster rows by genotype...
- baked into a session with the
runClusteringandclusterRegionmodel properties
In file order the matrix is a plaid. Clustering puts near-identical chromosomes together, so a swept haplotype forms one slab.
Subsampling populations for the haplotype matrix
Over the whole release each haplotype row falls below a pixel, so the figure
uses the same number of samples from each population. The script behind it
centers on one bcftools call over a list of sample IDs, one per line:
bcftools view -S sub.samples --force-samples -Oz -o lct_1kg38_chr2_6pop.vcf.gz pooled.vcf.gzAllele frequency per population across the LCT block
A few people from each population are enough to sort haplotypes and too few to
read a frequency off. bcftools +fill-tags therefore computes each population's
allele frequency over all of its unrelated samples and writes it into one INFO
field per population. Its -S table holds a sample ID and a group on each line,
tab-separated, so the same command takes any grouping:
# -S gives fill-tags the groups, and -t AF writes AF_<group> for each
# norm -d both keeps one record per position, so no two bedGraph intervals
# overlap
bcftools view -m2 -M2 -v snps -Ou pooled.vcf.gz |
bcftools norm -d both -Ou |
bcftools +fill-tags -Ou -- -S pops.txt -t AF |
bcftools query \
-f '%CHROM\t%POS0\t%END\t%AF_CEU\t%AF_FIN\t%AF_PJL\t%AF_TSI\t%AF_YRI\t%AF_CHB\n' \
> af.tsv
# one bedGraph per population, columns 4 to 9 of af.tsv, then a bigWig each
printf 'chr2\t242193529\n' > hg38.chrom.sizes
column=4
for pop in CEU FIN PJL TSI YRI CHB; do
cut -f 1-3,$column af.tsv > "af_$pop.bedgraph"
bedGraphToBigWig "af_$pop.bedgraph" hg38.chrom.sizes "lct_1kg38_chr2_af_$pop.bw"
column=$((column + 1))
doneA MultiQuantitativeTrack draws the
six bigWigs as a row each, on one axis from 0 to 1:
Goes in the tracks array of config.json. See Tracks.
{
"type": "MultiQuantitativeTrack",
"trackId": "kgp_lct_population_af",
"name": "Allele frequency per population, 1000 Genomes unrelated samples",
"assemblyNames": ["hg38"],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "CEU",
"color": "#4e79a7",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CEU.bw"
},
{
"type": "BigWigAdapter",
"source": "FIN",
"color": "#e15759",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_FIN.bw"
},
{
"type": "BigWigAdapter",
"source": "PJL",
"color": "#76b7b2",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_PJL.bw"
},
{
"type": "BigWigAdapter",
"source": "TSI",
"color": "#59a14f",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_TSI.bw"
},
{
"type": "BigWigAdapter",
"source": "YRI",
"color": "#edc948",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_YRI.bw"
},
{
"type": "BigWigAdapter",
"source": "CHB",
"color": "#f28e2b",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CHB.bw"
}
]
},
"displayDefaults": {
"height": 300,
"encoding": { "y": { "scale": { "domainMin": 0, "domainMax": 1 } } }
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "MultiQuantitativeTrack",
"trackId": "kgp_lct_population_af",
"name": "Allele frequency per population, 1000 Genomes unrelated samples",
"assemblyNames": ["hg38"],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "CEU",
"color": "#4e79a7",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CEU.bw"
},
{
"type": "BigWigAdapter",
"source": "FIN",
"color": "#e15759",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_FIN.bw"
},
{
"type": "BigWigAdapter",
"source": "PJL",
"color": "#76b7b2",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_PJL.bw"
},
{
"type": "BigWigAdapter",
"source": "TSI",
"color": "#59a14f",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_TSI.bw"
},
{
"type": "BigWigAdapter",
"source": "YRI",
"color": "#edc948",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_YRI.bw"
},
{
"type": "BigWigAdapter",
"source": "CHB",
"color": "#f28e2b",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CHB.bw"
}
]
},
"displayDefaults": {
"height": 300,
"encoding": { "y": { "scale": { "domainMin": 0, "domainMax": 1 } } }
}
}'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": "kgp_lct_population_af",
"name": "Allele frequency per population, 1000 Genomes unrelated samples",
"assemblyNames": ["hg38"],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "CEU",
"color": "#4e79a7",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CEU.bw"
},
{
"type": "BigWigAdapter",
"source": "FIN",
"color": "#e15759",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_FIN.bw"
},
{
"type": "BigWigAdapter",
"source": "PJL",
"color": "#76b7b2",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_PJL.bw"
},
{
"type": "BigWigAdapter",
"source": "TSI",
"color": "#59a14f",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_TSI.bw"
},
{
"type": "BigWigAdapter",
"source": "YRI",
"color": "#edc948",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_YRI.bw"
},
{
"type": "BigWigAdapter",
"source": "CHB",
"color": "#f28e2b",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CHB.bw"
}
]
},
"displayDefaults": {
"height": 300,
"encoding": { "y": { "scale": { "domainMin": 0, "domainMax": 1 } } }
}
}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%2Fhg38%2Fconfig.json&session=spec-%7B%22sessionTracks%22%3A%5B%7B%22type%22%3A%22MultiQuantitativeTrack%22%2C%22trackId%22%3A%22kgp_lct_population_af%22%2C%22name%22%3A%22Allele+frequency+per+population%2C+1000+Genomes+unrelated+samples%22%2C%22assemblyNames%22%3A%5B%22hg38%22%5D%2C%22adapter%22%3A%7B%22type%22%3A%22MultiWiggleAdapter%22%2C%22subadapters%22%3A%5B%7B%22type%22%3A%22BigWigAdapter%22%2C%22source%22%3A%22CEU%22%2C%22color%22%3A%22%234e79a7%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Flct_1kg38_chr2_af_CEU.bw%22%7D%2C%7B%22type%22%3A%22BigWigAdapter%22%2C%22source%22%3A%22FIN%22%2C%22color%22%3A%22%23e15759%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Flct_1kg38_chr2_af_FIN.bw%22%7D%2C%7B%22type%22%3A%22BigWigAdapter%22%2C%22source%22%3A%22PJL%22%2C%22color%22%3A%22%2376b7b2%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Flct_1kg38_chr2_af_PJL.bw%22%7D%2C%7B%22type%22%3A%22BigWigAdapter%22%2C%22source%22%3A%22TSI%22%2C%22color%22%3A%22%2359a14f%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Flct_1kg38_chr2_af_TSI.bw%22%7D%2C%7B%22type%22%3A%22BigWigAdapter%22%2C%22source%22%3A%22YRI%22%2C%22color%22%3A%22%23edc948%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Flct_1kg38_chr2_af_YRI.bw%22%7D%2C%7B%22type%22%3A%22BigWigAdapter%22%2C%22source%22%3A%22CHB%22%2C%22color%22%3A%22%23f28e2b%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fpopgen%2Flct_1kg38_chr2_af_CHB.bw%22%7D%5D%7D%2C%22displayDefaults%22%3A%7B%22height%22%3A300%2C%22encoding%22%3A%7B%22y%22%3A%7B%22scale%22%3A%7B%22domainMin%22%3A0%2C%22domainMax%22%3A1%7D%7D%7D%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22hg38%22%2C%22loc%22%3A%22chr2%3A135%2C844%2C000-135%2C858%2C000%22%2C%22tracks%22%3A%5B%22kgp_lct_population_af%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+Allele+frequency+per+population%2C+1000+Genomes+unrelated+samplesThis view in a notebook, with jbrowse-anywidget. Swap a track's uri for your file.
from jbrowse_anywidget import JBrowseApp, fetch_hub
config = fetch_hub("https://jbrowse.org/ucsc/hg38/config.json")
app = JBrowseApp(
assemblies=config["assemblies"],
tracks=config.get("tracks", []) + [
{
"type": "MultiQuantitativeTrack",
"trackId": "kgp_lct_population_af",
"name": "Allele frequency per population, 1000 Genomes unrelated samples",
"assemblyNames": [
"hg38"
],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "CEU",
"color": "#4e79a7",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CEU.bw"
},
{
"type": "BigWigAdapter",
"source": "FIN",
"color": "#e15759",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_FIN.bw"
},
{
"type": "BigWigAdapter",
"source": "PJL",
"color": "#76b7b2",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_PJL.bw"
},
{
"type": "BigWigAdapter",
"source": "TSI",
"color": "#59a14f",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_TSI.bw"
},
{
"type": "BigWigAdapter",
"source": "YRI",
"color": "#edc948",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_YRI.bw"
},
{
"type": "BigWigAdapter",
"source": "CHB",
"color": "#f28e2b",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CHB.bw"
}
]
},
"displayDefaults": {
"height": 300,
"encoding": {
"y": {
"scale": {
"domainMin": 0,
"domainMax": 1
}
}
}
}
}
],
views=[
{
"type": "LinearGenomeView",
"assembly": "hg38",
"loc": "chr2:135,844,000-135,858,000",
"tracks": [
"kgp_lct_population_af"
]
}
],
)
app # display the widgetThis view in your React 19 app, with @jbrowse/react-app2 and @jbrowse/core. Add your own files to tracks.
import { use } from 'react'
import { JBrowse } from '@jbrowse/react-app2'
import '@jbrowse/react-app2/styles.css'
import { addRelativeUris } from '@jbrowse/core/util/addRelativeUris'
const configUrl = "https://jbrowse.org/ucsc/hg38/config.json"
const configPromise = fetch(configUrl)
.then(res => res.json())
.then(config => {
addRelativeUris(config, new URL(configUrl))
return config
})
export default function Figure() {
const config = use(configPromise)
return (
<JBrowse
assemblies={config.assemblies}
tracks={[...(config.tracks ?? []), ...[
{
"type": "MultiQuantitativeTrack",
"trackId": "kgp_lct_population_af",
"name": "Allele frequency per population, 1000 Genomes unrelated samples",
"assemblyNames": [
"hg38"
],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "CEU",
"color": "#4e79a7",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CEU.bw"
},
{
"type": "BigWigAdapter",
"source": "FIN",
"color": "#e15759",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_FIN.bw"
},
{
"type": "BigWigAdapter",
"source": "PJL",
"color": "#76b7b2",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_PJL.bw"
},
{
"type": "BigWigAdapter",
"source": "TSI",
"color": "#59a14f",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_TSI.bw"
},
{
"type": "BigWigAdapter",
"source": "YRI",
"color": "#edc948",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_YRI.bw"
},
{
"type": "BigWigAdapter",
"source": "CHB",
"color": "#f28e2b",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CHB.bw"
}
]
},
"displayDefaults": {
"height": 300,
"encoding": {
"y": {
"scale": {
"domainMin": 0,
"domainMax": 1
}
}
}
}
}
]]}
aggregateTextSearchAdapters={config.aggregateTextSearchAdapters}
configuration={config.configuration}
views={[
{
"type": "LinearGenomeView",
"assembly": "hg38",
"loc": "chr2:135,844,000-135,858,000",
"tracks": [
"kgp_lct_population_af"
]
}
]}
/>
)
}jbrowse-img draws this view as an SVG, no browser needed. Swap --config or a track for your own.
cat > tracks.json <<'JSON'
[
{
"type": "MultiQuantitativeTrack",
"trackId": "kgp_lct_population_af",
"name": "Allele frequency per population, 1000 Genomes unrelated samples",
"assemblyNames": [
"hg38"
],
"adapter": {
"type": "MultiWiggleAdapter",
"subadapters": [
{
"type": "BigWigAdapter",
"source": "CEU",
"color": "#4e79a7",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CEU.bw"
},
{
"type": "BigWigAdapter",
"source": "FIN",
"color": "#e15759",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_FIN.bw"
},
{
"type": "BigWigAdapter",
"source": "PJL",
"color": "#76b7b2",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_PJL.bw"
},
{
"type": "BigWigAdapter",
"source": "TSI",
"color": "#59a14f",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_TSI.bw"
},
{
"type": "BigWigAdapter",
"source": "YRI",
"color": "#edc948",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_YRI.bw"
},
{
"type": "BigWigAdapter",
"source": "CHB",
"color": "#f28e2b",
"uri": "https://jbrowse.org/demos/popgen/lct_1kg38_chr2_af_CHB.bw"
}
]
},
"displayDefaults": {
"height": 300,
"encoding": {
"y": {
"scale": {
"domainMin": 0,
"domainMax": 1
}
}
}
}
}
]
JSON
npx @jbrowse/img --config https://jbrowse.org/ucsc/hg38/config.json \
--trackConfigs tracks.json \
--assembly hg38 --loc chr2:135,844,000-135,858,000 \
--track kgp_lct_population_af \
--out figure.svgFor a PNG, --out figure.png (needs rsvg-convert: apt install librsvg2-bin, brew install librsvg).
Open it over chr2:135,844,000-135,858,000, the stretch of MCM6 that holds
rs4988235:
- At
rs4988235the allele is common in the two northern European populations (CEU, FIN) and rarer in PJL (Punjabi) and TSI (Tuscan), the spread Bersaglieri et al. (2004) describe. - The YRI (Yoruba) and CHB (Han Chinese) rows have common variants elsewhere in the window, at sites where the other four are low.
Reproduce it end to end
build_lct_ld.sh
builds the triangles and the narrow Fst track, and writes a ready-to-serve
config. It:
- keeps the release's unrelated samples, since relatives share long haplotypes whether or not a sweep happened, and splits them into the European panel and everyone else
- cuts a region wide enough to reach past both edges of the block, and prints
mean r² against
rs4988235along it, so the block's ends show in the data - cuts the European panel out of that same slice, so the pooled and panel triangles hold the same variants and differ only in their samples
- correlates each cohort's common variants with PLINK, and scores Fst per variant between the panel and the rest
curl -fO https://raw.githubusercontent.com/GMOD/jbrowse-components/main/scripts/build_lct_ld.sh
bash build_lct_ld.sh # builds ./lct_ld_build/jbrowse2
npx --yes serve lct_ld_build/jbrowse2 # then open the printed URLThree more scripts build the other files:
build_lct_fst_scan.shwrites the wide Fst track, scoring the same panels with the same estimator over a wide stretch of chr2 with LCT at its middle, one value per variant. It prints wherers4988235ranks across the span.build_lct_haploblock.shbuilds the subsampled haplotype matrix from the same number of unrelated samples in each population, which span the lactase-persistence allele from common to absent, so none outweighs the rest in the clustering. It prints the allele's frequency in each, over the release and over the subsample.build_lct_population_af.shbuilds the per-population frequencies from every unrelated sample of the populations in the pooled slice, and prints the frequencies atrs4988235.
curl -fO https://raw.githubusercontent.com/GMOD/jbrowse-components/main/scripts/build_lct_fst_scan.sh
bash build_lct_fst_scan.sh # builds ./lct_fst_scan_buildcurl -fO https://raw.githubusercontent.com/GMOD/jbrowse-components/main/scripts/build_lct_haploblock.sh
bash build_lct_haploblock.sh # builds ./lct_haploblock_buildcurl -fO https://raw.githubusercontent.com/GMOD/jbrowse-components/main/scripts/build_lct_population_af.sh
bash build_lct_population_af.sh # builds ./lct_population_af_buildSee also
- Tutorial: LD across an inversion (mosquitoes)
- Tutorial: Selection scans (Drosophila DGRP)
- Tutorial: Phased trio analysis (1000 Genomes)
- User guide: Variant track
- User guide: GWAS / Manhattan track
- Config guide: Variant track configuration
Citations
- 1000 Genomes Project Consortium (2015). A global reference for human genetic variation
- Bersaglieri et al. (2004). Genetic signatures of strong recent positive selection at the lactase gene
- Byrska-Bishop et al. (2022). High-coverage whole-genome sequencing of the expanded 1000 Genomes Project cohort including 602 trios
- Halldorsson et al. (2019). Characterizing mutagenic effects of recombination through a sequence-level genetic map
Notes
-
PLINK 1.9 and PLINK 2.0 are separate programs, and the page runs both. plink2 gained
--r2-phasedin its a6 alphas, so on earlier builds the r² step needs PLINK 1.9. ThePlinkLDTabixAdapterreads the column names of either program from the header, so output from either loads. ↩
Feedback on this tutorial is welcome: contact us.