Welcome to bito’s documentation!¶
This is the documentation for interacting with bito from Python. See the README on the bito GitHub repository for installation and general description.
For conceptual background, see
Python API¶
The design principle here is that as much as is efficient to be in Python. So, we want Python users to be able to do everything needed to fit models, while having all of the tree manipulation and traversal happen in C++. This does mean a reasonable amount is in C++, though: for example, if we want efficient gradients for phylogenetic model parameters, the C++ needs to have data structures for these models.
From the perspective of a Python user, code is broken into two packages:
bito
is the direct interface to the C++ code; this module is generated by pybind11.vip
has all of the Python code; this module contains code to infer model parameters and do complete calculations.
A typical workflow looks like:
Load some collection of trees into the
bito
tree cache that define the SBN supportParse those trees to get the SBN support
Given this collection of trees,
bito
sets up data structures to hold SBN model parametersInitialize a phylogenetic model in
bito
and set parametersSample trees given the SBN model parameters (these get stored in the
bito
tree cache, over-writing the previously-cached trees)Set branch lengths for these trees according to some model (
bito
makes branch length vectors accessible as NumPy arrays)Evaluate model likelihoods and gradients in
bito
Modify parameters and go back to 5.
The vip
module facilitates this loop, both by having code that calls bito
, but also by having models for the bito
parameters.
For example, bito
doesn’t have a data structure that contains a model of branch lengths— it only has a way of setting the branch lengths.
Thus vip
has branch length models, including models based on split and primary subsplit pairs (PSPs).
On the other hand, bito
has a lot of functionality that make these models easy to put together on the Python side, such as the PSPIndexer
that gives the indices needed to do PSP model calculations.
Thus, there are typically two levels of state: the “raw” parameters in the bito
module, and the parameters of models of those bito
parameters, which is contained in vip
.
vip
also contains routines for running and benchmarking inference.
Erick’s suggestions for learning the Python API¶
Learn a little about the
bito
module by looking attest/test_bito.py
and running it viapytest -s test/test_bito.py
.Learn about the
vip
data structures by reading the vip.burrito code and its dependencies. You can find additional usage examples by looking at the tests in thevip/test
directory.Get an idea of how to use the burrito module by reading the vip.benchmark code.
Modules¶
Python interface to bito. |
|
Flags that can be passed to BEAGLE. |
|
Methods for running and benchmarking performance. |
|
Classes for modeling phylogenetic branch lengths. |
|
The Burrito class wraps an instance and relevant model data. |
|
The |
|
Classes that perform optimization and contain relevant state. |
|
Branch length priors. |
|
Stub (unimplemented) class for SBN modeling. |
|
Classes to model scalar quantities with various distributions. |
|
Module for doing stochastic gradient descent. |