bpp-phyl  2.2.0
bpp::AbstractCodonFitnessSubstitutionModel Class Referenceabstract

Abstract class for modelling of ratios of substitution rates between codons, whatever they are synonymous or not. More...

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

+ Inheritance diagram for bpp::AbstractCodonFitnessSubstitutionModel:
+ Collaboration diagram for bpp::AbstractCodonFitnessSubstitutionModel:

Public Member Functions

 AbstractCodonFitnessSubstitutionModel (FrequenciesSet *pfitset, const std::string &prefix)
 
 AbstractCodonFitnessSubstitutionModel (const AbstractCodonFitnessSubstitutionModel &model)
 
AbstractCodonFitnessSubstitutionModeloperator= (const AbstractCodonFitnessSubstitutionModel &model)
 
virtual ~AbstractCodonFitnessSubstitutionModel ()
 
void fireParameterChanged (const ParameterList &parameters)
 
void setFreq (std::map< int, double > &frequencies)
 Set equilibrium frequencies. More...
 
const FrequenciesSetgetFreq () const
 
void setNamespace (const std::string &prefix)
 
double getCodonsMulRate (size_t i, size_t j) const
 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...
 
const FrequenciesSetgetFitness () const
 
virtual CodonSubstitutionModelclone () const =0
 
virtual const GeneticCode * getGeneticCode () const =0
 
virtual std::string getName () const =0
 Get the name of the model. More...
 
virtual const std::vector< int > & getAlphabetStates () const =0
 
virtual const StateMapgetStateMap () const =0
 
virtual std::vector< size_t > getModelStates (int code) const =0
 Get the state in the model corresponding to a particular state in the alphabet. More...
 
virtual std::vector< size_t > getModelStates (const std::string &code) const =0
 Get the state in the model corresponding to a particular state in the alphabet. More...
 
virtual int getAlphabetStateAsInt (size_t index) const =0
 
virtual std::string getAlphabetStateAsChar (size_t index) const =0
 
virtual double freq (size_t i) const =0
 
virtual double Qij (size_t i, size_t j) const =0
 
virtual double Pij_t (size_t i, size_t j, double t) const =0
 
virtual double dPij_dt (size_t i, size_t j, double t) const =0
 
virtual double d2Pij_dt2 (size_t i, size_t j, double t) const =0
 
virtual const Vdouble & getFrequencies () const =0
 
virtual const Matrix< double > & getGenerator () const =0
 
virtual const Matrix< double > & getExchangeabilityMatrix () const =0
 
virtual double Sij (size_t i, size_t j) const =0
 
virtual const Matrix< double > & getPij_t (double t) const =0
 
virtual const Matrix< double > & getdPij_dt (double t) const =0
 
virtual const Matrix< double > & getd2Pij_dt2 (double t) const =0
 
virtual void enableEigenDecomposition (bool yn)=0
 Set if eigenValues and Vectors must be computed. More...
 
virtual bool enableEigenDecomposition ()=0
 Tell if eigenValues and Vectors must be computed. More...
 
virtual const Vdouble & getEigenValues () const =0
 
virtual const Vdouble & getIEigenValues () const =0
 
virtual bool isDiagonalizable () const =0
 
virtual bool isNonSingular () const =0
 
virtual const Matrix< double > & getRowLeftEigenVectors () const =0
 
virtual const Matrix< double > & getColumnRightEigenVectors () const =0
 
virtual const Alphabet * getAlphabet () const =0
 
virtual size_t getNumberOfStates () const =0
 Get the number of states. More...
 
virtual double getInitValue (size_t i, int state) const =0 throw (IndexOutOfBoundsException, BadIntException)
 
virtual double getScale () const =0
 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...
 
virtual void setScale (double scale)=0
 Multiplies the current generator by the given scale. More...
 
virtual double getRate () const =0
 Get the rate. More...
 
virtual void setRate (double rate)=0
 Set the rate of the model (must be positive). More...
 
virtual void addRateParameter ()=0
 
virtual void setFreqFromData (const SequenceContainer &data, double pseudoCount=0)=0
 Set equilibrium frequencies equal to the frequencies estimated from the data. More...
 
virtual const FrequenciesSetgetFrequenciesSet () const
 If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0. More...
 

Private Attributes

FrequenciesSetpfitset_
 
std::string fitName_
 

Detailed Description

Abstract class for modelling of ratios of substitution rates between codons, whatever they are synonymous or not.

Author
Fanny Pouyet, Laurent Guéguen

The fitness of a codon is a value between 0 and 1 defining the relative advantage of a codon, compared to others. If a codon $i$ has a fitness $\phi_i$ and another one ( $j$) has a fitness $\phi_j$, the substitution rate from codon $i$ to codon $j$ is multiplied by

\[-\frac{\log(\frac{\phi_i}{\phi_j})}{1-\frac{\phi_i}{\phi_j}}\]

The set of fitnesses is implemented through a Codon FrequenciesSet object. The parameters are named "fit_NameOfTheParameterInTheFrequenciesSet".

Definition at line 65 of file AbstractCodonFitnessSubstitutionModel.h.

Constructor & Destructor Documentation

◆ AbstractCodonFitnessSubstitutionModel() [1/2]

AbstractCodonFitnessSubstitutionModel::AbstractCodonFitnessSubstitutionModel ( FrequenciesSet pfitset,
const std::string &  prefix 
)

◆ AbstractCodonFitnessSubstitutionModel() [2/2]

bpp::AbstractCodonFitnessSubstitutionModel::AbstractCodonFitnessSubstitutionModel ( const AbstractCodonFitnessSubstitutionModel model)
inline

Definition at line 74 of file AbstractCodonFitnessSubstitutionModel.h.

◆ ~AbstractCodonFitnessSubstitutionModel()

AbstractCodonFitnessSubstitutionModel::~AbstractCodonFitnessSubstitutionModel ( )
virtual

Definition at line 53 of file AbstractCodonFitnessSubstitutionModel.cpp.

References pfitset_.

Member Function Documentation

◆ addRateParameter()

virtual void bpp::SubstitutionModel::addRateParameter ( )
pure virtualinherited

◆ clone()

◆ d2Pij_dt2()

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

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, bpp::F84, bpp::HKY85, bpp::JCprot, bpp::T92, bpp::K80, bpp::RN95, bpp::TN93, bpp::RE08, bpp::JCnuc, bpp::RN95s, bpp::BinarySubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AbstractBiblioSubstitutionModel::d2Pij_dt2().

◆ dPij_dt()

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

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, bpp::F84, bpp::HKY85, bpp::JCprot, bpp::T92, bpp::K80, bpp::RN95, bpp::TN93, bpp::RE08, bpp::JCnuc, bpp::RN95s, bpp::BinarySubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AbstractBiblioSubstitutionModel::dPij_dt().

◆ enableEigenDecomposition() [1/2]

virtual void bpp::SubstitutionModel::enableEigenDecomposition ( bool  yn)
pure virtualinherited

◆ enableEigenDecomposition() [2/2]

virtual bool bpp::SubstitutionModel::enableEigenDecomposition ( )
pure virtualinherited

Tell if eigenValues and Vectors must be computed.

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

◆ fireParameterChanged()

void AbstractCodonFitnessSubstitutionModel::fireParameterChanged ( const ParameterList &  parameters)

◆ freq()

virtual double bpp::SubstitutionModel::freq ( size_t  i) const
pure virtualinherited

◆ getAlphabet()

virtual const Alphabet* bpp::SubstitutionModel::getAlphabet ( ) const
pure virtualinherited
Returns
Get the alphabet associated to this model.

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AAExteriorSubstitutionRegister::AAExteriorSubstitutionRegister(), bpp::AAInteriorSubstitutionRegister::AAInteriorSubstitutionRegister(), bpp::SubstitutionModelSet::addModel(), bpp::DecompositionReward::alphabetIndexHasChanged(), bpp::ComprehensiveSubstitutionRegister::ComprehensiveSubstitutionRegister(), bpp::DecompositionReward::DecompositionReward(), bpp::DecompositionSubstitutionCount::DecompositionSubstitutionCount(), bpp::AbstractMutationProcess::detailedEvolve(), bpp::LaplaceSubstitutionCount::getAllNumbersOfSubstitutions(), bpp::AbstractSubstitutionRegister::getAlphabet(), bpp::AbstractBiblioSubstitutionModel::getAlphabet(), bpp::MarkovModulatedSubstitutionModel::getAlphabet(), bpp::SubstitutionMappingTools::getNormalizationsPerBranch(), bpp::DnDsSubstitutionRegister::getType(), bpp::SelectedSubstitutionRegister::SelectedSubstitutionRegister(), bpp::CategorySubstitutionRegister::setCategories(), bpp::LaplaceSubstitutionCount::setSubstitutionModel(), bpp::UniformizationSubstitutionCount::setSubstitutionModel(), bpp::DecompositionSubstitutionCount::setSubstitutionModel(), bpp::DecompositionReward::setSubstitutionModel(), bpp::UniformizationSubstitutionCount::substitutionRegisterHasChanged(), bpp::DecompositionSubstitutionCount::substitutionRegisterHasChanged(), bpp::UniformizationSubstitutionCount::UniformizationSubstitutionCount(), bpp::YpR::updateMatrices(), and bpp::BppOSubstitutionModelFormat::writeMixed_().

◆ getAlphabetStateAsChar()

virtual std::string bpp::SubstitutionModel::getAlphabetStateAsChar ( size_t  index) const
pure virtualinherited

◆ getAlphabetStateAsInt()

◆ getAlphabetStates()

◆ getCodonsMulRate()

double AbstractCodonFitnessSubstitutionModel::getCodonsMulRate ( size_t  ,
size_t   
) const
virtual

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

Reimplemented in bpp::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.

Definition at line 69 of file AbstractCodonFitnessSubstitutionModel.cpp.

References bpp::FrequenciesSet::getFrequencies(), and pfitset_.

Referenced by bpp::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::getCodonsMulRate().

◆ getColumnRightEigenVectors()

virtual const Matrix<double>& bpp::SubstitutionModel::getColumnRightEigenVectors ( ) const
pure virtualinherited

◆ getd2Pij_dt2()

◆ getdPij_dt()

◆ getEigenValues()

virtual const Vdouble& bpp::SubstitutionModel::getEigenValues ( ) const
pure virtualinherited

◆ getExchangeabilityMatrix()

virtual const Matrix<double>& bpp::SubstitutionModel::getExchangeabilityMatrix ( ) const
pure virtualinherited
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$.

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::Coala::Coala(), bpp::AbstractBiblioSubstitutionModel::getExchangeabilityMatrix(), and bpp::MarkovModulatedSubstitutionModel::updateMatrices().

◆ getFitness()

const FrequenciesSet* bpp::AbstractCodonFitnessSubstitutionModel::getFitness ( ) const
inline

◆ getFreq()

const FrequenciesSet& bpp::AbstractCodonFitnessSubstitutionModel::getFreq ( ) const
inline

Definition at line 93 of file AbstractCodonFitnessSubstitutionModel.h.

References pfitset_.

◆ getFrequencies()

◆ getFrequenciesSet()

◆ getGenerator()

virtual const Matrix<double>& bpp::SubstitutionModel::getGenerator ( ) const
pure virtualinherited
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()

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::LaplaceSubstitutionCount::computeCounts(), bpp::UniformizationSubstitutionCount::computeCounts_(), bpp::AbstractBiblioSubstitutionModel::getGenerator(), bpp::SimpleMutationProcess::SimpleMutationProcess(), and bpp::MarkovModulatedSubstitutionModel::updateMatrices().

◆ getGeneticCode()

◆ getIEigenValues()

virtual const Vdouble& bpp::SubstitutionModel::getIEigenValues ( ) const
pure virtualinherited
Returns
A vector with all imaginary parts of the eigen values of the generator of this model;

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AbstractBiblioSubstitutionModel::getIEigenValues().

◆ getInitValue()

virtual double bpp::SubstitutionModel::getInitValue ( size_t  i,
int  state 
) const
throw (IndexOutOfBoundsException,
BadIntException
)
pure 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();

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, bpp::RE08, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AbstractBiblioSubstitutionModel::getInitValue().

◆ getModelStates() [1/2]

virtual std::vector<size_t> bpp::SubstitutionModel::getModelStates ( int  code) const
pure virtualinherited

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.

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AbstractBiblioSubstitutionModel::getModelStates(), bpp::SubstitutionModelSet::getModelStates(), and bpp::MarginalAncestralStateReconstruction::recursiveMarginalAncestralStates().

◆ getModelStates() [2/2]

virtual std::vector<size_t> bpp::SubstitutionModel::getModelStates ( const std::string &  code) const
pure virtualinherited

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.

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

◆ 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 AbstractCodonFitnessSubstitutionModel(), bpp::AbstractSubstitutionModel::fireParameterChanged(), bpp::MixtureOfSubstitutionModels::getSubmodelNumbers(), bpp::BppOSubstitutionModelFormat::readMixed_(), bpp::AbstractBiblioSubstitutionModel::updateMatrices(), and bpp::BppOSubstitutionModelFormat::write().

◆ getNumberOfStates()

◆ getPij_t()

◆ getRate()

virtual double bpp::SubstitutionModel::getRate ( ) const
pure virtualinherited

◆ getRowLeftEigenVectors()

virtual const Matrix<double>& bpp::SubstitutionModel::getRowLeftEigenVectors ( ) const
pure virtualinherited

◆ getScale()

virtual double bpp::SubstitutionModel::getScale ( ) const
pure 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.

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AbstractBiblioSubstitutionModel::getScale().

◆ getStateMap()

virtual const StateMap& bpp::SubstitutionModel::getStateMap ( ) const
pure virtualinherited

◆ isDiagonalizable()

virtual bool bpp::SubstitutionModel::isDiagonalizable ( ) const
pure virtualinherited

◆ isNonSingular()

virtual bool bpp::SubstitutionModel::isNonSingular ( ) const
pure virtualinherited

◆ operator=()

AbstractCodonFitnessSubstitutionModel& bpp::AbstractCodonFitnessSubstitutionModel::operator= ( const AbstractCodonFitnessSubstitutionModel model)
inline

◆ Pij_t()

virtual double bpp::SubstitutionModel::Pij_t ( size_t  i,
size_t  j,
double  t 
) const
pure virtualinherited

◆ Qij()

◆ setFreq()

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

Set equilibrium frequencies.

Parameters
frequenciesThe map of the frequencies to use.

Reimplemented from bpp::SubstitutionModel.

Reimplemented in bpp::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.

Definition at line 63 of file AbstractCodonFitnessSubstitutionModel.cpp.

References pfitset_, and bpp::FrequenciesSet::setFrequenciesFromAlphabetStatesFrequencies().

Referenced by bpp::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::setFreq().

◆ setFreqFromData()

virtual void bpp::SubstitutionModel::setFreqFromData ( const SequenceContainer &  data,
double  pseudoCount = 0 
)
pure 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)} \]

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, bpp::JCprot, bpp::K80, bpp::RE08, bpp::JCnuc, bpp::UserProteinSubstitutionModel, bpp::AbstractBiblioSubstitutionModel, bpp::WAG01, bpp::DSO78, bpp::JTT92, bpp::LG08, and bpp::Coala.

Referenced by bpp::BppOSubstitutionModelFormat::read(), bpp::AbstractBiblioSubstitutionModel::setFreqFromData(), and bpp::MarkovModulatedSubstitutionModel::setFreqFromData().

◆ setNamespace()

void bpp::AbstractCodonFitnessSubstitutionModel::setNamespace ( const std::string &  prefix)
inline

◆ setRate()

virtual void bpp::SubstitutionModel::setRate ( double  rate)
pure virtualinherited

◆ setScale()

virtual void bpp::SubstitutionModel::setScale ( double  scale)
pure virtualinherited

Multiplies the current generator by the given scale.

Parameters
scalethe scale by which the generator is multiplied.

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AbstractBiblioSubstitutionModel::setScale(), and bpp::MarkovModulatedSubstitutionModel::setScale().

◆ Sij()

virtual double bpp::SubstitutionModel::Sij ( size_t  i,
size_t  j 
) const
pure virtualinherited
Returns
The exchangeability between state i and state j.

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

Implemented in bpp::AbstractSubstitutionModel, bpp::MarkovModulatedSubstitutionModel, and bpp::AbstractBiblioSubstitutionModel.

Referenced by bpp::AbstractBiblioSubstitutionModel::Sij().

Member Data Documentation

◆ fitName_

std::string bpp::AbstractCodonFitnessSubstitutionModel::fitName_
private

◆ pfitset_


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