bpp-phyl3  3.0.0
bpp::KCM Class Referenceabstract

The general multiple substitution model for codons, from Zaheri & al, 2014. More...

#include <Bpp/Phyl/Model/Codon/KCM.h>

+ Inheritance diagram for bpp::KCM:
+ Collaboration diagram for bpp::KCM:

Public Member Functions

 KCM (std::shared_ptr< const GeneticCode > gc, bool oneModel)
 constructor. More...
 
 KCM (const KCM &kcm)
 
KCMoperator= (const KCM &)
 
virtual ~KCM ()
 
KCMclone () const override
 
std::string getName () const override
 Get the name of the model. More...
 
const SubstitutionModelInterfacesubstitutionModel () const override
 
std::shared_ptr< const GeneticCodegetGeneticCode () const override
 
double getCodonsMulRate (size_t i, size_t j) const override
 Returns the multiplicative rate specific to two codons specified by their number. The respective generator rate is this rate multiplied by the rate defined by the model defined on nucleotides. More...
 
std::string getParNameFromPmodel (const std::string &name) const
 get the name of a parameter from its name in a submodel More...
 
std::string getPmodelParName (const std::string &name) const
 get the name of a parameter in the submodel from its apparent name More...
 
const FrequencySetInterfacefrequencySet () const override
 
const BranchModelInterfacemodel () const override
 
bool hasIndependentParameter (const std::string &name) const
 
const ParameterListgetIndependentParameters () const
 
size_t getNumberOfIndependentParameters () const
 
void aliasParameters (const std::string &p1, const std::string &p2)
 
void aliasParameters (std::map< std::string, std::string > &unparsedParams, bool verbose)
 
void unaliasParameters (const std::string &p1, const std::string &p2)
 
ParameterList getAliasedParameters (const ParameterList &pl) const
 
ParameterList getFromParameters (const ParameterList &pl) const
 
virtual std::vector< std::string > getAlias (const std::string &name) const
 
virtual std::map< std::string, std::string > getAliases () const
 
std::string getFrom (const std::string &name) const
 
bool hasParameter (const std::string &name) const override
 
const ParameterListgetParameters () const override
 
const Parameterparameter (const std::string &name) const override
 
const std::shared_ptr< Parameter > & getParameter (const std::string &name) const
 
double getParameterValue (const std::string &name) const override
 
void setAllParametersValues (const ParameterList &parameters) override
 
void setParameterValue (const std::string &name, double value) override
 
void setParametersValues (const ParameterList &parameters) override
 
bool matchParametersValues (const ParameterList &parameters) override
 
void removeConstraint (const std::string &name) override
 
void setConstraint (const std::string &name, std::shared_ptr< ConstraintInterface > constraint) override
 
size_t getNumberOfParameters () const override
 
std::string getNamespace () const override
 
std::string getParameterNameWithoutNamespace (const std::string &name) const override
 
virtual const Eigen::VectorXd & Lik_t (const Eigen::VectorXd &values, double t) const =0
 
const Eigen::VectorXd & Lik_t (const Eigen::VectorXd &values, double t) const override
 
virtual const Eigen::VectorXd & dLik_dt (const Eigen::VectorXd &values, double t) const =0
 
const Eigen::VectorXd & dLik_dt (const Eigen::VectorXd &values, double t) const override
 
virtual const Eigen::VectorXd & d2Lik_dt2 (const Eigen::VectorXd &values, double t) const =0
 
const Eigen::VectorXd & d2Lik_dt2 (const Eigen::VectorXd &values, double t) const override
 
virtual const TransitionModelInterfacetransitionModel () const =0
 
const TransitionModelInterfacetransitionModel () const
 
bool isScalable () const
 returns if model is scalable More...
 
void setScalable (bool scalable)
 sets if model is scalable, ie scale can be changed. Default : true, set to false to avoid normalization for example. More...
 
void normalize ()
 Normalize the generator. More...
 
void setDiagonal ()
 set the diagonal of the generator such that sum on each line equals 0. More...
 
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...
 
void addRateParameter () override
 Methods to supersede TransitionModel methods. More...
 
void setFreqFromData (const SequenceDataInterface &data, double pseudoCount=0) override
 Set equilibrium frequencies equal to the frequencies estimated from the data. More...
 
virtual void fireParameterChanged (const ParameterList &parameters) override
 Methods to supersede AbstractTransitionModel methods. More...
 
void setNamespace (const std::string &name) override
 
double freq (size_t i) const override
 Methods to supersede TransitionModel methods. More...
 
double Pij_t (size_t i, size_t j, double t) const override
 
double dPij_dt (size_t i, size_t j, double t) const override
 
double d2Pij_dt2 (size_t i, size_t j, double t) const override
 
const VdoublegetFrequencies () const override
 
const Matrix< double > & getPij_t (double t) const override
 
const Matrix< double > & getdPij_dt (double t) const override
 
const Matrix< double > & getd2Pij_dt2 (double t) const override
 
double getInitValue (size_t i, int state) const override
 
double getRate () const override
 Get the rate. More...
 
void setRate (double rate) override
 Set the rate of the model (must be positive). More...
 
bool computeFrequencies () const override
 
void computeFrequencies (bool yn) override
 
const std::vector< int > & getAlphabetStates () const override
 
const StateMapInterfacestateMap () const override
 
std::shared_ptr< const StateMapInterfacegetStateMap () const override
 
int getAlphabetStateAsInt (size_t i) const override
 
std::string getAlphabetStateAsChar (size_t i) const override
 
std::vector< size_t > getModelStates (int code) const override
 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 override
 Get the state in the model corresponding to a particular state in the alphabet. More...
 
const Alphabetalphabet () const override
 
std::shared_ptr< const AlphabetgetAlphabet () const override
 
size_t getNumberOfStates () const override
 Get the number of states. More...
 
double Qij (size_t i, size_t j) const
 Methods to supersede SubstitutionModel methods. More...
 
const Matrix< double > & generator () const
 
const Matrix< double > & exchangeabilityMatrix () const
 
double Sij (size_t i, size_t j) const
 
void enableEigenDecomposition (bool yn)
 Set if eigenValues and Vectors must be computed. More...
 
bool enableEigenDecomposition ()
 Tell if eigenValues and Vectors must be computed. More...
 
bool isDiagonalizable () const
 
bool isNonSingular () const
 
const VdoublegetEigenValues () const
 
const VdoublegetIEigenValues () const
 
const Matrix< double > & getRowLeftEigenVectors () const
 
const Matrix< double > & getColumnRightEigenVectors () const
 

Protected Member Functions

SubstitutionModelInterfacesubstitutionModel_ () override
 
const CodonFrequencySetInterfacecodonFrequencySet () const override
 
bool hasCodonFrequencySet () const override
 
void setFreq (std::map< int, double > &frequencies) override
 Set equilibrium frequencies. More...
 
void updateMatrices_ () override
 
VdoublegetFrequencies_ () override
 
BranchModelInterfacemodel_ ()
 
virtual TransitionModelInterfacetransitionModel_ ()=0
 
TransitionModelInterfacetransitionModel_ ()
 
const std::shared_ptr< Parameter > & getParameter (size_t i) const
 
std::shared_ptr< Parameter > & getParameter (size_t i)
 
void addParameter_ (Parameter *parameter)
 
void addParameters_ (const ParameterList &parameters)
 
void shareParameter_ (const std::shared_ptr< Parameter > &parameter)
 
void shareParameters_ (const ParameterList &parameters)
 
void includeParameters_ (const ParameterList &parameters)
 
void deleteParameter_ (size_t index)
 
void deleteParameter_ (std::string &name)
 
void deleteParameters_ (const std::vector< std::string > &names)
 
void resetParameters_ ()
 
ParametergetParameter_ (const std::string &name)
 
ParametergetParameter_ (size_t index)
 
const ParametergetParameter_ (size_t index) const
 
ParametergetParameterWithNamespace_ (const std::string &name)
 
const ParametergetParameterWithNamespace_ (const std::string &name) const
 
ParameterListgetParameters_ () override
 

Protected Attributes

std::map< std::string, std::string > mapParNamesFromPmodel_
 Tools to make the link between the Parameters of the object and those of pmixmodel_. More...
 
ParameterList lParPmodel_
 

Private Attributes

std::unique_ptr< KroneckerCodonDistanceSubstitutionModelpmodel_
 
bool oneModel_
 
ParameterList independentParameters_
 
std::map< std::string, std::shared_ptr< AliasParameterListener > > aliasListenersRegister_
 
ParameterList parameters_
 
std::string prefix_
 
Eigen::VectorXd lik_
 

Detailed Description

The general multiple substitution model for codons, from Zaheri & al, 2014.

Author
Laurent Guéguen

This model is built from one or several nucleotide substitution models. It also allows distinct equilibrium frequencies between codons. A multiplicative factor accounts for the selective restraints at the amino acid level, depending on the synonymy of the amino acids.

This model includes :

  • parameters of the nucleotide models,
  • $\omega$ for the ratio of non-synonymous vs synonymous substitution rates,
  • parameters of the equilibrium frequencies

The codon frequencies $\pi_j$ are either observed or inferred.

Reference:

  • Zaheri, M. and Dib, L. and Salamin, N. A Generalized Mechanistic Codon Model, Mol Biol Evol. 2014 Sep;31(9):2528-41. doi: 10.1093/molbev/msu196. Epub 2014 Jun 23.

Definition at line 41 of file KCM.h.

Constructor & Destructor Documentation

◆ KCM() [1/2]

◆ KCM() [2/2]

KCM::KCM ( const KCM kcm)

Definition at line 67 of file KCM.cpp.

◆ ~KCM()

virtual bpp::KCM::~KCM ( )
inlinevirtual

Definition at line 62 of file KCM.h.

Member Function Documentation

◆ addRateParameter()

◆ alphabet()

const Alphabet& bpp::AbstractWrappedModel::alphabet ( ) const
inlineoverridevirtualinherited

◆ clone()

KCM* bpp::KCM::clone ( ) const
inlineoverridevirtual

Implements bpp::CodonReversibleSubstitutionModelInterface.

Definition at line 64 of file KCM.h.

References KCM().

◆ codonFrequencySet()

const CodonFrequencySetInterface& bpp::KCM::codonFrequencySet ( ) const
inlineoverrideprotectedvirtual

Implements bpp::CoreCodonSubstitutionModelInterface.

Definition at line 78 of file KCM.h.

◆ computeFrequencies() [1/2]

bool bpp::AbstractTotallyWrappedTransitionModel::computeFrequencies ( ) const
inlineoverridevirtualinherited
Returns
Says if equilibrium frequencies should be computed

Implements bpp::TransitionModelInterface.

Definition at line 162 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::computeFrequencies(), and bpp::WrappedTransitionModelInterface::transitionModel().

Referenced by bpp::DFP07::DFP07(), and bpp::YN98::YN98().

◆ computeFrequencies() [2/2]

void bpp::AbstractTotallyWrappedTransitionModel::computeFrequencies ( bool  yn)
inlineoverridevirtualinherited
Returns
Set if equilibrium frequencies should be computed from the generator

Implements bpp::TransitionModelInterface.

Definition at line 171 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::computeFrequencies(), and bpp::AbstractWrappedTransitionModel::transitionModel_().

◆ d2Lik_dt2() [1/2]

virtual const Eigen::VectorXd& bpp::BranchModelInterface::d2Lik_dt2 ( const Eigen::VectorXd &  values,
double  t 
) const
pure virtualinherited

◆ d2Lik_dt2() [2/2]

const Eigen::VectorXd& bpp::AbstractLkTransitionModel::d2Lik_dt2 ( const Eigen::VectorXd &  values,
double  t 
) const
inlineoverridevirtualinherited

◆ d2Pij_dt2()

double bpp::AbstractTotallyWrappedTransitionModel::d2Pij_dt2 ( size_t  i,
size_t  j,
double  t 
) const
inlineoverridevirtualinherited
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::TransitionModelInterface.

Definition at line 124 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::d2Pij_dt2(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ dLik_dt() [1/2]

virtual const Eigen::VectorXd& bpp::BranchModelInterface::dLik_dt ( const Eigen::VectorXd &  values,
double  t 
) const
pure virtualinherited

◆ dLik_dt() [2/2]

const Eigen::VectorXd& bpp::AbstractLkTransitionModel::dLik_dt ( const Eigen::VectorXd &  values,
double  t 
) const
inlineoverridevirtualinherited

◆ dPij_dt()

double bpp::AbstractTotallyWrappedTransitionModel::dPij_dt ( size_t  i,
size_t  j,
double  t 
) const
inlineoverridevirtualinherited
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::TransitionModelInterface.

Definition at line 123 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::dPij_dt(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ enableEigenDecomposition() [1/2]

bool bpp::AbstractTotallyWrappedSubstitutionModel::enableEigenDecomposition ( )
inlinevirtualinherited

◆ enableEigenDecomposition() [2/2]

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

◆ exchangeabilityMatrix()

const Matrix<double>& bpp::AbstractTotallyWrappedSubstitutionModel::exchangeabilityMatrix ( ) 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::SubstitutionModelInterface.

Definition at line 234 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::exchangeabilityMatrix(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ fireParameterChanged()

virtual void bpp::AbstractBiblioTransitionModel::fireParameterChanged ( const ParameterList parameters)
inlineoverridevirtualinherited

◆ freq()

double bpp::AbstractTotallyWrappedTransitionModel::freq ( size_t  i) const
inlineoverridevirtualinherited

Methods to supersede TransitionModel methods.

Implements bpp::TransitionModelInterface.

Definition at line 120 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::freq(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ frequencySet()

const FrequencySetInterface& bpp::AbstractWrappedTransitionModel::frequencySet ( ) const
inlineoverridevirtualinherited
Returns
Get the FrequencySet of equilibrium of this model.
Exceptions
Exceptionif no FrequenceSet is associated to this model.

Reimplemented from bpp::AbstractWrappedModel.

Reimplemented in bpp::RegisterRatesSubstitutionModel, bpp::OneChangeTransitionModel, bpp::OneChangeRegisterTransitionModel, and bpp::YN98.

Definition at line 93 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::frequencySet(), and bpp::WrappedTransitionModelInterface::transitionModel().

Referenced by bpp::RegisterRatesSubstitutionModel::frequencySet().

◆ generator()

const Matrix<double>& bpp::AbstractTotallyWrappedSubstitutionModel::generator ( ) 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. Additionally, the rate_ attribute 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::SubstitutionModelInterface.

Definition at line 232 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::generator(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::AbstractWrappedModel::getAlphabet ( ) const
inlineoverridevirtualinherited

◆ getAlphabetStateAsChar()

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

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 46 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getAlphabetStateAsChar(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getAlphabetStateAsChar().

◆ getAlphabetStateAsInt()

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

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 44 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getAlphabetStateAsInt(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getAlphabetStateAsInt().

◆ getAlphabetStates()

const std::vector<int>& bpp::AbstractWrappedModel::getAlphabetStates ( ) const
inlineoverridevirtualinherited

@ brief Methods to supersede TransitionModel methods.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 38 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getAlphabetStates(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getAlphabetStates().

◆ getCodonsMulRate()

double bpp::KCM::getCodonsMulRate ( size_t  ,
size_t   
) const
inlineoverridevirtual

Returns the multiplicative rate specific to two codons specified by their number. The respective generator rate is this rate multiplied by the rate defined by the model defined on nucleotides.

Implements bpp::CoreCodonSubstitutionModelInterface.

Definition at line 73 of file KCM.h.

References pmodel_.

◆ getColumnRightEigenVectors()

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

Implements bpp::SubstitutionModelInterface.

Definition at line 252 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::getColumnRightEigenVectors(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ getd2Pij_dt2()

const Matrix<double>& bpp::AbstractTotallyWrappedTransitionModel::getd2Pij_dt2 ( double  t) const
inlineoverridevirtualinherited
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::TransitionModelInterface.

Definition at line 132 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::getd2Pij_dt2(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ getdPij_dt()

const Matrix<double>& bpp::AbstractTotallyWrappedTransitionModel::getdPij_dt ( double  t) const
inlineoverridevirtualinherited
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::TransitionModelInterface.

Definition at line 130 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::getdPij_dt(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ getEigenValues()

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

Implements bpp::SubstitutionModelInterface.

Definition at line 246 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::getEigenValues(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ getFrequencies()

const Vdouble& bpp::AbstractTotallyWrappedTransitionModel::getFrequencies ( ) const
inlineoverridevirtualinherited
Returns
A vector of all equilibrium frequencies.
See also
freq()

Implements bpp::TransitionModelInterface.

Definition at line 126 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::getFrequencies(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ getFrequencies_()

Vdouble& bpp::AbstractTotallyWrappedTransitionModel::getFrequencies_ ( )
inlineoverrideprotectedvirtualinherited

◆ getGeneticCode()

std::shared_ptr<const GeneticCode> bpp::KCM::getGeneticCode ( ) const
inlineoverridevirtual

Implements bpp::CodonSubstitutionModelInterface.

Definition at line 71 of file KCM.h.

References pmodel_.

◆ getIEigenValues()

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

Implements bpp::SubstitutionModelInterface.

Definition at line 248 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::getIEigenValues(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ getInitValue()

double bpp::AbstractTotallyWrappedTransitionModel::getInitValue ( size_t  i,
int  state 
) const
inlineoverridevirtualinherited

This method is used to initialize likelihoods in recursions. 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::BranchModelInterface.

Definition at line 134 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getInitValue(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ getModelStates() [1/2]

std::vector<size_t> bpp::AbstractWrappedModel::getModelStates ( const std::string &  code) const
inlineoverridevirtualinherited

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

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 50 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getModelStates(), and bpp::WrappedModelInterface::model().

◆ getModelStates() [2/2]

std::vector<size_t> bpp::AbstractWrappedModel::getModelStates ( int  code) const
inlineoverridevirtualinherited

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

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 48 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getModelStates(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getModelStates().

◆ getName()

std::string bpp::KCM::getName ( ) const
inlineoverridevirtual

Get the name of the model.

Returns
The name of this model.

Reimplemented from bpp::AbstractWrappedModel.

Definition at line 67 of file KCM.h.

References oneModel_.

◆ getNumberOfStates()

size_t bpp::AbstractWrappedModel::getNumberOfStates ( ) const
inlineoverridevirtualinherited

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

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 57 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getNumberOfStates(), and bpp::WrappedModelInterface::model().

◆ getParNameFromPmodel()

std::string AbstractBiblioTransitionModel::getParNameFromPmodel ( const std::string &  name) const
inherited

get the name of a parameter from its name in a submodel

Parameters
namethe name of the parameter in the submodel

Definition at line 37 of file AbstractBiblioSubstitutionModel.cpp.

References bpp::AbstractBiblioTransitionModel::mapParNamesFromPmodel_.

◆ getPij_t()

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

Implements bpp::TransitionModelInterface.

Definition at line 128 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::getPij_t(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ getPmodelParName()

std::string AbstractBiblioTransitionModel::getPmodelParName ( const std::string &  name) const
inherited

get the name of a parameter in the submodel from its apparent name

Parameters
namethe name of the parameter

Definition at line 47 of file AbstractBiblioSubstitutionModel.cpp.

References bpp::AbstractBiblioTransitionModel::mapParNamesFromPmodel_.

◆ getRate()

double bpp::AbstractTotallyWrappedTransitionModel::getRate ( ) const
inlineoverridevirtualinherited

◆ getRowLeftEigenVectors()

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

Implements bpp::SubstitutionModelInterface.

Definition at line 250 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::getRowLeftEigenVectors(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ getScale()

double bpp::AbstractTotallyWrappedSubstitutionModel::getScale ( ) const
inlinevirtualinherited

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

Definition at line 278 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::getScale(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ getStateMap()

std::shared_ptr<const StateMapInterface> bpp::AbstractWrappedModel::getStateMap ( ) const
inlineoverridevirtualinherited
Returns
A shared_ptr to the mapping of model states with alphabet states.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 42 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::getStateMap(), and bpp::WrappedModelInterface::model().

Referenced by bpp::RegisterRatesSubstitutionModel::getStateMap().

◆ hasCodonFrequencySet()

bool bpp::KCM::hasCodonFrequencySet ( ) const
inlineoverrideprotectedvirtual

Implements bpp::CoreCodonSubstitutionModelInterface.

Definition at line 83 of file KCM.h.

◆ isDiagonalizable()

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

Implements bpp::SubstitutionModelInterface.

Definition at line 242 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::isDiagonalizable(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ isNonSingular()

bool bpp::AbstractTotallyWrappedSubstitutionModel::isNonSingular ( ) const
inlinevirtualinherited

◆ isScalable()

bool bpp::AbstractTotallyWrappedSubstitutionModel::isScalable ( ) const
inlinevirtualinherited

◆ Lik_t() [1/2]

virtual const Eigen::VectorXd& bpp::BranchModelInterface::Lik_t ( const Eigen::VectorXd &  values,
double  t 
) const
pure virtualinherited

This method is used to compute likelihoods in recursions. It computes the probability of a vector given a start state.

Parameters
valuesAn vector of states on the site.
ttime
Exceptions
IndexOutOfBoundsExceptionif array position is out of range.
BadIntExceptionif states are not allowed in the associated alphabet.

Implemented in bpp::AbstractLkTransitionModel, bpp::TransitionModelInterface, bpp::TransitionFromTransitionModel, and bpp::MultinomialFromTransitionModel.

◆ Lik_t() [2/2]

const Eigen::VectorXd& bpp::AbstractLkTransitionModel::Lik_t ( const Eigen::VectorXd &  values,
double  t 
) const
inlineoverridevirtualinherited

This method is used to compute likelihoods in recursions. It computes the probability of a vector given a start state.

Parameters
valuesAn vector of states on the site.
tthe branch length

Implements bpp::TransitionModelInterface.

Definition at line 30 of file AbstractSubstitutionModel.h.

References bpp::TransitionModelInterface::getPij_t(), and bpp::AbstractLkTransitionModel::lik_.

◆ model()

◆ model_()

◆ normalize()

void bpp::AbstractTotallyWrappedSubstitutionModel::normalize ( )
inlinevirtualinherited

◆ operator=()

KCM & KCM::operator= ( const KCM kcm)

Definition at line 80 of file KCM.cpp.

References oneModel_, bpp::AbstractBiblioSubstitutionModel::operator=(), and pmodel_.

◆ Pij_t()

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

Implements bpp::TransitionModelInterface.

Definition at line 122 of file AbstractWrappedModel.h.

References bpp::TransitionModelInterface::Pij_t(), and bpp::WrappedTransitionModelInterface::transitionModel().

◆ Qij()

double bpp::AbstractTotallyWrappedSubstitutionModel::Qij ( size_t  i,
size_t  j 
) const
inlinevirtualinherited

Methods to supersede SubstitutionModel methods.

Implements bpp::SubstitutionModelInterface.

Definition at line 230 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::Qij(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ setDiagonal()

void bpp::AbstractTotallyWrappedSubstitutionModel::setDiagonal ( )
inlinevirtualinherited

set the diagonal of the generator such that sum on each line equals 0.

Implements bpp::SubstitutionModelInterface.

Definition at line 273 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::setDiagonal(), and bpp::AbstractWrappedSubstitutionModel::substitutionModel_().

◆ setFreq()

void bpp::KCM::setFreq ( std::map< int, double > &  frequencies)
inlineoverrideprotectedvirtual

Set equilibrium frequencies.

Parameters
frequenciesThe map of the frequencies to use.

Reimplemented from bpp::AbstractBiblioTransitionModel.

Definition at line 88 of file KCM.h.

References bpp::AbstractBiblioTransitionModel::setFreq().

◆ setFreqFromData()

void AbstractBiblioTransitionModel::setFreqFromData ( const SequenceDataInterface data,
double  pseudoCount = 0 
)
overridevirtualinherited

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

Definition at line 125 of file AbstractBiblioSubstitutionModel.cpp.

References bpp::SequenceContainerTools::getFrequencies(), and bpp::AbstractBiblioTransitionModel::setFreq().

◆ setNamespace()

◆ setRate()

void bpp::AbstractTotallyWrappedTransitionModel::setRate ( double  rate)
inlineoverridevirtualinherited

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

Parameters
ratemust be positive.

Implements bpp::BranchModelInterface.

Definition at line 144 of file AbstractWrappedModel.h.

References bpp::BranchModelInterface::setRate(), and bpp::AbstractWrappedTransitionModel::transitionModel_().

◆ setScalable()

void bpp::AbstractTotallyWrappedSubstitutionModel::setScalable ( bool  scalable)
inlinevirtualinherited

sets if model is scalable, ie scale can be changed. Default : true, set to false to avoid normalization for example.

Implements bpp::SubstitutionModelInterface.

Definition at line 263 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::setScalable(), and bpp::AbstractWrappedSubstitutionModel::substitutionModel_().

◆ setScale()

void bpp::AbstractTotallyWrappedSubstitutionModel::setScale ( double  scale)
inlinevirtualinherited

Multiplies the current generator by the given scale.

Parameters
scalethe scale by which the generator is multiplied.

Implements bpp::SubstitutionModelInterface.

Definition at line 283 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::setScale(), and bpp::AbstractWrappedSubstitutionModel::substitutionModel_().

◆ Sij()

double bpp::AbstractTotallyWrappedSubstitutionModel::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::SubstitutionModelInterface.

Definition at line 236 of file AbstractWrappedModel.h.

References bpp::SubstitutionModelInterface::Sij(), and bpp::WrappedSubstitutionModelInterface::substitutionModel().

◆ stateMap()

const StateMapInterface& bpp::AbstractWrappedModel::stateMap ( ) const
inlineoverridevirtualinherited
Returns
The mapping of model states with alphabet states.

Implements bpp::BranchModelInterface.

Reimplemented in bpp::RegisterRatesSubstitutionModel.

Definition at line 40 of file AbstractWrappedModel.h.

References bpp::WrappedModelInterface::model(), and bpp::BranchModelInterface::stateMap().

Referenced by bpp::RegisterRatesSubstitutionModel::stateMap().

◆ substitutionModel()

const SubstitutionModelInterface& bpp::KCM::substitutionModel ( ) const
inlineoverridevirtual

Implements bpp::WrappedSubstitutionModelInterface.

Definition at line 69 of file KCM.h.

References pmodel_.

◆ substitutionModel_()

SubstitutionModelInterface& bpp::KCM::substitutionModel_ ( )
inlineoverrideprotectedvirtual

Implements bpp::AbstractWrappedSubstitutionModel.

Definition at line 76 of file KCM.h.

References pmodel_.

◆ transitionModel() [1/2]

◆ transitionModel() [2/2]

◆ transitionModel_() [1/2]

TransitionModelInterface& bpp::AbstractWrappedSubstitutionModel::transitionModel_ ( )
inlineprotectedvirtualinherited

◆ transitionModel_() [2/2]

◆ updateMatrices_()

void bpp::AbstractBiblioSubstitutionModel::updateMatrices_ ( )
inlineoverrideprotectedvirtualinherited

Member Data Documentation

◆ lik_

Eigen::VectorXd bpp::AbstractLkTransitionModel::lik_
mutableprivateinherited

◆ lParPmodel_

◆ mapParNamesFromPmodel_

◆ oneModel_

bool bpp::KCM::oneModel_
private

Definition at line 47 of file KCM.h.

Referenced by getName(), and operator=().

◆ pmodel_

std::unique_ptr<KroneckerCodonDistanceSubstitutionModel> bpp::KCM::pmodel_
private

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