archaeopteryx 3.22.0 → 3.24.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 +135 -7
- package/archaeopteryx.js +930 -16
- package/forester.js +331 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -24,8 +24,8 @@ nothing is uploaded. Its **Expert options** panel exercises every launch
|
|
|
24
24
|
config key live and shows the exact config JSON to copy into your own
|
|
25
25
|
`launch()` call.
|
|
26
26
|
|
|
27
|
-
* [Auspice / Nextstrain JSON](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=auspice)
|
|
28
|
-
* [Swine H1 HA1 + alignment (Nexus)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=swh1)
|
|
27
|
+
* [Auspice / Nextstrain JSON (Time | Div, Clock plot)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=auspice)
|
|
28
|
+
* [Swine H1 HA1 + alignment (Nexus; Clock plot from the years in the names)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=swh1)
|
|
29
29
|
* [BEAST annotations (Nexus)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=beast)
|
|
30
30
|
* [Flavivirus mature peptides (10 trees)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=flavivirus)
|
|
31
31
|
* [SARS-CoV-2 time tree (calendar)](https://cmzmasek.github.io/archaeopteryx-js/demo.html?tree=sarscov2)
|
|
@@ -886,6 +886,76 @@ branches show divergence, and the Scale Axis measures distance instead. Each lay
|
|
|
886
886
|
Div is on screen says so and opens again showing divergence. All of this is
|
|
887
887
|
shared with the desktop.
|
|
888
888
|
|
|
889
|
+
### Clock plot
|
|
890
|
+
|
|
891
|
+
Beside the switch, a **Clock plot** button opens a panel that plots each
|
|
892
|
+
tip's **date** against its **divergence** from the root, with a straight
|
|
893
|
+
line through the tips — the root-to-tip plot of TempEst and TreeTime, and
|
|
894
|
+
Auspice's clock view. Under the plot:
|
|
895
|
+
|
|
896
|
+
- **Rate** — the slope of the line: substitutions per site per year (per
|
|
897
|
+
unit of the tree's dates where they are not calendar years). Negative
|
|
898
|
+
where the tips' divergence falls with time.
|
|
899
|
+
- **Root date, by the line** — the date at which the line comes down to the
|
|
900
|
+
root's divergence — over **Root date, in the tree**, the one the tree
|
|
901
|
+
states. How far apart they are is the point of showing both.
|
|
902
|
+
- **R²** and the number of **Tips** in the fit.
|
|
903
|
+
|
|
904
|
+
The line is ordinary least squares over the **tips only**: a tip's date is
|
|
905
|
+
an observation, an ancestor's was inferred (usually with a clock), and
|
|
906
|
+
counting it would have the estimate confirm itself. It is not forced through
|
|
907
|
+
the root. Tips share ancestry, so R² describes the fit and is no
|
|
908
|
+
significance test. On a BEAST clock-model tree the divergence *is* each
|
|
909
|
+
branch's time × its clock rate, so there the plot shows the model's rates,
|
|
910
|
+
not a measurement of its own (a strict clock is a perfect line), and the
|
|
911
|
+
panel says so.
|
|
912
|
+
|
|
913
|
+
The panel is **linked to the tree** and stays open while you work in it
|
|
914
|
+
(drag it by its title):
|
|
915
|
+
|
|
916
|
+
- a point wears its node's colour in the tree — the Color visualization,
|
|
917
|
+
search hits, the selection;
|
|
918
|
+
- pointing at a point lights its node in the tree (the collapsed clade
|
|
919
|
+
holding it, if it is hidden in one), and pointing at a node in the tree
|
|
920
|
+
rings its point;
|
|
921
|
+
- **clicking** a point selects or deselects its node, and **dragging** a box
|
|
922
|
+
selects the tips in it — the tree's own selection, so an outlier found on
|
|
923
|
+
the plot is found in the tree. **Deselect all** clears it;
|
|
924
|
+
- tips with one date and one divergence — identical sequences sampled on one
|
|
925
|
+
day — are drawn on one spot, and that dot answers for all of them: the
|
|
926
|
+
readout says how many tips are there and names the first five, all of them
|
|
927
|
+
light up in the tree, and a click selects them all (or deselects them all,
|
|
928
|
+
where all were selected);
|
|
929
|
+
- in a subtree view the plot is the clade's, with the clade's own line.
|
|
930
|
+
|
|
931
|
+
**Regression line** shows and hides the line. **Internal nodes** adds the
|
|
932
|
+
ancestors' points, each at its own date and divergence; the panel opens
|
|
933
|
+
without them, since the line is the tips' and a deep root would crowd them
|
|
934
|
+
into a corner.
|
|
935
|
+
|
|
936
|
+
The button is offered on two kinds of tree, whenever the line can be drawn
|
|
937
|
+
(three tips or more, not all on one date; a tree sampled at one moment has
|
|
938
|
+
no slope to estimate):
|
|
939
|
+
|
|
940
|
+
- a tree that has **Time | Div**: every node is dated and has a divergence,
|
|
941
|
+
so the ancestors can be shown too;
|
|
942
|
+
- a tree whose **branch lengths are its divergence and whose tips alone are
|
|
943
|
+
dated** — the tree a root-to-tip plot is run on *before* dating, TempEst's
|
|
944
|
+
case. A tip's divergence is the sum of the branch lengths from the root;
|
|
945
|
+
the plot has tips only (**Internal nodes** is not offered, since no
|
|
946
|
+
ancestor is dated); **Root date, in the tree** says `none`, since the tree
|
|
947
|
+
states no root date, and **Rate** is in the tree's own branch length unit,
|
|
948
|
+
where it states one. A tip's date is what the file states for it (a
|
|
949
|
+
phyloXML `<date>`, a `num_date` annotation) or, failing that, the date in
|
|
950
|
+
its **name**, as TempEst reads it: the rightmost date the label carries
|
|
951
|
+
(`A/swine/Iowa/A02524571/2020|1A.3.3.3` is 2020; a year alone is taken as
|
|
952
|
+
mid-year, 2020.5; a day/month-ambiguous `03/04/2020` is read day first),
|
|
953
|
+
and the panel's note says how many names it read and how many were
|
|
954
|
+
ambiguous. An ancestor is never dated by its name. Every tip must be
|
|
955
|
+
dated, by the file or by its name, and every branch must have a length: a
|
|
956
|
+
tree with a gap is not offered the plot, rather than plotted with tips
|
|
957
|
+
missing.
|
|
958
|
+
|
|
889
959
|
# forester.js
|
|
890
960
|
forester.js is a general suite for dealing with phylogenetic trees.
|
|
891
961
|
|
|
@@ -1096,7 +1166,10 @@ pick them up. Both metrics are retained, and
|
|
|
1096
1166
|
`forester.applyTimeBranchLengths(phy)` /
|
|
1097
1167
|
`forester.applyDivergenceBranchLengths(phy)` /
|
|
1098
1168
|
`forester.hasTimeAndDivergence(phy)` are the plumbing behind the
|
|
1099
|
-
**Time | Div** switch
|
|
1169
|
+
**Time | Div** switch (and `forester.clockPlotKind(phy)` /
|
|
1170
|
+
`forester.clockPlotData(phy, view)` / `forester.clockRegression(xs, ys)`
|
|
1171
|
+
behind the **Clock plot**: which trees have one, its points and its
|
|
1172
|
+
least-squares line). The two `apply` functions answer `true` when they
|
|
1100
1173
|
laid the tree out, and `false` — leaving every branch length as it was —
|
|
1101
1174
|
when their layout cannot state every branch.
|
|
1102
1175
|
|
|
@@ -2540,6 +2613,56 @@ figure never carries an artefact of where the view happened to be scrolled.
|
|
|
2540
2613
|
(The desktop pins its axes to the viewport bottom always; sticky is a
|
|
2541
2614
|
deliberate difference.)
|
|
2542
2615
|
|
|
2616
|
+
### The clock plot
|
|
2617
|
+
|
|
2618
|
+
**Model** (`forester.js`, pure). `forester.clockPlotKind(phy)` answers
|
|
2619
|
+
`'divergence'`, `'root-to-tip'` or `null`: `'divergence'` where the tree has
|
|
2620
|
+
Time and Div (`forester.hasTimeAndDivergence`); `'root-to-tip'` where every
|
|
2621
|
+
tip is dated (by the file, or by the date in its name:
|
|
2622
|
+
`forester.parseTipLabelDate`), no ancestor is, every branch states a length
|
|
2623
|
+
and no branch states a clock rate (a clock-model tree's lengths are time) — and in
|
|
2624
|
+
both cases three tips or more, not all on one date. It is asked of the
|
|
2625
|
+
**tree**, never of the view. `forester.clockPlotData(phy, view)` returns
|
|
2626
|
+
`{kind, forward, unit, divUnit, fromRates, points, root, fit}`: a point
|
|
2627
|
+
`{node, date, div, tip}` per node of the view (a tip also carries its
|
|
2628
|
+
`residual`; on a root-to-tip tree the tips only, their `div` the sum of the
|
|
2629
|
+
branch lengths from the tree's root), `forward` false where the dates are
|
|
2630
|
+
ages (on a root-to-tip tree: where their unit is geologic), `divUnit` the
|
|
2631
|
+
divergence's unit (`subs/site` on a Time | Div tree, a root-to-tip tree's
|
|
2632
|
+
stated branch length unit, or `null`), `fromRates` true where the divergence
|
|
2633
|
+
is time × clock rate, `calendar` true where the dates are calendar years
|
|
2634
|
+
(their unit says so, or they were read off the tips' names), `fromNames` and
|
|
2635
|
+
`ambiguousNames` how many tips a root-to-tip tree dates by their names and
|
|
2636
|
+
how many of those are day/month-ambiguous (read day first), `root.date`
|
|
2637
|
+
`null` on a root-to-tip tree, and `fit` =
|
|
2638
|
+
`forester.clockRegression(dates, divergences)` over the tips — ordinary least
|
|
2639
|
+
squares about the means, `{n, slope, intercept, r2}` — plus `rate` (the slope
|
|
2640
|
+
in the direction time runs) and `rootDate` (where the line reaches the view
|
|
2641
|
+
root's divergence; `null` unless the rate is positive). `fit` is `null` for a
|
|
2642
|
+
view with fewer than three tips or one date. `forester.calendarTickMonths`
|
|
2643
|
+
gives month ticks for a span too short for whole years.
|
|
2644
|
+
|
|
2645
|
+
**Panel** (`archaeopteryx.js`, the "Clock plot" section). A modeless
|
|
2646
|
+
`makeDialogShell` dialog, dragged by its title, placed in the tree area's top
|
|
2647
|
+
right corner and below anything the host page keeps there. The drawing is one
|
|
2648
|
+
SVG in the panel's own `--p-*` inks. `renderClockPlot` runs at the end of
|
|
2649
|
+
every `update()`: it works the points out and lays them down again only when
|
|
2650
|
+
the top of the view or its node count changed, or a checkbox did; otherwise
|
|
2651
|
+
it only goes over the points' colours. A point's colour is its node's in the
|
|
2652
|
+
tree (found, selected, the Color visualization, the file's styles).
|
|
2653
|
+
|
|
2654
|
+
**The link.** Pointer events on the SVG: the nearest point within 7 px, and
|
|
2655
|
+
with it every point of its kind within 1 px of it — one dot for tips that
|
|
2656
|
+
share a date and a divergence. The dot's nodes are lit through
|
|
2657
|
+
`showHoverGlow(node, also)` (each as the tree shows it: a tip hidden in a
|
|
2658
|
+
collapsed clade lights the clade); a click toggles them in `_selectedNodes`,
|
|
2659
|
+
a dragged box adds the tips inside it; `mouseover` on a tree node rings its
|
|
2660
|
+
point. Closing is synchronous: nothing waits for the dialog's `close` event.
|
|
2661
|
+
|
|
2662
|
+
There is no config key and no view key for the panel yet, and it is not part
|
|
2663
|
+
of any download. The numbers are pinned in `test/clock_test.js` (computed by
|
|
2664
|
+
hand), the panel in `test/browser/clock_plot.html`.
|
|
2665
|
+
|
|
2543
2666
|
## Node selection
|
|
2544
2667
|
|
|
2545
2668
|
With `enableManualNodeSelection` on, the node menu gains **Select/Deselect Node**
|
|
@@ -2553,7 +2676,12 @@ var selected = archaeopteryx.getSelectedNodes(); // array of node objects
|
|
|
2553
2676
|
Selected nodes are drawn in the selection colour, which is fixed so that it
|
|
2554
2677
|
stays distinguishable from the two search colours.
|
|
2555
2678
|
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2679
|
+
The **Clock plot** selects too, whatever this setting says: a click on a
|
|
2680
|
+
point, or a box dragged over tips, changes the same selection.
|
|
2681
|
+
|
|
2682
|
+
Every change of the selection — from the node menu or from the clock plot —
|
|
2683
|
+
dispatches a `selected_nodes_changed_event` on `document`, so the embedding
|
|
2684
|
+
application can read the selection then, or whenever it wants from its own
|
|
2685
|
+
button. Nothing announces "the user is done selecting". (Versions before 3.0
|
|
2686
|
+
carried a dormant, never-rendered "Submit Selected" button in the source; it
|
|
2687
|
+
was removed.)
|