bpp-phyl  2.2.0
bpp::DRTreeLikelihoodTools Class Reference

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

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

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

Static Public Member Functions

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

Detailed Description

Utilitary methods dealing with objects implementing the DRTreeLikelihood interface.

Definition at line 53 of file DRTreeLikelihoodTools.h.

Member Function Documentation

◆ getAncestralFrequencies() [1/2]

void TreeLikelihoodTools::getAncestralFrequencies ( const TreeLikelihood tl,
size_t  site,
std::map< int, std::vector< double > > &  frequencies,
bool  alsoForLeaves = false 
)
throw (Exception
)
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 unvalid model set.

Definition at line 45 of file TreeLikelihoodTools.cpp.

◆ getAncestralFrequencies() [2/2]

void TreeLikelihoodTools::getAncestralFrequencies ( const TreeLikelihood tl,
std::map< int, std::vector< double > > &  frequencies,
bool  alsoForLeaves = false 
)
throw (Exception
)
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 unvalid model set.

Definition at line 56 of file TreeLikelihoodTools.cpp.

◆ getPosteriorProbabilitiesForEachStateForEachRate()

VVVdouble DRTreeLikelihoodTools::getPosteriorProbabilitiesForEachStateForEachRate ( const DRTreeLikelihood drl,
int  nodeId 
)
static

Compute the posterior probabilities for each state and each rate of each distinct site.

Parameters
drlA DR tree likelihood object.
nodeIdThe id of the node at which probabilities must be computed.
Returns
A 3-dimensional array, with probabilities for each site, each rate and each state.

Definition at line 47 of file DRTreeLikelihoodTools.cpp.

References bpp::DRTreeLikelihood::computeLikelihoodAtNode(), bpp::DRASDRTreeLikelihoodData::getLeafLikelihoods(), bpp::DRTreeLikelihood::getLikelihoodData(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getNumberOfClasses(), bpp::DRASDRTreeLikelihoodData::getNumberOfDistinctSites(), bpp::TreeLikelihood::getNumberOfStates(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getRateDistribution(), bpp::TreeLikelihood::getTree(), and bpp::Tree::isLeaf().

Referenced by bpp::SubstitutionMappingTools::computeSubstitutionVectorsMarginal(), and getPosteriorStateFrequencies().

◆ getPosteriorStateFrequencies()

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

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

This method calls the getPosteriorProbabilitiesForEachStateForEachRate 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 120 of file DRTreeLikelihoodTools.cpp.

References bpp::DRTreeLikelihood::getLikelihoodData(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getNumberOfClasses(), bpp::TreeLikelihood::getNumberOfStates(), getPosteriorProbabilitiesForEachStateForEachRate(), and bpp::AbstractTreeLikelihoodData::getWeight().

Referenced by bpp::SubstitutionMappingTools::getRelativeCountsPerBranch().


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