bpp-phyl3  3.0.0
bpp::MarginalAncestralReconstruction Class Reference

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

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

+ Inheritance diagram for bpp::MarginalAncestralReconstruction:
+ Collaboration diagram for bpp::MarginalAncestralReconstruction:

Public Member Functions

 MarginalAncestralReconstruction (std::shared_ptr< LikelihoodCalculationSingleProcess > drl)
 
 MarginalAncestralReconstruction (const MarginalAncestralReconstruction &masr)
 
MarginalAncestralReconstructionoperator= (const MarginalAncestralReconstruction &masr)
 
MarginalAncestralReconstructionclone () const
 
virtual ~MarginalAncestralReconstruction ()
 
std::shared_ptr< const AlphabetgetAlphabet () const
 
std::vector< size_t > getAncestralStatesForNode (uint nodeId, VVdouble &probs, bool sample) const
 Get ancestral states for a given node as a vector of int. More...
 
std::vector< size_t > getAncestralStatesForNode (uint nodeId) const override
 Get ancestral states for a given node as a vector of int. More...
 
std::map< uint, std::vector< size_t > > getAllAncestralStates () const override
 Get all ancestral states for all nodes. More...
 
std::unique_ptr< SequencegetAncestralSequenceForNode (uint nodeId, VVdouble *probs, bool sample) const
 Get an ancestral sequence for a given node. More...
 
std::unique_ptr< SequencegetAncestralSequenceForNode (uint nodeId) const override
 Get the ancestral sequence for a given node. More...
 
std::unique_ptr< AlignedSequenceContainergetAncestralSequences () const override
 Get all the ancestral sequences for all nodes. More...
 
std::unique_ptr< AlignedSequenceContainergetAncestralSequences (bool sample) const
 

Private Member Functions

void recursiveMarginalAncestralStates (const std::shared_ptr< PhyloNode > node, std::map< uint, std::vector< size_t >> &ancestors, AlignmentDataInterface &data) const
 

Private Attributes

std::shared_ptr< LikelihoodCalculationSingleProcesslikelihood_
 
std::shared_ptr< const ParametrizablePhyloTreetree_
 
std::shared_ptr< const Alphabetalphabet_
 
size_t nbSites_
 
size_t nbDistinctSites_
 
size_t nbStates_
 
PatternType rootPatternLinks_
 

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 29 of file MarginalAncestralReconstruction.h.

Constructor & Destructor Documentation

◆ MarginalAncestralReconstruction() [1/2]

bpp::MarginalAncestralReconstruction::MarginalAncestralReconstruction ( std::shared_ptr< LikelihoodCalculationSingleProcess drl)
inline

Definition at line 43 of file MarginalAncestralReconstruction.h.

References tree_.

Referenced by clone().

◆ MarginalAncestralReconstruction() [2/2]

bpp::MarginalAncestralReconstruction::MarginalAncestralReconstruction ( const MarginalAncestralReconstruction masr)
inline

Definition at line 56 of file MarginalAncestralReconstruction.h.

◆ ~MarginalAncestralReconstruction()

virtual bpp::MarginalAncestralReconstruction::~MarginalAncestralReconstruction ( )
inlinevirtual

Definition at line 81 of file MarginalAncestralReconstruction.h.

Member Function Documentation

◆ clone()

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

◆ getAllAncestralStates()

map< uint, vector< size_t > > MarginalAncestralReconstruction::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::AncestralStateReconstruction.

Definition at line 55 of file MarginalAncestralReconstruction.cpp.

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::MarginalAncestralReconstruction::getAlphabet ( ) const
inline

Definition at line 84 of file MarginalAncestralReconstruction.h.

References alphabet_.

◆ getAncestralSequenceForNode() [1/2]

std::unique_ptr<Sequence> bpp::MarginalAncestralReconstruction::getAncestralSequenceForNode ( uint  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::AncestralStateReconstruction.

Definition at line 138 of file MarginalAncestralReconstruction.h.

References getAncestralSequenceForNode().

◆ getAncestralSequenceForNode() [2/2]

unique_ptr< Sequence > MarginalAncestralReconstruction::getAncestralSequenceForNode ( uint  nodeId,
VVdouble probs,
bool  sample 
) const

Get an 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 64 of file MarginalAncestralReconstruction.cpp.

References bpp::TextTools::toString().

Referenced by getAncestralSequenceForNode().

◆ getAncestralSequences() [1/2]

std::unique_ptr<AlignedSequenceContainer> bpp::MarginalAncestralReconstruction::getAncestralSequences ( ) const
inlineoverridevirtual

Get all the ancestral sequences for all nodes.

Returns
A new SiteContainer object.

Implements bpp::AncestralStateReconstruction.

Definition at line 143 of file MarginalAncestralReconstruction.h.

◆ getAncestralSequences() [2/2]

unique_ptr< AlignedSequenceContainer > MarginalAncestralReconstruction::getAncestralSequences ( bool  sample) const

Definition at line 132 of file MarginalAncestralReconstruction.cpp.

◆ getAncestralStatesForNode() [1/2]

std::vector<size_t> bpp::MarginalAncestralReconstruction::getAncestralStatesForNode ( uint  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::AncestralStateReconstruction.

Definition at line 111 of file MarginalAncestralReconstruction.h.

References getAncestralStatesForNode(), and nbSites_.

◆ getAncestralStatesForNode() [2/2]

vector< size_t > MarginalAncestralReconstruction::getAncestralStatesForNode ( uint  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 total number of 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 [in].
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) [out].
sampleTell if the sequence should be sampled from the posterior distribution instead of taking the one with maximum probability.
Returns
A vector of states indices.
See also
getAncestralSequenceForNode

Definition at line 13 of file MarginalAncestralReconstruction.cpp.

References bpp::copyEigenToBpp(), and bpp::RandomTools::giveRandomNumberBetweenZeroAndEntry().

Referenced by getAncestralStatesForNode().

◆ operator=()

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

◆ recursiveMarginalAncestralStates()

void MarginalAncestralReconstruction::recursiveMarginalAncestralStates ( const std::shared_ptr< PhyloNode node,
std::map< uint, std::vector< size_t >> &  ancestors,
AlignmentDataInterface data 
) const
private

Definition at line 93 of file MarginalAncestralReconstruction.cpp.

References bpp::Sequence::size().

Member Data Documentation

◆ alphabet_

std::shared_ptr<const Alphabet> bpp::MarginalAncestralReconstruction::alphabet_
mutableprivate

Definition at line 35 of file MarginalAncestralReconstruction.h.

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

◆ likelihood_

std::shared_ptr<LikelihoodCalculationSingleProcess> bpp::MarginalAncestralReconstruction::likelihood_
private

Definition at line 33 of file MarginalAncestralReconstruction.h.

Referenced by operator=().

◆ nbDistinctSites_

size_t bpp::MarginalAncestralReconstruction::nbDistinctSites_
private

Definition at line 37 of file MarginalAncestralReconstruction.h.

Referenced by operator=().

◆ nbSites_

size_t bpp::MarginalAncestralReconstruction::nbSites_
private

Definition at line 36 of file MarginalAncestralReconstruction.h.

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

◆ nbStates_

size_t bpp::MarginalAncestralReconstruction::nbStates_
private

Definition at line 39 of file MarginalAncestralReconstruction.h.

Referenced by operator=().

◆ rootPatternLinks_

PatternType bpp::MarginalAncestralReconstruction::rootPatternLinks_
private

Definition at line 40 of file MarginalAncestralReconstruction.h.

Referenced by operator=().

◆ tree_

std::shared_ptr<const ParametrizablePhyloTree> bpp::MarginalAncestralReconstruction::tree_
private

Definition at line 34 of file MarginalAncestralReconstruction.h.

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


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