core
Auto-generated from exported functions tagged #api in the source. See
imports and re-exports for how to
import these from a plugin.
AggregateOp
One summary over a group: count needs no field; sum, mean, min and
max read one, skipping values that are not numbers. The output field is
as, else count or <op>_<field>.
weight names a field each row counts by: count is then the sum of the
weights, sum the sum of value times weight, and mean that over the sum
of the weights, a row whose weight is not a number counting for nothing. A
weight moves no minimum or maximum, so min and max read none.
AggregateStep
One feature per distinct groupby value set (one for the whole region
with none), spanning its members' extent, carrying the group's fields and
every ops entry.
asTable
A table over a feature list, or the table itself.
import { asTable } from '@jbrowse/core/util/featureTable'
// type signature
(input: readonly Feature[] | FeatureTable) => FeatureTableBinStep
Place every feature in a genome-aligned bin of step bp, writing the bin's
edges over the fields as names — start and end by default, so an
aggregate grouped by those counts per bin and the bar spans the bin.
With field (start by default) a feature lands in the one bin that field
falls in. With fields, an interval's start and end, it is cut at the bin
edges into one piece per bin it overlaps, each piece writing overlap, the
bases of the interval inside its bin; a zero-length interval (an insertion)
is one piece of overlap 0 in the bin holding its position, and one whose
ends are not numbers is none. A piece is its feature with those fields
beside it, so its id and hover are the feature's, and an aggregate over
the pieces weighted by overlap is a mean per base.
breakendKeepsDirections
Which way the sequence each end of a breakend KEEPS runs from its breakpoint,
as +1 = right / -1 = left — the convention StarFusionAdapter's
tickDirection states and the one every producer in the tree emits.
The two halves read their strings with OPPOSITE polarity, which is the whole
reason to state them together. Join: 'right' says the mate piece is joined
to the RIGHT of the ref base, so this end keeps the sequence to its left:
negated. MateDirection: 'right' says the mate's own piece extends to the
right of the mate position, which is already the direction it keeps: taken as
read. So N[chr2:2000[ is { joinDirection: -1, mateDirection: 1 }, and that
is the same pair StarFusionAdapter emits for the fusion it describes — the
donor keeps the sequence below its breakpoint (-1) and the acceptor the
sequence above its own (+1).
Split out of parseSvAlt because a consumer holding an already-parsed
Breakend was re-deriving it by hand, in two adjacent ternaries of opposite
polarity — the shape that produced 78bb7b84f9.
import { breakendKeepsDirections } from '@jbrowse/core/util/svAlt'
// type signature
(bnd: Breakend) => { mateDirection: number; joinDirection: number; }buildColorRampLut
An RGBA lookup table over sampleColorRamp, laid out as the Nx1
texture both GPU backends upload and the Canvas2D twins index — entry i is
the color at t = i / (N - 1). N comes off the shader that samples it, so
the table and rampColor's texel mapping cannot disagree.
The table is always straight. A diverging ramp whose middle belongs at a
value off the centre of the domain reads it through rampMidT, the shader's
rule and its generated twin, so the middle follows a moving domain without a
new table.
import { buildColorRampLut } from '@jbrowse/core/util/colorRamp'
// type signature
(stops: readonly ColorRampStop[]) => Uint8Array<ArrayBuffer>categoricalField
labels names the domain's values in a key, one each in order, where a
config spells them for a reader rather than as the data does. held deals
each key the domain does not list a color of its own on first sight
(categoricalScale); the caller keeps it for as long as the colors should
hold.
import { categoricalField } from '@jbrowse/core/util/categoricalField'
// type signature
(field: string, { domain, range, labels, held, }?: { domain?: readonly string[] | undefined; range?: readonly string[] | undefined; labels?: readonly string[] | undefined; held?: HeldSlots | undefined; }) => CategoricalFieldCategoricalField
One categorical field as every channel reads it — a facet's sections, a
color's range entries, a key's rows. key files a value, compare
orders keys (the domain first, the rest by compareGroupKeys, ''
after them), label names a key in a legend, sectionLabel on a chip, and
color paints it. A key's color depends only on the key and the
declaration, so every region agrees on it, except that a field dealing its
colors (categoricalField's held) also steps a key off the colors of the
keys met before it.
CategoricalRef
A field bound to a categorical scale: each distinct value takes one entry
of the channel's range — a color for color, a shape name for
shape. Every value derives its entry from itself (an integer takes the
slot it names, anything else hashes in), so every region agrees on a value
it shares with another at the cost of an occasional collision. A domain
spends the range deliberately: the listed values take it in order, and a
value the domain leaves out never takes a listed value's entry. The domain
orders and spends; it never adds a value the data lacks.
CellsStep
Replace each aligned row with its cells against the reference: one feature
per run of columns in one state — match, mismatch or gap — on the
row's own reference span, a mismatch run carrying its base and a match or
mismatch run match as 1 or 0, and one interbase feature per insertion,
standing at the reference base it precedes with the inserted bases in
base and their count in length. The row's field (seq) is the
aligned text, and the reference's is the same field on the feature the row
was fanned out of, so a flatten over a MAF block's alignments stands in
front. A gap run reaching either end of the row is no cell, and a feature
with no parent answers none.
ChannelReader
A channel read per feature: the compiled form of a FieldRef, and what a display's own worker method hands the encoder for a channel no field name can say — a join against a second adapter, a lookup table, a rule over two fields.
clipQuantileOf
The quantile a clip toggle writes: a scale's declared default where that clips, below 1, else DEFAULT_CLIP_QUANTILE.
import { clipQuantileOf } from '@jbrowse/core/util/quantileExtent'
// type signature
(declaredDefault: unknown) => numberCodeLane
Codes into a list of labels, one per row.
COLOR_SCHEMES
The named ramps a continuous color scale's scheme takes, each one a stop
table in colorRamp.ts that every ramp baker reads, so no display can name
a scheme nothing bakes. viridis, magma, inferno and cividis are
matplotlib's perceptual ramps, dark at the low end; juicebox fades from
transparent to red, as Juicebox paints contacts; fall runs white through
yellow and red to black, as HiGlass does; reds and blues are
ColorBrewer's, from white; redblue and purpleorange diverge through
white, ColorBrewer's RdBu and PuOr; redgreyblue diverges through a grey
middle, which stays visible on a white page where a white middle would
not, as identity paints;
blueyellowred is ColorBrewer's RdYlBu turned round, so low reads cool and
high hot through a pale yellow middle, as dnds paints.
import { COLOR_SCHEMES } from '@jbrowse/core/util/colorSchemes'
// type signature
readonly ["viridis", "magma", "inferno", "cividis", "juicebox", "fall", "reds", "blues", "redblue", "purpleorange", "redgreyblue", "blueyellowred"]colorAt
The packed color instance i of channels paints: color[i], or color
itself where the color is a constant and so shipped as one number.
import { colorAt } from '@jbrowse/core/util/markEncoding'
// type signature
(channels: Pick<EncodedChannels, "color">, i: number) => number | undefinedColorEncoding
How a mark's color channel resolves. A CSS color or a jexl: expression
returning one paints per feature with no scale; the object forms bind a
field to a scale, which a legend can describe, and share the config's
member names.
colorEvaluator
A CSS color or jexl: color expression as a per-feature packed ABGR —
the unscaled arm of ColorEncoding, on its own for a display that
carries a plain color slot.
import { colorEvaluator } from '@jbrowse/core/util/markEncoding'
// type signature
(color: string, jexl: JexlInstance | undefined) => (feature: Feature) => numbercolorRampStops
The stops a continuous color scale samples: range's CSS colors where it
lists any, else the named scheme, viridis while that is unset, turned
round under reverse.
import { colorRampStops } from '@jbrowse/core/util/colorRamp'
// type signature
({ range, scheme, reverse, }: RampDeclaration) => readonly ColorRampStop[]ColorScaleTable
The scale a color channel was resolved through, as the legend reads it — the same table the colors in the payload came from, so the key cannot disagree with the painting.
ColorSchemeName
Column
A field's values over a table's rows, resolved once per step so the loop
reading it is chosen before the loop runs: a lane a step wrote, codes into
labels, a field read off the parser's own features, text or lists an
adapter holds typed, or a value a step computes per row. at is the row
each of the table's rows reads, where the lane or the features belong to a
table this one stands on.
ColumnTable
A table an adapter answers from the typed arrays it already holds, where
getFeaturesArray would make an object per row: a column per field, and
each row's id. A row's hover JSON is every field it holds.
import { ColumnTable } from '@jbrowse/core/util/featureTable'
// type signature
typeof ColumnTablecontinuousColorScale
A continuous color scale over extent, the values it met: the domain its
declared ends and the extent make, the straight table its stops bake to and
where its middle stop sits, and the packed color a value paints through
them: an infinity the end on its side, as a threshold places it, and NaN,
text that is no number, the misconfiguration grey. The encoder and every
display painting a ramp itself read it, so a value takes one color whoever
paints it.
import { continuousColorScale } from '@jbrowse/core/util/markEncoding'
// type signature
(encoding: ContinuousRef, extent: readonly [number, number]) => { domain: [number, number]; lut: Uint8Array<ArrayBufferLike>; midNorm: number; colorOf: (value: number) => number; }ContinuousRef
A numeric field read through a linear or log scale into a ramp. Each end of
the domain is pinned by domainMin or domainMax, or is the region's own
extreme where unset, so pinning both keeps colors consistent across a
whole view. The ramp is range's CSS colors, evenly spaced, where it
lists any, else the named scheme; reverse turns it round.
CoverageStep
Replace the features with runs of constant depth: how many of them overlap
each stretch of the region, in a field as (coverage by default), with
the stretches nothing overlaps left out. A read counts across its whole
span, deletions and introns included; gap-aware depth stays the alignments
display's (ADR-118).
darkAtLowEnd
Whether a named ramp runs dark at its low end, drawn over white: viridis and its siblings do, juicebox, fall, reds and blues do not.
import { darkAtLowEnd } from '@jbrowse/core/util/colorRamp'
// type signature
(scheme: "blues" | "blueyellowred" | "cividis" | "fall" | "inferno" | "juicebox" | "magma" | "purpleorange" | "redblue" | "redgreyblue" | "reds" | "viridis") => booleandealKeyColors
Deals keys their colors in field.compare order, so the colors a set
of keys first seen together takes do not depend on the order they arrive
in. A no-op for a field that deals nothing.
import { dealKeyColors } from '@jbrowse/core/util/categoricalField'
// type signature
(field: CategoricalField, keys: Iterable<string>) => voidDEFAULT_COLOR_SCHEME
The ramp a continuous scale samples while it names no range and no
scheme, so a declaration spelling it out and one leaving it unset resolve
alike.
import { DEFAULT_COLOR_SCHEME } from '@jbrowse/core/util/colorSchemes'
// type signature
"blues" | "blueyellowred" | "cividis" | "fall" | "inferno" | "juicebox" | "magma" | "purpleorange" | "redblue" | "redgreyblue" | "reds" | "viridis"EncodeContext
What surrounds an encode: the jexl instance a jexl: channel compiles
against — a caller whose channels are all readers or field names passes
none — and a progress reporter.
Encoded
EncodedChannels with the lanes in L present — what
encodeFeatures answers a caller that named them.
EncodedChannels
One encoding's channels over one region's features, dense and
index-aligned: instance i of every array is the same feature, and
featureIndex[i] says which one of the input list it was, or it is absent
where instance i is feature i (featureIndexAt). A lane is
present when the caller asked for it (LaneName); Encoded
is this type with a known lane set required.
encodedChannelTransferables
The buffers an EncodedChannels owns, for rpcResult's transfer
list.
import { encodedChannelTransferables } from '@jbrowse/core/util/markEncoding'
// type signature
(c: EncodedChannels) => ArrayBufferLike[]EncodedLayersResult
What CoreGetEncodedLayers answers for one region: layers[i] is the
request's layers[i] over the region's features, so a display's mark
list indexes straight into it.
encodeFeatures
Evaluate one encoding over a feature list into dense channel arrays for
the lanes named, the scale table each scaled channel came from, the y
extremes and — when index is among the lanes — a hit index.
A feature whose x, x2 or (declared and asked-for) y is not finite is
skipped and counted in skipped, so every array stays index-aligned with
the Flatbush. Pure: the RPC around it owns the adapter, the filters and the
transferables.
Columnar: one pass admits the rows over x, x2 and y alone, and none
runs where all three are lanes of whole numbers; every other lane is then
filled in its own loop over the admitted rows, a lane straight off a typed
column and a categorical over a category column per label.
import { encodeFeatures } from '@jbrowse/core/util/markEncoding'
// type signature
<L extends LaneName>(input: readonly Feature[] | FeatureTable, encoding: MarkEncodingInput, lanes: readonly L[], ctx?: EncodeContext) => Encoded<L>FacetedLayer
One layer of a faceted request: its rows in section order, and the stacked row of each, index for index.
facetLayers
A faceted request's layers: the rows split on the facet's field, the
facet's own steps and then each layer's run over each section alone, and
the sections stacked — a section's rows start where the one above it ends,
and it is as tall as the tallest layer packed it. Every layer's rows come
back in section order beside their stacked rows, so a faceted display is
the unfaceted one drawn once per section, and a row is handed on as its
steps left it. A layer naming no row field stands on each section's first
row, the answer the unfaceted encoder gives it.
The split is a counting sort into section order rather than a list per section: every step runs once over the ordered rows, keeping section order, and one that groups rows groups within a section.
import { facetLayers } from '@jbrowse/core/util/featureTransforms'
// type signature
(input: readonly Feature[] | FeatureTable, facet: FacetSpec, layers: readonly { transform?: readonly TransformStep[] | undefined; row?: string | undefined; }[], jexl?: JexlInstance | undefined) => { layers: FacetedLayer[]; sections: FacetSection[]; }FacetSection
One faceted section as the worker stacked it: its key, the row it starts on and how many rows it holds.
FacetSpec
A row facet: split the features on field's value, run transform and then
every layer's own steps over each section alone, and stack the sections,
each starting on the row after the one above it ends.
featureIndexAt
The input feature instance i of channels was: featureIndex[i], or i
itself where the encoder skipped none and so shipped no index.
import { featureIndexAt } from '@jbrowse/core/util/markEncoding'
// type signature
(channels: Pick<EncodedChannels, "featureIndex">, i: number) => numberFeatureTable
The rows one step of a mark's declaration hands the next: a column per
field and a view of one row as a Feature, for a jexl: expression, a
channel reader and the hover.
fenceOutliers
Where a value axis's open ends stand below a domainQuantile of 1: at the
extremes, unless one would stretch the axis past twice the span the
quantileExtent ends quantiles draw, 0 included where the axis
reaches it (zero); that end stops at the fence. So a plot with no spike
shows every value and cuts none, and a spike leaves the values under it at
least half the axis. Quantiles that meet span their own size, as a flat
domain widens in getNiceDomain.
import { fenceOutliers } from '@jbrowse/core/util/quantileExtent'
// type signature
({ extremes, quantiles, zero, }: { extremes: readonly [number, number]; quantiles: readonly [number, number]; zero: boolean; }) => [number, number]fieldReader
What a channel reads off a feature: a field by name, a dotted path into a
structured field where no field carries the whole name (INFO.SVTYPE on a
VCF record), or a jexl: expression over feature. A jexl expression that
does not compile throws here, once, rather than on every feature.
import { fieldReader } from '@jbrowse/core/util/fieldReader'
// type signature
(ref: string, jexl: JexlInstance | undefined) => (feature: Feature) => unknownFieldRef
Where a channel's value comes from: a feature field name, read natively
(feature.get(name)), or a jexl: expression over feature — the opt-in
escape, measured at 1.5x to 2.0x native per feature (MARK_ENCODING.md
"The jexl channel, measured").
FilterStep
Keep the features a jexl: expression over feature admits.
finiteExtremes
The least and greatest finite values of values[0, count),
[Infinity, -Infinity] where none is finite.
import { finiteExtremes } from '@jbrowse/core/util/quantileExtent'
// type signature
(values: ArrayLike<number>, count: number) => [number, number]FlattenStep
Fan each feature out into one feature per element of an array-valued field
— subfeatures, so a gene answers its transcripts and a transcript its
exons — or per entry of a record keyed by name, so a VCF record answers one
feature per sample and a MAF block one per species, each with its key in
key. Each answer reads the element's own fields first and the feature it
came from for everything else, so an exon still knows its gene's name and
strand and a species row its block's reference span. A feature whose field
holds no array and no record drops out unless keepEmpty says otherwise.
FormulaStep
Write a jexl: expression's value over feature into the field as of
every feature.
getBreakendMateLocString
The mate locString ("chr2:100") of a parsed breakend, or undefined when it
names no navigable position. Two ALT forms reach here without one: a single
breakend (.A / G.) has no mate at all, and the symbolic-mate forms
(G<DEL>, <DEL>G) get a placeholder <DEL>:1 from parseBreakend, which
puts a symbolic allele id where a contig name belongs. Callers that navigate
or split-view a mate must drop both rather than treat <DEL> as a refName.
import { getBreakendMateLocString } from '@jbrowse/core/util/svAlt'
// type signature
(breakend?: Breakend | undefined) => string | undefinedheldSlotsOf
The HeldSlots owner keeps under key, made empty on first ask. Lives as
long as owner and is never persisted, so a reload deals afresh.
import { heldSlotsOf } from '@jbrowse/core/util/categoricalField'
// type signature
(owner: object, key: string) => HeldSlotsHitIndexed
An encoded payload as a display stores it: the hit index the worker built with hitIndexOf, wrapped once where the payload lands.
hitIndexOf
The hit index over count instances: each a box from x to x2 at its
y, or at 0 for a mark with no value.
import { hitIndexOf } from '@jbrowse/core/util/markEncoding'
// type signature
(x: Uint32Array<ArrayBufferLike>, x2: Uint32Array<ArrayBufferLike>, y: Float32Array<ArrayBufferLike> | undefined, count?: number) => FlatbushisBreakend
Breakend notation, without parsing it: bracket forms (G[chr2:100[), single
breakends (.A / G.), and the symbolic-mate form (G<DEL>, an angle
bracket past position 0; a leading < is a plain symbolic allele).
import { isBreakend } from '@jbrowse/core/util/svAlt'
// type signature
(alt: string) => booleanisMissing
Whether a field holds no value at all, as against text that fails to parse:
absent, empty, or a VCF's AF=., which arrives as [undefined].
import { isMissing } from '@jbrowse/core/util/thresholdScale'
// type signature
(value: unknown) => booleanisPlainFieldRef
Whether a field ref is a bare name: what feature.get answers on its own,
with no path to walk and no expression to evaluate. A loop over a plain name
keeps the direct call, and only a config that writes a path pays for one.
import { isPlainFieldRef } from '@jbrowse/core/util/fieldReader'
// type signature
(ref: string) => ref is neverjunctionEnds
Where a paired record's junction is at each of its two ends, and which side
of it each end keeps — the one answer every launcher, the row menu and the
chain walk take, whether the record is a VCF breakend, a symbolic SV or a
paired adapter's row (BEDPE, STAR-Fusion). Refnames are as the record spells
them. undefined for a record naming no other end. A VCF record is read
through alt, its first ALT unless the caller names another.
A VCF end is its own position. A paired adapter's end is a block, and the
junction is the block's edge on the side the end keeps: stated by
mateDirection where the adapter knows it, read off the strands where the
record states one for each end as BEDPE does, and with neither the two
blocks face each other. A PAF row's strand is the query's orientation and
states none for the target, so it names no side.
import { junctionEnds } from '@jbrowse/core/util/svAlt'
// type signature
(feature: Feature, alt?: string | undefined, alleleIndex?: number | undefined) => { own: JunctionEnd; mate: JunctionEnd; } | undefinedkeyNames
What a key names each of keys, from a color object's labels: one each in
order, an empty or missing entry leaving that key its own name. Every key
that takes labels reads them through this, so a config means one thing by
them everywhere.
import { keyNames } from '@jbrowse/core/util/categoricalField'
// type signature
(keys: readonly unknown[], labels?: readonly string[]) => ReadonlyMap<string, string>LaneName
The lanes a caller asks the encoder to fill, beyond x and x2, which
every payload carries, and featureIndex, which one carries where a
feature was skipped: a mark's channels, and index for the Flatbush a
hover reads. A lane not asked for is neither
allocated nor transferred, and a caller that never hovers declines the
index, which is most of the encoder's cost after the walk.
LayerRequest
One layer of a CoreGetEncodedLayers request: the encoding to evaluate and
the lanes the display's mark reads.
layerTables
A layered request's rows: the shared steps, the facet's split where it names one, and each layer's own steps, with the row each layer's rows stand in — the field it names, or under a facet each row's stacked row. The split comes as early as it can: after the last shared step that must see every row, so the steps that follow it read the rows already in section order.
import { layerTables } from '@jbrowse/core/util/featureTransforms'
// type signature
(input: readonly Feature[] | FeatureTable, request: { transform?: readonly TransformStep[] | undefined; facet?: FacetSpec | undefined; layers: readonly { transform?: readonly TransformStep[] | undefined; row?: string | undefined; }[]; }, jexl?: JexlInstance | undefined) => { layers: { table: FeatureTable; row: string | Uint32Array<ArrayBufferLike> | undefined; }[]; sections: FacetSection[] | undefined; }ListColumn
A list of rows per row: row i's entries are the rows of entries from
start[i] up to start[i + 1], and keys, where the list is a record
keyed by name, the name of each entry.
ListedRowSource
One row an adapter lists: name is a value of the listing's field, and
label and color are what the adapter names and colors that row with.
listsRowSources
Whether an adapter implements RowSourceLister.
import { listsRowSources } from '@jbrowse/core/data_adapters/BaseAdapter/rowSources'
// type signature
(adapter: object) => adapter is RowSourceListerLocusRef
A position that may lie on another sequence: the field holding its refName
and the field holding its 0-based coordinate, as a paired record states
its mate ({ chrom: 'mate.refName', pos: 'mate.start' }). Spelt the way
GenomeSpy spells a genomic position over two columns.
MadeRows
A table whose rows a step made, which answers each row's identity, its hover JSON and the feature it hangs from.
MarkEncoding
The declared mapping from a feature's fields to a mark's channels. Every
positional channel is a field: x defaults to start and x2 to end, a
mark that plots no value leaves y off, and the scale y is read through
belongs to the display rather than to the encoding. shape is read by the
point mark alone, row — an integer field, 0 where missing — by every
mark, which stands a feature in the band it names.
MarkEncodingInput
What encodeFeatures takes: a MarkEncoding, any channel of which
may be a ChannelReader in place of its declared form, and row the
values themselves, one per input feature, where the caller computed them —
a facet's stacked rows. The declared form is what crosses the wire; a
reader or a value list is built in the worker.
matedBy
How a record states its other end, or undefined where it states none: the
mate a paired adapter fills (BEDPE, STAR-Fusion), an ALT the breakend
and symbolic-SV readers resolve, or a read's next_ref and next_pos. The
mate step admits exactly the features this names one for, so a caller
deciding whether links are the picture a track wants asks here rather than
re-reading the fields.
import { matedBy } from '@jbrowse/core/util/featureTransforms'
// type signature
(f: Feature) => "alt" | "mate" | "pair" | undefinedMateStep
One feature per other end a record states: the mate a paired adapter
fills in (BEDPE, STAR-Fusion), or each VCF ALT naming a locus, a
breakend's mate or a symbolic allele's END on CHR2 or its own
sequence. Each answer carries mate (refName, start, end, 0-based
and half-open, and the far end's mateDirection), its own end's
mateDirection, the alt it came from and svType, the structural
class the allele states (svClassOfAlt). A record naming no other end drops
out, and two records or alleles stating one pair of ends answer once.
MISCONFIGURED_ABGR
The misconfiguration grey packed as the encoder paints it: a jexl: color
that answered no string, a ramp value that is no number, text a threshold
cannot read.
import { MISCONFIGURED_ABGR } from '@jbrowse/core/util/markEncoding'
// type signature
numberNO_VALUE_ABGR
The no-value grey packed as the encoder paints it: a feature with nothing in the field a threshold reads.
import { NO_VALUE_ABGR } from '@jbrowse/core/util/markEncoding'
// type signature
numberNO_VALUE_LABEL
The row a feature with nothing in a categorical field lands on, so a key says why a mark is grey rather than listing a blank value.
import { NO_VALUE_LABEL } from '@jbrowse/core/util/markEncoding'
// type signature
"(no value)"NOT_A_NUMBER_LABEL
The key a value holding text that is no number files under on a threshold scale, painted the misconfiguration grey rather than passing for a missing value.
import { NOT_A_NUMBER_LABEL } from '@jbrowse/core/util/thresholdScale'
// type signature
"(not a number)"NumberLane
A typed lane a step wrote, one number per row.
numberReaderOf
readerOf as the number a quantitative channel or step reads,
NaN where a row holds none, by numericValue's rules.
import { numberReaderOf } from '@jbrowse/core/util/featureTable'
// type signature
(column: Column) => (i: number) => numbernumericDomain
A domain written as strings — the shared domain slot is a stringArray —
read back as the numbers it names. A member that is not a number reads NaN,
which every comparison against it declines.
import { numericDomain } from '@jbrowse/core/util/thresholdScale'
// type signature
(domain: readonly (string | number)[]) => number[]parseSvAlt
Parse raw (non-assembly-resolved) mate coordinates from a VCF SV feature+alt.
Returns undefined when no mate coordinate info is found. alleleIndex is
the alt's place in ALT, which a record repeating one symbolic allele with
several lengths needs; it defaults to the first place alt appears.
import { parseSvAlt } from '@jbrowse/core/util/svAlt'
// type signature
(feature: Feature, alt?: string | undefined, alleleIndex?: number) => { mateRefName: string; matePos: number; mateDirection?: number | undefined; joinDirection?: number | undefined; } | undefinedPileupStep
Assign every feature the lowest row on which it overlaps nothing already
there — greedy first fit in start order, the packing a pileup is — and
write it to the field as (row). fields names the interval read
(start, end); padding is bp of clearance kept between two features
sharing a row. The answer is the input in start order, so a span
encoding row stacks it. Under a facet it packs each section on its own.
quantileExtent
What the open ends of a scale follow over values[0, count): at a
quantile of 1 their finite extremes, and below it each end clipped at
that quantile of the values on its side of 0, so one spike takes neither
the axis nor the ramp, and a sparse tail of the other sign keeps its own
end. An axis that starts at 0 adds it itself. Under 0.5 reads as 0.5,
where the ends meet rather than cross. scales.y.domainQuantile and a
color's domainQuantile both name it. [Infinity, -Infinity] where
nothing is finite.
Nearest rank keeps ties: where one value holds the rank, as on a segmented copy-number track, a ramp clipped below 1 paints nearly every value one color. A value axis fences instead (fenceOutliers); a ramp takes the same fence once a color default below 1 meets tied data.
import { quantileExtent } from '@jbrowse/core/util/quantileExtent'
// type signature
(values: ArrayLike<number>, count: number, quantile?: number) => [number, number]quantileOf
The nearest-rank quantile of a[0, n): the smallest value at least that
share of them sit at or below, so a handful of values clips at their
maximum. Permutes a; 0 where n is.
import { quantileOf } from '@jbrowse/core/util/quantileExtent'
// type signature
(a: Float32Array<ArrayBufferLike>, n: number, quantile: number) => numberRampDeclaration
A continuous color scale's ramp as a config declares it.
rampDomain
The domain a continuous color scale spans: each end min or max pins,
else the extent's, ascending, since a span has no direction and reverse
is the ramp's. An open end stops at a pinned one rather than crossing it,
and an extent holding no value ([Infinity, -Infinity]) spans [0, 1].
import { rampDomain } from '@jbrowse/core/util/colorRamp'
// type signature
(min: number | undefined, max: number | undefined, extent: readonly [number, number]) => [number, number]rampGapScales
The rows a ramp's key lists beside its bar once a feature painted one: the not-a-number and no-value rows a threshold's key ends with. Empty while neither painted.
import { rampGapScales } from '@jbrowse/core/util/thresholdScale'
// type signature
(id: string, met: { missing?: boolean | undefined; notNumber?: boolean | undefined; }) => CategoricalScale[]rampLutOf
The buildColorRampLut table a ramp declaration asks for, the same
Uint8Array for the same declaration, since a GPU backend re-uploads its
ramp texture when the identity changes and a render state is rebuilt far
more often than its ramp.
import { rampLutOf } from '@jbrowse/core/util/colorRamp'
// type signature
(ramp: RampDeclaration) => Uint8Array<ArrayBufferLike>rampOverExtent
A ramp table over extent, the union a display took across the regions it
loaded: each open end of the domain moved to the union's, the pinned ends
kept. The table stays straight and domainMid a value, so the middle stop
follows the widened domain with no table baked again.
import { rampOverExtent } from '@jbrowse/core/util/markEncoding'
// type signature
(table: {…}, extent: [number, number]) => { kind: "ramp"; field: string; scale: "linear" | "log"; domain: [number, number]; pinned: [boolean, boolean]; domainMid?: number | undefined; range?: string[] | undefined; scheme?: "blues" | "blueyellowred" | "cividis" | "fall" | "inferno" | "juicebox" | "magma" | "purpleorange" | "redblue" | "redgreyblue" | "reds" | "viridis" | undefined; reverse?: boolean | undefined; extent: [number, number]; quantile?: number | undefined; lut: Uint8Array<…>; missing?: boolean | undefined; notNumber?: boolean | undefined; }readerOf
A reader of a column's values by row, its kind resolved here once. A
number lane with no index reads straight off the lane.
import { readerOf } from '@jbrowse/core/util/featureTable'
// type signature
(column: Column) => (i: number) => unknownREADS_REFERENCE
The adapterCapabilities entry of an adapter that reads the reference
sequence of the assembly it is displayed against: BAM and SAM for mismatches
without an MD tag, CRAM to rebuild bases, GC content and the reference scans
for everything they answer. Such an adapter is built with that reference and
keyed on it as well as on its config, so one config shown on two genomes is
two instances, each reading its own, and an instance never changes reference
for its life. Every other adapter keys on its config alone: a synteny adapter
is fetched from each of its assemblies and reads no reference.
import { READS_REFERENCE } from '@jbrowse/core/data_adapters/dataAdapterCache'
// type signature
"readsReference"relight
Move a color's OKLCH lightness by lightnessShift and scale its chroma,
holding its hue.
For extending a categorical palette past its length. Cycling a nine-color list over a 24-chromosome karyotype repeats the color outright; cycling it with a lightness shift per lap gives the hue back as a variant still told apart from the original — tab20's construction, which pairs a light and a dark of each hue.
SHIFT rather than a fixed lightness, and SCALE rather than a fixed chroma, because a categorical palette is uneven on purpose: category10's brown and its red are 5 degrees apart in hue and are told apart by chroma alone, so re-lighting both to one (lightness, chroma) makes them the same color. Keeping each color's own relative chroma keeps brown reading as brown.
In OKLCH rather than through lighten/darken, which work in sRGB, where
the same coefficient moves a yellow and a blue by visibly different amounts:
a lap has to read as one tone across the whole palette or it reads as noise.
import { relight } from '@jbrowse/core/util/color'
// type signature
(color: string, lightnessShift: number, chromaScale?: number) => stringRowSourceLister
An adapter that lists its rows without reading a region: a multi-BigWig its files, a MAF its species.
RowSourceListing
Every row an adapter has, in its own order, whatever the loaded regions hold, so a row display gives a row with nothing in view its place, label and color.
runTransforms
Run the transform steps over a feature list or a table, in order, in the worker. The table a step answers is what the next one reads, and the last one is what the encoder walks.
import { runTransforms } from '@jbrowse/core/util/featureTransforms'
// type signature
(input: readonly Feature[] | FeatureTable, steps: readonly TransformStep[], jexl?: JexlInstance | undefined) => FeatureTablesafeParseBreakend
parseBreakend, honoring its Breakend | undefined signature. ALT strings are
user data and malformed breakends do occur;
import { safeParseBreakend } from '@jbrowse/core/util/svAlt'
// type signature
(alt: string) => Breakend | undefinedsampleColorRamp
The color at t in [0, 1] across a list of EVENLY SPACED stops, linearly
interpolated per channel. t is clamped, so the ends are the end stops
rather than an extrapolation past them, and a one-stop ramp is that stop
everywhere.
import { sampleColorRamp } from '@jbrowse/core/util/colorRamp'
// type signature
(stops: readonly ColorRampStop[], t: number) => ColorRampStopscaleExtent
quantileExtent as a scale's open ends read it: over every finite
value on a linear scale, and on a log scale over the positive ones, since a
0 or a negative met there would floor the domain at 1 and fold a domain
below 1 flat. [Infinity, -Infinity] where the scale reads nothing.
import { scaleExtent } from '@jbrowse/core/util/quantileExtent'
// type signature
(values: ArrayLike<number>, count: number, scale: string, quantile?: number) => [number, number]ScaleTable
The table behind a channel a key is drawn from: a color's, whose kind
names the scale it resolved through, or a shape's. A size channel's
(SizeScaleTable) draws no key and stands outside.
selectEncodedFeature
Open the feature widget on the feature behind one instance of a
CoreGetEncodedLayers answer. A display holds channels, not records, so it
sends CoreGetEncodedFeature the request the instance's region came back
under, and the worker answers the entry of layer's list that the
instance's featureIndex names: the record as the adapter wrote it, or the
bin or run the steps made. A second click aborts the first.
import { selectEncodedFeature } from '@jbrowse/core/util/selectEncodedFeature'
// type signature
(self: IStateTreeNode<IAnyType>, rotation: { begin(): ActiveFetch; cancel: () => void; dispose(): void; }, args: Omit<CoreGetEncodedLayersArgs, "byteLimit"> & { layer: number; featureIndex: number; }) => voidselectNth
The kth smallest of a[0, n), permuting a in place. Exact, where a
histogram collapses skewed contact counts into its bottom bucket, and O(n)
where a sort of 4.5M counts measured ~1s. Median-of-three because Hi-C
contacts arrive nearly sorted.
import { selectNth } from '@jbrowse/core/util/quantileExtent'
// type signature
(a: Float32Array<ArrayBufferLike>, n: number, k: number) => numberselectRows
The table's rows rows names, in that order: over an adapter's features, a
source table over those features again, so every field still reads straight
off them; over rows a step made, a table standing on them.
import { selectRows } from '@jbrowse/core/util/featureTable'
// type signature
(table: FeatureTable, rows: Uint32Array<ArrayBufferLike>) => FeatureTableSessionPaletteProvider
Make JBrowse follow the host's light/dark state — the whole of it, in one mount:
<SessionPaletteProvider session={session} mode={myAppIsDark ? 'dark' : 'light'}>
{tracks}
</SessionPaletteProvider>mode is optional. Left out, JBrowse follows the page's declared
color-scheme — so a host whose dark-mode toggle sets it, as most do, mounts
this with a session and nothing else. A page that declares light dark
follows the OS, and a page that declares nothing stays light.
A component rather than a documented pair of calls because the pair has a
half that can be left out with nothing to show for it. PaletteProvider is
the name a host reaches for, and it colors the React side alone; the session
write is what reaches the RPC worker, which bakes feature labels into the
rendered image. So a host that mounts only the provider gets light-mode
labels on a dark page, from a canvas whose every other pixel is right, and
nothing errors. See useSessionPalette for the mechanism.
The session is the only thing that resolves a palette here, so a host
supplying colors of its own mounts PaletteProvider directly instead.
import { SessionPaletteProvider } from '@jbrowse/core/ui/PaletteContext'
// type signature
({ session, mode, children, }: { session: ThemeModeSession; mode?: "dark" | "light" | undefined; children: ReactNode; }) => ElementSHAPE_CODES
The point mark's painter code for each shape an encoding can name.
import { SHAPE_CODES } from '@jbrowse/core/util/shapeNames'
// type signature
Record<ShapeName, number>ShapeEncoding
A ShapeName, a jexl: expression over feature returning one, or
a field bound to a categorical scale whose range lists the shape names
handed out — the three shapes, in order, when absent.
ShapeScaleTable
The scale a shape channel was resolved through: which shape each value of the field took.
SizeEncoding
How a mark's size channel resolves: a number is a constant width in CSS
px for every instance, a field name is { field } with the defaults, and
the object binds the field to a scale.
SizeRef
A numeric field read through a linear or log scale into a width in CSS px:
range is the px at each end of the domain (1 to 6 unset), and each end of
the domain is pinned by domainMin or domainMax or follows the loaded
regions' extremes where unset, as a color ramp's does. A feature holding
no number takes the range's first px.
SizeScaleTable
The scale a size channel is read through: the size lane holds the raw
values and the shape maps them to px through this, so a display unions
extent over its loaded regions into the open ends of domain and every
region strokes the same value at the same width.
stopsFromRampLut
n evenly spaced legend stops read straight out of a
buildColorRampLut byte table — the same 256×1 RGBA array
uploadColorRampLut hands the GPU and the Canvas2D fillStyle LUTs index —
as the stops of a RampScale. It holds one claim by construction: the
swatch at bar fraction t is byte-identical to the ramp entry both backends
read at t, through the ramp's middle stop at midNorm (rampMidT). Alpha rides opacity (the juicebox fade), never baked into
the color string.
import { stopsFromRampLut } from '@jbrowse/core/util/colorRamp'
// type signature
(lut: Uint8Array<ArrayBufferLike>, n: number, midNorm?: number) => RampStop[]STRAND_FIELD
import { STRAND_FIELD } from '@jbrowse/core/util/categoricalField'
// type signature
"strand"SV_MIN_LENGTH
The conventional size floor for calling a sequence indel structural.
import { SV_MIN_LENGTH } from '@jbrowse/core/util/svAlt'
// type signature
50SV_TYPE_FIELD
The structural-variant class svClassOf names. A VCF record and a BEDPE
row carry it, and the mark display's mate step writes it per allele.
import { SV_TYPE_FIELD } from '@jbrowse/core/util/categoricalField'
// type signature
"svType"svClassOf
The structural-variant class of a VCF record as a whole: the one class its
alleles state, CNV where they are losses and gains of one segment, OTHER
where they otherwise disagree, and '' for a record with no structural
allele.
import { svClassOf } from '@jbrowse/core/util/svAlt'
// type signature
(feature: Feature) => stringsvClassOfAlt
The structural-variant class one ALT allele states, '' for one that is not
structural. A symbolic allele's own id wins. Otherwise VCF 4.4's EVENTTYPE
does; then a breakend is the class its SVTYPE declares where that says more
than BND, and a sequence allele is an insertion or deletion by its length
against REF, else its SVTYPE's class.
import { svClassOfAlt } from '@jbrowse/core/util/svAlt'
// type signature
(alt: string, { ref, info, alleleIndex, }?: { ref?: string | undefined; info?: Record<string, unknown> | undefined; alleleIndex?: number | undefined; }) => stringsvClassOfToken
The class a symbolic allele id, SVTYPE or EVENTTYPE names. A subtype folds
into its first level (DEL:ME:ALU is DEL, DUP:TANDEM DUP), except the
tandem repeats VCF 4.4 spells CNV:TR and ExpansionHunter STRn, and the
inverted duplication INV:DUP. 1000 Genomes' CNn counts one haplotype's
copies, so none is a deletion and two or more a duplication. '' for an
empty or missing token.
import { svClassOfToken } from '@jbrowse/core/util/svAlt'
// type signature
(raw: string) => stringTextColumn
Text held as bytes, one per character: row i's is length[i] bytes of
bytes from offset[i], so many rows share one buffer, as an adapter's
arena holds them.
thresholdCuts
A threshold scale's cut points as thresholdIndex walks them: the numbers the domain names, ascending. Cuts written high to low, as p-value thresholds often are, left the middle interval unreachable, the walk stopping at the first cut a value is under.
import { thresholdCuts } from '@jbrowse/core/util/thresholdScale'
// type signature
(domain: readonly (string | number)[]) => number[]thresholdField
A threshold scale read the way every categorical channel reads its field: a
value files under the label of the bin it falls in, a feature with no value
under '', and text that is no number under NOT_A_NUMBER_LABEL.
The bins are the whole domain, so a key lists each one. labels names the
bins in a key, one each from the lowest, where a config spells them for a
reader; a bin's key stays its interval.
import { thresholdField } from '@jbrowse/core/util/thresholdScale'
// type signature
(field: string, { domain, range, labels: names, }?: { domain?: readonly string[] | undefined; range?: readonly string[] | undefined; labels?: readonly string[] | undefined; }) => CategoricalFieldthresholdIndex
The bin a value falls in: how many of the ascending cut points it is at or
past, so a palette with one more entry than the domain paints it as
palette[thresholdIndex(value, domain)]. A value that is not a number is
in no bin and answers -1; an infinite one takes the end bin on its side, as
d3's threshold scale places it, so a -log10 of a zero p-value lands in
the top bin.
import { thresholdIndex } from '@jbrowse/core/util/thresholdScale'
// type signature
(value: unknown, domain: readonly number[]) => numberthresholdKeyEntries
A threshold key's rows: every interval, painted or not, since the bins are
the whole domain, then the not-a-number and no-value rows where a feature
took one, in the order thresholdField sorts them.
import { thresholdKeyEntries } from '@jbrowse/core/util/thresholdScale'
// type signature
(cuts: readonly number[], range: readonly string[] | undefined, met: { missing?: boolean | undefined; notNumber?: boolean | undefined; }, names?: readonly string[]) => { value: string; label: string; color: string; missing?: true | undefined; }[]thresholdLabels
What a threshold scale's bins are called in a key, one label per palette
entry: < a below the first cut, a – b between two, ≥ b past the last.
import { thresholdLabels } from '@jbrowse/core/util/thresholdScale'
// type signature
(domain: readonly number[]) => string[]thresholdPalette
The color of each interval, in order: the declared palette, and the default categorical palette where it runs out.
import { thresholdPalette } from '@jbrowse/core/util/thresholdScale'
// type signature
(bins: number, palette?: readonly string[]) => string[]ThresholdRef
A numeric field cut into intervals: domain is the ascending cut points
and range holds one color more, so a value paints the entry for the
number of cut points it is at or past. A value that is not a number
belongs to no interval.
TransformStep
One step over the features before a layer is encoded, named by type the
way GenomeSpy spells a transform; every step runs in order and the next
reads what the last answered.
valueAt
A column's value at a row, whatever its kind: for a loop that reads few rows.
import { valueAt } from '@jbrowse/core/util/featureTable'
// type signature
(column: Column, i: number) => unknownVIRIDIS_STOPS
The 256 viridis stops, fully opaque. Feed them to buildColorRampLut for the texture/fillStyle form, or to sampleColorRamp for legend stops.
import { VIRIDIS_STOPS } from '@jbrowse/core/util/colorRamp'
// type signature
readonly ColorRampStop[]withColumns
The table's rows with written beside them, in the order rows names
where it names one.
import { withColumns } from '@jbrowse/core/util/featureTable'
// type signature
(table: FeatureTable, written: ReadonlyMap<string, Column>, rows?: Uint32Array<ArrayBufferLike> | undefined) => FeatureTablewithHitIndex
HitIndexed over what the worker shipped.
import { withHitIndex } from '@jbrowse/core/util/markEncoding'
// type signature
<T extends EncodedChannels>(channels: T) => HitIndexed<T>ZoomRange
The bp/px interval, [minBpPerPx, maxBpPerPx), over which an adapter with
zoom levels answers a fetch from the same level it answered opts.bpPerPx
from. A display holding the answer refetches when the view leaves it.
Related links
- Developer guide: Dependencies and re-exports