5 #ifndef BPP_PHYL_MODEL_MARKOVMODULATEDSUBSTITUTIONMODEL_H
6 #define BPP_PHYL_MODEL_MARKOVMODULATEDSUBSTITUTIONMODEL_H
52 std::unique_ptr<ReversibleSubstitutionModelInterface>
model_;
53 std::shared_ptr<const MarkovModulatedStateMap>
stateMap_;
140 std::unique_ptr<ReversibleSubstitutionModelInterface> model,
141 unsigned int nbRates,
142 bool normalizeRateChanges,
143 const std::string& prefix) :
216 double freq(
size_t i)
const override {
return freq_[i]; }
220 double Pij_t (
size_t i,
size_t j,
double t)
const override {
return getPij_t(t)(i, j); }
224 double getInitValue(
size_t i,
int state)
const override;
228 model_->setFreqFromData(data, pseudoCount);
232 void setFreq(std::map<int, double>& frequencies)
override
234 model_->setFreq(frequencies);
240 throw NullPointerException(
"MarkovModulatedSubstitutionModel::frequencySet. No FrequencySet associated to this model. Frequencies are computed from the FrequencySet of the modulated model.");
266 return model_->isScalable();
271 model_->setScalable(scalable);
284 std::vector<double> v;
286 return -VectorTools::scalar<double, double>(v,
freq_);
311 model_->matchParametersValues(parameters);
Partial implementation of the TransitionModel interface, with function for likelihood computations.
void addParameters_(const ParameterList ¶meters)
std::string getNamespace() const override
Parametrize a set of state frequencies.
This class implements a state map for Markov modulated models.
Partial implementation of the Markov-modulated class of substitution models.
RowMatrix< double > d2pijt_
virtual void updateMatrices_()
double Qij(size_t i, size_t j) const override
A method for computing all necessary matrices.
std::shared_ptr< const StateMapInterface > getStateMap() const override
const Matrix< double > & generator() const override
Vdouble & getFrequencies_() override
bool compFreq_
Tell if the equilibrium frequencies should be computed from the generator.
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.
double Sij(size_t i, size_t j) const override
RowMatrix< double > rightEigenVectors_
The matrix made of right eigen vectors (by column).
double freq(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.
const Alphabet & alphabet() const override
bool enableEigenDecomposition() override
Tell if eigenValues and Vectors must be computed.
MarkovModulatedSubstitutionModel * clone() const override=0
double getInitValue(size_t i, int state) const override
bool isScalable() const override
returns if model is scalable
const Matrix< double > & getColumnRightEigenVectors() const override
std::shared_ptr< const MarkovModulatedStateMap > stateMap_
const FrequencySetInterface & frequencySet() const override
std::unique_ptr< ReversibleSubstitutionModelInterface > model_
void setScale(double scale) override
Multiplies the current generator by the given scale.
void setRate(double rate) override
Set the rate of the model (must be positive).
bool isDiagonalizable() const override
const Matrix< double > & getdPij_dt(double t) const override
void enableEigenDecomposition(bool yn) override
Set if eigenValues and Vectors must be computed.
void setScalable(bool scalable) override
sets if model is scalable, ie scale can be changed. Default : true, set to false to avoid normalizati...
RowMatrix< double > dpijt_
const std::vector< int > & getAlphabetStates() const override
MarkovModulatedSubstitutionModel & operator=(const MarkovModulatedSubstitutionModel &model)
virtual void fireParameterChanged(const ParameterList ¶meters) override
Tells the model that a parameter value has changed.
const Matrix< double > & getPij_t(double t) const override
bool normalizeRateChanges_
void normalize() override
Normalize the generator.
int getAlphabetStateAsInt(size_t index) const override
Vdouble iEigenValues_
The vector of imaginary parts of the eigen values (zero in case of reversible pmodel).
std::shared_ptr< const Alphabet > getAlphabet() const override
MarkovModulatedSubstitutionModel(std::unique_ptr< ReversibleSubstitutionModelInterface > model, unsigned int nbRates, bool normalizeRateChanges, const std::string &prefix)
Build a new MarkovModulatedSubstitutionModel object.
RowMatrix< double > ratesExchangeability_
RowMatrix< double > pijt_
These ones are for bookkeeping:
const Matrix< double > & getd2Pij_dt2(double t) const override
std::string nestedPrefix_
double Pij_t(size_t i, size_t j, double t) const override
bool isNonSingular() const override
const Matrix< double > & exchangeabilityMatrix() const override
RowMatrix< double > ratesGenerator_
size_t getRate(size_t i) const
Get the rate category corresponding to a particular state in the compound model.
double getScale() const override
Get the scalar product of diagonal elements of the generator and the frequencies vector....
void setFreqFromData(const SequenceDataInterface &data, double pseudoCount=0) override
Set equilibrium frequencies equal to the frequencies estimated from the data.
const StateMapInterface & stateMap() const override
RowMatrix< double > exchangeability_
The exchangeability matrix of the model.
Vdouble freq_
The vector of equilibrium frequencies.
RowMatrix< double > generator_
The generator matrix of the model.
bool computeFrequencies() const override
std::string getAlphabetStateAsChar(size_t index) const override
void setDiagonal() override
set the diagonal of the generator such that sum on each line equals 0.
bool eigenDecompose_
Tell if the eigen decomposition should be performed.
double dPij_dt(size_t i, size_t j, double t) const override
Vdouble eigenValues_
The vector of real parts of eigen values.
const Vdouble & getEigenValues() const override
virtual ~MarkovModulatedSubstitutionModel()
const Vdouble & getFrequencies() const override
virtual void updateRatesModel_()=0
Update the rates vector, generator and equilibrium frequencies.
double d2Pij_dt2(size_t i, size_t j, double t) const override
RowMatrix< double > rates_
const Matrix< double > & getRowLeftEigenVectors() const override
RowMatrix< double > leftEigenVectors_
The matrix made of left eigen vectors (by row).
const Vdouble & getIEigenValues() const override
double getRate() const override
Get the rate.
void setNamespace(const std::string &prefix) override
void computeFrequencies(bool yn) override
void setFreq(std::map< int, double > &frequencies) override
Set equilibrium frequencies.
size_t getNumberOfStates() const override
Get the number of states.
const ReversibleSubstitutionModelInterface & nestedModel() const
Interface for reversible substitution models.
Map the states of a given alphabet which have a model state.
Defines the basic types of data flow nodes.
std::vector< double > Vdouble