torchtree is a program designed for inferring phylogenetic trees from molecular sequences. Implemented in Python, it leverages PyTorch for automatic differentiation. The suite of inference algorithms encompasses variational inference, Hamiltonian Monte Carlo, maximum a posteriori, and Markov chain Monte Carlo.
Use an Anaconda environment (Optional)
conda env create -f environment.yml
conda activate torchtree
To install the latest stable version you can run
pip install torchtree
To build torchtree from source you can run
git clone https://github.com/4ment/torchtree
pip install torchtree/
Check install
torchtree --help
torchtree
requires a JSON file containing models and algorithms. A configuration file can be generated using torchtree-cli
, a command line-based tool. This two-step process allows the user to adjust values in the configuration file, such as hyperparameters.
Some examples of models using variational inference:
W4 refers to a site model with 4 rates categories coming from a discretized Weibull distribution. This is similar to the more commonly used discretized Gamma distribution site model.
torchtree-cli advi -i data/fluA.fa -t data/fluA.tree -m GTR -C 4 > fluA.json
torchtree-cli advi -i data/fluA.fa -t data/fluA.tree -m JC69 --clock strict --coalescent constant > fluA.json
This will generate sample.csv
and sample.trees
files containing parameter and tree samples drawn from the variational distribution
torchtree fluA.json
torchtree can be easily extended without modifying the code base thanks its modular implementation. Some examples of external packages
Distributed under the GPLv3 License. See LICENSE for more information.
torchtree makes use of the following libraries and tools, which are under their own respective licenses: