Weighted Robinson-Foulds distance between two phylogenetic trees: the branch-length-vector distance over matched bipartitions. Each bipartition (or, on rooted trees, each clade) shared between the two trees contributes the difference of its branch lengths; a bipartition present in only one tree is given length 0 in the other. The default cityblock reduction is the original weighted RF distance; the euclidean reduction is the Kuhner-Felsenstein branch score.
rsomics-tree-wrfd t1.nwk t2.nwk [--metric cityblock|euclidean] [--no-tips]
The companion topology overlaps compare_biparts and compare_subsets — the
normalized symmetric difference of the bipartition or subset sets, ignoring branch
lengths — are available as --compare biparts and --compare subsets. They are the
same "compare two trees" operation at a different weighting, which is why they live
here rather than in a separate crate.
Kept separate from rsomics-tree-rfd: weighted and unweighted RF are distinct
user-facing operations with different output meaning (branch-length divergence vs a
topology count).
# Weighted RF (cityblock)
rsomics-tree-wrfd a.nwk b.nwk
# Kuhner-Felsenstein branch score, terminal branches excluded
rsomics-tree-wrfd a.nwk b.nwk --metric euclidean --no-tips
# Normalized bipartition overlap (compare_biparts)
rsomics-tree-wrfd a.nwk b.nwk --compare biparts
Rooting is inferred from the first tree (rooted iff its root has exactly two
children), matching scikit-bio. Override with --rooted / --unrooted. Only taxa
shared between the two trees are considered.
This crate is an independent Rust reimplementation of scikit-bio's
TreeNode.compare_wrfd, compare_biparts and compare_subsets, informed by reading
the scikit-bio source (BSD-3-Clause), which we are permitted to read and cite:
- Robinson, D. F., & Foulds, L. R. (1979). Comparison of weighted labelled trees. Combinatorial Mathematics VI, 119-126.
- Kuhner, M. K., & Felsenstein, J. (1994). A simulation comparison of phylogeny algorithms under equal and unequal evolutionary rates. Molecular Biology and Evolution, 11(3), 459-468. DOI: 10.1093/oxfordjournals.molbev.a040126
Values are reproduced to within ~1e-9 of scikit-bio (the weighted reduction is a deterministic f64 sum; bipartition matching is exact set logic).
License: MIT OR Apache-2.0. Upstream credit: scikit-bio https://scikit-bio.org (BSD-3-Clause).