@jbrowse/bandage-core
v20.1.0
Published
Pangenome graph layout and drawing with no host: GFA in, the Bandage force-directed engine and reference-anchored layouts, a Canvas2D renderer, hit testing and labels out
Readme
@jbrowse/bandage-core
@jbrowse/bandage-core is the code that lays out and draws pangenome graphs in the JBrowse graph plugin, BandageJS and ggbandage, packaged so you can build your own viewer or figures with it.
- In: a pangenome graph as GFA, or a region of one read from a gfa-to-tabix walk file with @gmod/gfa-tabix
- Out: a layout of the graph, drawn on an HTML canvas (as in the JBrowse plugin and BandageJS), to an SVG file, or as tables of coordinates for another plotting library (ggbandage plots them with ggplot2)
- Layouts: Bandage's force-directed layout, which shows the graph's loops and bubbles, or layouts along the reference genome, such as one bar per haplotype or a tube map
Install
npm install @jbrowse/bandage-coreReading walk files also needs @gmod/gfa-tabix.
Usage
The example below reads LPA's KIV-2 repeat from the HPRC release 2.1 walk file on jbrowse.org and draws it with one panel per haplotype. It keeps three haplotypes besides GRCh38 and draws two of them:
import { WalkFile } from '@gmod/gfa-tabix'
import {
figureSvg,
forceLayout,
layoutEngine,
loadGraph,
} from '@jbrowse/bandage-core'
const walks = new WalkFile({
walksUrl:
'https://jbrowse.org/demos/hprc/hprc-v2.1-mc-grch38-f8.GRCh38.walks.gz',
})
const refName = 'GRCh38#0#chr6'
const { tables } = await walks.getGraphForRange(
'chr6',
160_614_798,
160_647_758,
{
haplotypes: ['HG00097', 'HG01960', 'HG00133'],
},
)
const graph = loadGraph(tables, 'KIV-2')
const spec = {
walks: [
{ name: refName },
{ name: 'HG00097#1#JBIRDD010000043.1' },
{ name: 'HG00133#1#CM090050.1' },
],
facet: { field: 'walk', columns: 3 },
}
const { result } = await forceLayout(graph, spec, layoutEngine)
const svg = figureSvg(graph, result, { spec })Haplotype threads
Leave out facet in the example above, and figureSvg draws the same three
haplotypes on the same graph, but on one layout, each in a different color along
the nodes it passes through. Where haplotypes pass through the same nodes, their
threads run side by side, so a loop drawn in one color is a loop only that
haplotype passes through. On a canvas, passing
walkLift(graph, resolvedSpecOf(spec, graph)) to buildGeometry as highlight
draws the same threads. A haplotype colored by pass splits into one thread per
trip round a repeat; see Threading by pass.
Docs
- API: the main exports, by task: loading, layouts, drawing to a canvas, figures, haplotypes, and genes and variants
- Walk rows and departures: where a haplotype leaves the reference, what the text beside each walk row means, and what a host app does
- Drawing reference: fitting a drawing to a pane, labels, small sites and threading by pass, for an app that draws with bandage-core
- Command-line tools:
bandage-figuredraws a figure from a JSON graph spec, andbandage-foldmerges small variants into the reference for viewing zoomed out
See also
- jbrowse-plugin-graphgenomeviewer: browses these graphs by locus in JBrowse 2
- BandageJS: browses GFA files and walk files in a web browser
- ggbandage (R): Bandage-style figures as ggplot2 layers
Similar project for tubemaps
- @jbrowse/tubemap-core: sequenceTubeMap's layout, without the DOM
JBrowse tutorials;
