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](./examples/t1.tre) and [t2.tre](./examples/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](./examples/multiple_trees_example) 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.
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``
Raw data
{
"_id": null,
"home_page": null,
"name": "cluster-affinity",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": null,
"author_email": "Sanket Wagle <swagle@iastate.edu>",
"download_url": "https://files.pythonhosted.org/packages/7d/c2/ded77369409d6732047efc08b1eadc4b54a9a317629d49947816e4c74680/cluster_affinity-0.6.0.tar.gz",
"platform": null,
"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. \n\n\nIf you use this software, please cite: Wagle, S., Markin, A., G\u00f3recki, 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)\n\nThis software also uses ete4 for visualization. Hence, please also cite: Jaime Huerta-Cepas, Fran\u00e7ois Serra and Peer Bork. \"ETE 3: Reconstruction, analysis and visualization of phylogenomic data.\" Mol Biol Evol (2016) doi: 10.1093/molbev/msw046\n\n### Installation\nCluster 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.\n\n\n### Tutorial\n---\nFor this tutorial, we will focus on visualizing the cluster affinity cost between the trees [t1.tre](./examples/t1.tre) and [t2.tre](./examples/t2.tre). Both trees are generated by the yule-harding model and contain 100 leaves each. \n\nThe 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\n\n``\ncluster_affinity examples/t1.tre examples/t2.tre \n``\n\nThe 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:\n\n\n\nTo compute the cluster support cost instead, ``cluster_affinity`` can be replaced with ``cluster_support`` in all commands. For example:\n``\ncluster_support t1.tre t2.tre\n``\ncomputes the cluster support cost from t1 to t2 and opens up an interactive browser session for the same. \n\nIf the command is used as part of a automation script, the cli flag can be used instead to prevent the interactive session from running.\n\n``\ncluster_affinity t1.tre t2.tre --cli\n``\n\nFurthermore, we also provide a ``cluster_matrix`` command to automatically generate matrix visualizations based on the cluster affinity cost. For example:\n``\ncluster_matrix --average t.tre matrix.png\n``\ncomputes 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](./examples/multiple_trees_example) is given below\n\n\n\nThe 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. \n\nThe following command generates the matrix with the cluster support cost instead\n``\n cluster_matrix t.tre matrix.png --cost cluster_support\n``\n\nFurther options can be accessed using ``cluster_affinity -h`` and ``cluster_matrix -h`` \n",
"bugtrack_url": null,
"license": null,
"summary": "A tool to calculate the cluster affinity distance between two trees",
"version": "0.6.0",
"project_urls": {
"Homepage": "https://github.com/swagle8987/cluster_affinity",
"Issues": "https://github.com/swagle8987/cluster_affinity/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6912df4dd7308ccb89a263590e8451cca07f6920905c07f3a5dcc6ab27350ca8",
"md5": "1d718011f0de3064f920495853684129",
"sha256": "4d6aa6060f582d4921e21473ade689e059318d8e2a23bd3967df8337afec6067"
},
"downloads": -1,
"filename": "cluster_affinity-0.6.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1d718011f0de3064f920495853684129",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 19068,
"upload_time": "2025-07-15T22:29:42",
"upload_time_iso_8601": "2025-07-15T22:29:42.874994Z",
"url": "https://files.pythonhosted.org/packages/69/12/df4dd7308ccb89a263590e8451cca07f6920905c07f3a5dcc6ab27350ca8/cluster_affinity-0.6.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7dc2ded77369409d6732047efc08b1eadc4b54a9a317629d49947816e4c74680",
"md5": "613372f64af63dc6a2f31f0518f64a4d",
"sha256": "93785950c6e633bd2f4f04684b4f7d7b016eb1c5364c07bca13c7f6fd1f5b731"
},
"downloads": -1,
"filename": "cluster_affinity-0.6.0.tar.gz",
"has_sig": false,
"md5_digest": "613372f64af63dc6a2f31f0518f64a4d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 15332,
"upload_time": "2025-07-15T22:29:44",
"upload_time_iso_8601": "2025-07-15T22:29:44.192107Z",
"url": "https://files.pythonhosted.org/packages/7d/c2/ded77369409d6732047efc08b1eadc4b54a9a317629d49947816e4c74680/cluster_affinity-0.6.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-15 22:29:44",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "swagle8987",
"github_project": "cluster_affinity",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "about-time",
"specs": [
[
"==",
"4.2.1"
]
]
},
{
"name": "alive-progress",
"specs": [
[
"==",
"3.2.0"
]
]
},
{
"name": "bottle",
"specs": [
[
"==",
"0.13.3"
]
]
},
{
"name": "Brotli",
"specs": [
[
"==",
"1.1.0"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2025.4.26"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.4.2"
]
]
},
{
"name": "cluster_affinity",
"specs": [
[
"==",
"0.1.1"
]
]
},
{
"name": "contourpy",
"specs": [
[
"==",
"1.3.2"
]
]
},
{
"name": "cycler",
"specs": [
[
"==",
"0.12.1"
]
]
},
{
"name": "ete4",
"specs": [
[
"==",
"4.3.0"
]
]
},
{
"name": "fonttools",
"specs": [
[
"==",
"4.58.2"
]
]
},
{
"name": "grapheme",
"specs": [
[
"==",
"0.6.0"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.10"
]
]
},
{
"name": "kiwisolver",
"specs": [
[
"==",
"1.4.8"
]
]
},
{
"name": "matplotlib",
"specs": [
[
"==",
"3.10.3"
]
]
},
{
"name": "numpy",
"specs": [
[
"==",
"2.2.6"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"25.0"
]
]
},
{
"name": "pillow",
"specs": [
[
"==",
"11.2.1"
]
]
},
{
"name": "pyparsing",
"specs": [
[
"==",
"3.2.3"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
"==",
"2.9.0.post0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.32.4"
]
]
},
{
"name": "scipy",
"specs": [
[
"==",
"1.15.3"
]
]
},
{
"name": "six",
"specs": [
[
"==",
"1.17.0"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.4.0"
]
]
}
],
"lcname": "cluster-affinity"
}