matrix_builder Module

This module will generate the Markov chain’s instantaneous rate matrix, Q.

class matrix_builder.MatrixBuilder(model_type, parameters)

Bases: object

Parent class for model instantaneous matrix creation.

Child class include the following:
  1. AminoAcid_Matrix
    • Empirical amino acid models
  2. Nucleotide_Matrix
    • Nucleotide models (GTR and nested)
  3. MechCodon_Matrix
    • So-called mechanistic codon models, which include GY-style and MG-style models (dN/dS models)
  4. ECM_Matrix
    • ECM (Kosiol2007) empirical codon model
  5. MutSel_Matrix
    • Mutation-selection model (Halpern and Bruno 1998), extended for either codon or nucleotides
Requires two positional argument:
  1. model_type, the type of model which will be built
  2. parameters, a dictionary containing parameters about the substitution process which will be checked.
class matrix_builder.AminoAcid_Matrix(*args)

Bases: matrix_builder.MatrixBuilder

Child class of MatrixBuilder. This class implements functions relevant to constructing amino acid model instantaneous matrices. Note that all empirical amino acid replacement matrices are in the file empirical_matrices.py.

class matrix_builder.Nucleotide_Matrix(*args)

Bases: matrix_builder.MatrixBuilder

Child class of MatrixBuilder. This class implements functions relevant to constructing nucleotide model instantaneous matrices. All models computed here are essentially nested versions of GTR.

class matrix_builder.MechCodon_Matrix(*args)

Bases: matrix_builder.MatrixBuilder

Child class of MatrixBuilder. This class implements functions relevant to “mechanistic” (dN/dS) codon models. Models include both GY-style or MG-style varieties, although users should always specify codon frequencies to class instance! Both dS and dN variation are allowed, as are GTR mutational parameters (not strictly HKY85).

class matrix_builder.MutSel_Matrix(*args)

Bases: matrix_builder.MatrixBuilder

Child class of MatrixBuilder. This class implements functions relevant to constructing mutation-selection balance model instantaneous matrices, according to the HalpernBruno 1998 model. Here, this model is extended such that it can be used for either nucleotide or codon. This class will automatically detect which one you want based on the provided state frequencies or fitness values.

class matrix_builder.ECM_Matrix(*args)

Bases: matrix_builder.MatrixBuilder

Child class of MatrixBuilder. This class implements functions relevant to constructing a matrix specifically for the ECM (described in Kosiol2007) model. We support both restricted (instantaneous single changes only) and unrestricted (instantaneous single, double, or triple) versions of this model (see paper for details).

!!! NOTE: The ECM model supports omega (dN/dS) and kappa (TI/TV) ratios in their calculations, and therefore I have included these parameters here. HOWEVER, I do NOT recommend their use.