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.13. 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, so we count each file's features per kilobase
into a small bigWig with jbrowse make-density and show those counts as tracks,
then zoom in to see the genes 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 counts at the end
Where the data comes from
The figures read UCSC's hg38 annotation tables, rehosted by genomes.jbrowse.org's hg38 with a per-kilobase bigWig beside each file.
The build script takes these files from their URLs, so there is nothing to download by hand.
- RefSeq curated genes, UCSC's
ncbiRefSeqCuratedtable as GFF3: jbrowse.org/…/ncbiRefSeqCurated.gff.gzhttps://jbrowse.org/ucsc/hg38/ncbiRefSeqCurated.gff.gz - RepeatMasker, UCSC's
rmsktable as BED with a column header: jbrowse.org/…/rmsk.bed.gzhttps://jbrowse.org/ucsc/hg38/rmsk.bed.gz - reference lengths, for the bigWig header: hgdownload.soe.ucsc.edu/…/hg38.chrom.sizeshttps://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/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 ↗
Open this track in JBrowse Desktop ↗ (JBrowse Desktop 5.0+)
extent: "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 ↗
Open this track in JBrowse Desktop ↗ (JBrowse Desktop 5.0+)
The 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 ↗
Open this track in JBrowse Desktop ↗ (JBrowse Desktop 5.0+)
Goes 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 ↗
Open this track in JBrowse Desktop ↗ (JBrowse Desktop 5.0+)
Gene and repeat density along chromosome 1
Add the four tracks above, then open chromosome 1 with all four.
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 ↗
Open this track in JBrowse Desktop ↗ (JBrowse Desktop 5.0+)
Checking the tracks against counts from the files
The tracks are counts, so counting the files checks them. Hovering a track shows
the count per kilobase under the cursor. Count one megabase under the tallest
run of the gene track, at 155 Mb, and one under a trough, at 60 Mb. A gene's
transcripts and exons have Parent=, so the gene line drops them and counts
each gene once:
tabix genes.gff.gz chr1:155,000,000-156,000,000 | grep -vc 'Parent='
tabix Alu.bed.gz chr1:155,000,000-156,000,000 | wc -l
tabix L1.bed.gz chr1:155,000,000-156,000,000 | wc -l
tabix Simple_repeat.bed.gz chr1:155,000,000-156,000,000 | wc -l| window, chr1 | genes | Alu | L1 | simple repeats |
|---|---|---|---|---|
| 155 to 156 Mb | 49 | 1298 | 254 | 269 |
| 60 to 61 Mb | 4 | 146 | 295 | 235 |
The gene count runs with the Alu count, while L1 and the simple repeats come out about the same in both, the same pattern the four tracks show.
Reproduce 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 of the four files per kilobase into a bigWig
- writes a JBrowse with the four files and their four 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.