Skip to main content

torchtree-physher

Testing License: GPL v3

About torchtree-physher

torchtree-physher is a python package providing fast gradient calculation implemented in physher for torchtree.

Getting Started

A C++ compiler such as g++ or clang++ is required. On Debian-based systems, this can be installed via apt:

sudo apt install g++

On MacOS, it is recommended to use the latest version of clang++:

brew install llvm

The pybind11 library is also used for binding the C++ functionality to Python.

Dependencies

physher is a phylogenetic program written in C that provides C++ wrappers to compute the tree and coalescent likelihoods and their gradients under different models.

To build physher from source you can run

git clone https://github.com/4ment/physher
cmake -S physher/ -B physher/build -DBUILD_CPP_WRAPPER=on -DBUILD_TESTING=on
cmake --build physher/build/ --target install

Check it works (optional)

ctest --test-dir physher/build/

Installation

To build torchtree-physher from source you can run

git clone https://github.com/4ment/torchtree-physher
pip install torchtree-physher/

Check install

If the installation was successful, this command should print the version of the torchtree_physher library

python -c "import torchtree_physher;print(torchtree_physher.__version__)"

Command line arguments

The torchtree-physher plugin adds these arguments to the torchtree CLI:

torchtree-cli advi --help
  ...
  --physher             use physher
  --physher_include_jacobian
                        include Jacobian of the node height transform in the node height gradient
  --physher_disable_sse
                        disable SSE in physher
  --physher_disable_coalescent
                        disable coalescent calculation by physher
  --physher_site {weibull,gamma}
                        distribution for rate heterogeneity across sites

Features

Tree likelihood

Some types in the JSON configuration file have to be replaced in order to use the tree likelihood implementation of physher. You simply need to add torchtree_physher. before a model type. Here is a list of models implemented in this plugin:

  • TreeLikelihoodModel
  • Substitution models:
    • JC69
    • HKY
    • GTR
    • GeneralNonSymmetricSubstitutionModel
  • Tree models:
    • UnRootedTreeModel
    • ReparameterizedTimeTreeModel
  • Clock models (optional):
    • StrictClockModel
    • SimpleClockModel
  • Site models:
    • ConstantSiteModel
    • GammaSiteModel
    • InvariantSiteModel
    • WeibullSiteModel

Note that the type of every sub-model of the tree likelihood object (e.g. site, tree models...) has to be replaced.

For example if we want to use ADVI with an unrooted tree and a Weibull site model:

torchtree-cli advi -i data.fa -t data.tree -C 4 > data.json
sed -i -E 's/TreeLikelihoodModel/torchtree_physher.TreeLikelihoodModel/; s/UnRootedTreeModel/torchtree_physher.UnRootedTreeModel/; s/WeibullSiteModel/torchtree_physher.WeibullSiteModel/' data.json
torchtree data.json

The JSON file can be created directly using the --physher option:

torchtree-cli advi -i data.fa -t data.tree -C 4 --physher > data.json

Coalescent models

Here is a list of coalescent models implemented in this plugin:

  • ConstantCoalescentModel
  • PiecewiseConstantCoalescentGridModel (aka skygrid)
  • PiecewiseConstantCoalescentModel (aka skyride)
  • PiecewiseLinearCoalescentGridModel

License

Distributed under the GPLv3 License. See LICENSE for more information.

Acknowledgements

torchtree-physher makes use of the following libraries and tools, which are under their own respective licenses:

Metadata

Release files for torchtree-physher 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchtree-physher 1.0.0
File Size Uploaded Provenance Actions
torchtree-physher-1.0.0.tar.gz 32.4 kB Without provenance Details for torchtree-physher-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torchtree-physher 1.0.0
File Interpreter ABI Platform Actions
torchtree_physher-1.0.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for torchtree_physher-1.0.0-cp312-cp312-macosx_11_0_arm64.whl

Total release size: 209.3 kB

Release files / torchtree-physher-1.0.0.tar.gz

Download URL torchtree-physher-1.0.0.tar.gz
Size 32.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1f84064326b6e490871f0279243af62d78390bd6b67e2444d7825279f27323e9
BLAKE2b-256 checksum
How to use checksums
4af2aeef673bca12a5bc12a5d97895f9406e919c4dc39c63e2ac9a11ca8aee3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Release files / torchtree_physher-1.0.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL torchtree_physher-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Size 176.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ff497093f473c000c1e24ae25c76bda0f14161e8713a6117ff88e15669d46fda
BLAKE2b-256 checksum
How to use checksums
ef418c3be80ab9227f7a871847190340d4223b1643fa2cf7af42c2bfd47c273d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.9.18

Security for torchtree-physher 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page