bpp-phyl  2.1.0
bpp::NonHomogeneousTreeLikelihood Class Reference

Specialization of the TreeLikelihood interface for the branch non-homogeneous and non-stationary models. More...

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

+ Inheritance diagram for bpp::NonHomogeneousTreeLikelihood:
+ Collaboration diagram for bpp::NonHomogeneousTreeLikelihood:

List of all members.

Public Member Functions

NonHomogeneousTreeLikelihoodclone () const =0
const SubstitutionModelgetSubstitutionModel (int nodeId, size_t siteIndex) const throw (NodeNotFoundException)
 Get the substitution model associated to a given node and alignment column.
SubstitutionModelgetSubstitutionModel (int nodeId, size_t siteIndex) throw (NodeNotFoundException)
 Get the substitution model associated to a given node and alignment column.
virtual const SubstitutionModelgetSubstitutionModelForNode (int nodeId) const =0 throw (NodeNotFoundException)
 Get the substitution model associated to a given node.
virtual SubstitutionModelgetSubstitutionModelForNode (int nodeId)=0 throw (NodeNotFoundException)
 Get the substitution model associated to a given node.
virtual const
SubstitutionModelSet
getSubstitutionModelSet () const =0
virtual SubstitutionModelSetgetSubstitutionModelSet ()=0
virtual void setSubstitutionModelSet (SubstitutionModelSet *model)=0 throw (Exception)
virtual ParameterList getRootFrequenciesParameters () const =0
virtual void setData (const SiteContainer &sites)=0
 Set the dataset for which the likelihood must be evaluated.
virtual const SiteContainergetData () const =0
 Get the dataset for which the likelihood must be evaluated.
virtual void initialize ()=0 throw (Exception)
 Init the likelihood object.
virtual bool isInitialized () const =0
virtual TreeLikelihoodDatagetLikelihoodData ()=0
virtual const TreeLikelihoodDatagetLikelihoodData () const =0
virtual double getLikelihoodForASite (size_t site) const =0
 Get the likelihood for a site.
virtual double getLogLikelihoodForASite (size_t site) const =0
 Get the logarithm of the likelihood for a site.
virtual double getLikelihoodForASiteForAState (size_t site, int state) const =0
 Get the likelihood for a site and for a state.
virtual double getLogLikelihoodForASiteForAState (size_t site, int state) const =0
 Get the logarithm of the likelihood for a site and for a state.
virtual Vdouble getLikelihoodForEachSite () const =0
 Get the likelihood for each site.
virtual Vdouble getLogLikelihoodForEachSite () const =0
 Get the logarithm of the likelihood for each site.
virtual VVdouble getLikelihoodForEachSiteForEachState () const =0
 Get the likelihood for each site and for each state.
virtual VVdouble getLogLikelihoodForEachSiteForEachState () const =0
 Get the logarithm of the likelihood for each site and for each state.
virtual double getLikelihood () const =0
 Get the likelihood for the whole dataset.
virtual double getLogLikelihood () const =0
 Get the logarithm of the likelihood for the whole dataset.
virtual const TreegetTree () const =0
 Get the tree (topology and branch lengths).
virtual size_t getNumberOfSites () const =0
 Get the number of sites in the dataset.
virtual size_t getNumberOfStates () const =0
 Get the number of states in the alphabet associated to the dataset.
virtual const AlphabetgetAlphabet () const =0
 Get the alphabet associated to the dataset.
virtual void enableDerivatives (bool yn)=0
 Tell if derivatives must be computed.
virtual ParameterList getDerivableParameters () const =0
 All derivable parameters.
virtual ParameterList getNonDerivableParameters () const =0
 All non derivable parameters.
virtual void enableSecondOrderDerivatives (bool yn)=0
virtual bool enableSecondOrderDerivatives () const =0
virtual double getSecondOrderDerivative (const std::string &variable) const =0
virtual double getSecondOrderDerivative (const std::string &variable1, const std::string &variable2) const =0
virtual double d2f (const std::string &variable, const ParameterList &parameters)
virtual double d2f (const std::string &variable1, const std::string &variable2, const ParameterList &parameters)
virtual void enableFirstOrderDerivatives (bool yn)=0
virtual bool enableFirstOrderDerivatives () const =0
virtual double getFirstOrderDerivative (const std::string &variable) const =0
virtual double df (const std::string &variable, const ParameterList &parameters)
virtual void setParameters (const ParameterList &parameters)=0
virtual double getValue () const =0
virtual double f (const ParameterList &parameters)
virtual bool hasParameter (const std::string &name) const =0
virtual const ParameterListgetParameters () const =0
virtual const ParametergetParameter (const std::string &name) const =0
virtual double getParameterValue (const std::string &name) const =0
virtual void setAllParametersValues (const ParameterList &parameters)=0
virtual void setParameterValue (const std::string &name, double value)=0
virtual void setParametersValues (const ParameterList &parameters)=0
virtual bool matchParametersValues (const ParameterList &parameters)=0
virtual size_t getNumberOfParameters () const =0
virtual void setNamespace (const std::string &prefix)=0
virtual std::string getNamespace () const =0
virtual std::string getParameterNameWithoutNamespace (const std::string &name) const =0
Retrieve some particular parameters subsets.
virtual ParameterList getBranchLengthsParameters () const =0
 Get the branch lengths parameters.
virtual ParameterList getSubstitutionModelParameters () const =0
 Get the parameters associated to substitution model(s).
virtual VVdouble getTransitionProbabilities (int nodeId, size_t siteIndex) const =0
 Retrieves all Pij(t) for a particular branch, defined by the upper node and site.
virtual ConstBranchModelIteratorgetNewBranchModelIterator (int nodeId) const =0
virtual ConstSiteModelIteratorgetNewSiteModelIterator (size_t siteIndex) const =0
virtual size_t getSiteIndex (size_t site) const =0 throw (IndexOutOfBoundsException)
 Get the index (used for inner computations) of a given site (original alignment column).
virtual const std::vector
< double > & 
getRootFrequencies (size_t siteIndex) const =0
 Get the values of the frequencies for each state in the alphabet at the root node.

Detailed Description

Specialization of the TreeLikelihood interface for the branch non-homogeneous and non-stationary models.

The main difference is that the likelihood depends on the position of the root. The frequencies at the root of the tree are new parameters, which are not necessarily equal to the equilibrium frequencies of the substitution model.

This interface further assumes that the substitution model is the same for all sites, for a given branch.

See also:
SubstitutionModelSet.

Definition at line 60 of file NonHomogeneousTreeLikelihood.h.


Member Function Documentation

virtual void bpp::TreeLikelihood::enableDerivatives ( bool  yn) [pure virtual, inherited]

Tell if derivatives must be computed.

This methods calls the enableFirstOrderDerivatives and enableSecondOrderDerivatives.

Parameters:
ynYes or no.

Implemented in bpp::AbstractTreeLikelihood.

virtual const Alphabet* bpp::TreeLikelihood::getAlphabet ( ) const [pure virtual, inherited]

Get the alphabet associated to the dataset.

Returns:
the alphabet associated to the dataset.

Implemented in bpp::AbstractTreeLikelihood.

virtual ParameterList bpp::TreeLikelihood::getBranchLengthsParameters ( ) const [pure virtual, inherited]

Get the branch lengths parameters.

Returns:
A ParameterList with all branch lengths.

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood, bpp::AbstractHomogeneousTreeLikelihood, and bpp::TwoTreeLikelihood.

Referenced by bpp::OptimizationTools::ScaleFunction::ScaleFunction().

virtual const SiteContainer* bpp::TreeLikelihood::getData ( ) const [pure virtual, inherited]

Get the dataset for which the likelihood must be evaluated.

Returns:
A pointer toward the site container where the sequences are stored.

Implemented in bpp::AbstractTreeLikelihood.

virtual ParameterList bpp::TreeLikelihood::getDerivableParameters ( ) const [pure virtual, inherited]

All derivable parameters.

Usually, this contains all branch lengths parameters.

Returns:
A ParameterList.

Implemented in bpp::RHomogeneousClockTreeLikelihood, and bpp::AbstractDiscreteRatesAcrossSitesTreeLikelihood.

virtual double bpp::TreeLikelihood::getLikelihood ( ) const [pure virtual, inherited]
virtual double bpp::TreeLikelihood::getLikelihoodForASite ( size_t  site) const [pure virtual, inherited]

Get the likelihood for a site.

Parameters:
siteThe site index to analyse.
Returns:
The likelihood for site site.

Implemented in bpp::RNonHomogeneousTreeLikelihood, bpp::RHomogeneousTreeLikelihood, bpp::DRNonHomogeneousTreeLikelihood, bpp::TwoTreeLikelihood, and bpp::DRHomogeneousTreeLikelihood.

Referenced by bpp::AbstractTreeLikelihood::getLikelihoodForEachSite().

virtual double bpp::TreeLikelihood::getLikelihoodForASiteForAState ( size_t  site,
int  state 
) const [pure virtual, inherited]

Get the likelihood for a site and for a state.

Parameters:
siteThe site index to analyse.
stateThe state to consider.
Returns:
The likelihood for site site and state state.

Implemented in bpp::AbstractDiscreteRatesAcrossSitesTreeLikelihood.

Referenced by bpp::AbstractTreeLikelihood::getLikelihoodForEachSiteForEachState().

virtual Vdouble bpp::TreeLikelihood::getLikelihoodForEachSite ( ) const [pure virtual, inherited]

Get the likelihood for each site.

Returns:
A vector with all likelihoods for each site.

Implemented in bpp::AbstractTreeLikelihood.

virtual VVdouble bpp::TreeLikelihood::getLikelihoodForEachSiteForEachState ( ) const [pure virtual, inherited]

Get the likelihood for each site and for each state.

Returns:
A 2d vector with all likelihoods for each site and for each state.

Implemented in bpp::AbstractTreeLikelihood.

virtual double bpp::TreeLikelihood::getLogLikelihood ( ) const [pure virtual, inherited]

Get the logarithm of the likelihood for the whole dataset.

Returns:
The logarithm of the likelihood of the dataset.

Implemented in bpp::RNonHomogeneousTreeLikelihood, bpp::RHomogeneousTreeLikelihood, bpp::DRNonHomogeneousTreeLikelihood, bpp::TwoTreeLikelihood, bpp::DRHomogeneousTreeLikelihood, and bpp::DRHomogeneousMixedTreeLikelihood.

virtual double bpp::TreeLikelihood::getLogLikelihoodForASite ( size_t  site) const [pure virtual, inherited]

Get the logarithm of the likelihood for a site.

Parameters:
siteThe site index to analyse.
Returns:
The logarithm of the likelihood for site site.

Implemented in bpp::RNonHomogeneousTreeLikelihood, bpp::RHomogeneousTreeLikelihood, bpp::DRNonHomogeneousTreeLikelihood, bpp::TwoTreeLikelihood, and bpp::DRHomogeneousTreeLikelihood.

Referenced by bpp::AbstractTreeLikelihood::getLogLikelihoodForEachSite().

virtual double bpp::TreeLikelihood::getLogLikelihoodForASiteForAState ( size_t  site,
int  state 
) const [pure virtual, inherited]

Get the logarithm of the likelihood for a site and for a state.

Parameters:
siteThe site index to analyse.
stateThe state to consider.
Returns:
The logarithm of the likelihood for site site and state state.

Implemented in bpp::AbstractDiscreteRatesAcrossSitesTreeLikelihood.

Referenced by bpp::AbstractTreeLikelihood::getLogLikelihoodForEachSiteForEachState().

virtual Vdouble bpp::TreeLikelihood::getLogLikelihoodForEachSite ( ) const [pure virtual, inherited]

Get the logarithm of the likelihood for each site.

Returns:
A vector with all log likelihoods for each site.

Implemented in bpp::AbstractTreeLikelihood.

virtual VVdouble bpp::TreeLikelihood::getLogLikelihoodForEachSiteForEachState ( ) const [pure virtual, inherited]

Get the logarithm of the likelihood for each site and for each state.

Returns:
A 2d vector with all log likelihoods for each site and for each state.

Implemented in bpp::AbstractTreeLikelihood.

virtual ParameterList bpp::TreeLikelihood::getNonDerivableParameters ( ) const [pure virtual, inherited]

All non derivable parameters.

Usually, this contains all substitution model parameters and rate distribution.

Returns:
A ParameterList.

Implemented in bpp::RHomogeneousClockTreeLikelihood, and bpp::AbstractDiscreteRatesAcrossSitesTreeLikelihood.

virtual size_t bpp::TreeLikelihood::getNumberOfSites ( ) const [pure virtual, inherited]

Get the number of sites in the dataset.

Returns:
the number of sites in the dataset.

Implemented in bpp::AbstractTreeLikelihood.

virtual size_t bpp::TreeLikelihood::getNumberOfStates ( ) const [pure virtual, inherited]

Get the number of states in the alphabet associated to the dataset.

Returns:
the number of states in the alphabet associated to the dataset.

Implemented in bpp::AbstractTreeLikelihood.

Referenced by bpp::DRTreeLikelihoodTools::getPosteriorProbabilitiesForEachStateForEachRate(), and bpp::DRTreeLikelihoodTools::getPosteriorStateFrequencies().

virtual const std::vector<double>& bpp::TreeLikelihood::getRootFrequencies ( size_t  siteIndex) const [pure virtual, inherited]

Get the values of the frequencies for each state in the alphabet at the root node.

For reversible models, these are the equilibrium frequencies. For non-reversible models, these usually are distinct parameters.

For models without site partitioning, the set of frequencies is the same for all positions. For partition models, the frequencies may differ from one site to another.

Parameters:
siteIndexThe index of the alignment position.
See also:
getSiteIndex
Returns:
A vector with ancestral frequencies for each state in the alphabet;

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood, bpp::AbstractHomogeneousTreeLikelihood, and bpp::TwoTreeLikelihood.

Returns:
The parameters on which the root frequencies depend.

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood.

Referenced by bpp::PhylogeneticsApplicationTools::optimizeParameters().

virtual size_t bpp::TreeLikelihood::getSiteIndex ( size_t  site) const throw (IndexOutOfBoundsException) [pure virtual, inherited]

Get the index (used for inner computations) of a given site (original alignment column).

Parameters:
siteAn alignment position.
Returns:
The site index corresponding to the given input alignment position.

Implemented in bpp::RHomogeneousTreeLikelihood, bpp::RNonHomogeneousTreeLikelihood, bpp::TwoTreeLikelihood, bpp::DRNonHomogeneousTreeLikelihood, and bpp::DRHomogeneousTreeLikelihood.

const SubstitutionModel* bpp::NonHomogeneousTreeLikelihood::getSubstitutionModel ( int  nodeId,
size_t  siteIndex 
) const throw (NodeNotFoundException) [inline, virtual]

Get the substitution model associated to a given node and alignment column.

Parameters:
nodeIdThe id of the request node.
siteIndexThe index of the alignment position.
See also:
getSiteIndex
Returns:
A pointer toward the corresponding model.
Exceptions:
NodeNotFoundExceptionThis exception may be thrown if the node is not found (depending on the implementation).

Implements bpp::TreeLikelihood.

Definition at line 69 of file NonHomogeneousTreeLikelihood.h.

References getSubstitutionModelForNode().

SubstitutionModel* bpp::NonHomogeneousTreeLikelihood::getSubstitutionModel ( int  nodeId,
size_t  siteIndex 
) throw (NodeNotFoundException) [inline, virtual]

Get the substitution model associated to a given node and alignment column.

Parameters:
nodeIdThe id of the request node.
siteIndexThe index of the alignment position.
See also:
getSiteIndex
Returns:
A pointer toward the corresponding model.
Exceptions:
NodeNotFoundExceptionThis exception may be thrown if the node is not found (depending on the implementation).

Implements bpp::TreeLikelihood.

Definition at line 74 of file NonHomogeneousTreeLikelihood.h.

References getSubstitutionModelForNode().

Get the substitution model associated to a given node.

Parameters:
nodeIdThe id of the request node.
Returns:
A pointer toward the corresponding model.
Exceptions:
NodeNotFoundExceptionThis exception may be thrown if the node is not found (depending on the implementation).

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood.

Referenced by getSubstitutionModel().

Get the substitution model associated to a given node.

Parameters:
nodeIdThe id of the request node.
Returns:
A pointer toward the corresponding model.
Exceptions:
NodeNotFoundExceptionThis exception may be thrown if the node is not found (depending on the implementation).

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood.

virtual ParameterList bpp::TreeLikelihood::getSubstitutionModelParameters ( ) const [pure virtual, inherited]

Get the parameters associated to substitution model(s).

Returns:
A ParameterList.

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood, bpp::AbstractHomogeneousTreeLikelihood, and bpp::TwoTreeLikelihood.

Returns:
The set of substitution models associated to this instance.

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood.

Returns:
The set of substitution models associated to this instance.

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood.

virtual VVdouble bpp::TreeLikelihood::getTransitionProbabilities ( int  nodeId,
size_t  siteIndex 
) const [pure virtual, inherited]

Retrieves all Pij(t) for a particular branch, defined by the upper node and site.

These intermediate results may be used by other methods.

Parameters:
nodeIdThe node defining the branch of interest.
siteIndexThe index of the alignment position.
See also:
getSiteIndex
Returns:
An array of dimension 2, where a[x][y] is the probability of substituting from x to y.

Implemented in bpp::AbstractDiscreteRatesAcrossSitesTreeLikelihood.

virtual void bpp::TreeLikelihood::initialize ( ) throw (Exception) [pure virtual, inherited]

Init the likelihood object.

This method is used to initialize all parameters. It is typically called after the constructor and the setData method. It contains virtual methods that can't be called in the constructor.

Exceptions:
Exceptionif something bad happened, for instance if no data are associated to the likelihood function.

Implemented in bpp::AbstractTreeLikelihood, bpp::RNonHomogeneousMixedTreeLikelihood, bpp::DRHomogeneousMixedTreeLikelihood, bpp::AbstractNonHomogeneousTreeLikelihood, bpp::AbstractHomogeneousTreeLikelihood, bpp::TwoTreeLikelihood, and bpp::RHomogeneousMixedTreeLikelihood.

virtual bool bpp::TreeLikelihood::isInitialized ( ) const [pure virtual, inherited]
Returns:
'true' is the likelihood function has been initialized.

Implemented in bpp::AbstractTreeLikelihood.

Returns:
Set the substitution models for this instance.
Exceptions:
ExceptionIf the model could not be set (for instance, because of a wrong alphabet type).

Implemented in bpp::AbstractNonHomogeneousTreeLikelihood.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Friends