bpp-phyl  2.2.0
bpp::AbstractSubstitutionModel Class Referenceabstract

Partial implementation of the SubstitutionModel interface. More...

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

+ Inheritance diagram for bpp::AbstractSubstitutionModel:
+ Collaboration diagram for bpp::AbstractSubstitutionModel:

Public Member Functions

 AbstractSubstitutionModel (const Alphabet *alpha, StateMap *stateMap, const std::string &prefix)
 
 AbstractSubstitutionModel (const AbstractSubstitutionModel &model)
 
AbstractSubstitutionModeloperator= (const AbstractSubstitutionModel &model)
 
virtual ~AbstractSubstitutionModel ()
 
virtual AbstractSubstitutionModelclone () const =0
 
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
 
virtual const Matrix< double > & getPij_t (double t) const
 
virtual const Matrix< double > & getdPij_dt (double t) const
 
virtual const Matrix< double > & getd2Pij_dt2 (double t) 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
 
virtual double Pij_t (size_t i, size_t j, double t) const
 
virtual double dPij_dt (size_t i, size_t j, double t) const
 
virtual double d2Pij_dt2 (size_t i, size_t j, double t) 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...
 
virtual void setFreq (std::map< int, double > &)
 Set equilibrium frequencies. 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 std::string getName () const =0
 Get the name of the model. More...
 
virtual size_t getNumberOfStates () const =0
 Get the number of states. More...
 
virtual const FrequenciesSetgetFrequenciesSet () const
 If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0. More...
 

Protected Member Functions

virtual void updateMatrices ()
 Diagonalize the $Q$ matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVectors_ matrices. More...
 

Protected Attributes

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...
 

Friends

class AbstractBiblioSubstitutionModel
 

Detailed Description

Partial implementation of the SubstitutionModel interface.

This abstract class provides some fields, namely:

  • alphabet_: a pointer toward the alphabet,
  • size_: the size of the alphabet, a parameter frequently called during various computations,
  • rate_: the rate of the model
  • generator_, leftEigenVectors_, rightEigenVectors_: useful matrices,
  • eigenValues_, iEigenValues_, freq_: useful vectors.
  • isDiagonalizable_ : boolean value useful for computation of the exponential

Access methods for these fields are implemented.

This class also provides the updateMatrices() method, which computes eigen values and vectors and fills the corresponding vector (eigenValues_) and matrices (leftEigenVectors_ and rightEigenVectors_) from the generator.

The freq_ vector and generator_ matrices are hence the only things to provide to create a substitution model. It is also possible to redefine one of these methods for better efficiency. The Pij_t, dPij_dt and d2Pij_dt2 are particularly inefficient since the matrix formula is used to compute all probabilities, and then the result for the initial and final state of interest is retrieved.

Note
This class is dedicated to "simple" substitution models, for which the number of states is equivalent to the number of characters in the alphabet. Consider using the MarkovModulatedSubstitutionModel for more complexe cases.

Definition at line 78 of file AbstractSubstitutionModel.h.

Constructor & Destructor Documentation

◆ AbstractSubstitutionModel() [1/2]

AbstractSubstitutionModel::AbstractSubstitutionModel ( const Alphabet *  alpha,
StateMap stateMap,
const std::string &  prefix 
)

Definition at line 56 of file AbstractSubstitutionModel.cpp.

References freq_, and size_.

◆ AbstractSubstitutionModel() [2/2]

bpp::AbstractSubstitutionModel::AbstractSubstitutionModel ( const AbstractSubstitutionModel model)
inline

Definition at line 182 of file AbstractSubstitutionModel.h.

◆ ~AbstractSubstitutionModel()

virtual bpp::AbstractSubstitutionModel::~AbstractSubstitutionModel ( )
inlinevirtual

Definition at line 230 of file AbstractSubstitutionModel.h.

Member Function Documentation

◆ addRateParameter()

void AbstractSubstitutionModel::addRateParameter ( )
virtual

Implements bpp::SubstitutionModel.

Definition at line 433 of file AbstractSubstitutionModel.cpp.

References rate_.

◆ clone()

◆ d2Pij_dt2()

virtual double bpp::AbstractSubstitutionModel::d2Pij_dt2 ( size_t  i,
size_t  j,
double  t 
) const
inlinevirtual
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()

Implements bpp::SubstitutionModel.

Reimplemented in bpp::F84, bpp::HKY85, bpp::JCprot, bpp::T92, bpp::K80, bpp::RN95, bpp::TN93, bpp::RE08, bpp::JCnuc, bpp::RN95s, and bpp::BinarySubstitutionModel.

Definition at line 281 of file AbstractSubstitutionModel.h.

References getd2Pij_dt2().

◆ dPij_dt()

virtual double bpp::AbstractSubstitutionModel::dPij_dt ( size_t  i,
size_t  j,
double  t 
) const
inlinevirtual
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()

Implements bpp::SubstitutionModel.

Reimplemented in bpp::F84, bpp::HKY85, bpp::JCprot, bpp::T92, bpp::K80, bpp::RN95, bpp::TN93, bpp::RE08, bpp::JCnuc, bpp::RN95s, and bpp::BinarySubstitutionModel.

Definition at line 280 of file AbstractSubstitutionModel.h.

References getdPij_dt().

◆ enableEigenDecomposition() [1/2]

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

Set if eigenValues and Vectors must be computed.

Implements bpp::SubstitutionModel.

Definition at line 289 of file AbstractSubstitutionModel.h.

References eigenDecompose_.

◆ enableEigenDecomposition() [2/2]

◆ fireParameterChanged()

◆ freq()

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

Implements bpp::SubstitutionModel.

Definition at line 275 of file AbstractSubstitutionModel.h.

References freq_.

◆ getAlphabet()

const Alphabet* bpp::AbstractSubstitutionModel::getAlphabet ( ) const
inlinevirtual

◆ getAlphabetStateAsChar()

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

Implements bpp::SubstitutionModel.

Definition at line 243 of file AbstractSubstitutionModel.h.

References stateMap_.

◆ getAlphabetStateAsInt()

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

Implements bpp::SubstitutionModel.

Definition at line 245 of file AbstractSubstitutionModel.h.

References stateMap_.

◆ getAlphabetStates()

const std::vector<int>& bpp::AbstractSubstitutionModel::getAlphabetStates ( ) const
inlinevirtual
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 stateMap_.

◆ getColumnRightEigenVectors()

const Matrix<double>& bpp::AbstractSubstitutionModel::getColumnRightEigenVectors ( ) const
inlinevirtual
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 rightEigenVectors_.

◆ getd2Pij_dt2()

const Matrix< double > & AbstractSubstitutionModel::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()

Implements bpp::SubstitutionModel.

Reimplemented in bpp::AbstractMixedSubstitutionModel, bpp::F84, bpp::HKY85, bpp::JCprot, bpp::T92, bpp::K80, bpp::RN95, bpp::TN93, bpp::RE08, bpp::JCnuc, bpp::RN95s, bpp::BinarySubstitutionModel, and bpp::WordSubstitutionModel.

Definition at line 274 of file AbstractSubstitutionModel.cpp.

References d2pijt_, eigenValues_, iEigenValues_, isDiagonalizable_, isNonSingular_, leftEigenVectors_, rate_, rightEigenVectors_, size_, tmpMat_, and vPowGen_.

Referenced by d2Pij_dt2().

◆ getdPij_dt()

const Matrix< double > & AbstractSubstitutionModel::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()

Implements bpp::SubstitutionModel.

Reimplemented in bpp::AbstractMixedSubstitutionModel, bpp::F84, bpp::HKY85, bpp::JCprot, bpp::T92, bpp::K80, bpp::RN95, bpp::TN93, bpp::RE08, bpp::JCnuc, bpp::RN95s, bpp::BinarySubstitutionModel, and bpp::WordSubstitutionModel.

Definition at line 205 of file AbstractSubstitutionModel.cpp.

References dpijt_, eigenValues_, iEigenValues_, isDiagonalizable_, isNonSingular_, leftEigenVectors_, rate_, rightEigenVectors_, size_, tmpMat_, and vPowGen_.

Referenced by dPij_dt().

◆ getEigenValues()

const Vdouble& bpp::AbstractSubstitutionModel::getEigenValues ( ) const
inlinevirtual
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 eigenValues_.

◆ getExchangeabilityMatrix()

const Matrix<double>& bpp::AbstractSubstitutionModel::getExchangeabilityMatrix ( ) const
inlinevirtual
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 exchangeability_.

◆ getFrequencies()

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

Implements bpp::SubstitutionModel.

Definition at line 251 of file AbstractSubstitutionModel.h.

References freq_.

◆ getFrequenciesSet()

◆ getGenerator()

const Matrix<double>& bpp::AbstractSubstitutionModel::getGenerator ( ) const
inlinevirtual
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 generator_.

◆ getIEigenValues()

const Vdouble& bpp::AbstractSubstitutionModel::getIEigenValues ( ) const
inlinevirtual
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 iEigenValues_.

◆ getInitValue()

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

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
inlinevirtual

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 stateMap_.

◆ getModelStates() [2/2]

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

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 stateMap_.

◆ getName()

virtual std::string bpp::SubstitutionModel::getName ( ) const
pure virtualinherited

Get the name of the model.

Returns
The name of this model.

Implemented in bpp::YpR_Gen, bpp::YpR_Sym, bpp::F84, bpp::HKY85, bpp::JCprot, bpp::T92, bpp::K80, bpp::RN95, bpp::GTR, bpp::TN93, bpp::RE08, bpp::MixtureOfSubstitutionModels, bpp::JCnuc, bpp::RN95s, bpp::CodonDistanceFrequenciesSubstitutionModel, bpp::BinarySubstitutionModel, bpp::CodonDistancePhaseFrequenciesSubstitutionModel, bpp::UserProteinSubstitutionModel, bpp::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel, bpp::MixtureOfASubstitutionModel, bpp::LLG08_EX3, bpp::WordSubstitutionModel, bpp::LLG08_EHO, bpp::LLG08_UL3, bpp::WAG01, bpp::SSR, bpp::LG10_EX_EHO, bpp::CodonDistanceSubstitutionModel, bpp::L95, bpp::LGL08_CAT, bpp::LLG08_EX2, bpp::LLG08_UL2, bpp::DSO78, bpp::JTT92, bpp::CodonRateFrequenciesSubstitutionModel, bpp::LG08, bpp::YNGKP_M1, bpp::G2001, bpp::gBGC, bpp::YNGKP_M8, bpp::GY94, bpp::YNGKP_M7, bpp::YN98, bpp::YNGKP_M3, bpp::TS98, bpp::TripletSubstitutionModel, bpp::YNGKP_M2, bpp::MG94, bpp::CodonRateSubstitutionModel, bpp::Coala, bpp::LLG08_EX3::EmbeddedModel, bpp::LLG08_EHO::EmbeddedModel, bpp::LLG08_UL3::EmbeddedModel, bpp::LG10_EX_EHO::EmbeddedModel, bpp::LGL08_CAT::EmbeddedModel, bpp::LLG08_EX2::EmbeddedModel, and bpp::LLG08_UL2::EmbeddedModel.

Referenced by bpp::AbstractCodonFitnessSubstitutionModel::AbstractCodonFitnessSubstitutionModel(), fireParameterChanged(), bpp::MixtureOfSubstitutionModels::getSubmodelNumbers(), bpp::BppOSubstitutionModelFormat::readMixed_(), bpp::AbstractBiblioSubstitutionModel::updateMatrices(), and bpp::BppOSubstitutionModelFormat::write().

◆ getNumberOfStates()

◆ getPij_t()

const Matrix< double > & AbstractSubstitutionModel::getPij_t ( double  t) const
virtual

◆ getRate()

double AbstractSubstitutionModel::getRate ( ) const
virtual

Get the rate.

Implements bpp::SubstitutionModel.

Definition at line 415 of file AbstractSubstitutionModel.cpp.

References rate_.

◆ getRowLeftEigenVectors()

const Matrix<double>& bpp::AbstractSubstitutionModel::getRowLeftEigenVectors ( ) const
inlinevirtual
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 leftEigenVectors_.

◆ getScale()

double AbstractSubstitutionModel::getScale ( ) const
virtual

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 freq_, and generator_.

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

◆ getStateMap()

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

Implements bpp::SubstitutionModel.

Definition at line 239 of file AbstractSubstitutionModel.h.

References stateMap_.

◆ isDiagonalizable()

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

Implements bpp::SubstitutionModel.

Definition at line 267 of file AbstractSubstitutionModel.h.

References isDiagonalizable_.

◆ isNonSingular()

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

Implements bpp::SubstitutionModel.

Definition at line 269 of file AbstractSubstitutionModel.h.

References isNonSingular_.

◆ operator=()

◆ Pij_t()

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

Implements bpp::SubstitutionModel.

Reimplemented in bpp::F84, bpp::HKY85, bpp::JCprot, bpp::T92, bpp::K80, bpp::RN95, bpp::TN93, bpp::RE08, bpp::JCnuc, bpp::RN95s, and bpp::BinarySubstitutionModel.

Definition at line 279 of file AbstractSubstitutionModel.h.

References getPij_t().

◆ Qij()

virtual double bpp::AbstractSubstitutionModel::Qij ( size_t  i,
size_t  j 
) const
inlinevirtual
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 generator_.

◆ setFreq()

◆ setFreqFromData()

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

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 setFreq(), and size_.

◆ setRate()

void AbstractSubstitutionModel::setRate ( double  rate)
virtual

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 rate_.

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

◆ setScale()

void AbstractSubstitutionModel::setScale ( double  scale)
virtual

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 generator_.

◆ Sij()

double bpp::AbstractSubstitutionModel::Sij ( size_t  i,
size_t  j 
) const
inlinevirtual
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 exchangeability_.

◆ updateMatrices()

void AbstractSubstitutionModel::updateMatrices ( )
protectedvirtual

Diagonalize the $Q$ matrix, and fill the eigenValues_, iEigenValues_, leftEigenVectors_ and rightEigenVectors_ matrices.

The generator_ matrix and freq_ vector must be initialized.

Eigen values and vectors are computed from the generator and assigned to the eigenValues_ for the real part, iEigenValues_ for the imaginary part, rightEigenVectors_ and leftEigenVectors_ variables. isDiagonalizable_ checks if the generator_ is diagonalizable in R.

The optional rate parameter is not taken into account in this method to prevent unnecessary computation.

Reimplemented in bpp::AbstractReversibleSubstitutionModel, bpp::YpR_Gen, bpp::YpR_Sym, bpp::JCprot, bpp::F84, bpp::HKY85, bpp::RE08, bpp::T92, bpp::K80, bpp::YpR, bpp::JCnuc, bpp::RN95, bpp::TN93, bpp::GTR, bpp::MixtureOfSubstitutionModels, bpp::AbstractCodonSubstitutionModel, bpp::RN95s, bpp::BinarySubstitutionModel, bpp::MixtureOfASubstitutionModel, bpp::SSR, bpp::L95, bpp::gBGC, bpp::WordSubstitutionModel, bpp::Coala, and bpp::AbstractWordSubstitutionModel.

Definition at line 86 of file AbstractSubstitutionModel.cpp.

References eigenValues_, enableEigenDecomposition(), exchangeability_, freq_, generator_, iEigenValues_, isDiagonalizable_, isNonSingular_, leftEigenVectors_, rightEigenVectors_, size_, and vPowGen_.

Referenced by fireParameterChanged(), setFreq(), bpp::L95::updateMatrices(), bpp::RE08::updateMatrices(), and bpp::AbstractReversibleSubstitutionModel::updateMatrices().

Friends And Related Function Documentation

◆ AbstractBiblioSubstitutionModel

friend class AbstractBiblioSubstitutionModel
friend

Definition at line 343 of file AbstractSubstitutionModel.h.

Member Data Documentation

◆ alphabet_

const Alphabet* bpp::AbstractSubstitutionModel::alphabet_
protected

◆ d2pijt_

RowMatrix<double> bpp::AbstractSubstitutionModel::d2pijt_
mutableprotected

◆ dpijt_

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

◆ eigenDecompose_

bool bpp::AbstractSubstitutionModel::eigenDecompose_
protected

Tell if the eigen decomposition should be performed.

Definition at line 134 of file AbstractSubstitutionModel.h.

Referenced by bpp::AbstractMixedSubstitutionModel::AbstractMixedSubstitutionModel(), enableEigenDecomposition(), and operator=().

◆ eigenValues_

◆ exchangeability_

◆ freq_

Vdouble bpp::AbstractSubstitutionModel::freq_
protected

The vector $\pi_e$ of equilibrium frequencies.

Definition at line 113 of file AbstractSubstitutionModel.h.

Referenced by 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(), freq(), bpp::RE08::getd2Pij_dt2(), bpp::RE08::getdPij_dt(), getFrequencies(), bpp::RN95s::getPij_t(), bpp::RE08::getPij_t(), bpp::RN95::getPij_t(), getScale(), bpp::JCprot::JCprot(), bpp::JTT92::JTT92(), bpp::LG08::LG08(), operator=(), bpp::RN95s::Pij_t(), bpp::RE08::Pij_t(), bpp::RN95::Pij_t(), bpp::RE08::RE08(), bpp::UserProteinSubstitutionModel::readFromFile(), 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(), bpp::BinarySubstitutionModel::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(), updateMatrices(), bpp::AbstractReversibleSubstitutionModel::updateMatrices(), bpp::UserProteinSubstitutionModel::UserProteinSubstitutionModel(), and bpp::WAG01::WAG01().

◆ generator_

◆ iEigenValues_

Vdouble bpp::AbstractSubstitutionModel::iEigenValues_
protected

◆ isDiagonalizable_

◆ isNonSingular_

◆ leftEigenVectors_

◆ pijt_

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

◆ rate_

double bpp::AbstractSubstitutionModel::rate_
protected

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 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(), 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(), 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(), getPij_t(), getRate(), bpp::AbstractMixedSubstitutionModel::normalizeVRates(), 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(), setRate(), and bpp::BinarySubstitutionModel::updateMatrices().

◆ rightEigenVectors_

◆ size_

◆ stateMap_

std::auto_ptr<StateMap> bpp::AbstractSubstitutionModel::stateMap_
protected

The map of model states with alphabet states.

Definition at line 91 of file AbstractSubstitutionModel.h.

Referenced by getAlphabetStateAsChar(), getAlphabetStateAsInt(), getAlphabetStates(), getModelStates(), getStateMap(), and operator=().

◆ tmpMat_

RowMatrix<double> bpp::AbstractSubstitutionModel::tmpMat_
mutableprotected

◆ vPowGen_

std::vector< RowMatrix<double> > bpp::AbstractSubstitutionModel::vPowGen_
protected

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