Skip to content

Commit 279e6db

Browse files
committed
More doc
1 parent bb22ba7 commit 279e6db

File tree

8 files changed

+211
-1
lines changed

8 files changed

+211
-1
lines changed

.github/workflows/publish_branch.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Publish the documentation on a branch
2+
3+
on:
4+
push:
5+
branches:
6+
- improve-documentation
7+
8+
jobs:
9+
publish:
10+
name: Publish
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout the branch
14+
uses: actions/checkout@v2.3.1
15+
with:
16+
persist-credentials: false
17+
18+
- name: Set up Python 3.9
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: 3.9
22+
- name: Build the documentation with Sphinx
23+
run: |
24+
pip install -r docs/requirements.txt
25+
sphinx-build -b html docs docs/build/html
26+
27+
- name: Publish the documentation
28+
uses: JamesIves/github-pages-deploy-action@3.6.2
29+
with:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
BRANCH: gh-pages
32+
FOLDER: docs/build/html
33+
target-folder: improve-documentation
34+
CLEAN: false

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99

1010
torchtree is a program designed for developing and inferring phylogenetic models. 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.
1111

12+
For a comprehensive assessment of torchtree's performance and use cases, please see our evaluation repository, [torchtree-experiments](https://github.com/4ment/torchtree-experiments), where torchtree was rigorously tested on various datasets and benchmarked for accuracy and speed.
13+
14+
1215
- [Getting Started](#getting-started)
1316
- [Dependencies](#dependencies)
1417
- [Installation](#installation)
1518
- [Quick start](#quick-start)
16-
- [Documentatoin](#documentation)
19+
- [Documentation](#documentation)
1720
- [Plug-ins](#torchtree-plug-in)
1821

1922
## Getting Started
@@ -84,6 +87,23 @@ torchtree can be easily extended without modifying the code base thanks its modu
8487

8588
A GitHub [template](https://github.com/4ment/torchtree-plugin-template) is available to assist in the development of a plug-in, and it is highly recommended to use it. This template provides a structured starting point, ensuring consistency and compatibility with `torchtree` while streamlining the development process.
8689

90+
## How to cite
91+
92+
If you use torchtree, please consider citing:
93+
94+
```
95+
96+
@misc{fourment2024torchtree,
97+
title={torchtree: flexible phylogenetic model development and inference using {PyTorch}},
98+
author={Mathieu Fourment and Matthew Macaulay and Christiaan J Swanepoel and Xiang Ji and Marc A Suchard and Frederick A Matsen IV},
99+
year={2024},
100+
eprint={2406.18044},
101+
archivePrefix={arXiv},
102+
primaryClass={q-bio.PE},
103+
url={https://arxiv.org/abs/2406.18044}
104+
}
105+
```
106+
87107
## License
88108

89109
Distributed under the GPLv3 License. See [LICENSE](LICENSE) for more information.

docs/advanced/benchmark.rst

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Benchmark
2+
=========
3+
4+
The `torchtree` software was evaluated alongside other phylogenetic tools in a published `benchmark study <https://github.com/4ment/gradient-benchmark>`_ [#Fourment2022]_.
5+
6+
This benchmark assesses the memory usage and speed of various gradient implementations for phylogenetic models, including tree likelihood and coalescent models.
7+
The study's aim was to compare the efficiency of automatic differentiation (AD) and analytic gradient methods.
8+
The gradient of the tree likelihood can be computed by `BITO <https://github.com/phylovi/bito>`_ or `physher <https://github.com/4ment/physher>`_ [#Fourment2014]_, efficient C++ and C libraries that analytically calculate the gradient.
9+
`torchtree` integrates with these libraries through the `torchtree-bito <https://github.com/4ment/torchtree-bito>`_ and `torchtree-physher <https://github.com/4ment/torchtree-physher>`_ plug-ins.
10+
11+
.. list-table:: Programs compared in the benchmark
12+
:header-rows: 1
13+
14+
* - Program
15+
- Language
16+
- Framework
17+
- Gradient
18+
- Libraries
19+
* - `physher <https://github.com/4ment/physher>`_
20+
- C
21+
-
22+
- analytic
23+
-
24+
* - `phylostan <https://github.com/4ment/phylostan>`_ [#Fourment2019]_
25+
- Stan
26+
- Stan
27+
- AD
28+
-
29+
* - `phylojax <https://github.com/4ment/phylojax>`_
30+
- python
31+
- JAX
32+
- AD
33+
-
34+
* - `torchtree <https://github.com/4ment/torchtree>`_
35+
- python
36+
- PyTorch
37+
- AD
38+
- BITO and physher
39+
* - `treeflow <https://github.com/christiaanjs/treeflow>`_
40+
- python
41+
- TensorFlow
42+
- AD
43+
-
44+
45+
In this study, we compared six gradient implementations of the phylogenetic likelihood functions, in isolation and also as part of a variational inference procedure.
46+
The data consisted of a collection of influenza A datasets ranging from 20 to 2000 sequences sampled from 2011 to 2013.
47+
48+
This macrobenchmark simulates the core steps of a real phylogenetic inference algorithm but simplifies the model to make it easier to implement across different frameworks.
49+
In this setup, we are estimating parameters of time tree under a strict clock with a constant-size coalescent model.
50+
Each implementation relies on automatic differentiation variational inference (ADVI) to maximize the evidence lower bound (ELBO) over 5,000 iterations.
51+
We specify an exponential prior (mean = 0.001) on the substitution rate and the Jeffrey's prior for the unknown population size.
52+
53+
.. figure:: images/benchmark-macro-time.png
54+
:align: center
55+
:alt: Speed of implementations for 5,000 iterations of variational time-tree inference with a strict clock
56+
57+
Speed of implementations for 5,000 iterations of variational time-tree inference with a strict clock.
58+
59+
As shown in the next figure, the relative performance of AD depends on the task.
60+
61+
.. figure:: images/benchmark-micro-time.png
62+
:align: center
63+
:alt: Speed of implementations for the gradient of various tasks needed for inference
64+
65+
Speed of implementations for the gradient of various tasks needed for inference.
66+
67+
.. [#Fourment2022] Fourment M, Swanepoel CJ, Galloway JG, Ji X, Gangavarapu K, Suchard MA, Matsen IV FA. Automatic differentiation is no panacea for phylogenetic gradient computation. *Genome Biology and Evolution*, 2023. doi:`10.1093/gbe/evad099 <https://doi.org/10.1093/gbe/evad099>`_ `arXiv:2211.02168 <https://arxiv.org/abs/2211.02168>`_
68+
69+
.. [#Fourment2014] Fourment M and Holmes EC. Novel non-parametric models to estimate evolutionary rates and divergence times from heterochronous sequence data. *BMC Evolutionary Biology*, 2014. doi:`10.1186/s12862-014-0163-6 <https://doi.org/10.1186/s12862-014-0163-6>`_
70+
71+
.. [#Fourment2019] Fourment M and Darling AE. Evaluating probabilistic programming and fast variational Bayesian inference in phylogenetics. *PeerJ*, 2019. doi:`10.7717/peerj.8272 <https://doi.org/10.7717/peerj.8272>`_
33 KB
Loading
64.5 KB
Loading

docs/getting_started/features.rst

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
Features
2+
========
3+
4+
Phylogenetic models
5+
-------------------
6+
7+
**Tree model:**
8+
9+
- unrooted tree with branches lengths representing expected number of substitutions.
10+
- Time (rooted) tree with branch lengths representing units of time.
11+
12+
**Substitution model:**
13+
14+
- Nucleotide models: JC69, HKY, GTR, SRD06. Any model nested within the GTR model using :py:class:`~torchtree.evolution.substitution_model.general.GeneralSymmetricSubstitutionModel`.
15+
- Amino acid models: LG and WAG.
16+
- Codon model: Muse and Gaut (MG94).
17+
- Any discrete trait model (e.g. phylogeography model).
18+
19+
**Rate heterogeneity across site:** Constant, proportion of invariant sites, discretized Weibull distribution.
20+
21+
**Molecular clock:** strict and variable (i.e. one rate per branch).
22+
23+
Phylogenetic priors
24+
-------------------
25+
26+
27+
**Unrooted tree branch lengths:**
28+
29+
- Exponential distribution (any appropriate distribution).
30+
- Compound gamma-Dirichlet prior.
31+
32+
**Time tree:**
33+
34+
- Coalescent:
35+
36+
- Constant and exponential growth population size.
37+
- Piecewise functions: skyride, skygrid (piecewise-constant on a grid), and skyglide (piecewise-linear on a grid).
38+
39+
- Birth-death: constant, exponential, and BDSKY.
40+
41+
**Molecular clock:**
42+
43+
- Strict: CTMC reference prior.
44+
- Variable: uncorrelated and correlated.
45+
46+
47+
Inference algorithms
48+
--------------------
49+
50+
**Variational Inference:**
51+
52+
- Automatic Differentiation Variational Inference (ADVI).
53+
54+
**Markov chain Monte Carlo (MCMC):**
55+
56+
- Vanilla MCMC.
57+
- Hamiltonian Monte Carlo (HMC).
58+
59+
**Optimization:**
60+
61+
- Maximum *a posteriori* (MAP).
62+
- Maximum likelihood.
63+
50.3 KB
Loading

docs/index.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,34 @@ torchtree can be easily extended without modifying the code base thanks its modu
4343
.. _bito: https://github.com/phylovi/bito
4444

4545

46+
How to cite
47+
-----------
48+
49+
.. tabs::
50+
51+
.. tab:: Cite
52+
53+
Mathieu Fourment, Matthew Macaulay, Christiaan J Swanepoel, Xiang Ji, Marc A Suchard and Frederick A Matsen IV. *torchtree: flexible phylogenetic model development and inference using PyTorch*, 2024 `arXiv:2406.18044 <https://arxiv.org/abs/2406.18044>`_
54+
55+
.. code-tab:: bibtex
56+
57+
@misc{fourment2024torchtree,
58+
title={torchtree: flexible phylogenetic model development and inference using {PyTorch}},
59+
author={Mathieu Fourment and Matthew Macaulay and Christiaan J Swanepoel and Xiang Ji and Marc A Suchard and Frederick A Matsen IV},
60+
year={2024},
61+
eprint={2406.18044},
62+
archivePrefix={arXiv},
63+
primaryClass={q-bio.PE},
64+
url={https://arxiv.org/abs/2406.18044}
65+
}
4666

4767
.. toctree::
4868
:maxdepth: 1
4969
:caption: Getting Started
5070

5171
getting_started/install.rst
5272
getting_started/quick_start.rst
73+
getting_started/features.rst
5374
getting_started/json_reference.rst
5475

5576

@@ -59,6 +80,7 @@ torchtree can be easily extended without modifying the code base thanks its modu
5980

6081
advanced/concepts.rst
6182
advanced/tree_likelihood.rst
83+
advanced/benchmark.rst
6284

6385
.. toctree::
6486
:hidden:

0 commit comments

Comments
 (0)