bpp-phyl3  3.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
bpp::UniformizationSubstitutionCount Class Reference

Analytical (weighted) substitution count using the uniformization method. More...

#include <Bpp/Phyl/Mapping/UniformizationSubstitutionCount.h>

+ Inheritance diagram for bpp::UniformizationSubstitutionCount:
+ Collaboration diagram for bpp::UniformizationSubstitutionCount:

Public Member Functions

 UniformizationSubstitutionCount (std::shared_ptr< const SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=nullptr, std::shared_ptr< const AlphabetIndex2 > distances=nullptr)
 
 UniformizationSubstitutionCount (const StateMapInterface &stateMap, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=nullptr, std::shared_ptr< const AlphabetIndex2 > distances=nullptr)
 
 UniformizationSubstitutionCount (const UniformizationSubstitutionCount &usc)
 
UniformizationSubstitutionCountoperator= (const UniformizationSubstitutionCount &usc)
 
virtual ~UniformizationSubstitutionCount ()
 
UniformizationSubstitutionCountclone () const override
 
double getNumberOfSubstitutions (size_t initialState, size_t finalState, double length, size_t type=1) const override
 Get the number of susbstitutions on a branch, given the initial and final states, and the branch length. More...
 
std::unique_ptr< Matrix< double > > getAllNumbersOfSubstitutions (double length, size_t type=1) const override
 Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length. More...
 
void storeAllNumbersOfSubstitutions (double length, size_t type, Eigen::MatrixXd &mat) const override
 Stores the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length. More...
 
std::vector< double > getNumberOfSubstitutionsPerType (size_t initialState, size_t finalState, double length) const override
 Get the numbers of susbstitutions on a branch for all types, for an initial and final states, given the branch length. More...
 
void setSubstitutionModel (std::shared_ptr< const SubstitutionModelInterface > model) override
 Set the substitution model associated with this count, if relevant. More...
 
bool hasSubstitutionRegister () const
 
void setSubstitutionRegister (std::shared_ptr< const SubstitutionRegisterInterface > reg)
 attribution of a SubstitutionRegister More...
 
std::shared_ptr< const SubstitutionRegisterInterfacegetSubstitutionRegister () const
 
virtual size_t getNumberOfSubstitutionTypes () const
 Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes(). More...
 
virtual std::shared_ptr< const AlphabetgetAlphabet () const
 Short cut function, equivalent to getSubstitutionRegister()->getAlphabet(). More...
 
virtual size_t getNumberOfStates () const
 Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize(). More...
 
void setWeights (std::shared_ptr< const AlphabetIndex2 > weights)
 
bool hasWeights () const
 
std::shared_ptr< const AlphabetIndex2getWeights () const
 
void setDistances (std::shared_ptr< const AlphabetIndex2 > distances)
 
bool hasDistances () const
 
std::shared_ptr< const AlphabetIndex2getDistances () const
 

Protected Member Functions

void computeCounts_ (double length) const
 
void substitutionRegisterHasChanged () override
 
void weightsHaveChanged () override
 
void distancesHaveChanged () override
 

Protected Attributes

std::shared_ptr< const SubstitutionRegisterInterfaceregister_
 
std::shared_ptr< const AlphabetIndex2weights_
 
std::shared_ptr< const AlphabetIndex2distances_
 

Private Member Functions

void resetBMatrices_ ()
 
void initBMatrices_ ()
 
void fillBMatrices_ ()
 
void setDistanceBMatrices_ ()
 

Private Attributes

std::shared_ptr< const SubstitutionModelInterfacemodel_
 
size_t nbStates_
 
std::vector< RowMatrix< double > > bMatrices_
 
std::vector< RowMatrix< double > > power_
 
std::vector< std::vector< RowMatrix< double > > > s_
 
double miu_
 
std::vector< RowMatrix< double > > counts_
 
double currentLength_
 

Detailed Description

Analytical (weighted) substitution count using the uniformization method.

The code is adapted from the original R code by Paula Tataru and Asger Hobolth.

Author
Julien Dutheil

Definition at line 22 of file UniformizationSubstitutionCount.h.

Constructor & Destructor Documentation

◆ UniformizationSubstitutionCount() [1/3]

UniformizationSubstitutionCount::UniformizationSubstitutionCount ( std::shared_ptr< const SubstitutionModelInterface model,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 weights = nullptr,
std::shared_ptr< const AlphabetIndex2 distances = nullptr 
)

Definition at line 16 of file UniformizationSubstitutionCount.cpp.

References bpp::abs(), fillBMatrices_(), initBMatrices_(), miu_, model_, and nbStates_.

Referenced by clone().

◆ UniformizationSubstitutionCount() [2/3]

UniformizationSubstitutionCount::UniformizationSubstitutionCount ( const StateMapInterface stateMap,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 weights = nullptr,
std::shared_ptr< const AlphabetIndex2 distances = nullptr 
)

Definition at line 53 of file UniformizationSubstitutionCount.cpp.

◆ UniformizationSubstitutionCount() [3/3]

bpp::UniformizationSubstitutionCount::UniformizationSubstitutionCount ( const UniformizationSubstitutionCount usc)
inline

Definition at line 50 of file UniformizationSubstitutionCount.h.

◆ ~UniformizationSubstitutionCount()

virtual bpp::UniformizationSubstitutionCount::~UniformizationSubstitutionCount ( )
inlinevirtual

Definition at line 80 of file UniformizationSubstitutionCount.h.

Member Function Documentation

◆ clone()

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

◆ computeCounts_()

◆ distancesHaveChanged()

void UniformizationSubstitutionCount::distancesHaveChanged ( )
overrideprotectedvirtual

◆ fillBMatrices_()

◆ getAllNumbersOfSubstitutions()

unique_ptr< Matrix< double > > UniformizationSubstitutionCount::getAllNumbersOfSubstitutions ( double  length,
size_t  type = 1 
) const
overridevirtual

Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length.

Parameters
lengthThe length of the branch.
typeThe type of susbstitution to count.
Returns
A matrix with all numbers of substitutions for each initial and final states.

Implements bpp::SubstitutionCountInterface.

Definition at line 195 of file UniformizationSubstitutionCount.cpp.

References computeCounts_(), counts_, currentLength_, model_, and bpp::TextTools::toString().

◆ getAlphabet()

virtual std::shared_ptr<const Alphabet> bpp::SubstitutionCountInterface::getAlphabet ( ) const
inlinevirtualinherited

Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().

Returns
The alphabet associated to this substitution count.

Definition at line 78 of file SubstitutionCount.h.

References bpp::SubstitutionCountInterface::getSubstitutionRegister().

◆ getDistances()

std::shared_ptr<const AlphabetIndex2> bpp::AbstractSubstitutionDistance::getDistances ( ) const
inlinevirtualinherited

◆ getNumberOfStates()

virtual size_t bpp::SubstitutionCountInterface::getNumberOfStates ( ) const
inlinevirtualinherited

Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().

Returns
The number of states in the model/alphabet.

Definition at line 85 of file SubstitutionCount.h.

References bpp::SubstitutionCountInterface::getSubstitutionRegister().

◆ getNumberOfSubstitutions()

double UniformizationSubstitutionCount::getNumberOfSubstitutions ( size_t  initialState,
size_t  finalState,
double  length,
size_t  type = 1 
) const
overridevirtual

Get the number of susbstitutions on a branch, given the initial and final states, and the branch length.

Parameters
initialStateThe initial state.
finalStateThe final state.
lengthThe length of the branch.
typeThe type of substitution to count.
Returns
The number of substitutions on a branch of specified length and according to initial and final states.

Implements bpp::SubstitutionCountInterface.

Definition at line 239 of file UniformizationSubstitutionCount.cpp.

References computeCounts_(), counts_, currentLength_, model_, and bpp::TextTools::toString().

◆ getNumberOfSubstitutionsPerType()

std::vector< double > UniformizationSubstitutionCount::getNumberOfSubstitutionsPerType ( size_t  initialState,
size_t  finalState,
double  length 
) const
overridevirtual

Get the numbers of susbstitutions on a branch for all types, for an initial and final states, given the branch length.

Parameters
initialStateThe initial state.
finalStateThe final state.
lengthThe length of the branch.
Returns
A matrix with all numbers of substitutions for each initial and final states.

Implements bpp::SubstitutionCountInterface.

Definition at line 256 of file UniformizationSubstitutionCount.cpp.

References computeCounts_(), counts_, currentLength_, bpp::SubstitutionCountInterface::getNumberOfSubstitutionTypes(), model_, and bpp::TextTools::toString().

◆ getNumberOfSubstitutionTypes()

virtual size_t bpp::SubstitutionCountInterface::getNumberOfSubstitutionTypes ( ) const
inlinevirtualinherited

◆ getSubstitutionRegister()

std::shared_ptr<const SubstitutionRegisterInterface> bpp::AbstractSubstitutionCount::getSubstitutionRegister ( ) const
inlinevirtualinherited
Returns
The SubstitutionRegister object associated to this instance. The register contains the description of the various substitutions types that are mapped.

Implements bpp::SubstitutionCountInterface.

Definition at line 170 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ getWeights()

std::shared_ptr<const AlphabetIndex2> bpp::AbstractWeightedSubstitutionCount::getWeights ( ) const
inlinevirtualinherited

◆ hasDistances()

bool bpp::AbstractSubstitutionDistance::hasDistances ( ) const
inlinevirtualinherited

◆ hasSubstitutionRegister()

bool bpp::AbstractSubstitutionCount::hasSubstitutionRegister ( ) const
inlinevirtualinherited
Returns
Tell if a substitution register has been attached to this class.

Implements bpp::SubstitutionCountInterface.

Definition at line 156 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_.

◆ hasWeights()

bool bpp::AbstractWeightedSubstitutionCount::hasWeights ( ) const
inlinevirtualinherited

◆ initBMatrices_()

void UniformizationSubstitutionCount::initBMatrices_ ( )
private

◆ operator=()

◆ resetBMatrices_()

void UniformizationSubstitutionCount::resetBMatrices_ ( )
private

◆ setDistanceBMatrices_()

void UniformizationSubstitutionCount::setDistanceBMatrices_ ( )
private

◆ setDistances()

void AbstractSubstitutionDistance::setDistances ( std::shared_ptr< const AlphabetIndex2 distances)
virtualinherited

◆ setSubstitutionModel()

void UniformizationSubstitutionCount::setSubstitutionModel ( std::shared_ptr< const SubstitutionModelInterface model)
overridevirtual

Set the substitution model associated with this count, if relevant.

Parameters
modelThe substitution model to use with this count.

Implements bpp::SubstitutionCountInterface.

Definition at line 278 of file UniformizationSubstitutionCount.cpp.

References bpp::abs(), computeCounts_(), currentLength_, fillBMatrices_(), initBMatrices_(), miu_, model_, nbStates_, and bpp::AbstractSubstitutionCount::register_.

◆ setSubstitutionRegister()

void bpp::AbstractSubstitutionCount::setSubstitutionRegister ( std::shared_ptr< const SubstitutionRegisterInterface reg)
inlinevirtualinherited

attribution of a SubstitutionRegister

Parameters
regpointer to a SubstitutionRegister

Implements bpp::SubstitutionCountInterface.

Definition at line 164 of file SubstitutionCount.h.

References bpp::AbstractSubstitutionCount::register_, and bpp::AbstractSubstitutionCount::substitutionRegisterHasChanged().

◆ setWeights()

void AbstractWeightedSubstitutionCount::setWeights ( std::shared_ptr< const AlphabetIndex2 weights)
virtualinherited

◆ storeAllNumbersOfSubstitutions()

void UniformizationSubstitutionCount::storeAllNumbersOfSubstitutions ( double  length,
size_t  type,
Eigen::MatrixXd &  mat 
) const
overridevirtual

Stores the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length.

Parameters
lengthThe length of the branch.
typeThe type of susbstitution to count.
matThe matrix filled with all numbers of substitutions for each initial and final states.

Implements bpp::SubstitutionCountInterface.

Definition at line 212 of file UniformizationSubstitutionCount.cpp.

References computeCounts_(), counts_, currentLength_, model_, nbStates_, and bpp::TextTools::toString().

◆ substitutionRegisterHasChanged()

void UniformizationSubstitutionCount::substitutionRegisterHasChanged ( )
overrideprotectedvirtual

◆ weightsHaveChanged()

void UniformizationSubstitutionCount::weightsHaveChanged ( )
overrideprotectedvirtual

Member Data Documentation

◆ bMatrices_

std::vector< RowMatrix<double> > bpp::UniformizationSubstitutionCount::bMatrices_
private

◆ counts_

std::vector< RowMatrix<double> > bpp::UniformizationSubstitutionCount::counts_
mutableprivate

◆ currentLength_

◆ distances_

◆ miu_

double bpp::UniformizationSubstitutionCount::miu_
private

◆ model_

◆ nbStates_

◆ power_

std::vector< RowMatrix<double> > bpp::UniformizationSubstitutionCount::power_
mutableprivate

Definition at line 31 of file UniformizationSubstitutionCount.h.

Referenced by computeCounts_(), and operator=().

◆ register_

◆ s_

std::vector< std::vector< RowMatrix<double> > > bpp::UniformizationSubstitutionCount::s_
mutableprivate

Definition at line 32 of file UniformizationSubstitutionCount.h.

Referenced by computeCounts_(), operator=(), and resetBMatrices_().

◆ weights_


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