Phylo Tree
A phylogenetic tree from Newick, rectangular or circular, with branch lengths or without. Branches meet in rounded elbows, and pointing at a node lights the path to every leaf below it. Color is kept for the clades you name.
Install
npx shadcn@latest add @nelumbo/phylo-treeA dated tree
Thirteen vertebrates at their divergence times, with scale="time" counting back from today. Point at a node, or tab in and use the arrows; click a clade or press Enter to fold it.
Support
Bootstrap support printed at the nodes, hidden under supportThreshold (70 here). support="dots" trades the numbers for marks. The human globins; the support values are illustrative.
From distances
neighborJoining builds a tree from a distance matrix (distances computes one from aligned sequences), and reroot hangs it from an outgroup. This is the textbook example.
| a | b | c | d | e | |
|---|---|---|---|---|---|
| a | 0 | 5 | 9 | 9 | 8 |
| b | 5 | 0 | 10 | 10 | 9 |
| c | 9 | 10 | 0 | 8 | 7 |
| d | 9 | 10 | 8 | 0 | 3 |
| e | 8 | 9 | 7 | 3 | 0 |
(d:2,e:1,(c:4,(a:2,b:3):3):2);Props
| Prop | Type | Default | Notes |
|---|---|---|---|
tree | string | PhyloNode | Newick, or a parsed tree. | |
layout | "rectangular" | "circular" | "rectangular" | Circular puts the root at the center. |
branchLengths | boolean | true | A phylogram; false lines the leaves up as a cladogram. |
alignLabels | boolean | false | Leaves in one column, with dotted leaders. |
ladderize | boolean | true | Children ordered by size. |
support | "values" | "dots" | false | "values" | Support at internal nodes. Circular uses dots. |
supportThreshold | number | 70 | Hide support below this. |
scale | "bar" | "time" | false | "bar" | A scale bar, or an axis counting back from the tips. |
unit | string | For the scale: Mya, substitutions/site. | |
clades | { taxa, label, color?, collapsed? }[] | Shaded clades, found as the common ancestor of taxa. | |
highlight | string[] | Leaves set in bold. | |
italic | boolean | false | Species names in italics. |
collapsible | boolean | false | Fold and unfold clades by click or Enter. |
rowHeight / size | number | 24 / 560 | Row height; the circular diameter cap. |
selectable | boolean | false | Keyboard focus: up and down through nodes, left to the parent, right to a child. |
onActiveChange | (focus: { node, taxa, depth, clade } | null) => void | The node pointed at or focused. | |
Helpers | parseNewick, toNewick, ladderize, leafNames, reroot, distances, neighborJoining | Parse and write Newick; order, root and build trees. |