Pangenome (hosting your own graph)
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.24. Desktop beta builds for Linux and
macOS are on the releases page;
the Windows build waits on code signing.
A pangenome graph of many genomes is too large to load whole, so JBrowse browses one from small indexed files, a window at a time, from a whole chromosome down to single nodes. One command cuts a graph into those files and writes the config that puts them on tracks. We run it on HPRC release 2's human graph, with E. coli and Arabidopsis graphs for the steps whose input the human graph lacks. We:
- install the GraphGenomeView plugin and index a graph with
gfa-to-tabix build - load the graph as a graph track, and as a row of segments with Display types
- add the tracks that show which haplotypes pass through each segment
- index the haplotypes' walks and load them as a graph track with one lane per haplotype
- convert the walks to PAF for a linear synteny view
The graph view is a beta plugin. We welcome your feedback.
Prerequisites
- the GraphGenomeView plugin
- htslib (
bgzip,tabix) andbcftools gfa-to-tabix5.0.0 or later, for the graph's files in format 2, which the configs below read, and the walk files (walk format 8, the only one the plugin reads)gfatools, for an rGFA's bubblesminigraph, for each assembly's path through the graphvg, for a plain GFA's bubbles- for the walks as PAF:
python3and the JBrowse CLI formake-pif
# Debian/Ubuntu
sudo apt install tabix bcftools
# or conda, which has every tool above
conda install -c bioconda -c conda-forge htslib bcftools gfatools minigraph \
vg
# any platform
cargo install gfa-to-tabix
npm install -g @jbrowse/cli@nextDownload the data
The input is HPRC release 2's
Minigraph-Cactus graphs. gfa-to-tabix build reads the rGFA, and the walk files
come from the base-level GFAs, all as local files. Fetch the rGFA first and the
base-level GFAs when you reach the walks:
B=https://s3-us-west-2.amazonaws.com/human-pangenomics/pangenomes/freeze/release2/minigraph-cactus/v2.1/hprc-v2.1-mc-grch38/hprc-v2.1-mc-grch38
# SV-resolution rGFA, 0.8 GB
wget -c $B.sv.gfa.gz
# base-level GFA with every haplotype's walk, 64 GB
wget -c $B.gfa.gz
C=https://s3-us-west-2.amazonaws.com/human-pangenomics/pangenomes/freeze/release2/minigraph-cactus/v2.1/hprc-v2.1-mc-chm13/hprc-v2.1-mc-chm13
# the same graph built on T2T-CHM13, for walks on hs1, 66 GB
wget -c $C.gfa.gzOther files (no download needed)
| What it is | File |
|---|---|
| The finished files, for comparison | README.txt |
Install the GraphGenomeView plugin
Install GraphGenomeView, which needs JBrowse 5, from the plugin store, at
Tools → Plugin store in JBrowse Web or Global plugins... on the JBrowse
Desktop start screen (Installing plugins). The config the
command writes names it with the plugins entry below, in which storePlugin
picks the build for the JBrowse reading the config, and esmUrl is the fallback
when the store cannot be read
(configuring plugins).
{
"plugins": [
{
"name": "GraphGenomeView",
"storePlugin": "GraphGenomeView",
"esmUrl": "https://jbrowse.org/plugins/jbrowse-plugin-graphgenomeviewer/latest/dist/jbrowse-plugin-graphgenomeviewer.esm.js"
}
]
}Index a graph with gfa-to-tabix build
The gfa-to-tabix build command writes every file below. Without a Rust
toolchain, take a Linux or macOS binary from its
releases.
The sections that apply depend on the file you have:
- An rGFA gives the graph track, the bubbles and the coarse tier here, and with the assemblies, each haplotype's allele at every bubble.
- A plain GFA gives the same tracks from a snarl VCF, and the haplotypes on each segment from its paths.
- A base-level GFA with W lines also gives haplotype lanes and whole-genome synteny.
- A GBZ converts to that GFA with
vg convert -f.
An rGFA, from minigraph or the minigraph stage of Minigraph-Cactus, needs an
output prefix and the assembly name your config uses. Its bubbles come from
gfatools bubble, so put gfatools on PATH:
gfa-to-tabix build graph.rgfa.gz -o hprc --assembly hg38To build your own rGFA, give minigraph PanSN-named FASTA records
(sample#haplotype#contig), since it takes each segment's stable name from the
input headers. If every per-strain file names its contig chr, every segment
gets the same chr name, and no query can tell the strains apart.
A plain GFA, from pggb, odgi, vg or base-level Minigraph-Cactus, also needs the backbone sample and its bubbles. The bubbles come from a snarl VCF (vg's word for a bubble is snarl):
vg deconstruct -awrites one record per snarl against the reference path, taggedLVfor its level in the snarl tree, andpggb -Vwrites the same file.gfa-to-tabix bubbleskeeps theLV=0records, so the tag has to be there.- The VCF's CHROM must be the assembly's refName, so rename the PanSN path
(
sample#haplotype#contig) as the pggb tutorial does:
# -p: the reference path to decompose against
vg deconstruct -a -p K12#1#chr graph.gfa > graph.snarls.vcf
printf 'K12#1#chr\tchr\n' > rename_chrs.tsv
bcftools annotate --rename-chrs rename_chrs.tsv graph.snarls.vcf \
| bcftools sort -Oz -o graph.snarls.vcf.gzgfa-to-tabix build graph.gfa -o ecoli --reference K12 --assembly K12 --snarls graph.snarls.vcf.gzOn a plain GFA, the command places each segment by walking the paths:
--referencetakes a sample, an assembly (HG002#1) or a path, and makes every contig of the assembly it resolves to the reference, walked first at rank 0. A bare sample (GRCh38) is enough for a haploid reference; for a diploid one, name the haplotype, or the command anchors on the sample's first haplotype and prints a note naming it.- A segment a path reaches twice takes its position from the first visit, so it is drawn as one node and the repeat shows as depth.
At human-chromosome scale, index the SV-resolution rGFA.
The command writes these files beside the prefix:
| file | what it holds |
|---|---|
.graph.bed.gz |
one row per segment and one per link, filed under reference coordinates for an rGFA and under the segment's coordinate on its source contig for a plain GFA; a link row has both ends in full |
.bubbles.bed.gz |
where haplotypes diverge and rejoin, with each bubble's shortest and longest allele |
.fold10000.graph.bed.gz |
the graph with variants under 10 kb folded into the reference, so a whole chromosome draws; a plain GFA folds under 50 bp, as .fold50.graph.bed.gz |
.contig.graph.bed.gz |
an rGFA's segment and link rows under the segment's coordinate on its source contig |
.graph.json |
a manifest naming the files above and the tier's fold size |
.config.json |
the tracks below, with the plugin entry |
Each .bed.gz gets a tabix index beside it. --format 1 writes the index, the
tier and the contig layout as .segs.bed.gz and .links.bed.gz pairs, and a
track reading such a pair leaves out "format": 2.
To check the index against the graph, query a locus out of it by the graph's PanSN name for the reference contig:
tabix hprc.graph.bed.gz 'GRCh38#0#chr1:103,690,000-103,700,000' \
| awk '$4 == "N"' | head -3GRCh38#0#chr1 103668404 103713477 N s653929 95 HG00323#2#CM087328.1 104135607 104135610
GRCh38#0#chr1 103668404 103713477 N s653930 95 HG00323#2#CM087328.1 104135610 104144685
GRCh38#0#chr1 103668404 103713477 N s663586 205 HG02723#2#JAHEOT020000031.1 103971922 104013350
The awk keeps the segment rows, which have N in column four where a link row
has L. In a segment row, columns one to three give the reference interval the
command filed it under, five the segment id, six its rank (build order), and
seven to nine the segment's contig and span.
- An empty result over a tiled reference means the query used the wrong
name:
chr1finds nothing whereGRCh38#0#chr1finds every segment. - Backbone rows with no alleles mark a place where the graph collapsed, as minigraph does with near-identical segmental duplications.
Index an rGFA in the contig layout
For an rGFA, index in the contig layout with three commands, so the graph
track's uri is the prefix itself. build writes the anchored layout at the
bare prefix (<prefix>.graph.bed.gz) and the contig layout at
<prefix>.contig; the three commands write the contig layout at the bare
prefix. First the segments and links:
# --layout contig: each segment under its coordinate on its source contig
gfa-to-tabix graph.rgfa.gz --layout contig -o graphThen the bubbles, which gfatools bubble writes unsorted:
gzip -dc graph.rgfa.gz | gfatools bubble - | sort -k1,1 -k2,2n | bgzip > graph.bubbles.bed.gz
tabix -C -p bed graph.bubbles.bed.gzThen the coarse tier, in the same layout as the segments:
# --below: fold variants under 10 kb into the reference
gfa-to-tabix fold graph.rgfa.gz --below 10000 --layout contig -o graph.fold10000The three commands write no .graph.json or .config.json, so the graph
track's coarse entry names the tier's prefix itself.
Add the coarse tier for whole-chromosome views
The coarse tier is a copy of the graph with every variant under a threshold
folded into the reference. It keeps each allele whose length, or the reference
it replaces, reaches the threshold, and the way back to the reference from both
of its ends. The graph track folds what it draws the same way at ten of the
linear view's pixels, so zooming out onto the tier keeps every loop the fine cut
drew. The threshold is in the file name, 10,000 bp by default for an rGFA;
--tier sets it, and a plain GFA defaults to 50, since most of its variants are
single bases. Without a tier, the graph track cuts at most 5 Mb of segments and
asks you to zoom in past that.
Configure the graph track
The config's first track is the graph track, whose adapter holds:
uri, the prefix, and"format": 2, which reads<prefix>.graph.bed.gzcoarse, which names the tier and its threshold,foldBelowBp; the track draws the tier past a tenth of that in bp per pixel, or pastaboveBpPerPxwherecoarsesets itassemblyNameToPanSN, which maps your assembly name to the graph's PanSN sample; the command writes it only when the two differ
Goes in the tracks array of config.json. See Tracks.
{
"type": "GraphTrack",
"trackId": "hprc_graph",
"name": "hprc graph",
"assemblyNames": ["hg38"],
"adapter": {
"type": "GfaTabixAdapter",
"uri": "hprc",
"format": 2,
"assemblyNameToPanSN": { "hg38": "GRCh38" },
"coarse": { "uri": "hprc.fold10000", "format": 2, "foldBelowBp": 10000 }
},
"displayDefaults": {
"labels": { "name": { "show": false }, "description": { "show": false } }
},
"displays": [
{ "type": "LinearGraphDisplay" },
{ "type": "LinearBasicDisplay" }
]
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "GraphTrack",
"trackId": "hprc_graph",
"name": "hprc graph",
"assemblyNames": ["hg38"],
"adapter": {
"type": "GfaTabixAdapter",
"uri": "hprc",
"format": 2,
"assemblyNameToPanSN": { "hg38": "GRCh38" },
"coarse": { "uri": "hprc.fold10000", "format": 2, "foldBelowBp": 10000 }
},
"displayDefaults": {
"labels": { "name": { "show": false }, "description": { "show": false } }
},
"displays": [
{ "type": "LinearGraphDisplay" },
{ "type": "LinearBasicDisplay" }
]
}'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": "GraphTrack",
"trackId": "hprc_graph",
"name": "hprc graph",
"assemblyNames": ["hg38"],
"adapter": {
"type": "GfaTabixAdapter",
"uri": "hprc",
"format": 2,
"assemblyNameToPanSN": { "hg38": "GRCh38" },
"coarse": { "uri": "hprc.fold10000", "format": 2, "foldBelowBp": 10000 }
},
"displayDefaults": {
"labels": { "name": { "show": false }, "description": { "show": false } }
},
"displays": [
{ "type": "LinearGraphDisplay" },
{ "type": "LinearBasicDisplay" }
]
}hprc, hprc.fold10000 are relative to a config.json. Replace each with its URL or its path on this computer.
build writes the config as <prefix>.config.json, here hprc.config.json.
Merge its plugins and tracks entries into your own config, then run
jbrowse validate config.json, which reports a misspelled or undeclared slot
JBrowse otherwise ignores. Without a config, File → Open track... → Add
pangenome graph track reads hprc.graph.json beside hprc.graph.bed.gz, so a
track opened from that url gets the coarse tier too.
A plain GFA's index and tier are in the contig layout, each segment under its coordinate on its source contig. In the anchored layout an rGFA gets, each segment is filed under every reference position its branch spans. On the E. coli pggb and Minigraph-Cactus graphs, that layout makes the track draw multi-megabase rows across every window.
Turned on, the track draws as a graph. Display types → Feature display in its track menu draws the same segments as a row.
The other two tracks in the config draw the bubbles as a row and as a curve. Turn them on and switch the graph back with Display types → Graph.
A node's right-click menu offers Open in the haplotype its rGFA id names
(NA20809#2#CM094351.1 opens NA20809#2), when the session holds an assembly
named or aliased sample#haplotype.
Record which haplotypes pass through each segment
The rank in an rGFA is build order, so it names the first assembly a segment came from. The full list of haplotypes whose paths pass through each segment comes from one of two sources.
With the assemblies, map each one back through the graph, the reference
included, and read the path it takes. Each call file's name, minus .call.bed,
becomes that sample's row label. Name the reference's file after its PanSN
sample (TAIR10 for contigs named TAIR10#1#Chr1), since gfa-to-tabix paths
drops <that name># from the contig names:
# --call: the path this sample takes through every bubble, one line per
# `gfatools bubble` line, in the same order for every sample
# -xasm: the assembly-to-graph preset
# -c: base-level alignment, which --call reads
minigraph -cxasm --call -t 8 graph.rgfa.gz TAIR10.pansn.fa > TAIR10.call.bed
minigraph -cxasm --call -t 8 graph.rgfa.gz sample.pansn.fa > sample.call.bedgfa-to-tabix paths
joins the call files, the reference's first, into one tabix-indexed row per
bubble per sample, drawn as one row per haplotype:
gfa-to-tabix paths -o graph.paths TAIR10.call.bed sample.call.bedThe file loads as a feature track with one row per haplotype, partitioned on
strain. The itemRgb column holds each block's color by class, so the track
needs no color config:
Goes in the tracks array of config.json. See Tracks.
{
"type": "FeatureTrack",
"trackId": "graph_paths",
"name": "graph: each haplotype's allele at every bubble",
"assemblyNames": ["TAIR10"],
"adapter": {
"type": "BedTabixAdapter",
"uri": "graph.paths.bed.gz",
"disableGeneHeuristic": true
},
"displays": [
{
"type": "LinearMultiRowFeatureDisplay",
"rows": { "field": "strain" }
}
]
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "FeatureTrack",
"trackId": "graph_paths",
"name": "graph: each haplotype'\''s allele at every bubble",
"assemblyNames": ["TAIR10"],
"adapter": {
"type": "BedTabixAdapter",
"uri": "graph.paths.bed.gz",
"disableGeneHeuristic": true
},
"displays": [
{
"type": "LinearMultiRowFeatureDisplay",
"rows": { "field": "strain" }
}
]
}'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": "graph_paths",
"name": "graph: each haplotype's allele at every bubble",
"assemblyNames": ["TAIR10"],
"adapter": {
"type": "BedTabixAdapter",
"uri": "graph.paths.bed.gz",
"disableGeneHeuristic": true
},
"displays": [
{
"type": "LinearMultiRowFeatureDisplay",
"rows": { "field": "strain" }
}
]
}graph.paths.bed.gz is relative to a config.json. Replace it with its URL or its path on this computer.
The arabidopsis pangenome config includes one such file as the track
arabidopsis_minigraph_paths. Open it over FLC at Chr5:3,170,000-3,186,000,
under TAIR10_genes:
With a plain GFA, the command records the haplotypes whose paths pass
through each segment while it reads the paths, as an SB:H: bitmask over the
haplotypes the file's #samples header lists (SM:Z: names in format 1). The
track below is written for a build like the
pggb graph of five E. coli strains,
indexed against K12.
- The node panel lists them as
samples; a track reads them asfeature.samplesand their count asfeature.sampleCount. - Color by → Attribute... with
sampleCountgives each count a separate color. - For more than a handful of haplotypes, Advanced → Edit plot... in the track menu takes a ramp, here red for a segment on one haplotype to grey for a segment on most. The track config below sets it:
Goes in the tracks array of config.json. See Tracks.
{
"type": "FeatureTrack",
"trackId": "graph_haplotypes_per_segment",
"name": "graph: haplotypes per segment",
"assemblyNames": ["K12"],
"adapter": {
"type": "GfaTabixAdapter",
"uri": "graph",
"format": 2
},
"displayDefaults": {
"encoding": {
"color": {
"field": "sampleCount",
"scale": {
"type": "linear",
"domainMin": 1,
"range": ["#e31a1c", "#bdbdbd"]
},
"legend": { "title": "Haplotypes" }
}
}
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "FeatureTrack",
"trackId": "graph_haplotypes_per_segment",
"name": "graph: haplotypes per segment",
"assemblyNames": ["K12"],
"adapter": {
"type": "GfaTabixAdapter",
"uri": "graph",
"format": 2
},
"displayDefaults": {
"encoding": {
"color": {
"field": "sampleCount",
"scale": {
"type": "linear",
"domainMin": 1,
"range": ["#e31a1c", "#bdbdbd"]
},
"legend": { "title": "Haplotypes" }
}
}
}
}'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": "graph_haplotypes_per_segment",
"name": "graph: haplotypes per segment",
"assemblyNames": ["K12"],
"adapter": {
"type": "GfaTabixAdapter",
"uri": "graph",
"format": 2
},
"displayDefaults": {
"encoding": {
"color": {
"field": "sampleCount",
"scale": {
"type": "linear",
"domainMin": 1,
"range": ["#e31a1c", "#bdbdbd"]
},
"legend": { "title": "Haplotypes" }
}
}
}
}graph is relative to a config.json. Replace it with its URL or its path on this computer.
The count is per haplotype (HG002.1), so a diploid sample's two copies count
separately.
Index haplotype walks with gfa-to-tabix
A walk is one haplotype's route through the graph. gfa-to-tabix --walks
writes every walk to one walk file per reference, which the graph track and the
haplotype lanes read one range at a time:
- each walk is cut into pieces, one for each stretch it spends in a 64 kb tile of the reference, and each piece is filed under its tile
- a tile holds the reference's path through it once, each distinct route a haplotype takes off that path once, and every other walk's piece as the list of routes it takes
- a departure record gives each place a walk leaves the reference and rejoins it in another piece, and is filed over the whole stretch between, so JBrowse still reads the haplotype that skips a deletion when the window lies inside that deletion
The base-level GFA holds each walk as a W line. Index the GRCh38 graph against GRCh38:1
# --refs: the reference sample whose coordinates the walk file is in
gfa-to-tabix hprc-v2.1-mc-grch38.gfa.gz --walks --refs GRCh38 \
-o hprc-v2.1-mc-grch38Index a track on T2T-CHM13 from the CHM13-built graph, whose reference passes no node twice, so every step is placed exactly:
gfa-to-tabix hprc-v2.1-mc-chm13.gfa.gz --walks --refs CHM13 -o hprc-v2.1-mc-chm13vg convert -f graph.gbz writes the same GFA for a graph published only as a
GBZ.
The tool writes a walk file and its directory for each sample in --refs, named
<prefix>.<sample>.walks.gz and <prefix>.<sample>.walks.gz.idx, so a track on
GRCh38 reads files that cover GRCh38 alone:
| file | what it holds |
|---|---|
hprc-v2.1-mc-grch38.GRCh38.walks.gz |
a header, then for each GRCh38 sequence its tiles, its departure records and a table of their byte ranges |
hprc-v2.1-mc-grch38.GRCh38.walks.gz.idx |
the byte range of the header and of each sequence's table |
hprc-v2.1-mc-chm13.CHM13.walks.gz |
the same for T2T-CHM13, with its own .idx |
A browser reads the directory, then fetches the tiles and departure records over
a window by range request. gzip -dc prints the whole file as text, header
first:
gzip -dc hprc-v2.1-mc-grch38.GRCh38.walks.gz | head -4#walks format:i:8 tile:i:65536 revisited:i:0 stay:i:311 abridge:i:1000000 abridgebytes:i:3000000 graph:Z:c9aa0d5f6907f27c leftout:i:1698
#reference GRCh38
#haplotype CHM13#0
#haplotype HG00097#1
#walksgives the file's format, the tile size,revisited, the number of nodes the reference passes more than once (0 when every step is placed exactly), and the--staythe tool ran withabridgeandabridgebytesare the--abridge-stepsand--abridge-bytesbudgets. Where a tile's walks exceed those budgets, usually in a satellite array, gfa-to-tabix moves the costliest walks to detail records that a window read skipsgraphandleftoutgive the hash of the graph the file was written from, which the graph's index also contains, and the number of paths left out because they have no step on a node of the reference#referenceand#haplotypelist the reference sample, then every other haplotype with rows in the file, the other reference included
A track's walksUri names one reference's walk file by its prefix,
<prefix>.<sample>, and reads <walksUri>.walks.gz with the .idx beside it.
The track below draws the graph and, as a second display, one lane per
haplotype. Each haplotype in assemblyNames is an assembly whose aliases
include its sample#haplotype name, as
the HPRC tutorial
declares one; assemblyNameToPanSN covers the reference, which has none:
Goes in the tracks array of config.json. See Tracks.
{
"type": "GraphTrack",
"trackId": "my_graph_lanes",
"name": "My graph: haplotypes vs the reference",
"assemblyNames": ["hg38", "HG00097.1", "HG00099.1"],
"adapter": {
"type": "GfaWalksSyntenyAdapter",
"walksUri": "https://example.com/graphs/my_graph.GRCh38",
"assemblyNames": ["hg38"],
"assemblyNameToPanSN": { "hg38": "GRCh38#0" }
},
"displays": [
{ "type": "MultiWaySyntenyDisplay", "height": 600 },
{ "type": "LinearGraphDisplay" }
]
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "GraphTrack",
"trackId": "my_graph_lanes",
"name": "My graph: haplotypes vs the reference",
"assemblyNames": ["hg38", "HG00097.1", "HG00099.1"],
"adapter": {
"type": "GfaWalksSyntenyAdapter",
"walksUri": "https://example.com/graphs/my_graph.GRCh38",
"assemblyNames": ["hg38"],
"assemblyNameToPanSN": { "hg38": "GRCh38#0" }
},
"displays": [
{ "type": "MultiWaySyntenyDisplay", "height": 600 },
{ "type": "LinearGraphDisplay" }
]
}'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": "GraphTrack",
"trackId": "my_graph_lanes",
"name": "My graph: haplotypes vs the reference",
"assemblyNames": ["hg38", "HG00097.1", "HG00099.1"],
"adapter": {
"type": "GfaWalksSyntenyAdapter",
"walksUri": "https://example.com/graphs/my_graph.GRCh38",
"assemblyNames": ["hg38"],
"assemblyNameToPanSN": { "hg38": "GRCh38#0" }
},
"displays": [
{ "type": "MultiWaySyntenyDisplay", "height": 600 },
{ "type": "LinearGraphDisplay" }
]
}The track aligns each walk to the reference walk at the nodes both pass through, so it needs no sequence beyond the walk file.
A graph track with no lanes names a walk file through GfaTabixAdapter, here
the CHM13 graph's:
Goes in the tracks array of config.json. See Tracks.
{
"type": "GraphTrack",
"trackId": "hprc_walks_chm13",
"name": "HPRC v2.1 haplotype walks",
"assemblyNames": ["hs1"],
"adapter": {
"type": "GfaTabixAdapter",
"walksUri": "hprc-v2.1-mc-chm13.CHM13",
"assemblyNameToPanSN": { "hs1": "CHM13" },
"defaultHaplotypes": [
"HG00097#1",
"HG00099#1",
"HG00128#1",
"HG00133#1",
"HG01109#1",
"HG01123#1",
"HG01960#1",
"HG02055#1"
]
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "GraphTrack",
"trackId": "hprc_walks_chm13",
"name": "HPRC v2.1 haplotype walks",
"assemblyNames": ["hs1"],
"adapter": {
"type": "GfaTabixAdapter",
"walksUri": "hprc-v2.1-mc-chm13.CHM13",
"assemblyNameToPanSN": { "hs1": "CHM13" },
"defaultHaplotypes": [
"HG00097#1",
"HG00099#1",
"HG00128#1",
"HG00133#1",
"HG01109#1",
"HG01123#1",
"HG01960#1",
"HG02055#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": "GraphTrack",
"trackId": "hprc_walks_chm13",
"name": "HPRC v2.1 haplotype walks",
"assemblyNames": ["hs1"],
"adapter": {
"type": "GfaTabixAdapter",
"walksUri": "hprc-v2.1-mc-chm13.CHM13",
"assemblyNameToPanSN": { "hs1": "CHM13" },
"defaultHaplotypes": [
"HG00097#1",
"HG00099#1",
"HG00128#1",
"HG00133#1",
"HG01109#1",
"HG01123#1",
"HG01960#1",
"HG02055#1"
]
}
}assemblyNameToPanSNmaps the assembly name to the walk file's reference sample, herehs1toCHM13defaultHaplotypeslists the haplotypes the track draws until the reader picks others, assample#haplotype, or a bare sample for both of its haplotypes
The HPRC tracks built this way open at chr22:20,000,000-20,100,000 on hs1, from the CHM13 graph's walk file and hg38, from the GRCh38 graph's walk file.
The track menu's Haplotypes submenu switches the track between The track's default haplotypes, Every haplotype in the graph and Chosen in Graph settings..., whose dialog offers the names from the walk file's header. A graph view opened from the track draws the same set. Where the graph collapses the copies of a repeat onto one set of nodes, the track draws a walk through them where the reference places those nodes.
Two budgets in the adapter's config set when a window is refused with a notice to zoom in:
walkByteBudgetcaps the compressed bytes a window would fetch from the walk file, which its directory gives before any row is read. A tile holds every haplotype's rows, so the bytes are the same for any set of haplotypes.walkStepBudgetcaps the walk steps a window keeps, counting only the haplotypes the track draws, so with fewer haplotypes the track can draw a wider window.
Convert the walks to PAF for a synteny view
The track reads the walk files one window at a time. For a whole-genome synteny view, a GFA's walks also convert to PAF against the reference walk, one record per stretch of nodes the two walks share. Convert the walks you want:
curl -fO https://raw.githubusercontent.com/cmdcolin/gfa-to-pairwise-paf/v1.0.0/gfa_to_pairwise_paf.py
# --contig-lengths: each assembly's .fai, since walks omit contig lengths
gzip -dc graph.gfa.gz | python3 gfa_to_pairwise_paf.py --reference GRCh38#0 \
--queries HG01109#1,HG00099#1 --contig-lengths contigs.fai > graph.pafIndex the PAF for JBrowse:
jbrowse make-pif graph.paf --csi --out graph.pif.gzbuild_hprc_multiway_synteny.sh
runs both on the release graph for eight haplotypes, with each haplotype's
contig lengths and CAT genes, and
its output is hosted,
one lane per haplotype under GRCh38.
Reproduce it end to end
gfa-to-tabix build builds the graph track, the bubbles and the tier, with the
tools under Prerequisites. It:
- places every segment on a genome: an rGFA holds each position in tags on the segment, and for a plain GFA the command follows the backbone's paths first, then places each remaining segment on the first other haplotype whose path passes through it
- finds the bubbles, with
gfatools bubbleon an rGFA or from the snarl VCF on a plain GFA, and builds the tier from them - writes the manifest and the config that list those files
gfa-to-tabix build hprc-v2.1-mc-grch38.sv.gfa.gz -o hprc --assembly hg38To rebuild the coarse tier alone, at another threshold, run
gfa-to-tabix fold:
gfa-to-tabix fold hprc-v2.1-mc-grch38.sv.gfa.gz --below 10000 -o hprc.fold10000The walk files come from the commands under Index haplotype walks with gfa-to-tabix.
See also
- Tutorial: Pangenome (HPRC) part 1: the graph's alleles and the haplotypes that have them
- Tutorial: Pangenome (HPRC) part 2: haplotypes against each other
- Tutorial: Pangenome (pggb)
- Tutorial: Pangenome (Minigraph-Cactus)
- User guide: Graph genome view
- BandageJS
External links
- Li H.
The rGFA format and
gfatools: the
SN/SO/SRtags and the bubble calls. - gfa-to-tabix's walk format:
the rows
--walkswrites. - gfa-to-tabix and gbz-base compared: what each holds, sizes and requests on HPRC v2.1.
- ggbandage and ggtubemap: R packages that draw a region of a walk file as ggplot2 layers.
Citations
- HPRC release 2, the worked example here.
Notes
-
On a shared 24-core machine
gfa-to-tabixtook 90 minutes and 8 GB of memory for GRCh38's 1.6 GB walk file, and 50 minutes and 9 GB for CHM13's 1.8 GB. ↩
Feedback on this tutorial is welcome: contact us.