Skip to main content

Spectral Cluster Supertree.

Project description

Spectral Cluster Supertree

PyPI Version Python Version Code Style

CI Coverage Status License DOI

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'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

pip install sc-supertree

Usage

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:

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|BOOTSTRAP. 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. -- bootstrap - The sum of bootstrap values of the $lca$ nodes across trees where two taxa appear as a proper cluster.

The branch weighting strategy is recommended when branch lengths are available. Otherwise, the depth weighting strategy is recommended over the one weighting strategy. The bootstrap strategy has not yet been empirically assessed.

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.

>>> 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sc_supertree-2025.12.9.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sc_supertree-2025.12.9-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file sc_supertree-2025.12.9.tar.gz.

File metadata

  • Download URL: sc_supertree-2025.12.9.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sc_supertree-2025.12.9.tar.gz
Algorithm Hash digest
SHA256 7606488e61ecc740944f10fed77a14b6ca6115f015d4c44b39dafd1718084fe6
MD5 c7fb0a047419cdeec86330f4e637a218
BLAKE2b-256 cf679113e4bb7e719b2f8210d97749aaec5163eeb004a1fe471ebae36122c38a

See more details on using hashes here.

Provenance

The following attestation bundles were made for sc_supertree-2025.12.9.tar.gz:

Publisher: release.yml on rmcar17/SpectralClusterSupertree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sc_supertree-2025.12.9-py3-none-any.whl.

File metadata

File hashes

Hashes for sc_supertree-2025.12.9-py3-none-any.whl
Algorithm Hash digest
SHA256 a950fd2f42e9701574b0a57e615e904138ef3c69b5e18f1b522f7a7553d6b186
MD5 0aadd7d11a888c89380d63c089e97bda
BLAKE2b-256 13629ccf697b8c0e535e98830f4dab89150f46dddd2b5062e04cb73ca7b90185

See more details on using hashes here.

Provenance

The following attestation bundles were made for sc_supertree-2025.12.9-py3-none-any.whl:

Publisher: release.yml on rmcar17/SpectralClusterSupertree

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page