bpp-phyl3
3.0.0
|
From a model, compute the likelihood of counts given an ancestral state. More...
#include <Bpp/Phyl/Model/MultinomialFromTransitionModel.h>
Public Member Functions | |
MultinomialFromTransitionModel (std::shared_ptr< TransitionModelInterface > originalModel) | |
MultinomialFromTransitionModel (const MultinomialFromTransitionModel &fmsm) | |
MultinomialFromTransitionModel & | operator= (const MultinomialFromTransitionModel &fmsm) |
virtual | ~MultinomialFromTransitionModel () |
MultinomialFromTransitionModel * | clone () const override |
void | fireParameterChanged (const ParameterList ¶meters) override |
const BranchModelInterface & | model () const override |
const TransitionModelInterface & | transitionModel () const |
const Eigen::VectorXd & | Lik_t (const Eigen::VectorXd &from, double t) const override |
const Eigen::VectorXd & | dLik_dt (const Eigen::VectorXd &from, double t) const override |
const Eigen::VectorXd & | d2Lik_dt2 (const Eigen::VectorXd &from, double t) const override |
void | setFreqFromData (const SequenceDataInterface &data, double pseudoCount=0) |
virtual void | setFreq (std::map< int, double > &m) |
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... | |
void | addRateParameter () override |
void | setNamespace (const std::string &prefix) |
bool | hasIndependentParameter (const std::string &name) const |
const ParameterList & | getIndependentParameters () 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 ParameterList & | getParameters () const override |
const Parameter & | parameter (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 ¶meters) override |
void | setParameterValue (const std::string &name, double value) override |
void | setParametersValues (const ParameterList ¶meters) override |
bool | matchParametersValues (const ParameterList ¶meters) 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 |
const std::vector< int > & | getAlphabetStates () const override |
const StateMapInterface & | stateMap () const override |
std::shared_ptr< const StateMapInterface > | getStateMap () 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 Alphabet & | alphabet () const override |
std::shared_ptr< const Alphabet > | getAlphabet () const override |
size_t | getNumberOfStates () const override |
Get the number of states. More... | |
const FrequencySetInterface & | frequencySet () const override |
Protected Member Functions | |
BranchModelInterface & | model () |
TransitionModelInterface & | transitionModel () |
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 ¶meters) |
void | shareParameter_ (const std::shared_ptr< Parameter > ¶meter) |
void | shareParameters_ (const ParameterList ¶meters) |
void | includeParameters_ (const ParameterList ¶meters) |
void | deleteParameter_ (size_t index) |
void | deleteParameter_ (std::string &name) |
void | deleteParameters_ (const std::vector< std::string > &names) |
void | resetParameters_ () |
Parameter & | getParameter_ (const std::string &name) |
Parameter & | getParameter_ (size_t index) |
const Parameter & | getParameter_ (size_t index) const |
Parameter & | getParameterWithNamespace_ (const std::string &name) |
const Parameter & | getParameterWithNamespace_ (const std::string &name) const |
ParameterList & | getParameters_ () override |
Private Types | |
typedef bool | lessEigenType(Eigen::VectorXd const &, Eigen::VectorXd const &) |
Private Member Functions | |
void | compute_Multinomial_ (const Eigen::VectorXd &counts) const |
Fills the res vector of the likelihoods of the counts given ancestral states & transition matrix. More... | |
void | compute_dMultinomial_dt_ (const Eigen::VectorXd &counts) const |
void | compute_d2Multinomial_dt2_ (const Eigen::VectorXd &counts) const |
double | getFact_ (const Eigen::VectorXd &counts) const |
Compute the log of the normalization term for the multinomial for any count, and keeps it in a map to avoid recalcultation. More... | |
Static Private Member Functions | |
static bool | lessEigen (Eigen::VectorXd const &a, Eigen::VectorXd const &b) |
static uint | factorial (uint n) |
Private Attributes | |
std::shared_ptr< TransitionModelInterface > | subModel_ |
The related model. More... | |
size_t | size_ |
double | tref_ |
Reference time to avoid recomuputation of transition matrix when time has not changed. If <0, it means that transition matrix should be recomputed (for ex if parameters have changed). More... | |
const Matrix< double > * | Pij_t |
Transition Matrices owned by the submodel. More... | |
const Matrix< double > * | dPij_dt |
const Matrix< double > * | d2Pij_dt2 |
Eigen::VectorXd | Pi_ |
Used return vectors. More... | |
Eigen::VectorXd | dPi_ |
Eigen::VectorXd | d2Pi_ |
std::map< Eigen::VectorXd, double, bool(*)(const Eigen::VectorXd &, const Eigen::VectorXd &)> | mapFact_ |
map to store constant values of multinomial More... | |
ParameterList | independentParameters_ |
std::map< std::string, std::shared_ptr< AliasParameterListener > > | aliasListenersRegister_ |
ParameterList | parameters_ |
std::string | prefix_ |
From a model, compute the likelihood of counts given an ancestral state.
It has the same parameters as the SubModel.
If counts are not integers, rounded values are used.
Definition at line 30 of file MultinomialFromTransitionModel.h.
|
private |
Definition at line 33 of file MultinomialFromTransitionModel.h.
|
inline |
Definition at line 98 of file MultinomialFromTransitionModel.h.
References bpp::AbstractParameterAliasable::addParameters_(), bpp::AbstractParameterAliasable::getNamespace(), and subModel_.
Referenced by clone().
|
inline |
Definition at line 109 of file MultinomialFromTransitionModel.h.
|
inlinevirtual |
Definition at line 133 of file MultinomialFromTransitionModel.h.
|
inlineoverridevirtual |
Implements bpp::BranchModelInterface.
Definition at line 180 of file MultinomialFromTransitionModel.h.
References bpp::AbstractParameterAliasable::addParameter_(), bpp::BranchModelInterface::addRateParameter(), bpp::AbstractParameterAliasable::getNamespace(), getRate(), model(), and bpp::Parameter::R_PLUS_STAR.
|
inlineoverridevirtualinherited |
Implements bpp::BranchModelInterface.
Reimplemented in bpp::RegisterRatesSubstitutionModel.
Definition at line 53 of file AbstractWrappedModel.h.
References bpp::BranchModelInterface::alphabet(), and bpp::WrappedModelInterface::model().
Referenced by bpp::RegisterRatesSubstitutionModel::alphabet(), and bpp::OneChangeRegisterTransitionModel::OneChangeRegisterTransitionModel().
|
inlineoverridevirtual |
Implements bpp::AbstractParameterAliasable.
Definition at line 135 of file MultinomialFromTransitionModel.h.
References MultinomialFromTransitionModel().
|
private |
Definition at line 54 of file MultinomialFromTransitionModel.cpp.
References bpp::exp(), and bpp::numeric::log().
|
private |
Definition at line 33 of file MultinomialFromTransitionModel.cpp.
References bpp::exp(), and bpp::numeric::log().
|
private |
Fills the res vector of the likelihoods of the counts given ancestral states & transition matrix.
Definition at line 14 of file MultinomialFromTransitionModel.cpp.
References bpp::exp(), and bpp::numeric::log().
|
overridevirtual |
Implements bpp::BranchModelInterface.
Definition at line 106 of file MultinomialFromTransitionModel.cpp.
References to().
|
overridevirtual |
Implements bpp::BranchModelInterface.
Definition at line 89 of file MultinomialFromTransitionModel.cpp.
References to().
|
inlinestaticprivate |
Definition at line 195 of file MultinomialFromTransitionModel.h.
|
inlineoverridevirtual |
Reimplemented from bpp::AbstractParameterAliasable.
Definition at line 138 of file MultinomialFromTransitionModel.h.
References bpp::AbstractParameterAliasable::fireParameterChanged(), bpp::AbstractParameterAliasable::matchParametersValues(), bpp::NumConstants::MINF(), model(), and tref_.
|
inlineoverridevirtualinherited |
Exception | if no FrequenceSet is associated to this model. |
Implements bpp::BranchModelInterface.
Reimplemented in bpp::RegisterRatesSubstitutionModel, bpp::OneChangeTransitionModel, bpp::OneChangeRegisterTransitionModel, bpp::YN98, and bpp::AbstractWrappedTransitionModel.
Definition at line 59 of file AbstractWrappedModel.h.
References bpp::BranchModelInterface::frequencySet(), and bpp::WrappedModelInterface::model().
Referenced by bpp::YN98::frequencySet().
|
inlineoverridevirtualinherited |
Implements bpp::BranchModelInterface.
Reimplemented in bpp::RegisterRatesSubstitutionModel.
Definition at line 55 of file AbstractWrappedModel.h.
References bpp::BranchModelInterface::getAlphabet(), and bpp::WrappedModelInterface::model().
Referenced by bpp::RegisterRatesSubstitutionModel::getAlphabet(), and bpp::OneChangeRegisterTransitionModel::OneChangeRegisterTransitionModel().
|
inlineoverridevirtualinherited |
index | The model state. |
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().
|
inlineoverridevirtualinherited |
index | The model state. |
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().
|
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().
|
inlineprivate |
Compute the log of the normalization term for the multinomial for any count, and keeps it in a map to avoid recalcultation.
Definition at line 206 of file MultinomialFromTransitionModel.h.
References mapFact_.
|
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.
i | the index of the state in the model. |
state | An observed state in the sequence/site. |
IndexOutOfBoundsException | if array position is out of range. |
BadIntException | if states are not allowed in the associated alphabet. |
Implements bpp::BranchModelInterface.
Definition at line 173 of file MultinomialFromTransitionModel.h.
References bpp::BranchModelInterface::getInitValue(), and transitionModel().
|
inlineoverridevirtualinherited |
Get the state in the model corresponding to a particular state in the alphabet.
code | The alphabet state to check. |
Implements bpp::BranchModelInterface.
Reimplemented in bpp::RegisterRatesSubstitutionModel.
Definition at line 50 of file AbstractWrappedModel.h.
References bpp::BranchModelInterface::getModelStates(), and bpp::WrappedModelInterface::model().
|
inlineoverridevirtualinherited |
Get the state in the model corresponding to a particular state in the alphabet.
code | The alphabet state to check. |
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().
|
inlineoverridevirtual |
Get the name of the model.
Reimplemented from bpp::AbstractWrappedModel.
Definition at line 175 of file MultinomialFromTransitionModel.h.
|
inlineoverridevirtualinherited |
Get the number of states.
For most models, this equals the size of the alphabet.
Implements bpp::BranchModelInterface.
Reimplemented in bpp::RegisterRatesSubstitutionModel.
Definition at line 57 of file AbstractWrappedModel.h.
References bpp::BranchModelInterface::getNumberOfStates(), and bpp::WrappedModelInterface::model().
|
inlineoverridevirtual |
Get the rate.
Implements bpp::BranchModelInterface.
Definition at line 169 of file MultinomialFromTransitionModel.h.
References bpp::BranchModelInterface::getRate(), and transitionModel().
Referenced by addRateParameter().
|
inlineoverridevirtualinherited |
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().
|
inlinestaticprivate |
Definition at line 75 of file MultinomialFromTransitionModel.h.
|
overridevirtual |
This method is used to compute likelihoods in recursions. It computes the probability of a vector given a start state.
values | An vector of states on the site. |
t | time |
IndexOutOfBoundsException | if array position is out of range. |
BadIntException | if states are not allowed in the associated alphabet. |
Implements bpp::BranchModelInterface.
Definition at line 76 of file MultinomialFromTransitionModel.cpp.
References to().
|
inlineprotected |
Definition at line 87 of file MultinomialFromTransitionModel.h.
References subModel_.
Referenced by addRateParameter(), and fireParameterChanged().
|
inlineoverridevirtual |
Implements bpp::WrappedModelInterface.
Definition at line 145 of file MultinomialFromTransitionModel.h.
References subModel_.
|
inline |
Definition at line 117 of file MultinomialFromTransitionModel.h.
References d2Pi_, dPi_, mapFact_, bpp::NumConstants::MINF(), bpp::AbstractParameterAliasable::operator=(), Pi_, size_, subModel_, and tref_.
|
inlinevirtual |
Definition at line 164 of file MultinomialFromTransitionModel.h.
References bpp::TransitionModelInterface::setFreq(), and transitionModel().
|
inline |
Definition at line 159 of file MultinomialFromTransitionModel.h.
References bpp::TransitionModelInterface::setFreqFromData(), and transitionModel().
|
inlineoverridevirtual |
Set the rate of the model (must be positive).
rate | must be positive. |
Implements bpp::BranchModelInterface.
Definition at line 171 of file MultinomialFromTransitionModel.h.
References bpp::BranchModelInterface::setRate(), and transitionModel().
|
inlineoverridevirtualinherited |
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().
|
inlineprotected |
Definition at line 92 of file MultinomialFromTransitionModel.h.
References subModel_.
Referenced by getInitValue(), getRate(), setFreq(), setFreqFromData(), and setRate().
|
inline |
Definition at line 150 of file MultinomialFromTransitionModel.h.
References subModel_.
|
private |
Definition at line 68 of file MultinomialFromTransitionModel.h.
Referenced by operator=().
|
private |
Definition at line 63 of file MultinomialFromTransitionModel.h.
|
private |
Definition at line 68 of file MultinomialFromTransitionModel.h.
Referenced by operator=().
|
private |
Definition at line 63 of file MultinomialFromTransitionModel.h.
|
mutableprivate |
map to store constant values of multinomial
Definition at line 73 of file MultinomialFromTransitionModel.h.
Referenced by getFact_(), and operator=().
|
mutableprivate |
Used return vectors.
Definition at line 68 of file MultinomialFromTransitionModel.h.
Referenced by operator=().
|
mutableprivate |
Transition Matrices owned by the submodel.
These ones are for bookkeeping:
Definition at line 63 of file MultinomialFromTransitionModel.h.
|
private |
Definition at line 46 of file MultinomialFromTransitionModel.h.
Referenced by operator=().
|
private |
The related model.
Definition at line 39 of file MultinomialFromTransitionModel.h.
Referenced by model(), MultinomialFromTransitionModel(), operator=(), and transitionModel().
|
mutableprivate |
Reference time to avoid recomuputation of transition matrix when time has not changed. If <0, it means that transition matrix should be recomputed (for ex if parameters have changed).
Definition at line 54 of file MultinomialFromTransitionModel.h.
Referenced by fireParameterChanged(), and operator=().