bpp-phyl3  3.0.0
bpp::DRTreeLikelihoodTools Class Reference

Utilitary methods dealing with objects implementing the DRTreeLikelihood interface. More...

#include <Bpp/Phyl/Legacy/Likelihood/DRTreeLikelihoodTools.h>

+ Inheritance diagram for bpp::DRTreeLikelihoodTools:
+ Collaboration diagram for bpp::DRTreeLikelihoodTools:

Static Public Member Functions

static VVVdouble getPosteriorProbabilitiesPerStatePerRate (const DRTreeLikelihoodInterface &drl, int nodeId)
 Compute the posterior probabilities for each state and each rate of each distinct site. More...
 
static Vdouble getPosteriorStateFrequencies (const DRTreeLikelihoodInterface &drl, int nodeId)
 Compute the posterior probabilities for each state for a given node. More...
 
static void getAncestralFrequencies (const TreeLikelihoodInterface &tl, size_t site, std::map< int, std::vector< double >> &frequencies, bool alsoForLeaves=false)
 Compute the expected ancestral frequencies of all states at all (inner) nodes according to a Markov process defined by a given substitution model. More...
 
static void getAncestralFrequencies (const TreeLikelihoodInterface &tl, std::map< int, std::vector< double >> &frequencies, bool alsoForLeaves=false)
 Compute the expected ancestral frequencies of all states at all (inner) nodes according to a Markov process defined by a given substitution model. More...
 

Static Private Member Functions

static void getAncestralFrequencies_ (const TreeLikelihoodInterface &tl, size_t siteIndex, int parentId, const std::vector< double > &ancestralFrequencies, std::map< int, std::vector< double >> &frequencies, bool alsoForLeaves)
 Recursive method, for internal use only. More...
 

Detailed Description

Utilitary methods dealing with objects implementing the DRTreeLikelihood interface.

Definition at line 18 of file DRTreeLikelihoodTools.h.

Member Function Documentation

◆ getAncestralFrequencies() [1/2]

void TreeLikelihoodTools::getAncestralFrequencies ( const TreeLikelihoodInterface tl,
size_t  site,
std::map< int, std::vector< double >> &  frequencies,
bool  alsoForLeaves = false 
)
staticinherited

Compute the expected ancestral frequencies of all states at all (inner) nodes according to a Markov process defined by a given substitution model.

The computation is performed for a given site. If the likelihood object has no site partition, then the method will return the same result for all positions.

Parameters
tl[in] A tree likelihood object.
site[in] The site for which the frequencies should be computed.
frequencies[out] A map where to store the results, as a vector of double (the size of which being equal to the number of states in the model), and with nodes id as keys.
alsoForLeaves[opt] Tell if frequencies should also be estimated for terminal nodes.
Exceptions
ExceptionIn case something bad happens, like an invalid model set.

Definition at line 10 of file TreeLikelihoodTools.cpp.

References bpp::TreeLikelihoodInterface::getRootFrequencies(), bpp::Tree::getRootId(), bpp::TreeLikelihoodInterface::getSiteIndex(), and bpp::TreeLikelihoodInterface::tree().

◆ getAncestralFrequencies() [2/2]

void TreeLikelihoodTools::getAncestralFrequencies ( const TreeLikelihoodInterface tl,
std::map< int, std::vector< double >> &  frequencies,
bool  alsoForLeaves = false 
)
staticinherited

Compute the expected ancestral frequencies of all states at all (inner) nodes according to a Markov process defined by a given substitution model.

The computation is averaged over all sites. If the likelihood object has no site partition, then the method will return the same result as all single site numbers.

Parameters
tl[in] A tree likelihood object.
frequencies[out] A map where to store the results, as a vector of double (the size of which being equal to the number of states in the model), and with nodes id as keys.
alsoForLeaves[opt] Tell if frequencies should also be estimated for terminal nodes.
Exceptions
ExceptionIn case something bad happens, like an invalid model set.

Definition at line 21 of file TreeLikelihoodTools.cpp.

References bpp::TreeLikelihoodData::getNumberOfDistinctSites(), bpp::TreeLikelihoodInterface::getNumberOfStates(), bpp::TreeLikelihoodData::getWeight(), and bpp::TreeLikelihoodInterface::likelihoodData().

◆ getAncestralFrequencies_()

void TreeLikelihoodTools::getAncestralFrequencies_ ( const TreeLikelihoodInterface tl,
size_t  siteIndex,
int  parentId,
const std::vector< double > &  ancestralFrequencies,
std::map< int, std::vector< double >> &  frequencies,
bool  alsoForLeaves 
)
staticprivateinherited

◆ getPosteriorProbabilitiesPerStatePerRate()

VVVdouble DRTreeLikelihoodTools::getPosteriorProbabilitiesPerStatePerRate ( const DRTreeLikelihoodInterface drl,
int  nodeId 
)
static

◆ getPosteriorStateFrequencies()

Vdouble DRTreeLikelihoodTools::getPosteriorStateFrequencies ( const DRTreeLikelihoodInterface drl,
int  nodeId 
)
static

Compute the posterior probabilities for each state for a given node.

This method calls the getPosteriorProbabilitiesPerStatePerRate function and average the probabilities over all sites and rate classes, resulting in a one-dimensionnal frequency array, with one frequency per model state.

Parameters
drlA DR tree likelihood object.
nodeIdThe id of the node at which probabilities must be computed.
Returns
vector of double with state frequencies for the given node.

Definition at line 88 of file DRTreeLikelihoodTools.cpp.

References bpp::DiscreteRatesAcrossSitesTreeLikelihoodInterface::getNumberOfClasses(), bpp::TreeLikelihoodInterface::getNumberOfStates(), getPosteriorProbabilitiesPerStatePerRate(), bpp::AbstractTreeLikelihoodData::getWeight(), and bpp::DRTreeLikelihoodInterface::likelihoodData().

Referenced by bpp::LegacySubstitutionMappingTools::computeCountsPerTypePerBranch().


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