bpp-phyl  2.1.0
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
bpp::AbstractCodonPhaseFrequenciesSubstitutionModel Class Referenceabstract

Abstract Class for substitution models on codons parametrized by a frequency. More...

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

+ Inheritance diagram for bpp::AbstractCodonPhaseFrequenciesSubstitutionModel:
+ Collaboration diagram for bpp::AbstractCodonPhaseFrequenciesSubstitutionModel:

Public Member Functions

 AbstractCodonPhaseFrequenciesSubstitutionModel (FrequenciesSet *pfreq, const std::string &prefix)
 Build a AbstractCodonPhaseFrequenciesSubstitutionModel instance. More...
 
 AbstractCodonPhaseFrequenciesSubstitutionModel (const AbstractCodonPhaseFrequenciesSubstitutionModel &model)
 
AbstractCodonPhaseFrequenciesSubstitutionModeloperator= (const AbstractCodonPhaseFrequenciesSubstitutionModel &model)
 
virtual ~AbstractCodonPhaseFrequenciesSubstitutionModel ()
 
void fireParameterChanged (const ParameterList &parameters)
 
void setFreq (std::map< int, double > &frequencies)
 Set equilibrium frequencies. More...
 
const FrequenciesSetgetFrequenciesSet () const
 If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0. More...
 
void setNamespace (const std::string &prefix)
 
double getCodonsMulRate (size_t, size_t) 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...
 
virtual CodonSubstitutionModelclone () const =0
 
virtual const GeneticCodegetGeneticCode () const =0
 
virtual std::string getName () const =0
 Get the name of the model. More...
 
virtual const std::vector< int > & getAlphabetChars () const =0
 
virtual int getAlphabetChar (size_t i) const =0
 Get the char in the alphabet corresponding to a given state in the model. More...
 
virtual std::vector< size_t > getModelStates (int i) const =0
 Get the state in the model corresponding to a particular char in the alphabet. More...
 
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 VdoublegetFrequencies () 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 VdoublegetEigenValues () const =0
 
virtual const VdoublegetIEigenValues () 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 AlphabetgetAlphabet () 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 size_t getNumberOfIndependentParameters () const =0
 
virtual void aliasParameters (const std::string &p1, const std::string &p2)=0
 
virtual void aliasParameters (std::map< std::string, std::string > &unparsedParams, bool verbose)=0
 
virtual void unaliasParameters (const std::string &p1, const std::string &p2)=0
 
virtual const ParameterListgetIndependentParameters () const =0
 
virtual std::vector< std::string > getAlias (const std::string &name) const =0
 
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
 
std::vector< std::string > getAlias (const std::string &name) const
 
std::string getFrom (const std::string &name) const
 
bool hasParameter (const std::string &name) const
 
const ParameterListgetParameters () const
 
const ParametergetParameter (const std::string &name) const
 
double getParameterValue (const std::string &name) const
 
void setAllParametersValues (const ParameterList &parameters)
 
void setParameterValue (const std::string &name, double value)
 
void setParametersValues (const ParameterList &parameters)
 
bool matchParametersValues (const ParameterList &parameters)
 
size_t getNumberOfParameters () const
 
std::string getNamespace () const
 
std::string getParameterNameWithoutNamespace (const std::string &name) const
 

Protected Member Functions

void addParameter_ (Parameter *parameter)
 
void addParameters_ (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_ ()
 

Private Attributes

WordFrequenciesSetposfreqset_
 Position dependent version of Codon Frequencies Set. More...
 
std::string freqName_
 

Detailed Description

Abstract Class for substitution models on codons parametrized by a frequency.

Author
Laurent Gu├ęguen

This class should be used with models which equilibrium distribution is fixed, ans does not depend on the parameters. Otherwise there may be problems of identifiability of the parameters.

If we denote $F$ the given frequencies for codons, $F_{j_k}$ is the frequency of letter $j$ in phase $k$.

For codons $i=i_1i_2i_3$ and $j=j_1j_2j_3$, the generator term defined from inherited and inheriting classes, $Q_{ij})$, is multiplied by the product of the $F_{j_k}$ for each $k \in 1, 2, 3$ such that $i_k \neq j_k$.

Definition at line 69 of file AbstractCodonPhaseFrequenciesSubstitutionModel.h.

Constructor & Destructor Documentation

AbstractCodonPhaseFrequenciesSubstitutionModel::AbstractCodonPhaseFrequenciesSubstitutionModel ( FrequenciesSet pfreq,
const std::string &  prefix 
)
bpp::AbstractCodonPhaseFrequenciesSubstitutionModel::AbstractCodonPhaseFrequenciesSubstitutionModel ( const AbstractCodonPhaseFrequenciesSubstitutionModel model)
inline
AbstractCodonPhaseFrequenciesSubstitutionModel::~AbstractCodonPhaseFrequenciesSubstitutionModel ( )
virtual

Definition at line 93 of file AbstractCodonPhaseFrequenciesSubstitutionModel.cpp.

References posfreqset_.

Member Function Documentation

virtual void bpp::SubstitutionModel::addRateParameter ( )
pure virtualinherited
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().

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

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

Tell if eigenValues and Vectors must be computed.

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

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

Get the char in the alphabet corresponding to a given state in the model.

In most cases, this method will return i.

Parameters
iThe index of the state.
Returns
The corresponding state in the alphabet.
See Also
MarkovModulatedSubstitutionModel
getStates()

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

Referenced by bpp::AbstractBiblioSubstitutionModel::getAlphabetChar(), bpp::MarginalAncestralStateReconstruction::getAncestralSequenceForNode(), and bpp::NonHomogeneousSequenceSimulator::multipleEvolve().

virtual const std::vector<int>& bpp::SubstitutionModel::getAlphabetChars ( ) const
pure virtualinherited
double AbstractCodonPhaseFrequenciesSubstitutionModel::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::CodonDistancePhaseFrequenciesSubstitutionModel, and bpp::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel.

Definition at line 111 of file AbstractCodonPhaseFrequenciesSubstitutionModel.cpp.

References bpp::FrequenciesSet::getFrequencies(), bpp::WordFrequenciesSet::getFrequenciesSetForLetter(), and posfreqset_.

Referenced by bpp::CodonDistanceFitnessPhaseFrequenciesSubstitutionModel::getCodonsMulRate(), and bpp::CodonDistancePhaseFrequenciesSubstitutionModel::getCodonsMulRate().

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

const FrequenciesSet* bpp::AbstractCodonPhaseFrequenciesSubstitutionModel::getFrequenciesSet ( ) const
inlinevirtual

If the model owns a FrequenciesSet, returns a pointer to it, otherwise return 0.

Reimplemented from bpp::SubstitutionModel.

Definition at line 115 of file AbstractCodonPhaseFrequenciesSubstitutionModel.h.

References posfreqset_.

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

virtual const GeneticCode* bpp::CodonSubstitutionModel::getGeneticCode ( ) const
pure virtualinherited
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().

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

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

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

Parameters
iThe alphabet char 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::MarkovModulatedSubstitutionModel::getModelStates(), and bpp::MarginalAncestralStateReconstruction::recursiveMarginalAncestralStates().

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::G2001, bpp::LG08, bpp::YNGKP_M1, bpp::YNGKP_M8, bpp::gBGC, bpp::TS98, bpp::YNGKP_M7, bpp::GY94, bpp::YNGKP_M2, bpp::YNGKP_M3, bpp::TripletSubstitutionModel, bpp::YN98, 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(), bpp::AbstractSubstitutionModel::fireParameterChanged(), bpp::MixtureOfSubstitutionModels::getSubmodelNumbers(), bpp::BppOSubstitutionModelFormat::readMixed_(), bpp::AbstractBiblioSubstitutionModel::updateMatrices(), and bpp::BppOSubstitutionModelFormat::write().

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

virtual bool bpp::SubstitutionModel::isDiagonalizable ( ) const
pure virtualinherited
virtual bool bpp::SubstitutionModel::isNonSingular ( ) const
pure virtualinherited
virtual double bpp::SubstitutionModel::Pij_t ( size_t  i,
size_t  j,
double  t 
) const
pure virtualinherited
void AbstractCodonPhaseFrequenciesSubstitutionModel::setFreq ( std::map< int, double > &  frequencies)
virtual
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::WAG01, bpp::AbstractBiblioSubstitutionModel, bpp::DSO78, bpp::JTT92, bpp::LG08, and bpp::Coala.

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

void bpp::AbstractCodonPhaseFrequenciesSubstitutionModel::setNamespace ( const std::string &  prefix)
inline
virtual void bpp::SubstitutionModel::setRate ( double  rate)
pure virtualinherited
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().

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

std::string bpp::AbstractCodonPhaseFrequenciesSubstitutionModel::freqName_
private
WordFrequenciesSet* bpp::AbstractCodonPhaseFrequenciesSubstitutionModel::posfreqset_
private

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