bpp-phyl  2.2.0
bpp::PairedSiteLikelihoods Class Reference

A container for paired-site likelihoods (likelihoods over the same sites for different models, especially topologies). An instance of this class is, roughly, a list of models, each of them having a name (stored in the modelNames attribute) and a set of site likelihoods (stored in the logLikelihoods attribute). More...

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

+ Collaboration diagram for bpp::PairedSiteLikelihoods:

Public Member Functions

 PairedSiteLikelihoods ()
 
 PairedSiteLikelihoods (const std::vector< std::vector< double > > &siteLogLikelihoods, const std::vector< std::string > &modelNames=std::vector< std::string >()) throw (Exception)
 Build a new object from a site likelihoods array. More...
 
 ~PairedSiteLikelihoods ()
 
void appendModel (const std::vector< double > &siteLogLikelihoods, const std::string &modelName="") throw (Exception)
 Append a model. More...
 
void appendModel (const bpp::TreeLikelihood &treelikelihood) throw (Exception)
 Append a model. More...
 
void appendModels (const PairedSiteLikelihoods &psl) throw (Exception)
 Append models by concatenation. More...
 
const std::vector< std::vector< double > > & getLikelihoods () const
 
const std::vector< std::string > & getModelNames () const
 
size_t getNumberOfModels () const
 Get the number of models in the container. More...
 
std::size_t getNumberOfSites () const throw (Exception)
 
void setName (std::size_t pos, std::string &name)
 Set the name of a model. More...
 
std::pair< std::vector< std::string >, std::vector< double > > computeExpectedLikelihoodWeights (int replicates=10000) const
 Compute the Expected Likelihood Weights of the models. More...
 

Static Public Member Functions

static std::vector< int > bootstrap (std::size_t length, double scaling=1)
 Draw a nonparametric pseudoreplicate. More...
 

Private Attributes

std::vector< std::vector< double > > logLikelihoods_
 
std::vector< std::string > modelNames_
 

Detailed Description

A container for paired-site likelihoods (likelihoods over the same sites for different models, especially topologies). An instance of this class is, roughly, a list of models, each of them having a name (stored in the modelNames attribute) and a set of site likelihoods (stored in the logLikelihoods attribute).

Definition at line 60 of file PairedSiteLikelihoods.h.

Constructor & Destructor Documentation

◆ PairedSiteLikelihoods() [1/2]

PairedSiteLikelihoods::PairedSiteLikelihoods ( )

Definition at line 56 of file PairedSiteLikelihoods.cpp.

◆ PairedSiteLikelihoods() [2/2]

PairedSiteLikelihoods::PairedSiteLikelihoods ( const std::vector< std::vector< double > > &  siteLogLikelihoods,
const std::vector< std::string > &  modelNames = std::vector<std::string>() 
)
throw (Exception
)

Build a new object from a site likelihoods array.

Parameters
siteLogLikelihoodsAn nmodels*nsites array of loglikelihoods.
modelNames(Optional) The names of the models.
Exceptions
ExceptionIf the number of sites differ between the models, or if the number of names and site loglikelihood records differ.

Definition at line 61 of file PairedSiteLikelihoods.cpp.

◆ ~PairedSiteLikelihoods()

bpp::PairedSiteLikelihoods::~PairedSiteLikelihoods ( )
inline

Definition at line 83 of file PairedSiteLikelihoods.h.

Member Function Documentation

◆ appendModel() [1/2]

void PairedSiteLikelihoods::appendModel ( const std::vector< double > &  siteLogLikelihoods,
const std::string &  modelName = "" 
)
throw (Exception
)

Append a model.

Parameters
siteLogLikelihoodsThe loglikelihoods of the sites under this model.
modelNameThe name of the model.
Exceptions
ExceptionIf the number of sites is not the same as in the container.

Definition at line 87 of file PairedSiteLikelihoods.cpp.

Referenced by appendModel().

◆ appendModel() [2/2]

void PairedSiteLikelihoods::appendModel ( const bpp::TreeLikelihood treelikelihood)
throw (Exception
)

Append a model.

Parameters
treelikelihoodA TreeLikelihood record.
Exceptions
ExceptionIf the number of sites is not the same as in the container.

Definition at line 99 of file PairedSiteLikelihoods.cpp.

References appendModel().

◆ appendModels()

void PairedSiteLikelihoods::appendModels ( const PairedSiteLikelihoods psl)
throw (Exception
)

Append models by concatenation.

Parameters
pslthe PairedSiteLikelihoods object to append to the caller.
Exceptions
ExceptionIf the number of sites in the two object is not equal.

Definition at line 107 of file PairedSiteLikelihoods.cpp.

◆ bootstrap()

std::vector< int > PairedSiteLikelihoods::bootstrap ( std::size_t  length,
double  scaling = 1 
)
static

Draw a nonparametric pseudoreplicate.

Parameters
lengthThe length of the data.
scalingThe length of the pseudoreplicate, in fraction of the length of the data.
Returns
A vector of the same length as the data, containing the count of each element in the pseudoreplicate.

Definition at line 178 of file PairedSiteLikelihoods.cpp.

Referenced by computeExpectedLikelihoodWeights().

◆ computeExpectedLikelihoodWeights()

pair< vector< string >, vector< double > > PairedSiteLikelihoods::computeExpectedLikelihoodWeights ( int  replicates = 10000) const

Compute the Expected Likelihood Weights of the models.

The weight $W_m$ of a model is :

\[ W_m = \frac{1}{B} \sum_{b \in B} \frac{L_m^{(b)}}{\sum L_k^{(b)}} = \frac{1}{B} \sum_{b \in B} \frac{exp(Y^{(b)}_m - Ymax^{(b)})}{\sum exp(Y_k^{(b)} - Y_{max}^{(b)})} \]

where $Y_k^{(b)}$ is the loglikelihood of model k for replicate b.

Returns
A pair of vectors containing the names and weights of the models.
Parameters
replicatesThe number of pseudoreplicates over which the weights are to be averaged.

Definition at line 124 of file PairedSiteLikelihoods.cpp.

References bootstrap(), getNumberOfModels(), getNumberOfSites(), logLikelihoods_, and modelNames_.

◆ getLikelihoods()

const std::vector<std::vector<double> >& bpp::PairedSiteLikelihoods::getLikelihoods ( ) const
inline
Returns
The site-likelihoods of all models.

Definition at line 118 of file PairedSiteLikelihoods.h.

References logLikelihoods_.

Referenced by bpp::IOTreepuzzlePairedSiteLikelihoods::write().

◆ getModelNames()

const std::vector<std::string>& bpp::PairedSiteLikelihoods::getModelNames ( ) const
inline
Returns
The model names.

Definition at line 126 of file PairedSiteLikelihoods.h.

References modelNames_.

Referenced by bpp::IOTreepuzzlePairedSiteLikelihoods::write().

◆ getNumberOfModels()

size_t bpp::PairedSiteLikelihoods::getNumberOfModels ( ) const
inline

Get the number of models in the container.

Definition at line 132 of file PairedSiteLikelihoods.h.

References logLikelihoods_.

Referenced by computeExpectedLikelihoodWeights(), and bpp::IOTreepuzzlePairedSiteLikelihoods::write().

◆ getNumberOfSites()

std::size_t bpp::PairedSiteLikelihoods::getNumberOfSites ( ) const
throw (Exception
)
inline
Returns
The number of sites for each model.
Exceptions
ExceptionIf the container is empty.

Definition at line 141 of file PairedSiteLikelihoods.h.

References logLikelihoods_.

Referenced by computeExpectedLikelihoodWeights(), and bpp::IOTreepuzzlePairedSiteLikelihoods::write().

◆ setName()

void bpp::PairedSiteLikelihoods::setName ( std::size_t  pos,
std::string &  name 
)
inline

Set the name of a model.

Parameters
posThe position of the target model.
nameThe new name.

Definition at line 159 of file PairedSiteLikelihoods.h.

References modelNames_.

Member Data Documentation

◆ logLikelihoods_

std::vector<std::vector<double> > bpp::PairedSiteLikelihoods::logLikelihoods_
private

◆ modelNames_

std::vector<std::string> bpp::PairedSiteLikelihoods::modelNames_
private

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