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.2.0.tar.gz (70.2 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.2.0-cp310-abi3-win_amd64.whl (804.5 kB view details)

Uploaded CPython 3.10+Windows x86-64

phylo2vec-1.2.0-cp310-abi3-win32.whl (740.5 kB view details)

Uploaded CPython 3.10+Windows x86

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

Uploaded CPython 3.10+musllinux: musl 1.2+ i686

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

phylo2vec-1.2.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.2.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.1 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ s390x

phylo2vec-1.2.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.2 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ppc64le

phylo2vec-1.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (999.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARMv7l

phylo2vec-1.2.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.2.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.2.0-cp310-abi3-macosx_11_0_arm64.whl (927.5 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

phylo2vec-1.2.0-cp310-abi3-macosx_10_12_x86_64.whl (976.7 kB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for phylo2vec-1.2.0.tar.gz
Algorithm Hash digest
SHA256 b0b4a6205ccb13915338f40767d395bbe05fc8cdc70f5dfdb83b58899b1a1844
MD5 dc57e2f5892043f4c306c5a5df370359
BLAKE2b-256 6c6f3cdd5310bd92504c9ea0b095893d98e9bb0c64f5294d27cbb1684080a247

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phylo2vec-1.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 804.5 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.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 70d8af3ff45f80280fa91a4a9fa625342e18b0940535c5b7b218dd0203c8bfe7
MD5 3df30012718d1546470d21794144df43
BLAKE2b-256 a9f804c2384758682a0437eaf9a4e9648d70d69974bc325d91ddd105c6a9d7b8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-win32.whl
Algorithm Hash digest
SHA256 72ad455b23cbee38bc688863abd3556e0c0c16a467a6a336275ee9d6464fcc31
MD5 edebb5b9d64c16ca8d8c733fbd871612
BLAKE2b-256 dfd63f09496fe58cec1a385955c090e2c63c4a86294da888fd42fdec4ab44d9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 bea0134cd1a0b1462792bb7d3da41a20811edff129e0a10fccf718c7f72169e9
MD5 b274c5a44b4a3bd181042f5c47785955
BLAKE2b-256 c91959e3fe7be0a49ea694fec3add59332d332f16f0ff4a45206df379000c960

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 6ba3856ff30783e00f7809b9bac19c0cf24924db99a999fd97f221d17c90b683
MD5 352b0152407ad8ca95ca0c4335cdf6ed
BLAKE2b-256 b00e31d8a6b96529e9bf2a89ce729702115a1f5219915b0501c5c7e42f7c4e4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 bae72a0c9e8c4bae86eb46eda76e03e622e5a0829dd5479fc03efb383c5987b9
MD5 61dccc2a8a88496401be5061b464ef81
BLAKE2b-256 1b5954aaf4e96efbc98ce5d50692e1480ce0f406a26f049c40da9589f76d99c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 3656aa5d73551cbc35819d85b6c91710cc9715d1897dc45ed47c623b7ddf7d30
MD5 73b32975ec7f4e48714a40ae71cc1f1b
BLAKE2b-256 284d53154e0c24fe7f7d272a5f43d14ddda940de127cf077e7aa84aac835cf9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 771b4966fa339626fcc5cc160cbfc4034e1fdc13e38259f61d3e768e336ee39b
MD5 18a8aa4e69a9183e897fb46c7bedc604
BLAKE2b-256 20bdccacabc25f450c2b95c0f01daccef87540d90bb7a8007db6643c39118d52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 239f3d2ee1120d3427d16d482aa21c2d9b0a9ee783b00a3fd78614bea9f83f1a
MD5 fd565587218a02ed1c58bc38b4022ed2
BLAKE2b-256 8d15f4741301d956f2bce20d58fff5572a921a61f5849d28c34d89c697e15b01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 7f7fc7b94295c72887aa9c78512ea25aee0a35a29721a83061d85967379b817b
MD5 be75f87a0ce45b9e45b2bb944f3d9ed2
BLAKE2b-256 88a414d035d91344b27ebe8e4ee4dcd24447583ea351d3adf90ce9fba930e3eb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 aff51eea60720751d6a461ba7b69af827a9f2b76e7fdad13068a4de9e03b6bb9
MD5 632f245646195c0148163ae7620f986a
BLAKE2b-256 c20112e5589f20f7cbf2b6a9e760496cf9d4a98630eed1304a3e2b2469762b83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 80da6d3f8e02a2e16eaa66eb990c7e923e6cb853469ff897079155b446ac9d39
MD5 2197ae46cf8c0cb3801257303c6e7ea7
BLAKE2b-256 133493d4bb3bf19ca0ed71fb7347257bcc43c0ff5158d76f5976ce19a90f8b0a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 d0b5410a21cd67ebfdb1d6038aa641bb6425565de6e050574e5d5f3453d4ca97
MD5 812fad7ab127f67193313773765929e6
BLAKE2b-256 be80261f05a1a2e809089285f357bd417f4deed407c8c0fcc9d59a27290066e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9b9bccdc5b262695609058a619e771b6abdc953626b9c16f678f6889dd7116d9
MD5 49c233942fb63b6f5b57e263214b567e
BLAKE2b-256 f0b2c37d48ad26e92ab8b399f64a0bf38d2115270eb617756b1ebb0dc898cdc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phylo2vec-1.2.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e4afdb782338a64a9d6fb29743c655f2b555c7a8b91592beb62aa07227f08b54
MD5 82b2962f82b7c9fe9c1af45f80957f13
BLAKE2b-256 478977e1908e896f321915d7e37474efc41d3551a5054bdeb4306f15d6519010

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