Skip to main content

Phylo2Vec: integer vector representation of binary (phylogenetic) trees

Project description

Phylo2Vec

PyPI version Documentation DOI

LGPL-3.0 License

pre-commit.ci status CI Python CI Rust CI R

Phylo2Vec is a high-performance software package for encoding, manipulating, and analyzing binary phylogenetic trees. At its core, the package contains representation of binary trees, which defines a bijection from any tree topology with 𝑛 leaves into an integer vector of size 𝑛 − 1. Compared to the traditional Newick format, phylo2vec was designed with fast sampling and rapid tree comparison in mind.

This current 2.0 version features a core implementation in Rust, providing significant performance improvements and memory efficiency while remaining available in Python (superseding the version described in the original paper (Penn et al., 2024)) and R via dedicated wrappers, making it accessible to a broad audience in the bioinformatics community.

Link to the paper: https://doi.org/10.1093/sysbio/syae030

Installation

Pip

The easiest way to install the Python package is using pip:

pip install phylo2vec

Manual installation

  • We recommend setting up pixi package management tool.
  • Clone the repository and install using pixi:
git clone https://github.com/sbhattlab/phylo2vec.git
cd phylo2vec
pixi run -e py-phylo2vec install-python

This will compile and install the package as the core functionality is written in Rust.

Installing R package

To install the R package, first you need to retrieve one of the compiled file within the package releases. Once the file is downloaded, simply run install.packages in your R command line.

install.packages("/path/to/package_file", repos = NULL, type = 'source')

Basic Usage

Python

Conversion between Newick and vector representations

import numpy as np
from phylo2vec import from_newick, to_newick

# Convert a vector to Newick string
v = np.array([0, 1, 2, 3, 4])
newick = to_newick(v)  # '(0,(1,(2,(3,(4,5)6)7)8)9)10;'

# Convert Newick string back to vector
v_converted = from_newick(newick)  # array([0, 1, 2, 3, 4], dtype=int16)

Tree Manipulation

from phylo2vec.utils.vector import add_leaf, remove_leaf, reroot_at_random

# Add a leaf to an existing tree
v_new = add_leaf(v, 2)  # Add a leaf to the third position

# Remove a leaf
v_reduced = remove_leaf(v, 1)  # Remove the second leaf

# Random rerooting
v_rerooted = reroot_at_random(v)

Optimization

from phylo2vec.opt import HillClimbingOptimizer

# Perform phylogenetic inference
hc = HillClimbingOptimizer(raxml_cmd="/path/to/raxml-ng", verbose=True)
v_opt, taxa_dict, losses = hc.fit("/path/to/your_fasta_file.fa")

Documentation

For comprehensive documentation, tutorials, and API reference, visit: https://phylo2vec.readthedocs.io

How to Contribute

We welcome contributions to Phylo2Vec! Here's how you can help:

  1. Fork the repository and create your branch from main
  2. Make your changes and add tests if applicable
  3. Run the tests to ensure they pass
  4. Submit a pull request with a detailed description of your changes

Please make sure to follow our coding standards and write appropriate tests for new features.

Thanks to our contributors so far!

Contributors

License

This project is distributed under the GNU Lesser General Public License v3.0 (LGPL).

Citation

If you use Phylo2Vec in your research, please cite:

@article{10.1093/sysbio/syae030,
    author = {Penn, Matthew J and Scheidwasser, Neil and Khurana, Mark P and Duchêne, David A and Donnelly, Christl A and Bhatt, Samir},
    title = {Phylo2Vec: a vector representation for binary trees},
    journal = {Systematic Biology},
    year = {2024},
    month = {03},
    doi = {10.1093/sysbio/syae030},
    url = {https://doi.org/10.1093/sysbio/syae030},
}

Related Work

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

phylo2vec-1.1.0.tar.gz (57.9 kB view details)

Uploaded Source

Built Distributions

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

phylo2vec-1.1.0-cp310-abi3-win_amd64.whl (797.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

phylo2vec-1.1.0-cp310-abi3-win32.whl (731.0 kB view details)

Uploaded CPython 3.10+Windows x86

phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_i686.whl (1.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_armv7l.whl (1.3 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARMv7l

phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_aarch64.whl (1.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ s390x

phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ppc64le

phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (992.3 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

phylo2vec-1.1.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.5+ i686

phylo2vec-1.1.0-cp310-abi3-macosx_11_0_arm64.whl (919.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

phylo2vec-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl (966.7 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file phylo2vec-1.1.0.tar.gz.

File metadata

  • Download URL: phylo2vec-1.1.0.tar.gz
  • Upload date:
  • Size: 57.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.8.4

File hashes

Hashes for phylo2vec-1.1.0.tar.gz
Algorithm Hash digest
SHA256 65c7d10e8e914a1ffc85d9664ae345ce5ceb3a7224e397bccbb36fce33add6c9
MD5 af91b1e5a655a314b6b94060133c98b3
BLAKE2b-256 49dbe3a84be1828ac67b13eaad28f309a19b1a53caa0c33be9980ba46ecd9453

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: phylo2vec-1.1.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 797.6 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.8.4

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f905fcf3fec0e3a8507fbafe40c10e47ccdcddb2deec1458ce4a3f9d7a9822da
MD5 f1d09a2382d6ba73e8dc39bff1db5782
BLAKE2b-256 4c71cfdfdbf3bf7e718073dc4c8b26eb7e4a38b7a96aae8c7dfa4bd55d854253

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-win32.whl.

File metadata

  • Download URL: phylo2vec-1.1.0-cp310-abi3-win32.whl
  • Upload date:
  • Size: 731.0 kB
  • Tags: CPython 3.10+, Windows x86
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.8.4

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 e55792f50f2ec3a484ba376870fb554bcb87d82482079a3d04b6f346d1ff2c6f
MD5 2525d6736255900968c19675abd0424e
BLAKE2b-256 ba224d4eaf2ede1e62a6b888268e72f731884687bb4a8a2c49bea4f87744061d

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e6487b2a5ee2b5bf647a880325c8cf3faf55aa7350c7b30581b1350570ef1d53
MD5 1609492e378818829ec366bf5c79d992
BLAKE2b-256 cd73d378e0fef2802bf0173083f75adae26cf29609a2dff484c34140c1903104

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 c232fd517b0db198785e3a14c56b5e2eab5ae35ef3b07781f5c6f9ef2ce34bb0
MD5 e1810b69e071c4e22d215779e32e37d8
BLAKE2b-256 e85c884ea432d268c0daef5e6c1e9c7c00fab9f080d72b0a5708c673712eca18

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 f26aef98362d4f12c14bc0c49fa351a1596e955701081adf98813dab289f97e7
MD5 917841e2b939acb10c83a7d00c00f250
BLAKE2b-256 6e714948c35dc6eae56bc6b66efa331b6752066f47736ff740f3ef56e8aa46a1

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 916fc58ff1d57f739f44faaa8eb8108ca35f41be2ddd8662b4739d33cf1c7856
MD5 26a1f028640e810653f5d08b5144e349
BLAKE2b-256 2edbf823857f619ab0b9ddb5472a4932fb84d521f04ac8b05d603fc7878e0196

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f53b088ec53ebe0109a4b8649e749fc8cb2fc29c5cd9665a2702c003a2c764bd
MD5 c7692d48a0a86b017c85a27a9a931b6d
BLAKE2b-256 4db52c1f9c0b48ead9dff9ff47f2b6b91c6fec59610c85cc1b4fcaf0b6e47263

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 cae884bacb97a3a067ea0ff099ec6c384888a7a5373f8666270b7ca607ca9aa0
MD5 ab7589dfb230102ca9b4b234aaa7583e
BLAKE2b-256 66b9349fcb19335f2a035f800c6bdc26e3d21f2e5f0a12f26f918c21e66bd35f

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 3306d99b6766fe6504f40f9a0c13a75b735641dd7915a4ef16f000c989c10ca3
MD5 cf56163bf0bbcb79c35db601278fc23a
BLAKE2b-256 95cc8331380f966afc1eb9b5711dc15a0bce69e898b58f40b11abb4b25f7f504

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 fcccdfcdf8856812fc891a8b1680583aa89d73c20d9349690bc74962442e3904
MD5 4bba45f39095766d7e3d8881def1d9c0
BLAKE2b-256 7aa6aa88be106a19c90bd1e6ce591ba287f42be1baa24e751d41800e3b73a2bf

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 37bc1134b0dc708852fe2ba1a1b8d00f1bb3f3d786d4b66dc4cbfc3b911958a4
MD5 53e8374f351cc44c7e0992ae3380b83c
BLAKE2b-256 86208147e8dc9a04675ebb0e8a35c3c62eab5bb6162c863e69ad5f0c96e68006

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 275db03886884f12077b20e83447a7b5851b25f92a32bd372cb187bdb971876b
MD5 a5318888fe3a864e96e979a98ccc3be5
BLAKE2b-256 3a089ca12980fdb4e60f67b841e5282e042771ce9a61e0bfefa21164fb563a69

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 690a0f9d48eeb2c23cfaa99da9d1cccc85874a65d908768fa63f9d252cb8d4e0
MD5 09a2367e3bf85a146af76cfc869d7a48
BLAKE2b-256 56b1619b719df3c2500d46dfea761654961e2e2421817e2195806fda7eb72835

See more details on using hashes here.

File details

Details for the file phylo2vec-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for phylo2vec-1.1.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 afde3d606b59deda79e546dbe1aa9e65fd1f151f3e7315691ae76f5021342fa9
MD5 13a82c1d3eaa2ebc893cca9c21ab34a5
BLAKE2b-256 b7a5e8c16acdca4b3b984aefcccc4cfcf7ff90377b00ce149ca821bde71b10d3

See more details on using hashes here.

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