bpp-phyl  2.2.0
bpp::MarginalAncestralStateReconstruction Class Reference

Likelihood ancestral states reconstruction: marginal method. More...

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

+ Inheritance diagram for bpp::MarginalAncestralStateReconstruction:
+ Collaboration diagram for bpp::MarginalAncestralStateReconstruction:

Public Member Functions

 MarginalAncestralStateReconstruction (const DRTreeLikelihood *drl)
 
 MarginalAncestralStateReconstruction (const MarginalAncestralStateReconstruction &masr)
 
MarginalAncestralStateReconstructionoperator= (const MarginalAncestralStateReconstruction &masr)
 
MarginalAncestralStateReconstructionclone () const
 
virtual ~MarginalAncestralStateReconstruction ()
 
std::vector< size_t > getAncestralStatesForNode (int nodeId, VVdouble &probs, bool sample) const
 Get ancestral states for a given node as a vector of int. More...
 
std::vector< size_t > getAncestralStatesForNode (int nodeId) const
 Get ancestral states for a given node as a vector of int. More...
 
std::map< int, std::vector< size_t > > getAllAncestralStates () const
 Get all ancestral states for all nodes. More...
 
Sequence * getAncestralSequenceForNode (int nodeId, VVdouble *probs, bool sample) const
 Get the ancestral sequence for a given node. More...
 
Sequence * getAncestralSequenceForNode (int nodeId) const
 Get the ancestral sequence for a given node. More...
 
AlignedSequenceContainer * getAncestralSequences () const
 Get all the ancestral sequences for all nodes. More...
 
AlignedSequenceContainer * getAncestralSequences (bool sample) const
 

Private Member Functions

void recursiveMarginalAncestralStates (const Node *node, std::map< int, std::vector< size_t > > &ancestors, AlignedSequenceContainer &data) const
 

Private Attributes

const DRTreeLikelihoodlikelihood_
 
TreeTemplate< Nodetree_
 
const Alphabet * alphabet_
 
size_t nbSites_
 
size_t nbDistinctSites_
 
size_t nbClasses_
 
size_t nbStates_
 
std::vector< size_t > rootPatternLinks_
 
std::vector< double > r_
 
std::vector< double > l_
 

Detailed Description

Likelihood ancestral states reconstruction: marginal method.

Reference: Z Yang, S Kumar and M Nei (1995), Genetics 141(4) 1641-50.

Definition at line 63 of file MarginalAncestralStateReconstruction.h.

Constructor & Destructor Documentation

◆ MarginalAncestralStateReconstruction() [1/2]

bpp::MarginalAncestralStateReconstruction::MarginalAncestralStateReconstruction ( const DRTreeLikelihood drl)
inline

Definition at line 79 of file MarginalAncestralStateReconstruction.h.

Referenced by clone().

◆ MarginalAncestralStateReconstruction() [2/2]

bpp::MarginalAncestralStateReconstruction::MarginalAncestralStateReconstruction ( const MarginalAncestralStateReconstruction masr)
inline

Definition at line 92 of file MarginalAncestralStateReconstruction.h.

◆ ~MarginalAncestralStateReconstruction()

virtual bpp::MarginalAncestralStateReconstruction::~MarginalAncestralStateReconstruction ( )
inlinevirtual

Definition at line 128 of file MarginalAncestralStateReconstruction.h.

Member Function Documentation

◆ clone()

MarginalAncestralStateReconstruction* bpp::MarginalAncestralStateReconstruction::clone ( ) const
inline

◆ getAllAncestralStates()

map< int, vector< size_t > > MarginalAncestralStateReconstruction::getAllAncestralStates ( ) const
virtual

Get all ancestral states for all nodes.

Call the getAncestralSequenceForNode() method on each node in the tree.

Returns
A map with nodes id as key, and a vector of states indices as value.
See also
getAncestralSequenceForNode

Implements bpp::AncestralStateReconstruction.

Definition at line 104 of file MarginalAncestralStateReconstruction.cpp.

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

◆ getAncestralSequenceForNode() [1/2]

Sequence * MarginalAncestralStateReconstruction::getAncestralSequenceForNode ( int  nodeId,
VVdouble *  probs,
bool  sample 
) const

Get the ancestral sequence for a given node.

The name of the sequence will be the name of the node if there is one, its id otherwise. A new sequence object is created, whose destruction is up to the user.

Parameters
nodeIdThe id of the node at which the sequence must be reconstructed.
probsA pointer toward a vector to be filled with the probability for each state at each site (set to NULL if you don't want these probabilities).
sampleTell if the sequence should be sample from the posterior distribution instead of taking the one with maximum probability.
Returns
A sequence object.

Definition at line 114 of file MarginalAncestralStateReconstruction.cpp.

References bpp::SubstitutionModel::getAlphabetStateAsInt().

Referenced by getAncestralSequenceForNode().

◆ getAncestralSequenceForNode() [2/2]

Sequence* bpp::MarginalAncestralStateReconstruction::getAncestralSequenceForNode ( int  nodeId) const
inlinevirtual

Get the ancestral sequence for a given node.

Parameters
nodeIdThe id of the node at which the sequence must be reconstructed.
Returns
A sequence object.

Implements bpp::AncestralStateReconstruction.

Definition at line 170 of file MarginalAncestralStateReconstruction.h.

References getAncestralSequenceForNode().

◆ getAncestralSequences() [1/2]

AlignedSequenceContainer* bpp::MarginalAncestralStateReconstruction::getAncestralSequences ( ) const
inlinevirtual

Get all the ancestral sequences for all nodes.

Returns
A new SiteContainer object.

Implements bpp::AncestralStateReconstruction.

Definition at line 175 of file MarginalAncestralStateReconstruction.h.

◆ getAncestralSequences() [2/2]

AlignedSequenceContainer * MarginalAncestralStateReconstruction::getAncestralSequences ( bool  sample) const

Definition at line 172 of file MarginalAncestralStateReconstruction.cpp.

◆ getAncestralStatesForNode() [1/2]

vector< size_t > MarginalAncestralStateReconstruction::getAncestralStatesForNode ( int  nodeId,
VVdouble &  probs,
bool  sample 
) const

Get ancestral states for a given node as a vector of int.

The size of the vector is the number of distinct sites in the container associated to the likelihood object. This method is mainly for efficient internal use in other classes. Consider using the getAncestralSequenceForNode() method for a more general output.

Parameters
nodeIdThe id of the node at which the states must be reconstructed.
probsA vector to be filled with the probability for each state at each position (will be the same size as the returned vector for states).
sampleTell if the sequence should be sample from the posterior distribution instead of taking the one with maximum probability.
Returns
A vector of states indices.
See also
getAncestralSequenceForNode

Definition at line 47 of file MarginalAncestralStateReconstruction.cpp.

Referenced by getAncestralStatesForNode().

◆ getAncestralStatesForNode() [2/2]

std::vector<size_t> bpp::MarginalAncestralStateReconstruction::getAncestralStatesForNode ( int  nodeId) const
inlinevirtual

Get ancestral states for a given node as a vector of int.

The size of the vector depends on the implementation. This method is mainly for efficient internal use in other classes. Consider using the getAncestralSequenceForNode() method for a more general output.

Parameters
nodeIdthe id of the node at which the states must be reconstructed.
Returns
A vector of states indices.
See also
getAncestralSequenceForNode

Implements bpp::AncestralStateReconstruction.

Definition at line 149 of file MarginalAncestralStateReconstruction.h.

References getAncestralStatesForNode(), and nbSites_.

◆ operator=()

MarginalAncestralStateReconstruction& bpp::MarginalAncestralStateReconstruction::operator= ( const MarginalAncestralStateReconstruction masr)
inline

◆ recursiveMarginalAncestralStates()

void MarginalAncestralStateReconstruction::recursiveMarginalAncestralStates ( const Node node,
std::map< int, std::vector< size_t > > &  ancestors,
AlignedSequenceContainer &  data 
) const
private

Member Data Documentation

◆ alphabet_

const Alphabet* bpp::MarginalAncestralStateReconstruction::alphabet_
private

Definition at line 69 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().

◆ l_

std::vector<double> bpp::MarginalAncestralStateReconstruction::l_
private

Definition at line 76 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().

◆ likelihood_

const DRTreeLikelihood* bpp::MarginalAncestralStateReconstruction::likelihood_
private

Definition at line 67 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().

◆ nbClasses_

size_t bpp::MarginalAncestralStateReconstruction::nbClasses_
private

Definition at line 72 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().

◆ nbDistinctSites_

size_t bpp::MarginalAncestralStateReconstruction::nbDistinctSites_
private

Definition at line 71 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().

◆ nbSites_

size_t bpp::MarginalAncestralStateReconstruction::nbSites_
private

Definition at line 70 of file MarginalAncestralStateReconstruction.h.

Referenced by getAncestralStatesForNode(), and operator=().

◆ nbStates_

size_t bpp::MarginalAncestralStateReconstruction::nbStates_
private

Definition at line 73 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().

◆ r_

std::vector<double> bpp::MarginalAncestralStateReconstruction::r_
private

Definition at line 75 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().

◆ rootPatternLinks_

std::vector<size_t> bpp::MarginalAncestralStateReconstruction::rootPatternLinks_
private

Definition at line 74 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().

◆ tree_

TreeTemplate<Node> bpp::MarginalAncestralStateReconstruction::tree_
private

Definition at line 68 of file MarginalAncestralStateReconstruction.h.

Referenced by operator=().


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