bpp-phyl  2.2.0
bpp::BinarySubstitutionModel Class Reference

The Model on two states. More...

#include <Bpp/Phyl/Model/BinarySubstitutionModel.h>

+ Inheritance diagram for bpp::BinarySubstitutionModel:
+ Collaboration diagram for bpp::BinarySubstitutionModel:

Public Member Functions

 BinarySubstitutionModel (const BinaryAlphabet *alpha, double kappa=1.)
 
virtual ~BinarySubstitutionModel ()
 
BinarySubstitutionModelclone () const
 
double Pij_t (size_t i, size_t j, double d) const
 
double dPij_dt (size_t i, size_t j, double d) const
 
double d2Pij_dt2 (size_t i, size_t j, double d) const
 
const Matrix< double > & getPij_t (double d) const
 
const Matrix< double > & getdPij_dt (double d) const
 
const Matrix< double > & getd2Pij_dt2 (double d) const
 
std::string getName () const
 Get the name of the model. More...
 
void setFreq (std::map< int, double > &freqs)
 Set equilibrium frequencies. More...
 
size_t getNumberOfStates () const
 Get the number of states. More...
 
const Alphabet * getAlphabet () const
 
const StateMapgetStateMap () const
 
const std::vector< int > & getAlphabetStates () const
 
std::string getAlphabetStateAsChar (size_t index) const
 
int getAlphabetStateAsInt (size_t index) const
 
std::vector< size_t > getModelStates (int code) const
 Get the state in the model corresponding to a particular state in the alphabet. More...
 
std::vector< size_t > getModelStates (const std::string &code) const
 Get the state in the model corresponding to a particular state in the alphabet. More...
 
virtual const Vdouble & getFrequencies () const
 
const Matrix< double > & getGenerator () const
 
const Matrix< double > & getExchangeabilityMatrix () const
 
double Sij (size_t i, size_t j) const
 
const Vdouble & getEigenValues () const
 
const Vdouble & getIEigenValues () const
 
bool isDiagonalizable () const
 
bool isNonSingular () const
 
const Matrix< double > & getRowLeftEigenVectors () const
 
const Matrix< double > & getColumnRightEigenVectors () const
 
virtual double freq (size_t i) const
 
virtual double Qij (size_t i, size_t j) const
 
double getInitValue (size_t i, int state) const throw (IndexOutOfBoundsException, BadIntException)
 
void setFreqFromData (const SequenceContainer &data, double pseudoCount=0)
 Set equilibrium frequencies equal to the frequencies estimated from the data. More...
 
void enableEigenDecomposition (bool yn)
 Set if eigenValues and Vectors must be computed. More...
 
bool enableEigenDecomposition ()
 Tell if eigenValues and Vectors must be computed. More...
 
virtual void fireParameterChanged (const ParameterList &parameters)
 Tells the model that a parameter value has changed. More...
 
void addRateParameter ()
 
double getScale () const
 Get the scalar product of diagonal elements of the generator and the frequencies vector. If the generator is normalized, then scale=1. Otherwise each element must be multiplied by 1/scale. More...
 
void setScale (double scale)
 Multiplies the current generator by the given scale. More...
 
virtual double getRate () const
 Get the rate. More...
 
virtual void setRate (double rate)
 Set the rate of the model (must be positive). More...
 
virtual const FrequenciesSetgetFrequenciesSet () const
 If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0. More...
 

Protected Member Functions

void updateMatrices ()
 Compute and diagonalize the $Q$ matrix, and fill the eigenValues_, leftEigenVectors_ and rightEigenVectors_ matrices. More...
 

Protected Attributes

double lambda_
 
double exp_
 
RowMatrix< double > p_
 
const Alphabet * alphabet_
 The alphabet relevant to this model. More...
 
std::auto_ptr< StateMapstateMap_
 The map of model states with alphabet states. More...
 
size_t size_
 The size of the generator, i.e. the number of states. More...
 
double rate_
 The rate of the model (default: 1). The generator (and all its vectorial components) is independent of the rate, since it should be normalized. More...
 
RowMatrix< double > generator_
 The generator matrix $Q$ of the model. More...
 
Vdouble freq_
 The vector $\pi_e$ of equilibrium frequencies. More...
 
RowMatrix< double > exchangeability_
 The exchangeability matrix $S$ of the model, defined as $ S_{ij}=\frac{Q_{ij}}{\pi_j}$. When the model is reversible, this matrix is symetric. More...
 
RowMatrix< double > pijt_
 These ones are for bookkeeping: More...
 
RowMatrix< double > dpijt_
 
RowMatrix< double > d2pijt_
 
bool eigenDecompose_
 Tell if the eigen decomposition should be performed. More...
 
Vdouble eigenValues_
 The vector of eigen values. More...
 
Vdouble iEigenValues_
 The vector of the imaginary part of the eigen values. More...
 
bool isDiagonalizable_
 boolean value for diagonalizability in R of the generator_ More...
 
RowMatrix< double > rightEigenVectors_
 The $U^-1$ matrix made of right eigen vectors (by column). More...
 
bool isNonSingular_
 boolean value for non-singularity of rightEigenVectors_ More...
 
RowMatrix< double > leftEigenVectors_
 The $U$ matrix made of left eigen vectors (by row) if rightEigenVectors_ is non-singular. More...
 
std::vector< RowMatrix< double > > vPowGen_
 vector of the powers of generator_ for Taylor development (if rightEigenVectors_ is singular). More...
 
RowMatrix< double > tmpMat_
 For computational issues. More...
 

Private Attributes

double kappa_
 

Detailed Description

The Model on two states.

\[ Q = r.\begin{pmatrix} -\kappa & \kappa \\ 1 & -1 \\ \end{pmatrix} \]

\[ \pi = diag\left(\frac{1}{\kappa+1}, \frac{\kappa}{\kappa+1}\right) \]

Normalization: $r$ is set so that $\sum_i Q_{i,i}\pi_i = -1$:

\[ Q = \begin{pmatrix} -\frac{\kappa + 1}2 & \frac{\kappa + 1}2 \\ \frac{\kappa+1}{2\kappa} & -\frac{\kappa+1}{2\kappa}\\ \end{pmatrix} \]

The eigen values are $\left(0, - \frac{(\kappa+1)^2}{2\kappa}\right)$, and IF $\kappa \neq 1$, the left eigen vectors are, by row:

\[ U = \begin{pmatrix} \frac{1}{1+\kappa} & \frac{\kappa}{1+\kappa} \\ \frac{\kappa-1}{\kappa+1} & -\frac{\kappa-1}{\kappa+1} \\ \end{pmatrix} \]

and the right eigen vectors are by column:

\[ U^{-1} = \begin{pmatrix} 1 & \frac \kappa{\kappa-1} \\ 1 & - \frac 1{\kappa-1} \\ \end{pmatrix} \]

The probabilities of changes are computed analytically using the formulas, with $\lambda= \frac{(\kappa+1)^2}{2\kappa}$ :

\[ P_{i,j}(t) = \begin{pmatrix} \frac{1}{\kappa+1} + \frac{\kappa}{\kappa+1}e^{-\lambda t} & \frac{\kappa}{\kappa+1} - \frac{\kappa}{\kappa+1}e^{-\lambda t} \\ \frac{1}{\kappa+1} - \frac{1}{\kappa+1}e^{-\lambda t} & \frac{\kappa}{\kappa+1} + \frac{1}{\kappa+1}e^{-\lambda t} \\ \end{pmatrix} \]

\[ \frac{\partial P_{i,j}(t)}{\partial t} = \begin{pmatrix} -\frac {\kappa+1} 2 e^{-\lambda t} & \frac {\kappa+1} 2 e^{-\lambda t} \\ \frac {\kappa+1} {2\kappa} e^{-\lambda t} & - \frac {\kappa+1} {2\kappa} e^{-\lambda t} \\ \end{pmatrix} \]

\begin{multline*} \frac{\partial^2 P_{i,j}(t)}{\partial t^2} = \\ \begin{pmatrix} \frac {\lambda (\kappa+1)} 2 e^{-\lambda t} & -\ frac {\lambda (\kappa+1)} 2 e^{-\lambda t} \\ \frac {\lambda (\kappa+1)} {2\kappa} e^{-\lambda t} & - \frac {\lambda (\kappa+1)} {2\kappa} e^{-\lambda t} \\ \end{pmatrix} \end{multline*}

The parameter is named "kappa" and its value may be retrieve with the command

getParameterValue("kappa")

Definition at line 114 of file BinarySubstitutionModel.h.

Constructor & Destructor Documentation

◆ BinarySubstitutionModel()

BinarySubstitutionModel::BinarySubstitutionModel ( const BinaryAlphabet *  alpha,
double  kappa = 1. 
)

Definition at line 53 of file BinarySubstitutionModel.cpp.

References kappa_, and updateMatrices().

Referenced by clone().

◆ ~BinarySubstitutionModel()

virtual bpp::BinarySubstitutionModel::~BinarySubstitutionModel ( )
inlinevirtual

Definition at line 127 of file BinarySubstitutionModel.h.

Member Function Documentation

◆ addRateParameter()

void AbstractSubstitutionModel::addRateParameter ( )
virtualinherited

◆ clone()

BinarySubstitutionModel* bpp::BinarySubstitutionModel::clone ( ) const
inlinevirtual

◆ d2Pij_dt2()

double BinarySubstitutionModel::d2Pij_dt2 ( size_t  i,
size_t  j,
double  t 
) const
virtual
Returns
The second order derivative of the probability of change from state i to state j with respect to time t, at time t.
See also
getd2Pij_dt2(), getStates()

Reimplemented from bpp::AbstractSubstitutionModel.

Definition at line 170 of file BinarySubstitutionModel.cpp.

References exp_, kappa_, and lambda_.

◆ dPij_dt()

double BinarySubstitutionModel::dPij_dt ( size_t  i,
size_t  j,
double  t 
) const
virtual
Returns
The first order derivative of the probability of change from state i to state j with respect to time t, at time t.
See also
getdPij_dt(), getStates()

Reimplemented from bpp::AbstractSubstitutionModel.

Definition at line 144 of file BinarySubstitutionModel.cpp.

References exp_, kappa_, and lambda_.

◆ enableEigenDecomposition() [1/2]

void bpp::AbstractSubstitutionModel::enableEigenDecomposition ( bool  yn)
inlinevirtualinherited

Set if eigenValues and Vectors must be computed.

Implements bpp::SubstitutionModel.

Definition at line 289 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::eigenDecompose_.

◆ enableEigenDecomposition() [2/2]

◆ fireParameterChanged()

virtual void bpp::AbstractSubstitutionModel::fireParameterChanged ( const ParameterList &  parameters)
inlinevirtualinherited

◆ freq()

virtual double bpp::AbstractSubstitutionModel::freq ( size_t  i) const
inlinevirtualinherited
Returns
Equilibrium frequency associated to character i.
See also
getFrequencies(), getStates()

Implements bpp::SubstitutionModel.

Definition at line 275 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::freq_.

◆ getAlphabet()

◆ getAlphabetStateAsChar()

std::string bpp::AbstractSubstitutionModel::getAlphabetStateAsChar ( size_t  index) const
inlinevirtualinherited
Parameters
indexThe model state.
Returns
The corresponding alphabet state as character code.

Implements bpp::SubstitutionModel.

Definition at line 243 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::stateMap_.

◆ getAlphabetStateAsInt()

int bpp::AbstractSubstitutionModel::getAlphabetStateAsInt ( size_t  index) const
inlinevirtualinherited
Parameters
indexThe model state.
Returns
The corresponding alphabet state as character code.

Implements bpp::SubstitutionModel.

Definition at line 245 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::stateMap_.

◆ getAlphabetStates()

const std::vector<int>& bpp::AbstractSubstitutionModel::getAlphabetStates ( ) const
inlinevirtualinherited
Returns
The alphabet states of each state of the model, as a vector of int codes.
See also
Alphabet

Implements bpp::SubstitutionModel.

Definition at line 241 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::stateMap_.

◆ getColumnRightEigenVectors()

const Matrix<double>& bpp::AbstractSubstitutionModel::getColumnRightEigenVectors ( ) const
inlinevirtualinherited
Returns
A matrix with right eigen vectors. Each column in the matrix stands for an eigen vector.

Implements bpp::SubstitutionModel.

Definition at line 273 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::rightEigenVectors_.

◆ getd2Pij_dt2()

const Matrix< double > & BinarySubstitutionModel::getd2Pij_dt2 ( double  t) const
virtual
Returns
All second order derivatives of the probability of change from state i to state j with respect to time t, at time t.
See also
d2Pij_dt2()

Reimplemented from bpp::AbstractSubstitutionModel.

Definition at line 222 of file BinarySubstitutionModel.cpp.

References exp_, kappa_, lambda_, and p_.

◆ getdPij_dt()

const Matrix< double > & BinarySubstitutionModel::getdPij_dt ( double  t) const
virtual
Returns
Get all first order derivatives of the probability of change from state i to state j with respect to time t, at time t.
See also
dPij_dt()

Reimplemented from bpp::AbstractSubstitutionModel.

Definition at line 209 of file BinarySubstitutionModel.cpp.

References exp_, kappa_, lambda_, and p_.

◆ getEigenValues()

const Vdouble& bpp::AbstractSubstitutionModel::getEigenValues ( ) const
inlinevirtualinherited
Returns
A vector with all real parts of the eigen values of the generator of this model;

Implements bpp::SubstitutionModel.

Definition at line 263 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::eigenValues_.

◆ getExchangeabilityMatrix()

const Matrix<double>& bpp::AbstractSubstitutionModel::getExchangeabilityMatrix ( ) const
inlinevirtualinherited
Returns
The matrix of exchangeability terms. It is recommended that exchangeability matrix be normalized so that the normalized generator be obtained directly by the dot product $S . \pi$.

Implements bpp::SubstitutionModel.

Definition at line 255 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::exchangeability_.

◆ getFrequencies()

virtual const Vdouble& bpp::AbstractSubstitutionModel::getFrequencies ( ) const
inlinevirtualinherited
Returns
A vector of all equilibrium frequencies.
See also
freq()

Implements bpp::SubstitutionModel.

Definition at line 251 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::freq_.

◆ getFrequenciesSet()

◆ getGenerator()

const Matrix<double>& bpp::AbstractSubstitutionModel::getGenerator ( ) const
inlinevirtualinherited
Returns
The normalized Markov generator matrix, i.e. all normalized rates of changes from state i to state j. The generator is normalized so that (i) $ \forall i; \sum_j Q_{i,j} = 0 $, meaning that $ $ \forall i; Q_{i,i} = -\sum_{j \neq i}Q_{i,j}$, and (ii) $ \sum_i Q_{i,i} \times \pi_i = -1$. This means that, under normalization, the mean rate of replacement at equilibrium is 1 and that time $t$ are measured in units of expected number of changes per site. Additionnaly, the rate_ attibute provides the possibility to increase or decrease this mean rate.

See Kosiol and Goldman (2005), Molecular Biology And Evolution 22(2) 193-9.

See also
Qij()

Implements bpp::SubstitutionModel.

Definition at line 253 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::generator_.

◆ getIEigenValues()

const Vdouble& bpp::AbstractSubstitutionModel::getIEigenValues ( ) const
inlinevirtualinherited
Returns
A vector with all imaginary parts of the eigen values of the generator of this model;

Implements bpp::SubstitutionModel.

Definition at line 265 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::iEigenValues_.

◆ getInitValue()

double AbstractSubstitutionModel::getInitValue ( size_t  i,
int  state 
) const
throw (IndexOutOfBoundsException,
BadIntException
)
virtualinherited

This method is used to initialize likelihoods in reccursions. It typically sends 1 if i = state, 0 otherwise, where i is one of the possible states of the alphabet allowed in the model and state is the observed state in the considered sequence/site.

Parameters
ithe index of the state in the model.
stateAn observed state in the sequence/site.
Returns
1 or 0 depending if the two states are compatible.
Exceptions
IndexOutOfBoundsExceptionif array position is out of range.
BadIntExceptionif states are not allowed in the associated alphabet.
See also
getStates();

Implements bpp::SubstitutionModel.

Reimplemented in bpp::RE08.

Definition at line 349 of file AbstractSubstitutionModel.cpp.

◆ getModelStates() [1/2]

std::vector<size_t> bpp::AbstractSubstitutionModel::getModelStates ( int  code) const
inlinevirtualinherited

Get the state in the model corresponding to a particular state in the alphabet.

Parameters
codeThe alphabet state to check.
Returns
A vector of indices of model states.

Implements bpp::SubstitutionModel.

Definition at line 247 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::stateMap_.

◆ getModelStates() [2/2]

std::vector<size_t> bpp::AbstractSubstitutionModel::getModelStates ( const std::string &  code) const
inlinevirtualinherited

Get the state in the model corresponding to a particular state in the alphabet.

Parameters
codeThe alphabet state to check.
Returns
A vector of indices of model states.

Implements bpp::SubstitutionModel.

Definition at line 249 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::stateMap_.

◆ getName()

std::string bpp::BinarySubstitutionModel::getName ( ) const
inlinevirtual

Get the name of the model.

Returns
The name of this model.

Implements bpp::SubstitutionModel.

Definition at line 140 of file BinarySubstitutionModel.h.

◆ getNumberOfStates()

size_t bpp::BinarySubstitutionModel::getNumberOfStates ( ) const
inlinevirtual

Get the number of states.

For most models, this equals the size of the alphabet.

See also
getAlphabetChars for the list of supported states.
Returns
The number of different states in the model.

Implements bpp::SubstitutionModel.

Definition at line 144 of file BinarySubstitutionModel.h.

◆ getPij_t()

const Matrix< double > & BinarySubstitutionModel::getPij_t ( double  t) const
virtual
Returns
All probabilities of change from state i to state j during time t.
See also
Pij_t()

Reimplemented from bpp::AbstractSubstitutionModel.

Definition at line 196 of file BinarySubstitutionModel.cpp.

References exp_, kappa_, lambda_, and p_.

◆ getRate()

double AbstractSubstitutionModel::getRate ( ) const
virtualinherited

Get the rate.

Implements bpp::SubstitutionModel.

Definition at line 415 of file AbstractSubstitutionModel.cpp.

References bpp::AbstractSubstitutionModel::rate_.

◆ getRowLeftEigenVectors()

const Matrix<double>& bpp::AbstractSubstitutionModel::getRowLeftEigenVectors ( ) const
inlinevirtualinherited
Returns
A matrix with left eigen vectors. Each row in the matrix stands for an eigen vector.

Implements bpp::SubstitutionModel.

Definition at line 271 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::leftEigenVectors_.

◆ getScale()

double AbstractSubstitutionModel::getScale ( ) const
virtualinherited

Get the scalar product of diagonal elements of the generator and the frequencies vector. If the generator is normalized, then scale=1. Otherwise each element must be multiplied by 1/scale.

Returns
Minus the scalar product of diagonal elements and the frequencies vector.

Implements bpp::SubstitutionModel.

Definition at line 400 of file AbstractSubstitutionModel.cpp.

References bpp::AbstractSubstitutionModel::freq_, and bpp::AbstractSubstitutionModel::generator_.

Referenced by bpp::AbstractReversibleSubstitutionModel::updateMatrices().

◆ getStateMap()

const StateMap& bpp::AbstractSubstitutionModel::getStateMap ( ) const
inlinevirtualinherited
Returns
The mapping of model states with alphabet states.

Implements bpp::SubstitutionModel.

Definition at line 239 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::stateMap_.

◆ isDiagonalizable()

bool bpp::AbstractSubstitutionModel::isDiagonalizable ( ) const
inlinevirtualinherited
Returns
True if the model is diagonalizable in R.

Implements bpp::SubstitutionModel.

Definition at line 267 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::isDiagonalizable_.

◆ isNonSingular()

bool bpp::AbstractSubstitutionModel::isNonSingular ( ) const
inlinevirtualinherited
Returns
True is the model is non-singular.

Implements bpp::SubstitutionModel.

Definition at line 269 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::isNonSingular_.

◆ Pij_t()

double BinarySubstitutionModel::Pij_t ( size_t  i,
size_t  j,
double  t 
) const
virtual
Returns
The probability of change from state i to state j during time t.
See also
getPij_t(), getStates()

Reimplemented from bpp::AbstractSubstitutionModel.

Definition at line 118 of file BinarySubstitutionModel.cpp.

References exp_, kappa_, and lambda_.

◆ Qij()

virtual double bpp::AbstractSubstitutionModel::Qij ( size_t  i,
size_t  j 
) const
inlinevirtualinherited
Returns
The rate in the generator of change from state i to state j.
See also
getStates();

Implements bpp::SubstitutionModel.

Reimplemented in bpp::AbstractMixedSubstitutionModel.

Definition at line 277 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::generator_.

◆ setFreq()

void BinarySubstitutionModel::setFreq ( std::map< int, double > &  frequencies)
virtual

Set equilibrium frequencies.

Parameters
frequenciesThe map of the frequencies to use.

Reimplemented from bpp::AbstractSubstitutionModel.

Definition at line 236 of file BinarySubstitutionModel.cpp.

References kappa_, and updateMatrices().

◆ setFreqFromData()

void AbstractSubstitutionModel::setFreqFromData ( const SequenceContainer &  data,
double  pseudoCount = 0 
)
virtualinherited

Set equilibrium frequencies equal to the frequencies estimated from the data.

Parameters
dataThe sequences to use.
pseudoCountA quantity $\psi$ to add to adjust the observed values in order to prevent issues due to missing states on small data set. The corrected frequencies shall be computed as

\[ \pi_i = \frac{n_i+\psi}{\sum_j (f_j+\psi)} \]

Implements bpp::SubstitutionModel.

Reimplemented in bpp::JCprot, bpp::K80, bpp::RE08, bpp::JCnuc, bpp::UserProteinSubstitutionModel, bpp::WAG01, bpp::DSO78, bpp::JTT92, bpp::LG08, and bpp::Coala.

Definition at line 366 of file AbstractSubstitutionModel.cpp.

References bpp::AbstractSubstitutionModel::setFreq(), and bpp::AbstractSubstitutionModel::size_.

◆ setRate()

void AbstractSubstitutionModel::setRate ( double  rate)
virtualinherited

Set the rate of the model (must be positive).

Parameters
ratemust be positive.

Implements bpp::SubstitutionModel.

Reimplemented in bpp::AbstractMixedSubstitutionModel.

Definition at line 422 of file AbstractSubstitutionModel.cpp.

References bpp::AbstractSubstitutionModel::rate_.

Referenced by bpp::AbstractMixedSubstitutionModel::setRate().

◆ setScale()

void AbstractSubstitutionModel::setScale ( double  scale)
virtualinherited

Multiplies the current generator by the given scale.

Parameters
scalethe scale by which the generator is multiplied.

Implements bpp::SubstitutionModel.

Definition at line 409 of file AbstractSubstitutionModel.cpp.

References bpp::AbstractSubstitutionModel::generator_.

◆ Sij()

double bpp::AbstractSubstitutionModel::Sij ( size_t  i,
size_t  j 
) const
inlinevirtualinherited
Returns
The exchangeability between state i and state j.

By definition Sij(i,j) = Sij(j,i).

Implements bpp::SubstitutionModel.

Definition at line 257 of file AbstractSubstitutionModel.h.

References bpp::AbstractSubstitutionModel::exchangeability_.

◆ updateMatrices()

void BinarySubstitutionModel::updateMatrices ( )
protectedvirtual

Compute and diagonalize the $Q$ matrix, and fill the eigenValues_, leftEigenVectors_ and rightEigenVectors_ matrices.

The exchangeability_ matrix and freq_ vector must be initialized. This function computes the generator_ matrix with the formula

\[ Q = S \times \pi \]

where $Q$ is the generator matrix, $S$ is the exchangeability matrix and $Pi$ the diagonal matrix with frequencies.

The generator is then scaled so that

\[ \sum_i Q_{i,i} \times \pi_i = -1 \]

( $\pi_i$ are the equilibrium frequencies).

Eigen values and vectors are computed from the scaled generator and assigned to the eigenValues_, rightEigenVectors_ and leftEigenVectors_ variables.

Reimplemented from bpp::AbstractReversibleSubstitutionModel.

Definition at line 68 of file BinarySubstitutionModel.cpp.

References bpp::AbstractSubstitutionModel::eigenValues_, bpp::AbstractSubstitutionModel::freq_, bpp::AbstractSubstitutionModel::generator_, kappa_, lambda_, bpp::AbstractSubstitutionModel::leftEigenVectors_, bpp::AbstractSubstitutionModel::rate_, and bpp::AbstractSubstitutionModel::rightEigenVectors_.

Referenced by BinarySubstitutionModel(), and setFreq().

Member Data Documentation

◆ alphabet_

◆ d2pijt_

◆ dpijt_

RowMatrix<double> bpp::AbstractSubstitutionModel::dpijt_
mutableprotectedinherited

◆ eigenDecompose_

bool bpp::AbstractSubstitutionModel::eigenDecompose_
protectedinherited

◆ eigenValues_

◆ exchangeability_

◆ exp_

double bpp::BinarySubstitutionModel::exp_
mutableprotected

Definition at line 121 of file BinarySubstitutionModel.h.

Referenced by d2Pij_dt2(), dPij_dt(), getd2Pij_dt2(), getdPij_dt(), getPij_t(), and Pij_t().

◆ freq_

Vdouble bpp::AbstractSubstitutionModel::freq_
protectedinherited

The vector $\pi_e$ of equilibrium frequencies.

Definition at line 113 of file AbstractSubstitutionModel.h.

Referenced by bpp::AbstractSubstitutionModel::AbstractSubstitutionModel(), bpp::WordSubstitutionModel::completeMatrices(), bpp::Coala::computeEquilibriumFrequencies(), bpp::RE08::d2Pij_dt2(), bpp::RE08::dPij_dt(), bpp::DSO78::DSO78(), bpp::LG08::fireParameterChanged(), bpp::DSO78::fireParameterChanged(), bpp::JTT92::fireParameterChanged(), bpp::WAG01::fireParameterChanged(), bpp::UserProteinSubstitutionModel::fireParameterChanged(), bpp::JCprot::fireParameterChanged(), bpp::AbstractSubstitutionModel::freq(), bpp::RE08::getd2Pij_dt2(), bpp::RE08::getdPij_dt(), bpp::AbstractSubstitutionModel::getFrequencies(), bpp::RN95s::getPij_t(), bpp::RE08::getPij_t(), bpp::RN95::getPij_t(), bpp::AbstractSubstitutionModel::getScale(), bpp::JCprot::JCprot(), bpp::JTT92::JTT92(), bpp::LG08::LG08(), bpp::AbstractSubstitutionModel::operator=(), bpp::RN95s::Pij_t(), bpp::RE08::Pij_t(), bpp::RN95::Pij_t(), bpp::RE08::RE08(), bpp::UserProteinSubstitutionModel::readFromFile(), bpp::AbstractSubstitutionModel::setFreq(), bpp::LG08::setFreqFromData(), bpp::DSO78::setFreqFromData(), bpp::JTT92::setFreqFromData(), bpp::WAG01::setFreqFromData(), bpp::UserProteinSubstitutionModel::setFreqFromData(), bpp::JCprot::setFreqFromData(), bpp::AbstractWordSubstitutionModel::updateMatrices(), bpp::gBGC::updateMatrices(), bpp::L95::updateMatrices(), bpp::SSR::updateMatrices(), bpp::MixtureOfASubstitutionModel::updateMatrices(), updateMatrices(), bpp::RN95s::updateMatrices(), bpp::MixtureOfSubstitutionModels::updateMatrices(), bpp::YpR::updateMatrices(), bpp::GTR::updateMatrices(), bpp::RN95::updateMatrices(), bpp::TN93::updateMatrices(), bpp::JCnuc::updateMatrices(), bpp::K80::updateMatrices(), bpp::T92::updateMatrices(), bpp::RE08::updateMatrices(), bpp::HKY85::updateMatrices(), bpp::F84::updateMatrices(), bpp::JCprot::updateMatrices(), bpp::AbstractSubstitutionModel::updateMatrices(), bpp::AbstractReversibleSubstitutionModel::updateMatrices(), bpp::UserProteinSubstitutionModel::UserProteinSubstitutionModel(), and bpp::WAG01::WAG01().

◆ generator_

◆ iEigenValues_

◆ isDiagonalizable_

◆ isNonSingular_

◆ kappa_

double bpp::BinarySubstitutionModel::kappa_
private

◆ lambda_

double bpp::BinarySubstitutionModel::lambda_
mutableprotected

◆ leftEigenVectors_

◆ p_

RowMatrix<double> bpp::BinarySubstitutionModel::p_
mutableprotected

Definition at line 122 of file BinarySubstitutionModel.h.

Referenced by getd2Pij_dt2(), getdPij_dt(), and getPij_t().

◆ pijt_

RowMatrix<double> bpp::AbstractSubstitutionModel::pijt_
mutableprotectedinherited

◆ rate_

double bpp::AbstractSubstitutionModel::rate_
protectedinherited

The rate of the model (default: 1). The generator (and all its vectorial components) is independent of the rate, since it should be normalized.

Definition at line 103 of file AbstractSubstitutionModel.h.

Referenced by bpp::AbstractSubstitutionModel::addRateParameter(), bpp::RN95s::d2Pij_dt2(), bpp::JCnuc::d2Pij_dt2(), bpp::TN93::d2Pij_dt2(), bpp::RN95::d2Pij_dt2(), bpp::K80::d2Pij_dt2(), bpp::T92::d2Pij_dt2(), bpp::JCprot::d2Pij_dt2(), bpp::HKY85::d2Pij_dt2(), bpp::F84::d2Pij_dt2(), bpp::RN95s::dPij_dt(), bpp::JCnuc::dPij_dt(), bpp::TN93::dPij_dt(), bpp::RN95::dPij_dt(), bpp::K80::dPij_dt(), bpp::T92::dPij_dt(), bpp::JCprot::dPij_dt(), bpp::HKY85::dPij_dt(), bpp::F84::dPij_dt(), bpp::WordSubstitutionModel::getd2Pij_dt2(), bpp::RN95s::getd2Pij_dt2(), bpp::JCnuc::getd2Pij_dt2(), bpp::TN93::getd2Pij_dt2(), bpp::RN95::getd2Pij_dt2(), bpp::K80::getd2Pij_dt2(), bpp::T92::getd2Pij_dt2(), bpp::JCprot::getd2Pij_dt2(), bpp::F84::getd2Pij_dt2(), bpp::HKY85::getd2Pij_dt2(), bpp::AbstractSubstitutionModel::getd2Pij_dt2(), bpp::WordSubstitutionModel::getdPij_dt(), bpp::RN95s::getdPij_dt(), bpp::JCnuc::getdPij_dt(), bpp::TN93::getdPij_dt(), bpp::RN95::getdPij_dt(), bpp::K80::getdPij_dt(), bpp::T92::getdPij_dt(), bpp::JCprot::getdPij_dt(), bpp::F84::getdPij_dt(), bpp::HKY85::getdPij_dt(), bpp::AbstractSubstitutionModel::getdPij_dt(), bpp::WordSubstitutionModel::getPij_t(), bpp::RN95s::getPij_t(), bpp::JCnuc::getPij_t(), bpp::TN93::getPij_t(), bpp::RN95::getPij_t(), bpp::K80::getPij_t(), bpp::T92::getPij_t(), bpp::JCprot::getPij_t(), bpp::F84::getPij_t(), bpp::HKY85::getPij_t(), bpp::AbstractSubstitutionModel::getPij_t(), bpp::AbstractSubstitutionModel::getRate(), bpp::AbstractMixedSubstitutionModel::normalizeVRates(), bpp::AbstractSubstitutionModel::operator=(), bpp::RN95s::Pij_t(), bpp::JCnuc::Pij_t(), bpp::TN93::Pij_t(), bpp::RN95::Pij_t(), bpp::K80::Pij_t(), bpp::T92::Pij_t(), bpp::JCprot::Pij_t(), bpp::F84::Pij_t(), bpp::HKY85::Pij_t(), bpp::AbstractMixedSubstitutionModel::setRate(), bpp::AbstractSubstitutionModel::setRate(), and updateMatrices().

◆ rightEigenVectors_

◆ size_

◆ stateMap_

◆ tmpMat_

◆ vPowGen_


The documentation for this class was generated from the following files: