fitchtree
Fitch–Margoliash distance trees for Biopython.
Biopython builds UPGMA and neighbour-joining trees (DistanceTreeConstructor), but has no
Fitch–Margoliash method. fitchtree adds one, returning an ordinary Bio.Phylo tree that you can
draw, print or save like any other.
pip install fitchtree
Usage
from Bio import Phylo
from fitchtree import fitch_margoliash
tree = fitch_margoliash([[0, 22, 39, 39],
[22, 0, 41, 41],
[39, 41, 0, 18],
[39, 41, 18, 0]], names=["A", "B", "C", "D"])
print(tree.format("newick")) # (A:10,B:12,(C:9,D:9):20):0;
Phylo.draw(tree, branch_labels=lambda c: c.branch_length and round(c.branch_length, 4))
fitch_margoliash accepts:
- a Biopython
DistanceMatrix(e.g. fromDistanceCalculator), or - a square matrix (list of lists or NumPy array) plus optional
names(defaultSeq1,Seq2, …).
percent_standard_deviation(tree, distances, names=None) gives Fitch & Margoliash's goodness-of-fit
score: 0 means the tree reproduces every distance exactly; lower is better.
Method
This is the sequential clustering procedure from Fitch & Margoliash (1967), as presented in textbooks such as Mount, Bioinformatics: Sequence and Genome Analysis:
- Join the closest pair of clusters A and B.
- Treat every other taxon as one group R and use the three-point formulas
a = (d(A,B) + d(A,R) − d(B,R)) / 2andb = d(A,B) − afor the branches to A and B. - Subtract the average branch depth already inside A and B, merge them, and repeat.
- Join the last three clusters at one central node (the tree is unrooted).
Distances between clusters are averages over their member taxa. When the distances fit a
clock-like tree, the method recovers it exactly (topology and branch lengths). Like UPGMA, it
always joins the closest pair first, so when the two closest taxa are not true neighbours (very
unequal rates of change) the topology can be wrong; percent_standard_deviation will show a
poor fit. Use neighbour joining for such data.
Branch lengths can come out negative when the distances are far from tree-like; that is a property of the method, not an error.
This package does not perform the weighted least-squares search over topologies used by
PHYLIP's fitch program; it builds one tree by the clustering procedure above.
License
MIT
Metadata
Release files for fitchtree 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| fitchtree-0.1.0.tar.gz | 7.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fitchtree-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.7 kB
Release files / fitchtree-0.1.0.tar.gz
| Download URL | fitchtree-0.1.0.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aea909d5de573139f8008de2139827a3c862d81e4f5f5303dd9c295ee24783c0
|
|
BLAKE2b-256 checksum How to use checksums |
286e291bfef5b0ced86f22ad08f0f7e3f0d26e1e82250b66a7fed785ad99def5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / fitchtree-0.1.0-py3-none-any.whl
| Download URL | fitchtree-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
210bf433d7b1de8818f8a43649178c6f7e88bfc0fe1f9210d2bea88c0587aa50
|
|
BLAKE2b-256 checksum How to use checksums |
6a3c9c4008c543af8722d209a388c9d61fa5fc0033c029a6c0d4c06098a635cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for fitchtree 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.