bpp-phyl3
3.0.0
|
Analytical (weighted) substitution count using the uniformization method. More...
#include <Bpp/Phyl/Mapping/UniformizationSubstitutionCount.h>
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) | |
UniformizationSubstitutionCount & | operator= (const UniformizationSubstitutionCount &usc) |
virtual | ~UniformizationSubstitutionCount () |
UniformizationSubstitutionCount * | clone () 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 SubstitutionRegisterInterface > | getSubstitutionRegister () const |
virtual size_t | getNumberOfSubstitutionTypes () const |
Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes(). More... | |
virtual std::shared_ptr< const Alphabet > | getAlphabet () 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 AlphabetIndex2 > | getWeights () const |
void | setDistances (std::shared_ptr< const AlphabetIndex2 > distances) |
bool | hasDistances () const |
std::shared_ptr< const AlphabetIndex2 > | getDistances () const |
Protected Member Functions | |
void | computeCounts_ (double length) const |
void | substitutionRegisterHasChanged () override |
void | weightsHaveChanged () override |
void | distancesHaveChanged () override |
Protected Attributes | |
std::shared_ptr< const SubstitutionRegisterInterface > | register_ |
std::shared_ptr< const AlphabetIndex2 > | weights_ |
std::shared_ptr< const AlphabetIndex2 > | distances_ |
Private Member Functions | |
void | resetBMatrices_ () |
void | initBMatrices_ () |
void | fillBMatrices_ () |
void | setDistanceBMatrices_ () |
Private Attributes | |
std::shared_ptr< const SubstitutionModelInterface > | model_ |
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_ |
Analytical (weighted) substitution count using the uniformization method.
The code is adapted from the original R code by Paula Tataru and Asger Hobolth.
Definition at line 22 of file UniformizationSubstitutionCount.h.
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::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.
|
inline |
Definition at line 50 of file UniformizationSubstitutionCount.h.
|
inlinevirtual |
Definition at line 80 of file UniformizationSubstitutionCount.h.
|
inlineoverridevirtual |
Implements bpp::SubstitutionCountInterface.
Definition at line 82 of file UniformizationSubstitutionCount.h.
References UniformizationSubstitutionCount().
|
protected |
Definition at line 130 of file UniformizationSubstitutionCount.cpp.
References bpp::MatrixTools::add(), bMatrices_, counts_, bpp::exp(), bpp::MatrixTools::fill(), bpp::MatrixTools::getId(), bpp::numeric::isinf(), bpp::log(), bpp::NumTools::logFact(), miu_, model_, bpp::MatrixTools::mult(), nbStates_, power_, bpp::AbstractSubstitutionCount::register_, s_, bpp::MatrixTools::scale(), and bpp::AbstractWeightedSubstitutionCount::weights_.
Referenced by distancesHaveChanged(), getAllNumbersOfSubstitutions(), getNumberOfSubstitutions(), getNumberOfSubstitutionsPerType(), setSubstitutionModel(), storeAllNumbersOfSubstitutions(), substitutionRegisterHasChanged(), and weightsHaveChanged().
|
overrideprotectedvirtual |
Implements bpp::AbstractSubstitutionDistance.
Definition at line 350 of file UniformizationSubstitutionCount.cpp.
References computeCounts_(), currentLength_, bpp::AbstractSubstitutionDistance::distances_, model_, bpp::AbstractSubstitutionCount::register_, and setDistanceBMatrices_().
|
private |
Definition at line 92 of file UniformizationSubstitutionCount.cpp.
References bMatrices_, bpp::AbstractSubstitutionDistance::distances_, model_, nbStates_, bpp::AbstractSubstitutionCount::register_, and setDistanceBMatrices_().
Referenced by setSubstitutionModel(), substitutionRegisterHasChanged(), and UniformizationSubstitutionCount().
|
overridevirtual |
Get the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length.
length | The length of the branch. |
type | The type of susbstitution to count. |
Implements bpp::SubstitutionCountInterface.
Definition at line 195 of file UniformizationSubstitutionCount.cpp.
References computeCounts_(), counts_, currentLength_, model_, and bpp::TextTools::toString().
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet().
Definition at line 78 of file SubstitutionCount.h.
References bpp::SubstitutionCountInterface::getSubstitutionRegister().
|
inlinevirtualinherited |
Implements bpp::SubstitutionDistance.
Definition at line 67 of file SubstitutionDistance.h.
References bpp::AbstractSubstitutionDistance::distances_.
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister()->getAlphabet()->getSize().
Definition at line 85 of file SubstitutionCount.h.
References bpp::SubstitutionCountInterface::getSubstitutionRegister().
|
overridevirtual |
Get the number of susbstitutions on a branch, given the initial and final states, and the branch length.
initialState | The initial state. |
finalState | The final state. |
length | The length of the branch. |
type | The type of substitution to count. |
Implements bpp::SubstitutionCountInterface.
Definition at line 239 of file UniformizationSubstitutionCount.cpp.
References computeCounts_(), counts_, currentLength_, model_, and bpp::TextTools::toString().
|
overridevirtual |
Get the numbers of susbstitutions on a branch for all types, for an initial and final states, given the branch length.
initialState | The initial state. |
finalState | The final state. |
length | The length of the branch. |
Implements bpp::SubstitutionCountInterface.
Definition at line 256 of file UniformizationSubstitutionCount.cpp.
References computeCounts_(), counts_, currentLength_, bpp::SubstitutionCountInterface::getNumberOfSubstitutionTypes(), model_, and bpp::TextTools::toString().
|
inlinevirtualinherited |
Short cut function, equivalent to getSubstitutionRegister().getNumberOfSubstitutionTypes().
Definition at line 71 of file SubstitutionCount.h.
References bpp::SubstitutionCountInterface::getSubstitutionRegister().
Referenced by bpp::SubstitutionMappingTools::computeCounts(), bpp::DecompositionSubstitutionCount::getNumberOfSubstitutionsPerType(), bpp::NaiveSubstitutionCount::getNumberOfSubstitutionsPerType(), and getNumberOfSubstitutionsPerType().
|
inlinevirtualinherited |
Implements bpp::SubstitutionCountInterface.
Definition at line 170 of file SubstitutionCount.h.
References bpp::AbstractSubstitutionCount::register_.
|
inlinevirtualinherited |
Implements bpp::WeightedSubstitutionCount.
Definition at line 66 of file WeightedSubstitutionCount.h.
References bpp::AbstractWeightedSubstitutionCount::weights_.
|
inlinevirtualinherited |
Implements bpp::SubstitutionDistance.
Definition at line 66 of file SubstitutionDistance.h.
References bpp::AbstractSubstitutionDistance::distances_.
|
inlinevirtualinherited |
Implements bpp::SubstitutionCountInterface.
Definition at line 156 of file SubstitutionCount.h.
References bpp::AbstractSubstitutionCount::register_.
|
inlinevirtualinherited |
Implements bpp::WeightedSubstitutionCount.
Definition at line 65 of file WeightedSubstitutionCount.h.
References bpp::AbstractWeightedSubstitutionCount::weights_.
|
private |
Definition at line 82 of file UniformizationSubstitutionCount.cpp.
References bMatrices_, counts_, nbStates_, and bpp::AbstractSubstitutionCount::register_.
Referenced by setSubstitutionModel(), substitutionRegisterHasChanged(), and UniformizationSubstitutionCount().
|
inline |
Definition at line 64 of file UniformizationSubstitutionCount.h.
References bMatrices_, counts_, currentLength_, miu_, model_, nbStates_, bpp::AbstractSubstitutionDistance::operator=(), bpp::AbstractWeightedSubstitutionCount::operator=(), power_, and s_.
|
private |
Definition at line 73 of file UniformizationSubstitutionCount.cpp.
References bMatrices_, counts_, bpp::AbstractSubstitutionCount::register_, and s_.
Referenced by substitutionRegisterHasChanged().
|
private |
Definition at line 111 of file UniformizationSubstitutionCount.cpp.
References bMatrices_, bpp::AbstractSubstitutionDistance::distances_, model_, nbStates_, and bpp::AbstractSubstitutionCount::register_.
Referenced by distancesHaveChanged(), and fillBMatrices_().
|
virtualinherited |
Implements bpp::SubstitutionDistance.
Definition at line 9 of file SubstitutionDistance.cpp.
References bpp::AbstractSubstitutionDistance::distances_, and bpp::AbstractSubstitutionDistance::distancesHaveChanged().
|
overridevirtual |
Set the substitution model associated with this count, if relevant.
model | The 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_.
|
inlinevirtualinherited |
attribution of a SubstitutionRegister
reg | pointer to a SubstitutionRegister |
Implements bpp::SubstitutionCountInterface.
Definition at line 164 of file SubstitutionCount.h.
References bpp::AbstractSubstitutionCount::register_, and bpp::AbstractSubstitutionCount::substitutionRegisterHasChanged().
|
virtualinherited |
Implements bpp::WeightedSubstitutionCount.
Definition at line 9 of file WeightedSubstitutionCount.cpp.
References bpp::AbstractWeightedSubstitutionCount::weights_, and bpp::AbstractWeightedSubstitutionCount::weightsHaveChanged().
|
overridevirtual |
Stores the numbers of susbstitutions on a branch, for each initial and final states, and given the branch length.
length | The length of the branch. |
type | The type of susbstitution to count. |
mat | The 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().
|
overrideprotectedvirtual |
Implements bpp::AbstractSubstitutionCount.
Definition at line 317 of file UniformizationSubstitutionCount.cpp.
References computeCounts_(), currentLength_, fillBMatrices_(), initBMatrices_(), model_, bpp::AbstractSubstitutionCount::register_, and resetBMatrices_().
|
overrideprotectedvirtual |
Implements bpp::AbstractWeightedSubstitutionCount.
Definition at line 337 of file UniformizationSubstitutionCount.cpp.
References computeCounts_(), currentLength_, model_, bpp::AbstractSubstitutionCount::register_, and bpp::AbstractWeightedSubstitutionCount::weights_.
|
private |
Definition at line 30 of file UniformizationSubstitutionCount.h.
Referenced by computeCounts_(), fillBMatrices_(), initBMatrices_(), operator=(), resetBMatrices_(), and setDistanceBMatrices_().
|
mutableprivate |
Definition at line 34 of file UniformizationSubstitutionCount.h.
Referenced by computeCounts_(), getAllNumbersOfSubstitutions(), getNumberOfSubstitutions(), getNumberOfSubstitutionsPerType(), initBMatrices_(), operator=(), resetBMatrices_(), and storeAllNumbersOfSubstitutions().
|
mutableprivate |
Definition at line 35 of file UniformizationSubstitutionCount.h.
Referenced by distancesHaveChanged(), getAllNumbersOfSubstitutions(), getNumberOfSubstitutions(), getNumberOfSubstitutionsPerType(), operator=(), setSubstitutionModel(), storeAllNumbersOfSubstitutions(), substitutionRegisterHasChanged(), and weightsHaveChanged().
|
protectedinherited |
Definition at line 43 of file SubstitutionDistance.h.
Referenced by bpp::DecompositionSubstitutionCount::distancesHaveChanged(), distancesHaveChanged(), bpp::DecompositionSubstitutionCount::fillBMatrices_(), fillBMatrices_(), bpp::AbstractSubstitutionDistance::getDistances(), bpp::AbstractSubstitutionDistance::hasDistances(), bpp::AbstractSubstitutionDistance::operator=(), bpp::DecompositionSubstitutionCount::setDistanceBMatrices_(), setDistanceBMatrices_(), and bpp::AbstractSubstitutionDistance::setDistances().
|
private |
Definition at line 33 of file UniformizationSubstitutionCount.h.
Referenced by computeCounts_(), operator=(), setSubstitutionModel(), and UniformizationSubstitutionCount().
|
private |
Definition at line 28 of file UniformizationSubstitutionCount.h.
Referenced by computeCounts_(), distancesHaveChanged(), fillBMatrices_(), getAllNumbersOfSubstitutions(), getNumberOfSubstitutions(), getNumberOfSubstitutionsPerType(), operator=(), setDistanceBMatrices_(), setSubstitutionModel(), storeAllNumbersOfSubstitutions(), substitutionRegisterHasChanged(), UniformizationSubstitutionCount(), and weightsHaveChanged().
|
private |
Definition at line 29 of file UniformizationSubstitutionCount.h.
Referenced by computeCounts_(), fillBMatrices_(), initBMatrices_(), operator=(), setDistanceBMatrices_(), setSubstitutionModel(), storeAllNumbersOfSubstitutions(), and UniformizationSubstitutionCount().
|
mutableprivate |
Definition at line 31 of file UniformizationSubstitutionCount.h.
Referenced by computeCounts_(), and operator=().
|
protectedinherited |
Definition at line 146 of file SubstitutionCount.h.
Referenced by computeCounts_(), bpp::DecompositionSubstitutionCount::distancesHaveChanged(), distancesHaveChanged(), bpp::DecompositionSubstitutionCount::fillBMatrices_(), fillBMatrices_(), bpp::NaiveSubstitutionCount::getNumberOfSubstitutions(), bpp::AbstractSubstitutionCount::getSubstitutionRegister(), bpp::AbstractSubstitutionCount::hasSubstitutionRegister(), initBMatrices_(), bpp::DecompositionSubstitutionCount::initCounts_(), resetBMatrices_(), bpp::DecompositionSubstitutionCount::setDistanceBMatrices_(), setDistanceBMatrices_(), bpp::DecompositionSubstitutionCount::setSubstitutionModel(), setSubstitutionModel(), bpp::AbstractSubstitutionCount::setSubstitutionRegister(), bpp::DecompositionSubstitutionCount::substitutionRegisterHasChanged(), substitutionRegisterHasChanged(), bpp::DecompositionSubstitutionCount::weightsHaveChanged(), and weightsHaveChanged().
|
mutableprivate |
Definition at line 32 of file UniformizationSubstitutionCount.h.
Referenced by computeCounts_(), operator=(), and resetBMatrices_().
|
protectedinherited |
Definition at line 42 of file WeightedSubstitutionCount.h.
Referenced by bpp::DecompositionSubstitutionCount::computeCounts_(), computeCounts_(), bpp::NaiveSubstitutionCount::getNumberOfSubstitutions(), bpp::AbstractWeightedSubstitutionCount::getWeights(), bpp::AbstractWeightedSubstitutionCount::hasWeights(), bpp::AbstractWeightedSubstitutionCount::operator=(), bpp::AbstractWeightedSubstitutionCount::setWeights(), bpp::DecompositionSubstitutionCount::weightsHaveChanged(), and weightsHaveChanged().