bpp-phyl3  3.0.0
bpp::LegacyMarginalAncestralStateReconstruction Class Reference

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

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

+ Inheritance diagram for bpp::LegacyMarginalAncestralStateReconstruction:
+ Collaboration diagram for bpp::LegacyMarginalAncestralStateReconstruction:

Public Member Functions

 LegacyMarginalAncestralStateReconstruction (std::shared_ptr< const DRTreeLikelihoodInterface > drl)
 
 LegacyMarginalAncestralStateReconstruction (const LegacyMarginalAncestralStateReconstruction &masr)=default
 
LegacyMarginalAncestralStateReconstructionoperator= (const LegacyMarginalAncestralStateReconstruction &masr)=default
 
LegacyMarginalAncestralStateReconstructionclone () const
 
virtual ~LegacyMarginalAncestralStateReconstruction ()
 
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 override
 Get ancestral states for a given node as a vector of int. More...
 
std::map< int, std::vector< size_t > > getAllAncestralStates () const override
 Get all ancestral states for all nodes. More...
 
std::unique_ptr< SequencegetAncestralSequenceForNode (int nodeId, VVdouble *probs, bool sample) const
 Get the ancestral sequence for a given node. More...
 
std::unique_ptr< SequencegetAncestralSequenceForNode (int nodeId) const override
 Get the ancestral sequence for a given node. More...
 
std::unique_ptr< SiteContainerInterfacegetAncestralSequences () const override
 Get all the ancestral sequences for all nodes. More...
 
std::unique_ptr< SiteContainerInterfacegetAncestralSequences (bool sample) const
 

Private Member Functions

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

Private Attributes

std::shared_ptr< const DRTreeLikelihoodInterfacelikelihood_
 
TreeTemplate< Nodetree_
 
std::shared_ptr< const Alphabetalphabet_
 
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 27 of file MarginalAncestralStateReconstruction.h.

Constructor & Destructor Documentation

◆ LegacyMarginalAncestralStateReconstruction() [1/2]

bpp::LegacyMarginalAncestralStateReconstruction::LegacyMarginalAncestralStateReconstruction ( std::shared_ptr< const DRTreeLikelihoodInterface drl)
inline

Definition at line 43 of file MarginalAncestralStateReconstruction.h.

Referenced by clone().

◆ LegacyMarginalAncestralStateReconstruction() [2/2]

bpp::LegacyMarginalAncestralStateReconstruction::LegacyMarginalAncestralStateReconstruction ( const LegacyMarginalAncestralStateReconstruction masr)
default

◆ ~LegacyMarginalAncestralStateReconstruction()

virtual bpp::LegacyMarginalAncestralStateReconstruction::~LegacyMarginalAncestralStateReconstruction ( )
inlinevirtual

Definition at line 62 of file MarginalAncestralStateReconstruction.h.

Member Function Documentation

◆ clone()

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

◆ getAllAncestralStates()

map< int, vector< size_t > > LegacyMarginalAncestralStateReconstruction::getAllAncestralStates ( ) const
overridevirtual

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::LegacyAncestralStateReconstruction.

Definition at line 69 of file MarginalAncestralStateReconstruction.cpp.

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

◆ getAncestralSequenceForNode() [1/2]

std::unique_ptr<Sequence> bpp::LegacyMarginalAncestralStateReconstruction::getAncestralSequenceForNode ( int  nodeId) const
inlineoverridevirtual

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::LegacyAncestralStateReconstruction.

Definition at line 103 of file MarginalAncestralStateReconstruction.h.

References getAncestralSequenceForNode().

◆ getAncestralSequenceForNode() [2/2]

std::unique_ptr< Sequence > LegacyMarginalAncestralStateReconstruction::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 78 of file MarginalAncestralStateReconstruction.cpp.

References bpp::TextTools::toString().

Referenced by getAncestralSequenceForNode().

◆ getAncestralSequences() [1/2]

std::unique_ptr<SiteContainerInterface> bpp::LegacyMarginalAncestralStateReconstruction::getAncestralSequences ( ) const
inlineoverridevirtual

Get all the ancestral sequences for all nodes.

Returns
A new SiteContainer object.

Implements bpp::LegacyAncestralStateReconstruction.

Definition at line 108 of file MarginalAncestralStateReconstruction.h.

◆ getAncestralSequences() [2/2]

unique_ptr< SiteContainerInterface > LegacyMarginalAncestralStateReconstruction::getAncestralSequences ( bool  sample) const

Definition at line 137 of file MarginalAncestralStateReconstruction.cpp.

◆ getAncestralStatesForNode() [1/2]

std::vector<size_t> bpp::LegacyMarginalAncestralStateReconstruction::getAncestralStatesForNode ( int  nodeId) const
inlineoverridevirtual

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::LegacyAncestralStateReconstruction.

Definition at line 82 of file MarginalAncestralStateReconstruction.h.

References getAncestralStatesForNode(), and nbSites_.

◆ getAncestralStatesForNode() [2/2]

vector< size_t > LegacyMarginalAncestralStateReconstruction::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 12 of file MarginalAncestralStateReconstruction.cpp.

References bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry(), and bpp::VectorTools::whichMax().

Referenced by getAncestralStatesForNode().

◆ operator=()

LegacyMarginalAncestralStateReconstruction& bpp::LegacyMarginalAncestralStateReconstruction::operator= ( const LegacyMarginalAncestralStateReconstruction masr)
default

◆ recursiveMarginalAncestralStates()

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

Member Data Documentation

◆ alphabet_

std::shared_ptr<const Alphabet> bpp::LegacyMarginalAncestralStateReconstruction::alphabet_
private

Definition at line 33 of file MarginalAncestralStateReconstruction.h.

◆ l_

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

Definition at line 40 of file MarginalAncestralStateReconstruction.h.

◆ likelihood_

std::shared_ptr<const DRTreeLikelihoodInterface> bpp::LegacyMarginalAncestralStateReconstruction::likelihood_
private

Definition at line 31 of file MarginalAncestralStateReconstruction.h.

◆ nbClasses_

size_t bpp::LegacyMarginalAncestralStateReconstruction::nbClasses_
private

Definition at line 36 of file MarginalAncestralStateReconstruction.h.

◆ nbDistinctSites_

size_t bpp::LegacyMarginalAncestralStateReconstruction::nbDistinctSites_
private

Definition at line 35 of file MarginalAncestralStateReconstruction.h.

◆ nbSites_

size_t bpp::LegacyMarginalAncestralStateReconstruction::nbSites_
private

Definition at line 34 of file MarginalAncestralStateReconstruction.h.

Referenced by getAncestralStatesForNode().

◆ nbStates_

size_t bpp::LegacyMarginalAncestralStateReconstruction::nbStates_
private

Definition at line 37 of file MarginalAncestralStateReconstruction.h.

◆ r_

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

Definition at line 39 of file MarginalAncestralStateReconstruction.h.

◆ rootPatternLinks_

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

Definition at line 38 of file MarginalAncestralStateReconstruction.h.

◆ tree_

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

Definition at line 32 of file MarginalAncestralStateReconstruction.h.


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