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 (or phylo2vec) is a high-performance software package for encoding, manipulating, and analysing 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, fast conversion/compression from Newick-format trees to the Phylo2Vec format, and rapid tree comparison in mind.

This current 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) 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.1.tar.gz (58.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.1.1-cp310-abi3-win_amd64.whl (797.6 kB view details)

Uploaded CPython 3.10+Windows x86-64

phylo2vec-1.1.1-cp310-abi3-win32.whl (731.1 kB view details)

Uploaded CPython 3.10+Windows x86

phylo2vec-1.1.1-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.1-cp310-abi3-musllinux_1_2_i686.whl (1.2 MB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

phylo2vec-1.1.1-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.1-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.1-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.1-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (992.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

phylo2vec-1.1.1-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.1-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.1-cp310-abi3-macosx_11_0_arm64.whl (919.1 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

phylo2vec-1.1.1-cp310-abi3-macosx_10_12_x86_64.whl (966.6 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for phylo2vec-1.1.1.tar.gz
Algorithm Hash digest
SHA256 9cf4a375095a591c64343fb6de26e3e66054b698830767300e2dfd21349a8afc
MD5 0f0079f839414b19d4c50f6f198a39f4
BLAKE2b-256 3bed20186092b8fc68cdc41cbe6b2827203493385a12af30ceebc2956f22ee6a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phylo2vec-1.1.1-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.6

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 58b227e337dbe5cc5252f4da25b6bf2064fc8909aeb95c7fe116fca3042457ab
MD5 930c6ce1e5215a0b85a50980b6030879
BLAKE2b-256 41748960eca6d1501230154c0f49c1106b525ec67753c58c4454a207eeb4c0be

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 50f89695be895bc2a97ff7f78d83b6e492ff8101040ad0bd9d9e30394fc37dc0
MD5 8ca599c503f0298fc287e4cfbf4d00ab
BLAKE2b-256 39b32bbe59e9a6d6f9147f4d23ab23654685d941ade364132c8f38e441827200

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 724ca69b2aaa9be4d2b281b5c0774ad3f7ea8c7d1c3f208cc7af11305ed1d2e6
MD5 373a752320774abad8faf42d6d2f305e
BLAKE2b-256 1a7c0f79245ec72cca39fb4747a0d0a9e2962217741638c8a0375e1243658a1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 9116b369e8e63abd8043a41220066bff6decbb2c86ba68fa3e0fd21fd0cf3629
MD5 a2afd8a9d77dbc6d76e155ad93a56d4b
BLAKE2b-256 006f5db3dfea1fa5c3b5e8f7bed128c03c74a290b3267916cce81e12ca70df07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 8e53a1e22146e58049f6dd1d2b43b7c878bf2015f2d1ba497595e24cd712da67
MD5 4c4e312a47e58b546e0cc8cbb0ce757b
BLAKE2b-256 9ba7c132d953407e2005a5b8e3d26fa4bfa3409905968c177d5dccd95ca694dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 15ed28b661e6c28031d4a85f3d921100ba4450eacb3f6f1a3bffc9c676652252
MD5 626d7cf4ee6bfe35733cf8f42e7807a9
BLAKE2b-256 f4847082ab7a76d4d3a28c426dbfbc4156255eb1b65cd3fdb07cf7bb82a54297

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 82cbb89b14b7f8030c874e8f71ed90cf37c8f760adb195c35685dd8b89d0a936
MD5 793ed0bf6c5071f3e6fe9045ebdac9c2
BLAKE2b-256 1d5016cdc8d7970380bf5055b8a5a8203e1a5c6f3671e356f95b1d1170af1720

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 3c9cbe28d337266432795f350dce5ca62798e95f96bf4789e749354be6d293d5
MD5 bb8a861bf9e3d01736ad72e5e5d36c24
BLAKE2b-256 cda3e9aeea87da1f7d78c5d373892e6cb7f7eeb81ad89f2873cc3392fa9e100d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 b739d1f1407b4b45791b3e30fb888b7eb188c2efbff51b8b528b7c0b35073b1b
MD5 3f2c8696a007e0ec0213750b3331d58a
BLAKE2b-256 c225a3b1a4ac44487f7f1d438f90c68fb7623ef408941f70e0f7042d6d2a2e15

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 6e88ab14db15875c4e1992f45dcd1f953572a78742cc46f9702c63928b79f5cd
MD5 dba49c354f75e9422466c54e10333c84
BLAKE2b-256 ec5ba9b269e1c843b8e12fa018ed64bd980ded2eea8c11b03f9f781ef7a02fc9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 be62bd17481bbb1796bbfc48c738978d4af3d6a0c912fddcd56d451b96208c55
MD5 185ad0615def6229498df0b3c54ebae2
BLAKE2b-256 4aa1d683233e584e7946e14c869c06ed101bc44ca789c6be919c405a82e6a2d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 662ae61cea2d27b4bb98c2f66776aae29af3c24555504cadda71d35bd2baeb1b
MD5 a176a0d85fa04f7e649413cec00279d2
BLAKE2b-256 f349321947934dabf59a52341805b2426cee2a0ed365ef9584d3820549f01f7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b714b8ef48f5239d1b600c3d0983b4f1bc3c65996e0a12b8aba0d0403a3ecb61
MD5 8b12a817b38cdd81e61980e70015de45
BLAKE2b-256 bdea9b4cc707f8a8c7c377f5d6d5044771564f5d6ea77b15d99b362eeae41f11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.1.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2f01355c11dbecad503eee92aad651b89c9c73b8cf4ff28687d206ecadbc5e5d
MD5 aa3c387463a66a6d0e98793140936805
BLAKE2b-256 b469a80cab8b450216c0a9521dde959482a396c826e0c0b3035ac7c667084d2a

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