bpp-phyl3  3.0.0
bpp::LikelihoodCalculationSingleProcess Class Reference

#include <Bpp/Phyl/Likelihood/DataFlow/LikelihoodCalculationSingleProcess.h>

+ Inheritance diagram for bpp::LikelihoodCalculationSingleProcess:
+ Collaboration diagram for bpp::LikelihoodCalculationSingleProcess:

Classes

class  ProcessNodes
 DF Nodes used in the process. ProcessTree is used without any rate multiplier. More...
 
class  RateCategoryTrees
 

Public Member Functions

 LikelihoodCalculationSingleProcess (Context &context, std::shared_ptr< const AlignmentDataInterface > sites, std::shared_ptr< const SubstitutionProcessInterface > process)
 
 LikelihoodCalculationSingleProcess (Context &context, std::shared_ptr< const SubstitutionProcessInterface > process)
 
 LikelihoodCalculationSingleProcess (std::shared_ptr< CollectionNodes > collection, std::shared_ptr< const AlignmentDataInterface > sites, size_t nProcess)
 
 LikelihoodCalculationSingleProcess (std::shared_ptr< CollectionNodes > collection, size_t nProcess)
 
 LikelihoodCalculationSingleProcess (const LikelihoodCalculationSingleProcess &lik)
 
LikelihoodCalculationSingleProcessclone () const
 
void setData (std::shared_ptr< const AlignmentDataInterface > sites)
 
void setNumericalDerivateConfiguration (double delta, const NumericalDerivativeType &config)
 Set derivation procedure (see DataFlowNumeric.h) More...
 
void setClockLike (double rate=1)
 
void makeLikelihoods ()
 
const DAGindexesgetNodesIds (uint speciesId) const
 Get indexes of the nodes in the Likelihood DAG that have a given species index. More...
 
const DAGindexesgetEdgesIds (uint speciesId, size_t nCat) const
 Get indexes of the non-empty edges in the Likelihood DAG that have a given species index for a given rate class index. More...
 
size_t getNumberOfSites () const
 
size_t getNumberOfDistinctSites () const
 
const SubstitutionProcessInterfacesubstitutionProcess () const
 Return the ref to the SubstitutionProcess. More...
 
std::shared_ptr< const SubstitutionProcessInterfacegetSubstitutionProcess () const
 
const AlignmentDataInterfacedata () const
 
std::shared_ptr< const AlignmentDataInterfacegetData () const
 
const StateMapInterfacestateMap () const
 
std::shared_ptr< const StateMapInterfacegetStateMap () const
 
size_t getRootArrayPosition (size_t currentPosition) const
 
const PatternTypegetRootArrayPositions () const
 
ValueRef< PatternTypegetRootPatternLinks () const
 
const AlignmentDataInterfaceshrunkData () const
 
std::shared_ptr< const AlignmentDataInterfacegetShrunkData () const
 
ValueRef< RowLikexpandVector (ValueRef< RowLik > vector)
 
ValueRef< MatrixLikexpandMatrix (ValueRef< MatrixLik > matrix)
 
unsigned int getWeight (size_t pos) const
 
std::shared_ptr< SiteWeightsgetRootWeights ()
 
ValueRef< Eigen::RowVectorXd > getRootFreqs ()
 
ConditionalLikelihoodRef getLikelihoodsAtNode (uint nodeId, bool shrunk=false)
 
size_t getNumberOfClasses () const
 
ConditionalLikelihoodRef getForwardLikelihoodsAtNodeForClass (uint nodeId, size_t nCat)
 
ConditionalLikelihoodRef getBackwardLikelihoodsAtNodeForClass (uint nodeId, size_t nCat)
 
ConditionalLikelihoodRef getBackwardLikelihoodsAtEdgeForClass (uint edgeId, size_t nCat)
 
ConditionalLikelihoodRef getConditionalLikelihoodsAtNodeForClass (uint nodeId, size_t nCat)
 
SiteLikelihoodsRef getLikelihoodsAtNodeForClass (uint nodeId, size_t nCat)
 Get shrunked conditional likelihood matrix at Node (ie just above the node), for a given rate class. More...
 
void makeLikelihoodsTree ()
 make backward likelihood tree (only computed when needed) More...
 
RowLik getSiteLikelihoodsForAClass (size_t nCat, bool shrunk=false)
 Get site likelihoods for a rate category. More...
 
AllRatesSiteLikelihoods getSiteLikelihoodsForAllClasses (bool shrunk=false)
 Output array (Classes X Sites) of likelihoods for all sites & classes. More...
 
std::shared_ptr< ProcessTreegetTreeNode (size_t nCat)
 Get process tree for a rate category. More...
 
std::shared_ptr< ForwardLikelihoodTreegetForwardLikelihoodTree (size_t nCat)
 
std::shared_ptr< BackwardLikelihoodTreegetBackwardLikelihoodTree (size_t nCat)
 
void cleanAllLikelihoods ()
 
SiteLikelihoodsRef getSiteLikelihoods (bool shrunk=false)
 
void setSiteLikelihoods (SiteLikelihoodsRef ll, bool shrunk=false)
 
DataLik getLikelihoodForASite (size_t pos, bool shrunk=false)
 
DataLik getLogLikelihoodForASite (size_t pos, bool shrunk=false)
 
VDataLik getLikelihoodPerSite ()
 Get the likelihood for each site. More...
 
ValueRef< DataLikgetLikelihoodNode ()
 
virtual bool isInitialized () const
 
const ContextgetContext () const
 
void setLikelihoodNode (ValueRef< DataLik > ll)
 
void setNamespace (const std::string &prefix)
 
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 void fireParameterChanged (const ParameterList &parameters)
 

Protected Member Functions

ContextgetContext_ ()
 
ValueRef< DataLikgetLikelihoodNode_ ()
 
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

SiteLikelihoodsRef siteLikelihoods_
 
SiteLikelihoodsRef patternedSiteLikelihoods_
 
ValueRef< DataLiklikelihood_
 

Private Member Functions

void setPatterns_ ()
 
void makeForwardLikelihoodTree_ ()
 
void makeProcessNodes_ ()
 
void makeRootFreqs_ ()
 
void makeLikelihoodsAtRoot_ ()
 
void makeProcessNodes_ (CollectionNodes &pl, size_t nProc)
 make DF nodes of a process in a collection, using ConfiguredParameters defined in a CollectionNodes. More...
 
void makeLikelihoodsAtNode_ (uint nodeId)
 Compute the likelihood at a given node in the tree, which number may not be the same number in the DAG. More...
 
void makeLikelihoodsAtDAGNode_ (uint nodeId)
 Compute the likelihood at a given node in the DAG,. More...
 
std::shared_ptr< SiteLikelihoodsTreegetSiteLikelihoodsTree_ (size_t nCat)
 

Private Attributes

std::shared_ptr< const SubstitutionProcessInterfaceprocess_
 
std::shared_ptr< const AlignmentDataInterfacepsites_
 
ValueRef< PatternTyperootPatternLinks_
 
std::shared_ptr< SiteWeightsrootWeights_
 The frequency of each site. More...
 
std::shared_ptr< AlignmentDataInterfaceshrunkData_
 
ProcessNodes processNodes_
 
ValueRef< Eigen::RowVectorXd > rFreqs_
 
std::vector< RateCategoryTreesvRateCatTrees_
 
ValueRef< Eigen::RowVectorXd > catProb_
 
std::shared_ptr< ConditionalLikelihoodTreecondLikelihoodTree_
 
Contextcontext_
 
ParameterList independentParameters_
 
std::map< std::string, std::shared_ptr< AliasParameterListener > > aliasListenersRegister_
 
ParameterList parameters_
 
std::string prefix_
 

Friends

class LikelihoodCalculationOnABranch
 

Detailed Description

Definition at line 112 of file LikelihoodCalculationSingleProcess.h.

Constructor & Destructor Documentation

◆ LikelihoodCalculationSingleProcess() [1/5]

LikelihoodCalculationSingleProcess::LikelihoodCalculationSingleProcess ( Context context,
std::shared_ptr< const AlignmentDataInterface sites,
std::shared_ptr< const SubstitutionProcessInterface process 
)

◆ LikelihoodCalculationSingleProcess() [2/5]

LikelihoodCalculationSingleProcess::LikelihoodCalculationSingleProcess ( Context context,
std::shared_ptr< const SubstitutionProcessInterface process 
)

◆ LikelihoodCalculationSingleProcess() [3/5]

LikelihoodCalculationSingleProcess::LikelihoodCalculationSingleProcess ( std::shared_ptr< CollectionNodes collection,
std::shared_ptr< const AlignmentDataInterface sites,
size_t  nProcess 
)

◆ LikelihoodCalculationSingleProcess() [4/5]

LikelihoodCalculationSingleProcess::LikelihoodCalculationSingleProcess ( std::shared_ptr< CollectionNodes collection,
size_t  nProcess 
)

◆ LikelihoodCalculationSingleProcess() [5/5]

LikelihoodCalculationSingleProcess::LikelihoodCalculationSingleProcess ( const LikelihoodCalculationSingleProcess lik)

Member Function Documentation

◆ cleanAllLikelihoods()

void LikelihoodCalculationSingleProcess::cleanAllLikelihoods ( )
virtual

◆ clone()

LikelihoodCalculationSingleProcess* bpp::LikelihoodCalculationSingleProcess::clone ( ) const
inlinevirtual

Reimplemented from bpp::AlignedLikelihoodCalculation.

Definition at line 247 of file LikelihoodCalculationSingleProcess.h.

◆ data()

const AlignmentDataInterface& bpp::LikelihoodCalculationSingleProcess::data ( ) const
inline

Definition at line 337 of file LikelihoodCalculationSingleProcess.h.

References psites_.

◆ expandMatrix()

ValueRef<MatrixLik> bpp::LikelihoodCalculationSingleProcess::expandMatrix ( ValueRef< MatrixLik matrix)
inline

◆ expandVector()

ValueRef<RowLik> bpp::LikelihoodCalculationSingleProcess::expandVector ( ValueRef< RowLik vector)
inline

◆ getBackwardLikelihoodsAtEdgeForClass()

◆ getBackwardLikelihoodsAtNodeForClass()

ConditionalLikelihoodRef LikelihoodCalculationSingleProcess::getBackwardLikelihoodsAtNodeForClass ( uint  nodeId,
size_t  nCat 
)

◆ getBackwardLikelihoodTree()

std::shared_ptr< BackwardLikelihoodTree > LikelihoodCalculationSingleProcess::getBackwardLikelihoodTree ( size_t  nCat)

◆ getConditionalLikelihoodsAtNodeForClass()

ConditionalLikelihoodRef LikelihoodCalculationSingleProcess::getConditionalLikelihoodsAtNodeForClass ( uint  nodeId,
size_t  nCat 
)

◆ getContext()

const Context& bpp::LikelihoodCalculation::getContext ( ) const
inlineinherited

Definition at line 76 of file LikelihoodCalculation.h.

References bpp::LikelihoodCalculation::context_.

◆ getContext_()

◆ getData()

std::shared_ptr<const AlignmentDataInterface> bpp::LikelihoodCalculationSingleProcess::getData ( ) const
inline

◆ getEdgesIds()

const DAGindexes & LikelihoodCalculationSingleProcess::getEdgesIds ( uint  speciesId,
size_t  nCat 
) const

Get indexes of the non-empty edges in the Likelihood DAG that have a given species index for a given rate class index.

Parameters
speciesIdLooked species Index
nCatRate class category

Definition at line 782 of file LikelihoodCalculationSingleProcess.cpp.

References bpp::TextTools::toString(), and vRateCatTrees_.

Referenced by bpp::SubstitutionMappingTools::computeCounts(), bpp::SubstitutionMappingTools::computeNormalizations(), and bpp::RewardMappingTools::computeRewardVectors().

◆ getForwardLikelihoodsAtNodeForClass()

◆ getForwardLikelihoodTree()

std::shared_ptr< ForwardLikelihoodTree > LikelihoodCalculationSingleProcess::getForwardLikelihoodTree ( size_t  nCat)

◆ getLikelihoodForASite()

◆ getLikelihoodNode()

ValueRef<DataLik> bpp::LikelihoodCalculation::getLikelihoodNode ( )
inlineinherited

◆ getLikelihoodNode_()

ValueRef<DataLik> bpp::LikelihoodCalculation::getLikelihoodNode_ ( )
inlineprotectedinherited

◆ getLikelihoodPerSite()

VDataLik bpp::AlignedLikelihoodCalculation::getLikelihoodPerSite ( )
inlineinherited

Get the likelihood for each site.

Returns
A vector with all site likelihoods.

Definition at line 221 of file LikelihoodCalculation.h.

References bpp::copyEigenToBpp(), and bpp::AlignedLikelihoodCalculation::getSiteLikelihoods().

◆ getLikelihoodsAtNode()

ConditionalLikelihoodRef bpp::LikelihoodCalculationSingleProcess::getLikelihoodsAtNode ( uint  nodeId,
bool  shrunk = false 
)
inline

◆ getLikelihoodsAtNodeForClass()

SiteLikelihoodsRef LikelihoodCalculationSingleProcess::getLikelihoodsAtNodeForClass ( uint  nodeId,
size_t  nCat 
)

Get shrunked conditional likelihood matrix at Node (ie just above the node), for a given rate class.

These likelihoods are multiplied by the probability of the node.

Parameters
nodeIdNode Index in the forward tree (! ie in the computation tree, not the species tree).
nCatRate class category

Definition at line 730 of file LikelihoodCalculationSingleProcess.cpp.

References makeLikelihoodsAtDAGNode_(), bpp::TextTools::toString(), and vRateCatTrees_.

Referenced by bpp::SubstitutionMappingTools::computeCounts(), bpp::SubstitutionMappingTools::computeNormalizations(), and bpp::RewardMappingTools::computeRewardVectors().

◆ getLogLikelihoodForASite()

DataLik bpp::AlignedLikelihoodCalculation::getLogLikelihoodForASite ( size_t  pos,
bool  shrunk = false 
)
inlineinherited

◆ getNodesIds()

const DAGindexes & LikelihoodCalculationSingleProcess::getNodesIds ( uint  speciesId) const

Get indexes of the nodes in the Likelihood DAG that have a given species index.

Parameters
speciesIdLooked species Index

Definition at line 774 of file LikelihoodCalculationSingleProcess.cpp.

References vRateCatTrees_.

◆ getNumberOfClasses()

size_t bpp::LikelihoodCalculationSingleProcess::getNumberOfClasses ( ) const
inline

Definition at line 466 of file LikelihoodCalculationSingleProcess.h.

References vRateCatTrees_.

◆ getNumberOfDistinctSites()

◆ getNumberOfSites()

size_t bpp::LikelihoodCalculationSingleProcess::getNumberOfSites ( ) const
inline

◆ getRootArrayPosition()

size_t bpp::LikelihoodCalculationSingleProcess::getRootArrayPosition ( size_t  currentPosition) const
inline

Definition at line 370 of file LikelihoodCalculationSingleProcess.h.

References rootPatternLinks_.

◆ getRootArrayPositions()

const PatternType& bpp::LikelihoodCalculationSingleProcess::getRootArrayPositions ( ) const
inline

◆ getRootFreqs()

ValueRef<Eigen::RowVectorXd> bpp::LikelihoodCalculationSingleProcess::getRootFreqs ( )
inline

Definition at line 435 of file LikelihoodCalculationSingleProcess.h.

References rFreqs_.

◆ getRootPatternLinks()

ValueRef<PatternType> bpp::LikelihoodCalculationSingleProcess::getRootPatternLinks ( ) const
inline

Definition at line 377 of file LikelihoodCalculationSingleProcess.h.

References rootPatternLinks_.

◆ getRootWeights()

std::shared_ptr<SiteWeights> bpp::LikelihoodCalculationSingleProcess::getRootWeights ( )
inline

Definition at line 430 of file LikelihoodCalculationSingleProcess.h.

References rootWeights_.

◆ getShrunkData()

std::shared_ptr<const AlignmentDataInterface> bpp::LikelihoodCalculationSingleProcess::getShrunkData ( ) const
inline

◆ getSiteLikelihoods()

◆ getSiteLikelihoodsForAClass()

RowLik LikelihoodCalculationSingleProcess::getSiteLikelihoodsForAClass ( size_t  nCat,
bool  shrunk = false 
)

Get site likelihoods for a rate category.

Parameters
nCat: index of the rate category
shrunk: if returns on shrunked data (default: false)

Definition at line 344 of file LikelihoodCalculationSingleProcess.cpp.

References expandVector(), and getSiteLikelihoodsTree_().

Referenced by getSiteLikelihoodsForAllClasses().

◆ getSiteLikelihoodsForAllClasses()

AllRatesSiteLikelihoods LikelihoodCalculationSingleProcess::getSiteLikelihoodsForAllClasses ( bool  shrunk = false)

Output array (Classes X Sites) of likelihoods for all sites & classes.

Parameters
shrunk: if returns on shrunked data (default: false)

Definition at line 352 of file LikelihoodCalculationSingleProcess.cpp.

References getNumberOfDistinctSites(), getNumberOfSites(), getSiteLikelihoodsForAClass(), and vRateCatTrees_.

◆ getSiteLikelihoodsTree_()

std::shared_ptr< SiteLikelihoodsTree > LikelihoodCalculationSingleProcess::getSiteLikelihoodsTree_ ( size_t  nCat)
private

◆ getStateMap()

std::shared_ptr<const StateMapInterface> bpp::LikelihoodCalculationSingleProcess::getStateMap ( ) const
inline

◆ getSubstitutionProcess()

std::shared_ptr<const SubstitutionProcessInterface> bpp::LikelihoodCalculationSingleProcess::getSubstitutionProcess ( ) const
inline

◆ getTreeNode()

std::shared_ptr<ProcessTree> bpp::LikelihoodCalculationSingleProcess::getTreeNode ( size_t  nCat)
inline

◆ getWeight()

unsigned int bpp::LikelihoodCalculationSingleProcess::getWeight ( size_t  pos) const
inline

Definition at line 425 of file LikelihoodCalculationSingleProcess.h.

References rootWeights_.

◆ isInitialized()

◆ makeForwardLikelihoodTree_()

◆ makeLikelihoods()

void bpp::LikelihoodCalculationSingleProcess::makeLikelihoods ( )
inlinevirtual

◆ makeLikelihoodsAtDAGNode_()

void LikelihoodCalculationSingleProcess::makeLikelihoodsAtDAGNode_ ( uint  nodeId)
private

Compute the likelihood at a given node in the DAG,.

This is not enough to compute likelihoods at species nodes, use makeLikelihoodsAtNode_ instead.

Parameters
nodeId: index of the node in the DAG

Definition at line 634 of file LikelihoodCalculationSingleProcess.cpp.

References bpp::conditionalLikelihoodDimension(), bpp::ConstantOne< T >::create(), bpp::MatrixProduct< R, T0, T1 >::create(), bpp::LikelihoodCalculation::getContext_(), getNumberOfDistinctSites(), makeForwardLikelihoodTree_(), makeRootFreqs_(), bpp::numeric::one(), rFreqs_, stateMap(), and vRateCatTrees_.

Referenced by getBackwardLikelihoodsAtNodeForClass(), getConditionalLikelihoodsAtNodeForClass(), and getLikelihoodsAtNodeForClass().

◆ makeLikelihoodsAtNode_()

void LikelihoodCalculationSingleProcess::makeLikelihoodsAtNode_ ( uint  nodeId)
private

◆ makeLikelihoodsAtRoot_()

◆ makeLikelihoodsTree()

void bpp::LikelihoodCalculationSingleProcess::makeLikelihoodsTree ( )
inline

make backward likelihood tree (only computed when needed)

Definition at line 544 of file LikelihoodCalculationSingleProcess.h.

References makeLikelihoodsAtNode_(), and process_.

◆ makeProcessNodes_() [1/2]

◆ makeProcessNodes_() [2/2]

◆ makeRootFreqs_()

◆ setClockLike()

◆ setData()

◆ setLikelihoodNode()

void bpp::LikelihoodCalculation::setLikelihoodNode ( ValueRef< DataLik ll)
inlineinherited

◆ setNumericalDerivateConfiguration()

◆ setPatterns_()

◆ setSiteLikelihoods()

void bpp::AlignedLikelihoodCalculation::setSiteLikelihoods ( SiteLikelihoodsRef  ll,
bool  shrunk = false 
)
inlineinherited

◆ shrunkData()

const AlignmentDataInterface& bpp::LikelihoodCalculationSingleProcess::shrunkData ( ) const
inline

Definition at line 382 of file LikelihoodCalculationSingleProcess.h.

References shrunkData_.

◆ stateMap()

◆ substitutionProcess()

Friends And Related Function Documentation

◆ LikelihoodCalculationOnABranch

friend class LikelihoodCalculationOnABranch
friend

Definition at line 634 of file LikelihoodCalculationSingleProcess.h.

Member Data Documentation

◆ catProb_

ValueRef<Eigen::RowVectorXd> bpp::LikelihoodCalculationSingleProcess::catProb_
private

◆ condLikelihoodTree_

std::shared_ptr<ConditionalLikelihoodTree> bpp::LikelihoodCalculationSingleProcess::condLikelihoodTree_
private

◆ context_

Context& bpp::LikelihoodCalculation::context_
privateinherited

◆ likelihood_

◆ patternedSiteLikelihoods_

◆ process_

◆ processNodes_

◆ psites_

std::shared_ptr<const AlignmentDataInterface> bpp::LikelihoodCalculationSingleProcess::psites_
private

◆ rFreqs_

ValueRef<Eigen::RowVectorXd> bpp::LikelihoodCalculationSingleProcess::rFreqs_
private

◆ rootPatternLinks_

◆ rootWeights_

std::shared_ptr<SiteWeights> bpp::LikelihoodCalculationSingleProcess::rootWeights_
private

The frequency of each site.

Definition at line 192 of file LikelihoodCalculationSingleProcess.h.

Referenced by cleanAllLikelihoods(), getRootWeights(), getWeight(), makeLikelihoodsAtRoot_(), and setPatterns_().

◆ shrunkData_

std::shared_ptr<AlignmentDataInterface> bpp::LikelihoodCalculationSingleProcess::shrunkData_
private

◆ siteLikelihoods_

◆ vRateCatTrees_


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