bpp-phyl3  3.0.0
bpp::OneChangeTransitionModel Class Referenceabstract

From a model, compute transition probabilities given there is at least a change in the branch. More...

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

+ Inheritance diagram for bpp::OneChangeTransitionModel:
+ Collaboration diagram for bpp::OneChangeTransitionModel:

Public Member Functions

 OneChangeTransitionModel (std::unique_ptr< SubstitutionModelInterface > originalModel)
 
 OneChangeTransitionModel (const OneChangeTransitionModel &fmsm)
 
OneChangeTransitionModeloperator= (const OneChangeTransitionModel &fmsm)
 
virtual ~OneChangeTransitionModel ()
 
OneChangeTransitionModelclone () const override
 
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 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 freq (size_t i) const override
 
const VdoublegetFrequencies () const override
 
const FrequencySetInterfacefrequencySet () const override
 
void setFreqFromData (const SequenceDataInterface &data, double pseudoCount) override
 Set equilibrium frequencies equal to the frequencies estimated from the data. More...
 
virtual void setFreq (std::map< int, double > &m) override
 Set equilibrium frequencies. More...
 
double getRate () const override
 Get the rate. More...
 
void setRate (double rate) override
 Set the rate of the model (must be positive). More...
 
double getInitValue (size_t i, int state) const override
 
std::string getName () const override
 Get the name of the model. More...
 
const SubstitutionModelInterfacesubstitutionModel () const
 
const TransitionModelInterfacetransitionModel () const override
 
const BranchModelInterfacemodel () const override
 
bool computeFrequencies () const override
 
void computeFrequencies (bool yn) override
 
virtual void addRateParameter () override
 
virtual void fireParameterChanged (const ParameterList &parameters) override
 
virtual void setNamespace (const std::string &prefix) 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
 
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...
 

Protected Member Functions

VdoublegetFrequencies_ () override
 
SubstitutionModelInterfacesubstitutionModel_ ()
 
TransitionModelInterfacetransitionModel_ () override
 
BranchModelInterfacemodel_ ()
 
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::unique_ptr< SubstitutionModelInterfacesubModel_
 The related model. More...
 
size_t size_
 
RowMatrix< double > pij_t
 These ones are for bookkeeping: More...
 
RowMatrix< double > dpij_t
 
RowMatrix< double > d2pij_t
 
std::string nestedPrefix_
 

Private Attributes

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

Detailed Description

From a model, compute transition probabilities given there is at least a change in the branch.

It has the same parameters as the SubModel.

Definition at line 20 of file OneChangeTransitionModel.h.

Constructor & Destructor Documentation

◆ OneChangeTransitionModel() [1/2]

bpp::OneChangeTransitionModel::OneChangeTransitionModel ( std::unique_ptr< SubstitutionModelInterface originalModel)
inline

Definition at line 24 of file OneChangeTransitionModel.h.

Referenced by clone().

◆ OneChangeTransitionModel() [2/2]

bpp::OneChangeTransitionModel::OneChangeTransitionModel ( const OneChangeTransitionModel fmsm)
inline

Definition at line 31 of file OneChangeTransitionModel.h.

◆ ~OneChangeTransitionModel()

virtual bpp::OneChangeTransitionModel::~OneChangeTransitionModel ( )
inlinevirtual

Definition at line 46 of file OneChangeTransitionModel.h.

Member Function Documentation

◆ addRateParameter()

◆ alphabet()

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

◆ clone()

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

Implements bpp::AbstractParameterAliasable.

Definition at line 48 of file OneChangeTransitionModel.h.

References OneChangeTransitionModel().

◆ computeFrequencies() [1/2]

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

Implements bpp::TransitionModelInterface.

Definition at line 69 of file AbstractFromSubstitutionModelTransitionModel.h.

References bpp::AbstractFromSubstitutionModelTransitionModel::subModel_.

◆ computeFrequencies() [2/2]

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

Implements bpp::TransitionModelInterface.

Definition at line 78 of file AbstractFromSubstitutionModelTransitionModel.h.

References bpp::AbstractFromSubstitutionModelTransitionModel::subModel_.

◆ 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 OneChangeTransitionModel::d2Pij_dt2 ( size_t  i,
size_t  j,
double  t 
) const
overridevirtual
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 60 of file OneChangeTransitionModel.cpp.

References bpp::exp().

◆ 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 OneChangeTransitionModel::dPij_dt ( size_t  i,
size_t  j,
double  t 
) const
overridevirtual
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 34 of file OneChangeTransitionModel.cpp.

References bpp::exp().

◆ fireParameterChanged()

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

◆ freq()

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

Implements bpp::TransitionModelInterface.

Definition at line 61 of file OneChangeTransitionModel.h.

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

◆ frequencySet()

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

Reimplemented from bpp::AbstractWrappedTransitionModel.

Definition at line 65 of file OneChangeTransitionModel.h.

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

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

◆ getd2Pij_dt2()

const Matrix< double > & OneChangeTransitionModel::getd2Pij_dt2 ( double  t) const
overridevirtual
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 221 of file OneChangeTransitionModel.cpp.

References bpp::exp(), and RowMatrix< double >::getRow().

◆ getdPij_dt()

const Matrix< double > & OneChangeTransitionModel::getdPij_dt ( double  t) const
overridevirtual
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 150 of file OneChangeTransitionModel.cpp.

References bpp::exp(), and RowMatrix< double >::getRow().

◆ getFrequencies()

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

Implements bpp::TransitionModelInterface.

Definition at line 63 of file OneChangeTransitionModel.h.

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

◆ getFrequencies_()

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

◆ getInitValue()

double bpp::OneChangeTransitionModel::getInitValue ( size_t  i,
int  state 
) const
inlineoverridevirtual

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 84 of file OneChangeTransitionModel.h.

References bpp::BranchModelInterface::getInitValue(), and bpp::AbstractFromSubstitutionModelTransitionModel::model().

◆ 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::OneChangeTransitionModel::getName ( ) const
inlineoverridevirtual

Get the name of the model.

Returns
The name of this model.

Reimplemented from bpp::AbstractWrappedModel.

Definition at line 89 of file OneChangeTransitionModel.h.

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

◆ getPij_t()

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

Implements bpp::TransitionModelInterface.

Definition at line 106 of file OneChangeTransitionModel.cpp.

References bpp::exp(), and RowMatrix< double >::getRow().

◆ getRate()

double bpp::OneChangeTransitionModel::getRate ( ) const
inlineoverridevirtual

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

◆ 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_()

◆ operator=()

◆ Pij_t()

double OneChangeTransitionModel::Pij_t ( size_t  i,
size_t  j,
double  t 
) const
overridevirtual
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 14 of file OneChangeTransitionModel.cpp.

References bpp::exp().

◆ setFreq()

virtual void bpp::OneChangeTransitionModel::setFreq ( std::map< int, double > &  frequencies)
inlineoverridevirtual

Set equilibrium frequencies.

Parameters
frequenciesThe map of the frequencies to use.

Implements bpp::TransitionModelInterface.

Definition at line 75 of file OneChangeTransitionModel.h.

References bpp::TransitionModelInterface::setFreq(), and bpp::AbstractFromSubstitutionModelTransitionModel::transitionModel_().

◆ setFreqFromData()

void bpp::OneChangeTransitionModel::setFreqFromData ( const SequenceDataInterface data,
double  pseudoCount 
)
inlineoverridevirtual

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 70 of file OneChangeTransitionModel.h.

References bpp::TransitionModelInterface::setFreqFromData(), and bpp::AbstractFromSubstitutionModelTransitionModel::transitionModel_().

◆ setNamespace()

virtual void bpp::AbstractFromSubstitutionModelTransitionModel::setNamespace ( const std::string &  prefix)
inlineoverridevirtualinherited

◆ setRate()

void bpp::OneChangeTransitionModel::setRate ( double  rate)
inlineoverridevirtual

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

Parameters
ratemust be positive.

Implements bpp::BranchModelInterface.

Definition at line 82 of file OneChangeTransitionModel.h.

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

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

◆ substitutionModel_()

SubstitutionModelInterface& bpp::AbstractFromSubstitutionModelTransitionModel::substitutionModel_ ( )
inlineprotectedinherited

◆ transitionModel()

◆ transitionModel_()

Member Data Documentation

◆ d2pij_t

RowMatrix<double> bpp::AbstractFromSubstitutionModelTransitionModel::d2pij_t
mutableprotectedinherited

◆ dpij_t

RowMatrix<double> bpp::AbstractFromSubstitutionModelTransitionModel::dpij_t
mutableprotectedinherited

◆ lik_

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

◆ nestedPrefix_

◆ pij_t

RowMatrix<double> bpp::AbstractFromSubstitutionModelTransitionModel::pij_t
mutableprotectedinherited

◆ size_

◆ subModel_


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