archaeopteryx 3.21.0 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -33,6 +33,7 @@ config key live and shows the exact config JSON to copy into your own
33
33
  * [Caliciviridae (186 strains)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=caliciviridae_500)
34
34
  * [Adenoviridae (321 strains)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=adenoviridae)
35
35
  * [Apaf-1 gene family (domain architectures)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=apaf)
36
+ * [Genome regions (gene arrows, anchored)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=genome_regions)
36
37
  * [Clustergram (heat map + column clustering)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=clustergram)
37
38
  * [Nucleotide alignment (600 columns)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=alignment_nt)
38
39
  * [Genome alignment (150 × 30,000 columns)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=genome_alignment)
@@ -589,6 +590,81 @@ warning, never fatal. The tracks ride into the SVG, PDF and PNG exports.
589
590
  This is the desktop's domain display, drawn to the same numbers
590
591
  (`test/domain_test.js` holds them).
591
592
 
593
+ ## Genome regions
594
+
595
+ A tree whose tips are genomes can carry (part of) each genome: its genes as
596
+ `<sequence>` elements, one per gene, each with a `<location>` on a contig and
597
+ its family in an `<annotation ref="…">`, plus one `<sequence type="dna">`
598
+ record per contig. The viewer draws them as a **gene track** beside the
599
+ tips: a thin backbone per genome with an **arrow per gene**, pointing by
600
+ strand, coloured by family, on one scale shared by the whole tree so
601
+ distances compare across genomes. The rows are **anchored**: the anchor
602
+ family's gene sits at the same place in every row, pointing right, and the
603
+ neighbours follow — a genome carrying it on the other strand is mirrored —
604
+ so gene order, inversions, insertions and deletions read down the tree, as
605
+ in BV-BRC's Compare Region Viewer. A family met in one genome only is grey,
606
+ a gene with no family lighter grey, so conserved order stands out. A bar at
607
+ the end of a backbone marks a contig end; the track's own scale bar under
608
+ the rows reads in kb. The track appears from the start whenever a tree
609
+ carries regions; the **Genes** checkbox under Display Data toggles it, and
610
+ the **Genome regions** section holds the controls:
611
+
612
+ * **Track width** `−` / `+` — the widest row starts at a quarter of the
613
+ window and scales by 0.8 / 1.2 per press (hold to repeat).
614
+ * **Anchor** — `Auto` (the family single-copy in the most genomes, at least
615
+ half of them; the choice is named), any family that can anchor two
616
+ genomes or more, or `None`, which left-aligns the rows.
617
+ * **Family** — which annotation namespace colours the genes and anchors the
618
+ rows, offered when the genes carry more than one (a BV-BRC export carries
619
+ both PGfams and PLfams).
620
+ * **Labels** — `On genes` (the symbol, when it fits), `Legend` (a card of
621
+ the families with their commonest product and genome counts, draggable,
622
+ double-click to send it home), or `None`.
623
+
624
+ **Hovering an arrow** reads the gene out: symbol, product, family, location,
625
+ length, the genome it belongs to and its accession; **clicking** opens its
626
+ BV-BRC feature page for a BV-BRC accession (`fig|…`) or NCBI's protein page
627
+ for a GenBank / RefSeq one. In the circular and unrooted layouts the arrows
628
+ ride each named tip's spoke, as the domain tracks do, and both tracks can
629
+ show at once, the genes past the domains. Whole genomes are for viruses; a
630
+ bacterial genome is shown as a window of a few dozen genes around a gene of
631
+ interest, chosen by whoever writes the file. The tree is labelled by node
632
+ name: a genome's sequences describe the region beside the tip, not the tip.
633
+
634
+ The file needs nothing phyloXML has not got — `<location>` is the schema's
635
+ "location of a sequence on a genome/chromosome", an annotation's `ref` its
636
+ reference to an external database:
637
+
638
+ ```xml
639
+ <clade>
640
+ <name>Brucella melitensis bv. 1 str. 16M</name>
641
+ <sequence type="dna"> <!-- the contig record, FIRST -->
642
+ <accession source="RefSeq">NC_003317.1</accession>
643
+ <name>chromosome I</name>
644
+ <location>NC_003317.1:1-2117144</location>
645
+ </sequence>
646
+ <sequence type="protein"> <!-- one per gene, any order -->
647
+ <accession source="BV-BRC">fig|224914.11.peg.1021</accession>
648
+ <symbol>dnaK</symbol>
649
+ <name>Chaperone protein DnaK</name>
650
+ <location>NC_003317.1:1055720-1057636(-)</location>
651
+ <annotation ref="pgfam:PGF_00019355"></annotation>
652
+ </sequence>
653
+ </clade>
654
+ ```
655
+
656
+ A location is `contig:start-end(+)`, 1-based and inclusive, split on its
657
+ last colon; a located sequence **with** a strand is a gene, one **without**
658
+ is the contig's record, whose span says where the contig ends. The record
659
+ comes first because a tip's first sequence is "the" sequence to every other
660
+ reader. A tip's genes on a second contig are not drawn (one contig per
661
+ genome: the one with the most genes) and a location not in the grammar is
662
+ skipped; both are counted in a console warning. The demo is synthetic
663
+ ([Genome regions](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=genome_regions),
664
+ twelve genomes with one row per rule: an inversion, a deletion, two
665
+ insertions, a mirrored genome, a contig end, two contigs, overlapping genes,
666
+ a doubled anchor); `test/gene_test.js` pins its numbers.
667
+
592
668
  ## Sequence alignments
593
669
 
594
670
  A tree whose tips carry `<mol_seq is_aligned="true">` shows the alignment as
@@ -1100,7 +1176,7 @@ when the sequences are of unequal length, why it cannot.
1100
1176
  size* (the default) is the whole tree, re-laid-out large enough that no tip
1101
1177
  name has to be hidden — in rows in the rectangular layout, around the ring in
1102
1178
  the circular one — and cropped to the drawing, with the legends (colour,
1103
- shape, domains, the heat-map ring's scale) stacked beside the tree rather
1179
+ shape, domains, gene families, the heat-map ring's scale) stacked beside the tree rather
1104
1180
  than over it. The window itself is left exactly as it was. An unrooted fan
1105
1181
  is enlarged only while that still frees names: tips on very short branches
1106
1182
  can collide at any size. An alignment track is drawn as its window, the
@@ -1389,6 +1465,10 @@ copy-pastable JSON.
1389
1465
  | `domainLabels` | `'domains'` | Where domain names go: `'domains'` (on the boxes), `'legend'` (a card), or `'none'`. |
1390
1466
  | `domainGlow` | `false` | Open with the glow around each domain box on. |
1391
1467
  | `domainEvalueExponent` | `-3` | The E-value threshold's exponent at launch, an integer from `-20` to `3`: domains with an E-value at or under `10^exponent` are drawn. |
1468
+ | `showGenes` | tree-derived | Open with the gene track shown. Default: on when any tip carries a genome region (two or more located genes), off otherwise — an explicit `true`/`false` overrides that. |
1469
+ | `geneAnchor` | `'auto'` | The family the gene track's rows line up on: `'auto'` (the family single-copy in the most genomes), `'none'` (left-aligned rows), or a family ref such as `'pgfam:PGF_00019355'`. |
1470
+ | `geneFamily` | `'auto'` | The annotation namespace that colours the genes and anchors the rows: `'auto'` (the one most genes carry) or a prefix such as `'pgfam'`. |
1471
+ | `geneLabels` | `'genes'` | Where gene symbols go: `'genes'` (on the arrows), `'legend'` (a card of the families), or `'none'`. |
1392
1472
  | `showScaleAxis` | tree-derived | Open with the scale axis shown: the time axis on a time tree whose branches show time, a distance axis on any other phylogram. Default: on when the tree carries `<date>` elements and opens shown in time, off otherwise (a dated tree that opens in divergence is a divergence tree on screen) — an explicit `true`/`false` overrides that. |
1393
1473
  | `showScaleGrid` | `false` | Open with the Scale Grid lines on (only meaningful — and only offered as a checkbox — while the scale axis itself is shown). |
1394
1474
  | `showSupportDots` | `false` | Open with the Support Dots marks on (the checkbox appears whenever the tree has confidences). |
@@ -1930,7 +2010,10 @@ Two rules, in order:
1930
2010
  of the current pick's (substantially more economical) takes it.
1931
2011
 
1932
2012
  A field with no printable values is never checked (apaf's sequences carry
1933
- only domain architectures, so its Sequence box starts unchecked). The choice
2013
+ only domain architectures, so its Sequence box starts unchecked). On a tree
2014
+ of genomes the sequence field has none either: a tip's located sequences —
2015
+ its contig record and its genes — describe the region drawn beside it, not
2016
+ the tip, so the node name stands. The choice
1934
2017
  is logged to the console at launch, and the user can recheck anything — the
1935
2018
  rules only set the initial state.
1936
2019
 
@@ -2063,6 +2146,68 @@ numbers — apaf.xml: 31 tips, `Lmax` 2080, 202 domains; 9 names / 166 boxes
2063
2146
  at 1e−3; the palette; 22_MOUSE's box offsets at `W = 300` — are the
2064
2147
  desktop's, in `test/domain_test.js`.
2065
2148
 
2149
+ ### The gene track
2150
+
2151
+ Data model (forester): a tip's `sequences` with a `location` the grammar
2152
+ reads (`forester.parseSequenceLocation`: `contig:start-end(+)`, split on the
2153
+ last colon, 1-based, `end ≥ start`) are genes when the strand is given and
2154
+ contig records when not; `forester.geneRegionOf(node)` is the tip's genes
2155
+ on ONE contig (the most genes, ties to the first listed) in position order,
2156
+ that contig's record, the span and the count left out; null without a gene.
2157
+ A gene's family in a namespace is its first annotation ref with that prefix
2158
+ (`geneFamilyOf`); `geneFamilyNamespaces` ranks the prefixes by use.
2159
+ `collectBasicTreeProperties` sets `geneRegions` when some tip carries two
2160
+ genes or more (a gene-family tree locating one gene per tip is not a tree
2161
+ of genomes) and `maxGeneRegionLength`; `treeStatistics` counts
2162
+ `tipsWithGenes`. Anchor: `geneAnchorCandidates` counts per family the
2163
+ regions carrying it exactly once (`single`) and at all; `geneDefaultAnchor`
2164
+ is the top one when `single` is at least half the regions, ties by code
2165
+ unit. Rows: `geneTrackRows(regions, anchor, ns)` maps every row onto one
2166
+ coordinate in bp — an anchored row's anchor midpoint at 0, mirrored
2167
+ (`x → −x`, directions flipped) when the anchor is on `−`; a row with no
2168
+ anchor gene, or two, left-aligned at the anchored rows' leftmost edge (0
2169
+ without any). The backbone is the span padded by 2% (`GENE_REGION_PAD`),
2170
+ clamped to the record's span with a cap where it was clamped (caps swap
2171
+ with the flip). Lanes: greedy by start, the first of two that is free, else
2172
+ the one that frees first. Scale: `f = W / (extent.max − extent.min) × 0.9`
2173
+ px per bp, `W` by the domain track's rules (a quarter of the viewport,
2174
+ −/+ by 0.8/1.2, 20…2000; radial `min(W, 0.2 × radius)`), kept apart from
2175
+ the domain track's width. Placement as the domain tracks and past them when
2176
+ both show: rectangular `start = _w + nodeLabelGap + labelSpace +
2177
+ _domainReserve + 20`, reserve `20 + W + 10` in `_geneReserve` (counted
2178
+ wherever `_w` is); circular `r0 = maxRad + labelSpace + domainRadialExtent
2179
+ + 4`; unrooted `start = labelSpace + domainRadialExtent + 4`; the radial fit
2180
+ adds `4 + W + 10`. Arrow: `geneArrowPath(x, y, w, h, dir)`, head
2181
+ `min(h/2, w)`, a triangle when shorter than its head; two lanes share the
2182
+ height (`max(3, h/2)` each); each arrow is its own path carrying
2183
+ `__aptxGene` for the readout, with a 1 px `darken(base, 0.3)` border; the
2184
+ backbone (1 px) and the caps (1.5 px bars) are one path per track, one per
2185
+ row in the radial layouts. Symbol (or gene name) on the body in `min(font,
2186
+ h − 2)` px when over 4 px and at most `w − head − 4` wide, rectangular
2187
+ only. Colours: the families SHARED over the tree (two regions or more),
2188
+ sorted by code unit, take the domain palette (`domainQualitativeColor`) in
2189
+ order; a singleton `#9e9e9e`, no family `#cfcfcf`; dealt at load and on a
2190
+ namespace change. The kb bar: `geneScaleBar(f, 80)`, a round number of bp
2191
+ labelled in kb from 1000 up, 12 px under the lowest row. Legend
2192
+ (`'legend'`): title `Gene families (<ns>)`, rows `product (regions)` in
2193
+ screen order over the view (`geneFamilySummary` with the tree's shared set,
2194
+ so a family shown once in a subtree keeps its colour), then `unique to one
2195
+ genome (n)` and `no family (n)`; home bottom-right, drag keeps its place as
2196
+ a fraction of the view, double-click sends it home. Links: `geneReference`
2197
+ — BV-BRC's feature page for `fig|…` or a BV-BRC / PATRIC source, NCBI's
2198
+ protein page for GenBank / RefSeq / UniProt. State: `showGenes` (auto-on
2199
+ with `geneRegions`), `geneAnchor` (`'auto'` | `'none'` | a ref),
2200
+ `geneFamily` (`'auto'` | a namespace), `geneLabels`; the view carries
2201
+ `genes`, `geneLabels`, and `geneAnchor` / `geneFamily` as the EFFECTIVE
2202
+ values. Labels: on a tree with `geneRegions`, a tip whose first sequence is
2203
+ located contributes no sequence text to the label suggestion
2204
+ (`suggestLabelFields`), so the node name stands. Gates as the domain
2205
+ tracks (external labels on, radial labels in a radial layout, a name the
2206
+ crowding rule left). Fixture `test/data/genome_regions.xml`, generated by
2207
+ `test/make_genome_regions_fixture.js` (the demo copy is byte-identical and
2208
+ a test says so); the numbers in `test/gene_test.js`, the SVG in
2209
+ `test/browser/genes.html`.
2210
+
2066
2211
  ### The alignment track
2067
2212
 
2068
2213
  Data model: per-tip `sequences[0].mol_seq = {is_aligned, value}` (the gapped
@@ -2212,7 +2357,7 @@ the tree ≥ 220 px))`. It is budgeted **before** the alignment, and the
2212
2357
  alignment's own band then yields to it: the matrix wants a fixed, finite width
2213
2358
  while the alignment's band is a window that scrolls and so loses nothing by
2214
2359
  giving way. (Budgeted the other way round, an 18-column matrix got a 60 px
2215
- sliver.) It sits between the domain tracks and the alignment, its right edge at
2360
+ sliver.) It sits between the domain and gene tracks and the alignment, its right edge at
2216
2361
  `displayWidth − rootOffset − msaReserve`. Rows tile the cluster height by the
2217
2362
  same once-derived midpoints the alignment uses. Column width is
2218
2363
  `clamp(band / columns, 3, 14)`; past `band / 3` columns the matrix shows a
@@ -60,12 +60,25 @@ export interface ArchaeopteryxConfig {
60
60
  collapseControlPanel?: boolean;
61
61
  displayHeight?: number;
62
62
  displayWidth?: number;
63
+ /** The domain tracks' E-value threshold at launch, as an exponent: -20 to 3. */
64
+ domainEvalueExponent?: number;
65
+ domainGlow?: boolean;
66
+ domainLabels?: 'none' | 'domains' | 'legend';
63
67
  enableAccessToDatabases?: boolean;
64
68
  enableDownloads?: boolean;
65
69
  enableDynamicSizing?: boolean;
66
70
  enableManualNodeSelection?: boolean;
67
71
  enableSubtreeDeletion?: boolean;
68
72
  enableVisualizations?: boolean;
73
+ /** The family the gene track's rows line up on: 'auto' (the family
74
+ * single-copy in the most genomes), 'none' (left-aligned rows), or a
75
+ * family ref such as 'pgfam:PGF_00019355'. */
76
+ geneAnchor?: string;
77
+ /** The annotation namespace that colours the genes and anchors the rows:
78
+ * 'auto' (the one most genes carry) or a prefix such as 'pgfam'. */
79
+ geneFamily?: string;
80
+ /** Where gene symbols go: on the arrows, in a legend of the families, or nowhere. */
81
+ geneLabels?: 'none' | 'genes' | 'legend';
69
82
  initialVisualization?: string | null;
70
83
  ladderizeTree?: boolean;
71
84
  layout?: Layout;
@@ -98,6 +111,11 @@ export interface ArchaeopteryxConfig {
98
111
  * while heatmapColumnOrder is 'manual'. A ref the tree has not got is
99
112
  * ignored; a column this does not name follows the ones it does. */
100
113
  heatmapManualOrder?: string[] | null;
114
+ /** The domain tracks. Default: on when any tip carries a domain architecture. */
115
+ showDomainArchitectures?: boolean;
116
+ /** The gene track (genome regions). Default: on when any tip carries two
117
+ * or more located genes. */
118
+ showGenes?: boolean;
101
119
  showHeatmap?: boolean;
102
120
  showMsa?: boolean;
103
121
  /** Summarize the alignment as a sequence logo instead of a conservation
@@ -179,6 +197,12 @@ export interface ViewState {
179
197
  domainLabels?: 'none' | 'domains' | 'legend';
180
198
  domainGlow?: boolean;
181
199
  domainEvalue?: number;
200
+ genes?: boolean;
201
+ /** The anchor family in effect: a ref, or 'none'. */
202
+ geneAnchor?: string;
203
+ /** The family namespace in effect. */
204
+ geneFamily?: string;
205
+ geneLabels?: 'none' | 'genes' | 'legend';
182
206
  scaleAxis?: boolean;
183
207
  scaleGrid?: boolean;
184
208
  /** @deprecated the name of scaleAxis in older links; still read. */