phylo_tree
Evolutionary distances from aligned DNA (p-distance, Jukes-Cantor 1969, Kimura two-parameter 1980, with large-sample standard errors) or a distance matrix given directly, and trees from them by neighbour joining (Saitou-Nei, Studier-Keppler form) and UPGMA: Newick text, branch lengths, tree-against-input residuals, cophenetic correlation, and the three-point (ultrametric) and four-point (additive) tests.
- Field
- Genomics
- Version
- 0.1.0
- Runs as
- Compiled (Rust)
- Typical run
- 0.05 s
Compiled from source: run sh packs/install.sh once before admitting it.
Known answers it must pass
r0001Jukes-Cantor 1969 closed form: 3 of 10 sites differ, p = 0.3, d = -(3/4) ln(0.6) = 0.383119; SE = sqrt(p(1-p)/n)/(1-4p/3) = 0.241523 (rel 1e-9, exact formula)passed
max_distance0.383119 ± 3.8e-100.383119lockedunder 0.01 % of the tolerance usedpairs.s1|s2.p_distance{"value": 0.3, "rel_tol": 1e-12}pairs.s1|s2.standard_error{"value": 0.24152294576982397, "rel_tol": 1e-09}nj_tree_length0.383119 ± 3.8e-100.383119lockedunder 0.01 % of the tolerance usedr0002Kimura 1980 two-parameter closed form: P = Q = 0.1 over 20 sites, d = -(1/2) ln 0.7 - (1/4) ln 0.8 = 0.234123; Kimura variance gives SE = 0.123863; ts/tv = 1 (rel 1e-9, exact formula)passed
max_distance0.234123 ± 2.3e-100.234123lockedunder 0.01 % of the tolerance usedpairs.s1|s2.standard_error{"value": 0.12386281190684065, "rel_tol": 1e-09}pairs.s1|s2.transitions= 2misseddifferspairs.s1|s2.transversions= 2misseddiffersts_tv_ratio1 ± 1e-121lockedunder 0.01 % of the tolerance usedr0003Neighbour joining, five-taxon textbook example (Saitou-Nei method; Wikipedia 'Neighbor joining'): ab 5 ... de 3 gives branches a 2, b 3, c 4, d 2, e 1, internal 3 and 2; additive, so residual 0 (abs 1e-9, exact arithmetic)passed
leaves.a.nj_branch{"value": 2.0, "abs_tol": 1e-09}leaves.b.nj_branch{"value": 3.0, "abs_tol": 1e-09}leaves.c.nj_branch{"value": 4.0, "abs_tol": 1e-09}leaves.d.nj_branch{"value": 2.0, "abs_tol": 1e-09}leaves.e.nj_branch{"value": 1.0, "abs_tol": 1e-09}nj_internal_branches.0{"value": 3.0, "abs_tol": 1e-09}nj_internal_branches.1{"value": 2.0, "abs_tol": 1e-09}nj_tree_length17 ± 1e-0917lockedunder 0.01 % of the tolerance usednj_max_abs_residual0 ± 1e-090lockedunder 0.01 % of the tolerance usednj_cophenetic_r1 ± 1e-121lockedunder 0.01 % of the tolerance usedadditive= truetruelockedexact matchultrametric= falsefalselockedexact matchr0004UPGMA recovers an ultrametric matrix exactly: the tree ((a:1,b:1):2,(c:2,d:2):1) gives ab 2, cd 4, others 6; merges at heights 1, 2, 3, tree length 9, residual 0, cophenetic r = 1 (abs 1e-12, exact arithmetic)passed
upgma_merge_heights.0{"value": 1.0, "abs_tol": 1e-12}upgma_merge_heights.1{"value": 2.0, "abs_tol": 1e-12}upgma_root_height3 ± 1e-123lockedunder 0.01 % of the tolerance usedupgma_tree_length9 ± 1e-129lockedunder 0.01 % of the tolerance usedupgma_max_abs_residual0 ± 1e-120lockedunder 0.01 % of the tolerance usedupgma_cophenetic_r1 ± 1e-121lockedunder 0.01 % of the tolerance usedultrametric= truetruelockedexact matchupgma_newick= ((a:1,b:1):2,(c:2,d:2):1);((a:1,b:1):2,(c:2,d:2):1);lockedexact matchr0005Neighbour joining recovers an additive, non-ultrametric six-taxon matrix exactly: path lengths on the tree ((a:1,b:4):2,(c:3,d:1):5,(e:2,f:6):1) give leaf branches 1,4,3,1,2,6, internal 5,2,1, length 25, residual 0 (abs 1e-9, exact arithmetic)passed
leaves.a.nj_branch{"value": 1.0, "abs_tol": 1e-09}leaves.b.nj_branch{"value": 4.0, "abs_tol": 1e-09}leaves.c.nj_branch{"value": 3.0, "abs_tol": 1e-09}leaves.d.nj_branch{"value": 1.0, "abs_tol": 1e-09}leaves.e.nj_branch{"value": 2.0, "abs_tol": 1e-09}leaves.f.nj_branch{"value": 6.0, "abs_tol": 1e-09}nj_internal_branches.0{"value": 5.0, "abs_tol": 1e-09}nj_internal_branches.1{"value": 2.0, "abs_tol": 1e-09}nj_internal_branches.2{"value": 1.0, "abs_tol": 1e-09}nj_tree_length25 ± 1e-0925lockedunder 0.01 % of the tolerance usednj_max_abs_residual0 ± 1e-090lockedunder 0.01 % of the tolerance usedadditive= truetruelockedexact matchultrametric= falsefalselockedexact match
Each line is one reading the kernel checked. The bright band is the tolerance; the needle is the value the instrument actually returned when it was admitted. A needle near the centre line used little of its tolerance.
Inputs
| Name | Unit | Default | Meaning |
|---|---|---|---|
model | jc69 | Distance from sequences: "p" proportion of differing sites, "jc69" Jukes-Cantor d = -(3/4) ln(1 - 4p/3), "k2p" Kimura two-parameter d = -(1/2) ln(1 - 2P - Q) - (1/4) ln(1 - 2Q). Ignored for a matrix. | |
gaps | pairwise | Missing sites ('-', '?', N, IUPAC ambiguity letters): "pairwise" skips a site only for the pairs where it is missing; "complete" skips a site missing in any sequence for all pairs. | |
sequences | {} | Aligned DNA as {"name": "ACGT..."}; all the same length. Note: names are taken in sorted order. Give this, or fasta / fasta_file, or a matrix. | |
fasta | Aligned DNA as FASTA text ('>name' lines, then the bases). | ||
fasta_file | An aligned FASTA file. | ||
names | [] | Taxon names, one per row of 'distances' (t1, t2, ... if left out). | |
distances | 1 | [] | A square symmetric distance matrix with a zero diagonal, 2 to 200 taxa (substitutions per site or any one unit; the tree's branch lengths come out in the same unit). |
Readings
| Name | Unit | Meaning |
|---|---|---|
taxa_count | 1 | |
site_count | 1 | Alignment length (sequences only). |
sites_compared_min | 1 | |
ts_tv_ratio | 1 | Transitions over transversions, summed over all pairs (null with no transversion). |
distance_matrix | 1 | |
min_distance | 1 | |
max_distance | 1 | |
mean_distance | 1 | |
ultrametric | Three-point condition holds (to 1e-9 of the largest distance). | |
three_point_max_violation | 1 | |
additive | Four-point condition holds (to 1e-9 of the largest distance). | |
four_point_max_violation | 1 | |
triangle_violations | 1 | |
nj_newick | Neighbour-joining tree, unrooted (the last three nodes meet at the top level). | |
nj_tree_length | 1 | |
nj_internal_branches | 1 | Internal branch lengths, largest first. |
nj_min_branch | 1 | |
nj_negative_branches | 1 | |
nj_max_abs_residual | 1 | |
nj_rms_residual | 1 | |
nj_cophenetic_r | 1 | |
upgma_newick | UPGMA tree, rooted, ultrametric. | |
upgma_tree_length | 1 | |
upgma_root_height | 1 | |
upgma_merge_heights | 1 | |
upgma_merges | ||
upgma_max_abs_residual | 1 | |
upgma_rms_residual | 1 | |
upgma_cophenetic_r | 1 | |
leaves | ||
pairs | ||
better_fit | "nj", "upgma" or "tie": the smaller rms residual. | |
tree_ok | No negative neighbour-joining branch and no broken triangle inequality. | |
warnings |
Try the call
Change a value and the command updates. Nothing runs here; paste it into your terminal or give it to your agent.