Gene density and transposon density along a chromosome
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.17. Desktop beta builds are coming soon.
We look at where the genes sit along human chromosome 1 and which transposons sit near them: Alu elements pile up where the genes are, and L1 elements spread more evenly. A whole chromosome holds more genes, and far more repeat copies, than a browser fetches at once. We:
- count each file's features per kilobase into a small bigWig with
jbrowse make-density - load the counts as gene and repeat density tracks along chromosome 1
- zoom in to 1q21, where the tracks give way to the features themselves
Prerequisites
- a JBrowse to open the figures' sessions in (Web or Desktop)
- Node.js, which the JBrowse CLI runs on
- the JBrowse CLI, for
jbrowse make-density bedGraphToBigWigfrom the UCSC utilities, whichmake-densityruns- htslib (
bgzip,tabix), for the build script
# Debian/Ubuntu
sudo apt install tabix nodejs
# or conda, which has every tool above
conda install -c bioconda -c conda-forge htslib 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/cliThe data
The figures read UCSC's hg38 annotation tables, rehosted by genomes.jbrowse.org's hg38 with a per-kilobase bigWig beside each file.
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 counting step takes any GFF3 or BED of your own.
| What it is | File |
|---|---|
RefSeq curated genes, UCSC's ncbiRefSeqCurated table as GFF3 | ncbiRefSeqCurated.gff.gz |
RepeatMasker, UCSC's rmsk table as BED with a column header | rmsk.bed.gz |
| Reference lengths, for the bigWig header | hg38.chrom.sizes |
Loading hg38
We'll load hg38, the assembly the UCSC tables were cut from. Every track below
names it in assemblyNames.
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"
}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 Show all available genomes and pick it. To load the files of this config instead:
In JBrowse Desktop, Open new 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
Counting features per kilobase into a bigWig
One bigWig per file holds the number of features starting in each 1 kb bin,
counted once. jbrowse make-density reads the GFF3 and writes it beside the
input, named for the file with .density.bw in place of its .gz:
# --chrom-sizes gives the bigWig header its reference lengths;
# --assembly hg38.fa reads them off the FASTA's .fai instead
# a GFF3 counts only lines with no Parent= attribute, so a gene is one
# count however many transcripts and exons hang under it; a BED or VCF
# counts every record, and a GTF its transcript rows
# every bin is written, empty ones included, so the zoomed-out levels of
# the bigWig average over the whole span
jbrowse make-density genes.gff.gz --chrom-sizes hg38.chrom.sizesAdd the bigWig as a track:
Goes in the tracks array of config.json. See Tracks.
{
"trackId": "hg38_genes_density",
"name": "RefSeq genes per kb",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/gene_density/genes.gff.density.bw",
"displayDefaults": { "extent": "none" }
}jbrowse add-track https://jbrowse.org/demos/gene_density/genes.gff.density.bw \
--trackId hg38_genes_density \
--name "RefSeq genes per kb" \
--assemblyNames hg38 \
--displayDefaults '{"extent":"none"}'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_genes_density",
"name": "RefSeq genes per kb",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/gene_density/genes.gff.density.bw",
"displayDefaults": { "extent": "none" }
}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%22trackId%22%3A%22hg38_genes_density%22%2C%22name%22%3A%22RefSeq+genes+per+kb%22%2C%22assemblyNames%22%3A%5B%22hg38%22%5D%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fgene_density%2Fgenes.gff.density.bw%22%2C%22displayDefaults%22%3A%7B%22extent%22%3A%22none%22%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22hg38%22%2C%22loc%22%3A%22chr1%22%2C%22tracks%22%3A%5B%22hg38_genes_density%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+RefSeq+genes+per+kbextent: "none" draws each bin's mean alone. Most kilobases hold no gene or
one, so the min-max band drawn around the mean would fill every zoomed-out pixel
to the same height.
The three repeat tracks come from cutting the RepeatMasker table into one BED
per repFamily, so the Alu bigWig counts only Alus. The same make-density
line over each family BED builds its bigWig:
Goes in the tracks array of config.json. See Tracks.
{
"trackId": "hg38_Alu_density",
"name": "Alu per kb",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/gene_density/Alu.bed.density.bw",
"displayDefaults": { "extent": "none" }
}jbrowse add-track https://jbrowse.org/demos/gene_density/Alu.bed.density.bw \
--trackId hg38_Alu_density \
--name "Alu per kb" \
--assemblyNames hg38 \
--displayDefaults '{"extent":"none"}'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_Alu_density",
"name": "Alu per kb",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/gene_density/Alu.bed.density.bw",
"displayDefaults": { "extent": "none" }
}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%22trackId%22%3A%22hg38_Alu_density%22%2C%22name%22%3A%22Alu+per+kb%22%2C%22assemblyNames%22%3A%5B%22hg38%22%5D%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fgene_density%2FAlu.bed.density.bw%22%2C%22displayDefaults%22%3A%7B%22extent%22%3A%22none%22%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22hg38%22%2C%22loc%22%3A%22chr1%22%2C%22tracks%22%3A%5B%22hg38_Alu_density%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+Alu+per+kbThe L1 track and the simple-repeat control follow, with the file names swapped:
Goes in the tracks array of config.json. See Tracks.
{
"trackId": "hg38_L1_density",
"name": "L1 per kb",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/gene_density/L1.bed.density.bw",
"displayDefaults": { "extent": "none" }
}jbrowse add-track https://jbrowse.org/demos/gene_density/L1.bed.density.bw \
--trackId hg38_L1_density \
--name "L1 per kb" \
--assemblyNames hg38 \
--displayDefaults '{"extent":"none"}'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_L1_density",
"name": "L1 per kb",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/gene_density/L1.bed.density.bw",
"displayDefaults": { "extent": "none" }
}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%22trackId%22%3A%22hg38_L1_density%22%2C%22name%22%3A%22L1+per+kb%22%2C%22assemblyNames%22%3A%5B%22hg38%22%5D%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fgene_density%2FL1.bed.density.bw%22%2C%22displayDefaults%22%3A%7B%22extent%22%3A%22none%22%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22hg38%22%2C%22loc%22%3A%22chr1%22%2C%22tracks%22%3A%5B%22hg38_L1_density%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+L1+per+kbGoes in the tracks array of config.json. See Tracks.
{
"trackId": "hg38_Simple_repeat_density",
"name": "Simple repeats per kb",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/gene_density/Simple_repeat.bed.density.bw",
"displayDefaults": { "extent": "none" }
}jbrowse add-track https://jbrowse.org/demos/gene_density/Simple_repeat.bed.density.bw \
--trackId hg38_Simple_repeat_density \
--name "Simple repeats per kb" \
--assemblyNames hg38 \
--displayDefaults '{"extent":"none"}'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_Simple_repeat_density",
"name": "Simple repeats per kb",
"assemblyNames": ["hg38"],
"uri": "https://jbrowse.org/demos/gene_density/Simple_repeat.bed.density.bw",
"displayDefaults": { "extent": "none" }
}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%22trackId%22%3A%22hg38_Simple_repeat_density%22%2C%22name%22%3A%22Simple+repeats+per+kb%22%2C%22assemblyNames%22%3A%5B%22hg38%22%5D%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fgene_density%2FSimple_repeat.bed.density.bw%22%2C%22displayDefaults%22%3A%7B%22extent%22%3A%22none%22%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22hg38%22%2C%22loc%22%3A%22chr1%22%2C%22tracks%22%3A%5B%22hg38_Simple_repeat_density%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+Simple+repeats+per+kbGene and repeat density along chromosome 1
Add the tracks above, then open chromosome 1 with all of them.
The gap in every track is the centromere and the 1q12 heterochromatin beside it.
Zooming in to 1q21 with the genes as features
Add the gene file as a track, then type chr1:150,000,000-160,000,000, 10 Mb
over 1q21 to 1q23. At this width the gene track's fetch fits, so it draws each
gene:
Goes in the tracks array of config.json. See Tracks.
{
"type": "FeatureTrack",
"trackId": "hg38_genes",
"name": "RefSeq curated genes",
"assemblyNames": ["hg38"],
"adapter": {
"type": "Gff3TabixAdapter",
"uri": "https://jbrowse.org/demos/gene_density/genes.gff.gz"
}
}jbrowse add-track https://jbrowse.org/demos/gene_density/genes.gff.gz \
--trackId hg38_genes \
--name "RefSeq curated genes" \
--assemblyNames hg38In 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/gene_density/genes.gff.gz
Click Next. JBrowse reads the adapter and track type off the file name. Then fill in:
- Track name:
RefSeq curated genes - Assembly:
hg38
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%2Fhg38%2Fconfig.json&session=spec-%7B%22sessionTracks%22%3A%5B%7B%22type%22%3A%22FeatureTrack%22%2C%22trackId%22%3A%22hg38_genes%22%2C%22name%22%3A%22RefSeq+curated+genes%22%2C%22assemblyNames%22%3A%5B%22hg38%22%5D%2C%22adapter%22%3A%7B%22type%22%3A%22Gff3TabixAdapter%22%2C%22uri%22%3A%22https%3A%2F%2Fjbrowse.org%2Fdemos%2Fgene_density%2Fgenes.gff.gz%22%7D%7D%5D%2C%22views%22%3A%5B%7B%22type%22%3A%22LinearGenomeView%22%2C%22assembly%22%3A%22hg38%22%2C%22loc%22%3A%22chr1%3A150%2C000%2C000-160%2C000%2C000%22%2C%22tracks%22%3A%5B%22hg38_genes%22%5D%7D%5D%7D&sessionName=JBrowse+docs%3A+RefSeq+curated+genesReproduce it end to end
build_gene_density.sh
wraps every step above. It:
- fetches the two UCSC tables and the reference lengths
- cuts the RepeatMasker table into the three family BEDs
- counts each file per kilobase into a bigWig
- writes a JBrowse with the files and their bigWigs as tracks
curl -fO https://raw.githubusercontent.com/GMOD/jbrowse-components/main/scripts/build_gene_density.sh
bash build_gene_density.sh # builds ./gene_density_build/jbrowse2
npx --yes serve gene_density_build/jbrowse2 # then open the printed URLSee also
- Tutorial: RepeatMasker as one row per class
- Tutorial: Synteny on a circle (human and mouse)
- Tutorial: A map of the human mitochondrial genome
- Tutorial: Reviewing a gene prediction (Tiberius)
- Docs: Command line tools (JBrowse CLI)
- Docs: JBrowse web quick start
Citations
- Lander et al. (2001). Initial sequencing and analysis of the human genome
- Smit, Hubley and Green (2013-2015). RepeatMasker Open-4.0
Feedback on this tutorial is welcome: contact us.