substmodel_belief_propagation.tppl
function compute_postorder_message
Compute postorder messages on the observed tree
function compute_postorder_message(tree: GTR_Tree, data: Int[][], q: Matrix[Real]) => Matrix[Real][]
function get_leaf_message
Get message from leaves for each site
function get_leaf_message(seq: Int) => Matrix[Real]
function get_log_likes
Compute log likelihood for each site
function get_log_likes(msg: Matrix[Real], pi_col: Matrix[Real]) => Real
function gtr
A help function to compute the scaled rate matrix for GTR
function gtr(pi: Real[], r: Real[]) => Matrix[Real]
type GTR_Tree
type GTR_Tree =
| Leaf {age: Real, index: Int}
| Node {age: Real, left: GTR_Tree, right: GTR_Tree}
function message
A simple help function to compute a message for a branch in the tree in a postorder traversal towards the root. We assume standard conventions here for the structure of q with respect to time (rows = from-states)
function message(start_msg: Matrix[Real][], q: Matrix[Real], time: Real) => Matrix[Real][]
function myModel
MODEL clock_rate not needed in this version
model function myModel(data: Int[][], tree: GTR_Tree) => TheReturn
type TheReturn
type TheReturn = TheReturn{stationary_probs: Real[], exchangeability_rates: Real[]}