package phylogenetics

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Likelihood calculations for continuous-time Markov chain along a tree

This module implements several variants of the so-called pruning algorithm, as well as functions to sample substitution mappings conditionally on leaf values.

type matrix_decomposition = [ `Mat of Linear_algebra.mat | `Transpose of Linear_algebra.mat | `Diag of Linear_algebra.vec ] list

The type matrix_decomposition represents a product of matrices. In the case that the product is eventually applied to a vector, it is faster to perform a series of matrix-vector products than computing the product of matrices.

  • The constructor `Mat of mat represents a matrix without any decomposition.
  • The constructor `Transpose of mat represents the transpose of a matrix.
  • The constructor `Diag of vec represents a diagonal matrix.

Example usage:

let decomposition = [
  `Mat matrix1;
  `Transpose matrix2;
  `Diag vector1;
] in

let result = matrix_decomposition_reduce ~dim:3 decomposition in
(* process_result result ...*)
val matrix_decomposition_reduce : dim:int -> matrix_decomposition -> Linear_algebra.mat

matrix_decomposition_reduce dim md computes the product of elements in md as a single matrix of dimension dim.

type shifted_vector =
  1. | SV of Linear_algebra.vec * float
    (*

    〚SV (v, carry)〛= 〚v〛. exp(〚carry〛)

    *)
module SV : sig ... end
val pruning : ('n, 'l, 'b) Tree.t -> nstates:int -> transition_probabilities:('b -> matrix_decomposition) -> leaf_state:('l -> int) -> root_frequencies:Linear_algebra.vec -> float

pruning t ~nstates ~transition_probabilities ~leaf_state ~root_frequencies returns the probability of observing the states returned by leaf_state at the leaves of t given the CTMC specified by nstates, transition_probabilities and root_frequencies.

val pruning_with_missing_values : ('n, 'l, 'b) Tree.t -> nstates:int -> transition_probabilities:('b -> matrix_decomposition) -> leaf_state:('l -> int option) -> root_frequencies:Linear_algebra.vec -> float

pruning t ~nstates ~transition_probabilities ~leaf_state ~root_frequencies returns the probability of observing the states returned by leaf_state at the leaves of t given the CTMC specified by nstates, transition_probabilities and root_frequencies. With this variant, one can specify that some leaves are unobserved.

val conditional_likelihoods : ('n, 'l, 'b) Tree.t -> nstates:int -> leaf_state:('l -> int) -> transition_probabilities:('b -> Linear_algebra.mat) -> (shifted_vector, int, 'b * Linear_algebra.mat) Tree.t

conditional_likelihoods t ~nstates ~leaf_state ~transition_probabilities computes the conditional likelihoods of observing the states returned by leaf_state at the leaves of t given the CTMC specified by nstates and transition_probabilities.

val conditional_simulation : Gsl.Rng.t -> (shifted_vector, int, 'b * Linear_algebra.mat) Tree.t -> root_frequencies:Linear_algebra.vec -> (int, int, 'b * Linear_algebra.mat) Tree.t

conditional_simulation rng tree ~root_frequencies performs a conditional simulation on the provided tree given the root_frequencies using the provided random number generator rng.

module Ambiguous : sig ... end

In this variant implementation, one can specify some uncertainty for a given leaf, by letting leaf_state return true for several states. In that case, it is understood that each state has equal probability. If leaf_state always returns false for a given leaf, it is interpreted as the leaf being unobserved.

module Uniformized_process : sig ... end
module Path_sampler : sig ... end
val substitution_mapping : rng:Gsl.Rng.t -> path_sampler:('b -> Path_sampler.t) -> (int, int, 'b * Linear_algebra.mat) Tree.t -> (int, int, 'b * (int * float) array) Tree.t
OCaml

Innovation. Community. Security.