A tool to calculate the cluster affinity distance between two trees
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cluster_affinity-0.7.4.tar.gz.
File metadata
- Download URL: cluster_affinity-0.7.4.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1adb2bc733a825bc7a02bd759c8dbc844570bf7b923e72dc2fad8311c6945ba2
|
|
| MD5 |
eb7f74bfcc58d57dc9d5573bfda51c11
|
|
| BLAKE2b-256 |
b55ec039e6479d849b65bc72e71f5a43fd77b49629d93d04ded4713198d3eae5
|
Provenance
The following attestation bundles were made for cluster_affinity-0.7.4.tar.gz:
Publisher:
python-publish.yml on swagle8987/cluster_affinity
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cluster_affinity-0.7.4.tar.gz -
Subject digest:
1adb2bc733a825bc7a02bd759c8dbc844570bf7b923e72dc2fad8311c6945ba2 - Sigstore transparency entry: 1001686533
- Sigstore integration time:
-
Permalink:
swagle8987/cluster_affinity@e75b7d3d739afd66309fca1125399752143fac88 -
Branch / Tag:
refs/tags/v0.7.4 - Owner: https://github.com/swagle8987
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e75b7d3d739afd66309fca1125399752143fac88 -
Trigger Event:
release
-
Statement type:
File details
Details for the file cluster_affinity-0.7.4-py3-none-any.whl.
File metadata
- Download URL: cluster_affinity-0.7.4-py3-none-any.whl
- Upload date:
- Size: 19.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9d7014b12b069c11d55328a910e64ae181dc741a0c05798ab491cdd973c9689
|
|
| MD5 |
30ca82d92babba23f71741db6e3e6018
|
|
| BLAKE2b-256 |
694a9441b15f641d4a30dd233748eab81047ba38eeb58cb78646b75795366928
|
Provenance
The following attestation bundles were made for cluster_affinity-0.7.4-py3-none-any.whl:
Publisher:
python-publish.yml on swagle8987/cluster_affinity
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
cluster_affinity-0.7.4-py3-none-any.whl -
Subject digest:
d9d7014b12b069c11d55328a910e64ae181dc741a0c05798ab491cdd973c9689 - Sigstore transparency entry: 1001686538
- Sigstore integration time:
-
Permalink:
swagle8987/cluster_affinity@e75b7d3d739afd66309fca1125399752143fac88 -
Branch / Tag:
refs/tags/v0.7.4 - Owner: https://github.com/swagle8987
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@e75b7d3d739afd66309fca1125399752143fac88 -
Trigger Event:
release
-
Statement type: