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.0.0.tar.gz (57.1 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.0.0-cp310-abi3-win_amd64.whl (793.2 kB view details)

Uploaded CPython 3.10+Windows x86-64

phylo2vec-1.0.0-cp310-abi3-win32.whl (726.4 kB view details)

Uploaded CPython 3.10+Windows x86

phylo2vec-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl (1.2 MB view details)

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

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

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

phylo2vec-1.0.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.0.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.0.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.0.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (989.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

phylo2vec-1.0.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.0.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.0.0-cp310-abi3-macosx_11_0_arm64.whl (914.6 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

phylo2vec-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl (961.6 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for phylo2vec-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9fc53f7de464bc6d9e3071080e22b696b3616eadc71ce6dcb7177c6114dc0afa
MD5 7111f6b443768e11b4dd6c832e81d316
BLAKE2b-256 b572786e5750c2dfcf3bb3a5d9118482f8210ce5a82f47483cdf03183215ff57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 74a21a8aecd470593932be42b9b9d4580a67c59fc238e291e05e0a22bb43d144
MD5 6aab5e6d3a14c6bae09bf931adcbc2c4
BLAKE2b-256 a3ed277c76411efa9bb03f0791eef48426692850bc5d7ab8e115f6db49d63ddc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 f61b60acbbcca0b990f48529e75019caec6d5f035989b6a0a68f40addcdffe1b
MD5 ffdd3078e8894c0e733b3edca92c0303
BLAKE2b-256 dfc44dbc7f29f17076ef35964e71afecf8af49106972046894eaaa0ae0a642df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 54620142d8f46ac11e780d2a1165a91d053992e22d96e8ae2459e1512b6deafb
MD5 f2b98143f23aa3f859c6d13c2e22cc42
BLAKE2b-256 04060345ac6d01108afff4a479a90e037c5ab2d94cdc429935d597496699d558

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 0ea28fe7b2b0a5ec2653ea406108f7e1f290beed845d9349e0a232a76cdba730
MD5 e84d7af897f07325bbbf1ea2d06a8415
BLAKE2b-256 18c3207c6c35c6865c2ee7ae20af86a7d190cb99971e8db2e565ea61c16f0228

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 2f559172d3079bb6c07ad523d7c01e72f2b0f31a4054424d43c94dabd5dd220a
MD5 5f2bcf07c3fa28af4b014cd1f341e35b
BLAKE2b-256 908054d4710a438a4f829763240c386a96782151203b83bcc8dbf408d178b744

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2311327099ce06614e405c61b61e4cdb012c412e5491314e1d8799ed8c10d6d9
MD5 bf14300dc3dedb93237ae4e5ddbd2f00
BLAKE2b-256 040521909977bea9ddccd7db5bf886add55073017cd92174747e30226ed0916b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f75b616cecd66bf8e29f5b41713d3349dc0d11376276d884ba8a21e06191f3ba
MD5 d002ee789c60786135debb1d1425a7c2
BLAKE2b-256 2ee85fc5498925cbbc150328cc307e22919bf18acdd25e467cf04b065c806a68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 b65dddbc5a49e376ab1440a04c579938a979a36db1db6494ee855dcc433c1128
MD5 e3dbcb8295d695b02cd1b0d0d33e1f2f
BLAKE2b-256 cc1ac87b7edccedbc470e4a4cf972b178ab82b81cd403304b55dfdcc8c648b13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 0ae0a6331e00a4af4c79be863ee670ca41061ff2828d37c9f22741c5f967333e
MD5 88f5f742ff9118e09ff4d103dc049dfd
BLAKE2b-256 497c59e8d8f0185bb4216bb273a6c19b7b82719d3ecdf41c640f677e272abcaf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 bdfa1e8ba9120e010af91f9ec3fddc5496a4ad1b2e47af415a27975ef24ff7ff
MD5 e54f378822c8aa3f6628c2af404c8c4b
BLAKE2b-256 9b1f81e70241f2f8b1dcec8911a42b98be5441ebd019ed9a2145904942f5e821

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c022a90f66a90235d43736c4635e9c2fcb8be5059f3de40f1dfa688b2d55c48f
MD5 983d3fa9d717eb090d3b36991b6d0e8e
BLAKE2b-256 8aa3ccbe33c55393d5d792329db0c7c5bbb47cba24cdc15f98af79980a530226

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 47d21e07c0ccb90209e12ce90c100cc26e120c6c78d90ca0f70051e053a7a9dc
MD5 5db1c6d04fb97e483669eca040c1dccd
BLAKE2b-256 ea1456e295d53496afb3c207899668013e109fe895dbb0eb51ac88506d375ae4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 07b0f19cd339cb28da70a695bcb0f211a0d6e853a2602aee222a56432e3134f8
MD5 6ec0f6ecd4b171a9e9d78b12b73bf867
BLAKE2b-256 d1c0403dbb29933562665675e3547789c02c110a776aca2873f8ebffff539554

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.0.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 35791dfaf9ef50e2d47022e21f4c48f798146d5396dcfda03ac1253c8016ffb5
MD5 330789ee977979ea49a992ca99ac23d0
BLAKE2b-256 95b48ac74af930f1910a43a1df516b5d4da20730bd186d80a9a557387580c2fd

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