sc-supertree


Namesc-supertree JSON
Version 2024.8.26 PyPI version JSON
download
home_pageNone
SummarySpectral Cluster Supertree
upload_time2024-08-26 07:04:23
maintainerNone
docs_urlNone
authorRobert McArthur
requires_python<3.13,>=3.10
licenseNone
keywords supertree phylogeny biology bioinformatics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Spectral Cluster Supertree

[![PyPI Version](https://img.shields.io/pypi/v/sc-supertree)](https://pypi.org/project/sc-supertree/)
[![Python Version](https://img.shields.io/pypi/pyversions/sc-supertree)](https://pypi.org/project/sc-supertree/)
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

[![CI](https://github.com/rmcar17/SpectralClusterSupertree/workflows/CI/badge.svg)](https://github.com/rmcar17/SpectralClusterSupertree/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/rmcar17/SpectralClusterSupertree/badge.svg?branch=main)](https://coveralls.io/github/rmcar17/SpectralClusterSupertree?branch=main)
[![License](https://img.shields.io/github/license/rmcar17/SpectralClusterSupertree)](https://github.com/rmcar17/SpectralClusterSupertree/blob/main/LICENSE)
[![DOI](https://zenodo.org/badge/667189656.svg)](https://zenodo.org/badge/latestdoi/667189656)

Spectral Cluster Supertree is a state-of-the-art algorithm for constructing rooted supertrees from collections of rooted source trees.

Spectral Cluster Supertree can be used on Newick formatted trees in Python in conjunction with [cogent3](https://github.com/cogent3/cogent3)'s tree objects, or invoked from the command line.

Spectral Cluster Supertree can employ a number of weighting strategies that take into account the depths of nodes in the trees, as well as branch lengths. A user can specify weights of trees to add bias to some of the source trees if desired.

## Installation

```bash
pip install sc-supertree
```

## Usage

### Python

```python
from sc_supertree import load_trees, construct_supertree

source_trees = load_trees("source_tree_file.tre")

supertree = construct_supertree(source_trees, pcg_weighting="branch")

supertree.write("supertree_file.tre")
```

### CLI

In your environment which has `sc-supertree` installed:

```bash
scs -i SOURCE_TREE_FILE -o SUPERTREE_FILE -p PCG_WEIGHTING_STRATEGY
```

The ```-i``` and ```-o``` options for the input and output files are required.

The ```-p``` *proper cluster graph* weighting strategy option must be one of ```ONE|DEPTH|BRANCH```. It defaults to ```BRANCH``` when not provided (not recommended when some trees are missing branch lengths - see below). Tree weights are not supported through the command line.

## Weighting Strategies

### Proper Cluster Graph Weighting

Spectral Cluster Supertree recursively partitions the complete set of taxa to form a supertree. The core component of the algorithm involves partitioning the *proper cluster graph* through spectral clustering when the source trees are not consistent.

The *proper cluster graph* has the set of all taxa in the source trees as its vertices, and an edge connects two taxa if they appear together on the same side of the root in any of the source trees (such pairs of taxa are called **proper clusters**). Let $lca$ be the lowest common ancestor of a proper cluster. Each edge is weighted according to the specified strategy:

- **one** - The number of trees in which the pair of taxa appear as a proper cluster in.
- **depth** - The sum of the depths of the $lca$ of the proper cluster in all of the source trees.
- **branch** - The sum of the root to $lca$ branch lengths of the proper cluster in all of the source trees. If branch lengths are missing defaults to one (equivalent to depth). Do not use if source trees contain a mix of some trees with branch lengths and some without.

The **branch** weighting strategy is recommended when branch lengths are available. Otherwise, the **depth** weighting strategy is recommended over the **one** weighting strategy.

### Tree Weighting

In addition to the above, users may associate trees with weights to bias the results towards specific trees. Prior to the summation of the weights for an edge in the *proper cluster graph*, they are each multiplied by the weight of the corresponding tree. The weight of each tree defaults to one if not specified.

An example is shown below, without the tree weights the algorithm would randomly return either triple.

```python
>>> from sc_supertree import construct_supertree
>>> from cogent3 import make_tree
>>> tree_1 = make_tree("(a,(b,c))")
>>> tree_2 = make_tree("(c,(b,a))")
>>> print(construct_supertree([tree_1, tree_2], weights=[1, 1.5]))
(c,(b,a));
```

Tree weighting can only be used in the python implementation, not the CLI.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "sc-supertree",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.13,>=3.10",
    "maintainer_email": null,
    "keywords": "supertree, phylogeny, biology, bioinformatics",
    "author": "Robert McArthur",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/56/16/ffd66a5ba4678f4a72e5d0a6812faf13cbf857c46cda24ef3bade91d7376/sc_supertree-2024.8.26.tar.gz",
    "platform": null,
    "description": "# Spectral Cluster Supertree\n\n[![PyPI Version](https://img.shields.io/pypi/v/sc-supertree)](https://pypi.org/project/sc-supertree/)\n[![Python Version](https://img.shields.io/pypi/pyversions/sc-supertree)](https://pypi.org/project/sc-supertree/)\n[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\n[![CI](https://github.com/rmcar17/SpectralClusterSupertree/workflows/CI/badge.svg)](https://github.com/rmcar17/SpectralClusterSupertree/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/rmcar17/SpectralClusterSupertree/badge.svg?branch=main)](https://coveralls.io/github/rmcar17/SpectralClusterSupertree?branch=main)\n[![License](https://img.shields.io/github/license/rmcar17/SpectralClusterSupertree)](https://github.com/rmcar17/SpectralClusterSupertree/blob/main/LICENSE)\n[![DOI](https://zenodo.org/badge/667189656.svg)](https://zenodo.org/badge/latestdoi/667189656)\n\nSpectral Cluster Supertree is a state-of-the-art algorithm for constructing rooted supertrees from collections of rooted source trees.\n\nSpectral Cluster Supertree can be used on Newick formatted trees in Python in conjunction with [cogent3](https://github.com/cogent3/cogent3)'s tree objects, or invoked from the command line.\n\nSpectral Cluster Supertree can employ a number of weighting strategies that take into account the depths of nodes in the trees, as well as branch lengths. A user can specify weights of trees to add bias to some of the source trees if desired.\n\n## Installation\n\n```bash\npip install sc-supertree\n```\n\n## Usage\n\n### Python\n\n```python\nfrom sc_supertree import load_trees, construct_supertree\n\nsource_trees = load_trees(\"source_tree_file.tre\")\n\nsupertree = construct_supertree(source_trees, pcg_weighting=\"branch\")\n\nsupertree.write(\"supertree_file.tre\")\n```\n\n### CLI\n\nIn your environment which has `sc-supertree` installed:\n\n```bash\nscs -i SOURCE_TREE_FILE -o SUPERTREE_FILE -p PCG_WEIGHTING_STRATEGY\n```\n\nThe ```-i``` and ```-o``` options for the input and output files are required.\n\nThe ```-p``` *proper cluster graph* weighting strategy option must be one of ```ONE|DEPTH|BRANCH```. It defaults to ```BRANCH``` when not provided (not recommended when some trees are missing branch lengths - see below). Tree weights are not supported through the command line.\n\n## Weighting Strategies\n\n### Proper Cluster Graph Weighting\n\nSpectral Cluster Supertree recursively partitions the complete set of taxa to form a supertree. The core component of the algorithm involves partitioning the *proper cluster graph* through spectral clustering when the source trees are not consistent.\n\nThe *proper cluster graph* has the set of all taxa in the source trees as its vertices, and an edge connects two taxa if they appear together on the same side of the root in any of the source trees (such pairs of taxa are called **proper clusters**). Let $lca$ be the lowest common ancestor of a proper cluster. Each edge is weighted according to the specified strategy:\n\n- **one** - The number of trees in which the pair of taxa appear as a proper cluster in.\n- **depth** - The sum of the depths of the $lca$ of the proper cluster in all of the source trees.\n- **branch** - The sum of the root to $lca$ branch lengths of the proper cluster in all of the source trees. If branch lengths are missing defaults to one (equivalent to depth). Do not use if source trees contain a mix of some trees with branch lengths and some without.\n\nThe **branch** weighting strategy is recommended when branch lengths are available. Otherwise, the **depth** weighting strategy is recommended over the **one** weighting strategy.\n\n### Tree Weighting\n\nIn addition to the above, users may associate trees with weights to bias the results towards specific trees. Prior to the summation of the weights for an edge in the *proper cluster graph*, they are each multiplied by the weight of the corresponding tree. The weight of each tree defaults to one if not specified.\n\nAn example is shown below, without the tree weights the algorithm would randomly return either triple.\n\n```python\n>>> from sc_supertree import construct_supertree\n>>> from cogent3 import make_tree\n>>> tree_1 = make_tree(\"(a,(b,c))\")\n>>> tree_2 = make_tree(\"(c,(b,a))\")\n>>> print(construct_supertree([tree_1, tree_2], weights=[1, 1.5]))\n(c,(b,a));\n```\n\nTree weighting can only be used in the python implementation, not the CLI.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Spectral Cluster Supertree",
    "version": "2024.8.26",
    "project_urls": {
        "Bug Tracker": "https://github.com/rmcar17/SpectralClusterSupertree/issues",
        "Source Code": "https://github.com/rmcar17/SpectralClusterSupertree"
    },
    "split_keywords": [
        "supertree",
        " phylogeny",
        " biology",
        " bioinformatics"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "06f77f4e23d62777ea2b3f3df7b5728a6eefde26884c363207eafafd091e6af5",
                "md5": "1141322f2aa65351e44d98d483d85917",
                "sha256": "d75fe803b5128f2e3c620dbfd681b3cee70114e7ae243f9dce40e16b34e8e59a"
            },
            "downloads": -1,
            "filename": "sc_supertree-2024.8.26-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "1141322f2aa65351e44d98d483d85917",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.13,>=3.10",
            "size": 11374,
            "upload_time": "2024-08-26T07:04:22",
            "upload_time_iso_8601": "2024-08-26T07:04:22.231425Z",
            "url": "https://files.pythonhosted.org/packages/06/f7/7f4e23d62777ea2b3f3df7b5728a6eefde26884c363207eafafd091e6af5/sc_supertree-2024.8.26-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5616ffd66a5ba4678f4a72e5d0a6812faf13cbf857c46cda24ef3bade91d7376",
                "md5": "5e90116796f7ee3fc06350123cfa7993",
                "sha256": "d836bf8f9d184047dcb010450f929f9fffdee95a7148efadda28d2ab003294e1"
            },
            "downloads": -1,
            "filename": "sc_supertree-2024.8.26.tar.gz",
            "has_sig": false,
            "md5_digest": "5e90116796f7ee3fc06350123cfa7993",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.13,>=3.10",
            "size": 11692,
            "upload_time": "2024-08-26T07:04:23",
            "upload_time_iso_8601": "2024-08-26T07:04:23.206964Z",
            "url": "https://files.pythonhosted.org/packages/56/16/ffd66a5ba4678f4a72e5d0a6812faf13cbf857c46cda24ef3bade91d7376/sc_supertree-2024.8.26.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-26 07:04:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rmcar17",
    "github_project": "SpectralClusterSupertree",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sc-supertree"
}
        
Elapsed time: 9.55654s