The Asymmetric Cluster Affinity cost is a phylogenetic cost quantifying the topological distance from a source tree to a target tree. It does so by finding the best possible match for each cluster in the source tree from all clusters in the target tree.
If you use this software, please cite: Wagle, S., Markin, A., Górecki, P., Anderson, T. K., & Eulenstein, O. (2024). Asymmetric cluster-based measures for comparative phylogenetics. Journal of Computational Biology, 31(4), 312-327. doi:(https://doi.org/10.1089/cmb.2023.0338)
This software also uses ete4 for visualization. Hence, please also cite: Jaime Huerta-Cepas, François Serra and Peer Bork. "ETE 3: Reconstruction, analysis and visualization of phylogenomic data." Mol Biol Evol (2016) doi: 10.1093/molbev/msw046
Installation
Cluster Affinity is available in PyPi and can be installed as pip install cluster-affinity. Note that the package is built for Python 3.10 or higher.
Tutorial
For this tutorial, we will focus on visualizing the cluster affinity cost between the trees t1.tre and t2.tre. Both trees are generated by the yule-harding model and contain 100 leaves each.
The following command computes the cluster affinity cost from source tree t1 to target tree t2 and returns the normalized cluster affinity cost. The cost is normalized on a scale of 0-1 where 0 is a tree identical to t1 and 1 is the maximum cluster affinity cost attainable by t1
cluster_affinity examples/t1.tre examples/t2.tre
The command also opens up an interactive web session (by default at localhost:5000) to visualize the source and target trees. The source tree has node labels representing the cluster affinity cost for that node (normalized to 0-1 as well), with branches colored by the cluster affinity cost as well. An example of source tree visualization is given below:
To compute the cluster support cost instead, cluster_affinity can be replaced with cluster_support in all commands. For example:
cluster_support t1.tre t2.tre
computes the cluster support cost from t1 to t2 and opens up an interactive browser session for the same.
If the command is used as part of a automation script, the cli flag can be used instead to prevent the interactive session from running.
cluster_affinity t1.tre t2.tre --cli
Furthermore, we also provide a cluster_matrix command to automatically generate matrix visualizations based on the cluster affinity cost. For example:
cluster_matrix --average t.tre matrix.png
computes the cluster affinity cost between each pair of trees in t.tre and saves the matrix to out.png. An example matrix computed by the trees multiple_trees_example.tre is given below
The dark green boxes in the matrix image are low cost pairings while the red boxes are high cost pairings. The x axis represents the target trees i.e. the trees being mapped to and the y axis represents the source i.e. the trees being mapped from. As usual, each cost is normalized by the maximum possible value from the source tree. The --average flag also adds an extra column summarizing the average distance from the source tree to other trees in the matrix. If processing unrooted trees, use the --unrooted flag as well.
The following command generates the matrix with the cluster support cost instead
cluster_matrix t.tre matrix.png --cost cluster_support
Further options can be accessed using cluster_affinity -h and cluster_matrix -h
Metadata
Release files for cluster-affinity 0.7.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cluster_affinity-0.7.4.tar.gz | 15.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cluster_affinity-0.7.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.9 kB
Release files / cluster_affinity-0.7.4.tar.gz
| Download URL | cluster_affinity-0.7.4.tar.gz |
|---|---|
| Size | 15.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1adb2bc733a825bc7a02bd759c8dbc844570bf7b923e72dc2fad8311c6945ba2
|
|
BLAKE2b-256 checksum How to use checksums |
b55ec039e6479d849b65bc72e71f5a43fd77b49629d93d04ded4713198d3eae5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 27, 2026.
Transparency logRelease files / cluster_affinity-0.7.4-py3-none-any.whl
| Download URL | cluster_affinity-0.7.4-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9d7014b12b069c11d55328a910e64ae181dc741a0c05798ab491cdd973c9689
|
|
BLAKE2b-256 checksum How to use checksums |
694a9441b15f641d4a30dd233748eab81047ba38eeb58cb78646b75795366928
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 27, 2026.
Transparency log