bpp-phyl3  3.0.0
bpp::SubstitutionMappingTools Class Reference

Provide methods to compute substitution mappings. More...

#include <Bpp/Phyl/Mapping/SubstitutionMappingTools.h>

Public Member Functions

 SubstitutionMappingTools ()
 
virtual ~SubstitutionMappingTools ()
 

Static Public Member Functions

static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeCounts (LikelihoodCalculationSingleProcess &rltc, SubstitutionCountInterface &substitutionCount, short unresolvedOption=UNRESOLVED_ZERO, double threshold=-1, bool verbose=true)
 Methods to compute mapping Trees. More...
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeCounts (LikelihoodCalculationSingleProcess &rltc, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=0, std::shared_ptr< const AlphabetIndex2 > distances=0, short unresolvedOption=UNRESOLVED_ZERO, double threshold=-1, bool verbose=true)
 Compute the substitutions tree for a particular dataset. More...
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeCounts (LikelihoodCalculationSingleProcess &rltc, const std::vector< uint > &speciesIds, SubstitutionCountInterface &substitutionCount, short unresolvedOption=UNRESOLVED_ZERO, double threshold=-1, bool verbose=true)
 Compute the substitutions tree for a particular dataset. More...
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeCounts (LikelihoodCalculationSingleProcess &rltc, const std::vector< uint > &edgeIds, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=0, std::shared_ptr< const AlphabetIndex2 > distances=0, short unresolvedOption=UNRESOLVED_ZERO, double threshold=-1, bool verbose=true)
 Compute the substitutions tree for a particular dataset. More...
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeNormalizations (LikelihoodCalculationSingleProcess &rltc, const std::vector< uint > &edgeIds, std::shared_ptr< const BranchedModelSet > nullModels, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > distances=0, short unresolvedOption=UNRESOLVED_ZERO, bool verbose=true)
 Compute the normalizations tree due to the models of "null" process on each branch, for each register. More...
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeNormalizations (LikelihoodCalculationSingleProcess &rltc, std::shared_ptr< const BranchedModelSet > nullModels, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > distances=0, short unresolvedOption=UNRESOLVED_ZERO, bool verbose=true)
 Compute the normalizations tree due to the models of "null" process on each branch, for each register. More...
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeNormalizedCounts (LikelihoodCalculationSingleProcess &rltc, const std::vector< uint > &edgeIds, std::shared_ptr< const BranchedModelSet > nullModels, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=0, std::shared_ptr< const AlphabetIndex2 > distances=0, bool perTimeUnit=false, uint siteSize=1, short unresolvedOption=SubstitutionMappingTools::UNRESOLVED_ZERO, double threshold=-1, bool verbose=true)
 Compute the substitution counts tree, normalized by the models of "null" process on each branch, for each register. More...
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeNormalizedCounts (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, const std::vector< uint > &edgeIds, bool perTimeUnit=false, uint siteSize=1)
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeNormalizedCounts (LikelihoodCalculationSingleProcess &rltc, std::shared_ptr< const BranchedModelSet > nullModels, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=0, std::shared_ptr< const AlphabetIndex2 > distances=0, bool perTimeUnit=false, uint siteSize=1, short unresolvedOption=SubstitutionMappingTools::UNRESOLVED_ZERO, double threshold=-1, bool verbose=true)
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeNormalizedCounts (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, bool perTimeUnit, uint siteSize=1)
 
static std::unique_ptr< ProbabilisticSubstitutionMappingcomputeOneJumpCounts (LikelihoodCalculationSingleProcess &rltc, bool verbose=true)
 This method computes for each site and for each branch the probability that at least one jump occurred. More...
 
static std::unique_ptr< PhyloTreegetTreeForType (const ProbabilisticSubstitutionMapping &counts, size_t type)
 Methods to get trees of counts. These methods can use raw or normalized counting trees (ie computed with computeCounts and computeNormalizedCounts methods). More...
 
static std::unique_ptr< PhyloTreegetTreeForType (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, size_t type)
 Sum all sites substitutions a given type. More...
 
static VVVdouble getCountsPerSitePerBranchPerType (const ProbabilisticSubstitutionMapping &counts, const std::vector< uint > &ids=Vuint(0))
 Methods to get std::vectors of counts. More...
 
static Vdouble getCountsForSitePerBranch (const ProbabilisticSubstitutionMapping &counts, size_t site)
 Sum all type of substitutions for each branch of a given position. More...
 
static Vdouble getCountsForSitePerBranch (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, size_t site)
 
static VVdouble getCountsPerSitePerBranch (const ProbabilisticSubstitutionMapping &counts, const std::vector< uint > &ids=Vuint(0))
 Sum all type of substitutions for each site for each branch. More...
 
static VVdouble getCountsPerSitePerBranch (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, const std::vector< uint > &ids=Vuint(0))
 
static Vdouble getCountsForBranchPerType (const ProbabilisticSubstitutionMapping &counts, uint branchId)
 Sum all sites substitutions for each type of a given branch. More...
 
static VVdouble getCountsPerBranchPerType (const ProbabilisticSubstitutionMapping &counts, const std::vector< uint > &ids=Vuint(0))
 Sum all sites substitutions for each branch for each type. More...
 
static VVdouble getCountsPerTypePerBranch (const ProbabilisticSubstitutionMapping &counts, const std::vector< uint > &ids=Vuint(0))
 
static VVdouble computeCountsPerTypePerBranch (LikelihoodCalculationSingleProcess &rltc, const std::vector< uint > &ids, std::shared_ptr< const SubstitutionRegisterInterface > reg, std::shared_ptr< const AlphabetIndex2 > weights=0, std::shared_ptr< const AlphabetIndex2 > distances=0, short unresolvedOption=UNRESOLVED_ZERO, double threshold=-1, bool verbose=true)
 Compute the sum over all branches of the counts per type per branch. More...
 
static Vdouble getCountsForSitePerType (const ProbabilisticSubstitutionMapping &counts, size_t site, const std::vector< uint > &ids=Vuint(0))
 Methods that sum on branches need raw mapping trees, or raw mapping trees and normalization trees (ie computed with computeCounts and computeNormalizations). More...
 
static Vdouble getCountsForSitePerType (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, size_t site, bool perTimeUnit, uint siteSize=1)
 Sum and normalize all type of substitutions for each type of a given position on all nodes. More...
 
static Vdouble getCountsForSitePerType (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, size_t site, const std::vector< uint > &ids, bool perTimeUnit, uint siteSize=1)
 Sum and normalize all type of substitutions for each type of a given position on a set of nodes. More...
 
static VVdouble getCountsPerSitePerType (const ProbabilisticSubstitutionMapping &counts, const std::vector< uint > &ids=Vuint(0))
 Sum all type of substitutions for each site for each type. More...
 
static VVdouble getCountsPerSitePerType (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, bool perTimeUnit, uint siteSize=1)
 Sum and normalize all type of substitutions for each site for each type on all nodes. More...
 
static VVdouble getCountsPerSitePerType (const ProbabilisticSubstitutionMapping &counts, const ProbabilisticSubstitutionMapping &factors, const std::vector< uint > &ids, bool perTimeUnit, uint siteSize=1)
 Sum and normalize all type of substitutions for each site for each type on a set of nodes. More...
 
static double getNormForSite (const ProbabilisticSubstitutionMapping &counts, size_t site)
 Compute the norm of a substitution std::vector for a given position. More...
 
static void outputPerSitePerBranch (const std::string &filename, const std::vector< uint > &ids, const AlignmentDataInterface &sites, const VVdouble &counts)
 Outputs of counts. More...
 
static void outputPerSitePerType (const std::string &filename, const SubstitutionRegisterInterface &reg, const AlignmentDataInterface &sites, const VVdouble &counts)
 Output Per Site Per Type in SGED format. More...
 
static void outputPerType (const std::string &filename, const SubstitutionRegisterInterface &reg, const AlignmentDataInterface &sites, const VVdouble &counts)
 Output Per Type. More...
 
static void outputPerSitePerBranchPerType (const std::string &filenamePrefix, const std::vector< uint > &ids, const SubstitutionRegisterInterface &reg, const AlignmentDataInterface &sites, const VVVdouble &counts)
 Output Per Site Per Branch Per Type, one SGED file per type. More...
 
static void writeToStream (const ProbabilisticSubstitutionMapping &substitutions, const AlignmentDataInterface &sites, size_t type, std::ostream &out)
 Write the substitutions std::vectors to a stream. More...
 
static void readFromStream (std::istream &in, ProbabilisticSubstitutionMapping &substitutions, size_t type)
 Read the substitutions std::vectors from a stream. More...
 

Static Public Attributes

static const short UNRESOLVED_ZERO = 0
 Constants describing how unresolved characters are counted: More...
 
static const short UNRESOLVED_AVERAGE = 2
 
static const short UNRESOLVED_ONE = 1
 

Detailed Description

Provide methods to compute substitution mappings.

For now, only 4 methods are implemented, and provide probabilistic substitution mappings.

See: Dutheil J, Pupko T, Jean-Marie A, Galtier N. A model-based approach for detecting coevolving positions in a molecule. Mol Biol Evol. 2005 Sep;22(9):1919-28. Epub 2005 Jun 8.

Author
Julien Dutheil

Definition at line 32 of file SubstitutionMappingTools.h.

Constructor & Destructor Documentation

◆ SubstitutionMappingTools()

bpp::SubstitutionMappingTools::SubstitutionMappingTools ( )
inline

Definition at line 52 of file SubstitutionMappingTools.h.

◆ ~SubstitutionMappingTools()

virtual bpp::SubstitutionMappingTools::~SubstitutionMappingTools ( )
inlinevirtual

Definition at line 54 of file SubstitutionMappingTools.h.

Member Function Documentation

◆ computeCounts() [1/4]

unique_ptr< ProbabilisticSubstitutionMapping > SubstitutionMappingTools::computeCounts ( LikelihoodCalculationSingleProcess rltc,
const std::vector< uint > &  edgeIds,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 weights = 0,
std::shared_ptr< const AlphabetIndex2 distances = 0,
short  unresolvedOption = UNRESOLVED_ZERO,
double  threshold = -1,
bool  verbose = true 
)
static

Compute the substitutions tree for a particular dataset.

Parameters
rltcA LikelihoodCalculationSingleProcess object.
edgeIdsThe Ids of the nodes the substitutions are counted on. If empty, count substitutions on all nodes.
regThe SubstitutionRegister to use.
weightsPointer to AlphabetIndex2 for weights for all substitutions (default: null means no weight),
distancesPointer to AlphabetIndex2 for distances for all substitutions (default: null means each distance = 1),
unresolvedOptionDescribes how unresolved are managed (see above).
thresholdvalue above which counts are considered saturated (default: -1 means no threshold).
verbosePrint info to screen.
Returns
A tree <PhyloNode, PhyloBranchMapping>

Definition at line 28 of file SubstitutionMappingTools.cpp.

References bpp::LikelihoodCalculationSingleProcess::getNumberOfDistinctSites(), bpp::LikelihoodCalculationSingleProcess::getRootArrayPositions(), bpp::LikelihoodCalculation::isInitialized(), and bpp::LikelihoodCalculationSingleProcess::substitutionProcess().

◆ computeCounts() [2/4]

unique_ptr< ProbabilisticSubstitutionMapping > SubstitutionMappingTools::computeCounts ( LikelihoodCalculationSingleProcess rltc,
const std::vector< uint > &  speciesIds,
SubstitutionCountInterface substitutionCount,
short  unresolvedOption = UNRESOLVED_ZERO,
double  threshold = -1,
bool  verbose = true 
)
static

Compute the substitutions tree for a particular dataset.

Parameters
rltcA LikelihoodCalculationSingleProcess object.
speciesIdsThe Species Ids of the edges the substitutions are counted on.
substitutionCountThe SubstitutionCount to use.
unresolvedOptionDescribes how unresolved are managed (see above).
thresholdvalue above which counts are considered saturated (default: -1 means no threshold).
verbosePrint info to screen.
Returns
A tree <PhyloNode, PhyloBranchMapping>

Definition at line 57 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionCountInterface::clone(), bpp::VectorTools::contains(), bpp::numeric::convert(), bpp::numeric::cwise(), bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::ApplicationTools::displayWarning(), bpp::LikelihoodCalculationSingleProcess::getBackwardLikelihoodsAtEdgeForClass(), bpp::LikelihoodCalculationSingleProcess::getEdgesIds(), bpp::LikelihoodCalculationSingleProcess::getForwardLikelihoodsAtNodeForClass(), bpp::LikelihoodCalculationSingleProcess::getForwardLikelihoodTree(), bpp::LikelihoodCalculationSingleProcess::getLikelihoodsAtNodeForClass(), bpp::LikelihoodCalculationSingleProcess::getNumberOfDistinctSites(), bpp::SubstitutionCountInterface::getNumberOfSubstitutionTypes(), bpp::ProbabilityDAG::getProbaAtNode(), bpp::LikelihoodCalculationSingleProcess::getRootArrayPositions(), bpp::LikelihoodCalculationSingleProcess::getTreeNode(), bpp::numeric::isinf(), bpp::LikelihoodCalculation::isInitialized(), bpp::ApplicationTools::message, bpp::LikelihoodCalculationSingleProcess::substitutionProcess(), bpp::TextTools::toString(), UNRESOLVED_AVERAGE, UNRESOLVED_ZERO, and bpp::ExtendedFloatEigen< R, C, EigenType >::Zero().

◆ computeCounts() [3/4]

static std::unique_ptr<ProbabilisticSubstitutionMapping> bpp::SubstitutionMappingTools::computeCounts ( LikelihoodCalculationSingleProcess rltc,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 weights = 0,
std::shared_ptr< const AlphabetIndex2 distances = 0,
short  unresolvedOption = UNRESOLVED_ZERO,
double  threshold = -1,
bool  verbose = true 
)
inlinestatic

Compute the substitutions tree for a particular dataset.

Parameters
rltcA LikelihoodCalculationSingleProcess object.
regThe SubstitutionRegister to use.
weightsPointer to AlphabetIndex2 for weights for all substitutions (default: null means no weight),
distancesPointer to AlphabetIndex2 for distances for all substitutions (default: null means each distance = 1),
unresolvedOptionDescribes how unresolved are managed (see above).
thresholdvalue above which counts are considered saturated (default: -1 means no threshold).
verbosePrint info to screen.
Returns
A tree <PhyloNode, PhyloBranchMapping>

Definition at line 103 of file SubstitutionMappingTools.h.

References computeCounts(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), bpp::SubstitutionProcessInterface::parametrizablePhyloTree(), and bpp::LikelihoodCalculationSingleProcess::substitutionProcess().

◆ computeCounts() [4/4]

static std::unique_ptr<ProbabilisticSubstitutionMapping> bpp::SubstitutionMappingTools::computeCounts ( LikelihoodCalculationSingleProcess rltc,
SubstitutionCountInterface substitutionCount,
short  unresolvedOption = UNRESOLVED_ZERO,
double  threshold = -1,
bool  verbose = true 
)
inlinestatic

Methods to compute mapping Trees.

Compute the substitutions tree for a particular dataset

Parameters
rltcA LikelihoodCalculationSingleProcess object.
substitutionCountThe SubstitutionCount to use.
unresolvedOptionDescribes how unresolved are managed (see above).
thresholdvalue above which counts are considered saturated (default: -1 means no threshold).
verbosePrint info to screen.
Returns
A tree <PhyloNode, PhyloBranchMapping>

Definition at line 74 of file SubstitutionMappingTools.h.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), bpp::SubstitutionProcessInterface::parametrizablePhyloTree(), and bpp::LikelihoodCalculationSingleProcess::substitutionProcess().

Referenced by computeCounts(), bpp::SingleProcessSubstitutionMapping::computeCounts(), bpp::OneProcessSequenceSubstitutionMapping::computeCounts(), and computeOneJumpCounts().

◆ computeCountsPerTypePerBranch()

VVdouble SubstitutionMappingTools::computeCountsPerTypePerBranch ( LikelihoodCalculationSingleProcess rltc,
const std::vector< uint > &  ids,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 weights = 0,
std::shared_ptr< const AlphabetIndex2 distances = 0,
short  unresolvedOption = UNRESOLVED_ZERO,
double  threshold = -1,
bool  verbose = true 
)
static

Compute the sum over all branches of the counts per type per branch.

Parameters
rltcA LikelihoodCalculationSingleProcess object.
idsThe vector of numbers of the nodes of the tree
regthe Substitution Register
      If the SubstitutionRegister is a non-stationary
      CategorySubstitutionRegister, a correction is made.
weightsPointer to AlphabetIndex2 for weights for all substitutions (default: null means no weight),
distancesPointer to AlphabetIndex2 for distances for all substitutions (default: null means each distance = 1),
unresolvedOptionDescribes how unresolved are managed (see above).
thresholdvalue above which counts are considered saturated (default: -1 means no threshold).
verboseDisplay progress messages.

Definition at line 975 of file SubstitutionMappingTools.cpp.

References bpp::VectorTools::sum().

◆ computeNormalizations() [1/2]

unique_ptr< ProbabilisticSubstitutionMapping > SubstitutionMappingTools::computeNormalizations ( LikelihoodCalculationSingleProcess rltc,
const std::vector< uint > &  edgeIds,
std::shared_ptr< const BranchedModelSet nullModels,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 distances = 0,
short  unresolvedOption = UNRESOLVED_ZERO,
bool  verbose = true 
)
static

Compute the normalizations tree due to the models of "null" process on each branch, for each register.

Parameters
rltcA LikelihoodCalculationSingleProcess object.
edgeIdsThe Ids of the nodes the substitutions are counted on. If empty, count substitutions on all nodes.
nullModelsThe "null" models used for normalization
regthe Substitution Register
distancesPointer to AlphabetIndex2 for distances for all substitutions (default: null means each distance = 1),
unresolvedOptionDescribes how unresolved are managed (see above).
verboseDisplay progress messages.
Returns
A tree <PhyloNode, PhyloBranchMapping> of normalization factors.

Definition at line 320 of file SubstitutionMappingTools.cpp.

References bpp::VectorTools::contains(), bpp::numeric::convert(), bpp::numeric::cwise(), bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::LikelihoodCalculationSingleProcess::getBackwardLikelihoodsAtEdgeForClass(), bpp::LikelihoodCalculationSingleProcess::getEdgesIds(), bpp::LikelihoodCalculationSingleProcess::getForwardLikelihoodsAtNodeForClass(), bpp::LikelihoodCalculationSingleProcess::getForwardLikelihoodTree(), bpp::LikelihoodCalculationSingleProcess::getLikelihoodsAtNodeForClass(), bpp::LikelihoodCalculationSingleProcess::getNumberOfDistinctSites(), bpp::ProbabilityDAG::getProbaAtNode(), bpp::LikelihoodCalculationSingleProcess::getRootArrayPositions(), bpp::LikelihoodCalculationSingleProcess::getTreeNode(), bpp::LikelihoodCalculation::isInitialized(), bpp::ApplicationTools::message, bpp::LikelihoodCalculationSingleProcess::substitutionProcess(), bpp::TextTools::toString(), UNRESOLVED_AVERAGE, UNRESOLVED_ZERO, and bpp::ExtendedFloatEigen< R, C, EigenType >::Zero().

Referenced by bpp::SingleProcessSubstitutionMapping::computeNormalizations(), bpp::OneProcessSequenceSubstitutionMapping::computeNormalizations(), and computeNormalizations().

◆ computeNormalizations() [2/2]

static std::unique_ptr<ProbabilisticSubstitutionMapping> bpp::SubstitutionMappingTools::computeNormalizations ( LikelihoodCalculationSingleProcess rltc,
std::shared_ptr< const BranchedModelSet nullModels,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 distances = 0,
short  unresolvedOption = UNRESOLVED_ZERO,
bool  verbose = true 
)
inlinestatic

Compute the normalizations tree due to the models of "null" process on each branch, for each register.

Parameters
rltcA LikelihoodCalculationSingleProcess object.
nullModelsThe "null" models used for normalization
regthe Substitution Register
distancesPointer to AlphabetIndex2 for distances for all substitutions (default: null means each distance = 1),
unresolvedOptionDescribes how unresolved are managed (see above).
verboseDisplay progress messages.
Returns
A tree <PhyloNode, PhyloBranchMapping> of normalization factors.

Definition at line 211 of file SubstitutionMappingTools.h.

References computeNormalizations(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), bpp::SubstitutionProcessInterface::parametrizablePhyloTree(), and bpp::LikelihoodCalculationSingleProcess::substitutionProcess().

◆ computeNormalizedCounts() [1/4]

static std::unique_ptr<ProbabilisticSubstitutionMapping> bpp::SubstitutionMappingTools::computeNormalizedCounts ( const ProbabilisticSubstitutionMapping counts,
const ProbabilisticSubstitutionMapping factors,
bool  perTimeUnit,
uint  siteSize = 1 
)
inlinestatic

◆ computeNormalizedCounts() [2/4]

◆ computeNormalizedCounts() [3/4]

unique_ptr< ProbabilisticSubstitutionMapping > SubstitutionMappingTools::computeNormalizedCounts ( LikelihoodCalculationSingleProcess rltc,
const std::vector< uint > &  edgeIds,
std::shared_ptr< const BranchedModelSet nullModels,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 weights = 0,
std::shared_ptr< const AlphabetIndex2 distances = 0,
bool  perTimeUnit = false,
uint  siteSize = 1,
short  unresolvedOption = SubstitutionMappingTools::UNRESOLVED_ZERO,
double  threshold = -1,
bool  verbose = true 
)
static

Compute the substitution counts tree, normalized by the models of "null" process on each branch, for each register.

Parameters
rltcA LikelihoodCalculationSingleProcess object.
edgeIdsThe Ids of the nodes the substitutions are counted on. If empty, count substitutions on all nodes.
nullModelsThe "null" models used for normalization
regthe Substitution Register
weightsPointer to AlphabetIndex2 for weights for all substitutions (default: null means no weight),
distancesPointer to AlphabetIndex2 for distances for all substitutions (default: null means each distance = 1),
perTimeUnitIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches) (default: false).
siteSizeThe length of a site, as considered as a counting unit (default = 1)
unresolvedOptionDescribes how unresolved are managed (see above).
thresholdvalue above which non-normalized counts are considered saturated (default: -1 means no threshold).
verboseDisplay progress messages.
Returns
A tree <PhyloNode, PhyloBranchMapping> of normalized counts..

Definition at line 630 of file SubstitutionMappingTools.cpp.

Referenced by computeNormalizedCounts().

◆ computeNormalizedCounts() [4/4]

static std::unique_ptr<ProbabilisticSubstitutionMapping> bpp::SubstitutionMappingTools::computeNormalizedCounts ( LikelihoodCalculationSingleProcess rltc,
std::shared_ptr< const BranchedModelSet nullModels,
std::shared_ptr< const SubstitutionRegisterInterface reg,
std::shared_ptr< const AlphabetIndex2 weights = 0,
std::shared_ptr< const AlphabetIndex2 distances = 0,
bool  perTimeUnit = false,
uint  siteSize = 1,
short  unresolvedOption = SubstitutionMappingTools::UNRESOLVED_ZERO,
double  threshold = -1,
bool  verbose = true 
)
inlinestatic

◆ computeOneJumpCounts()

static std::unique_ptr<ProbabilisticSubstitutionMapping> bpp::SubstitutionMappingTools::computeOneJumpCounts ( LikelihoodCalculationSingleProcess rltc,
bool  verbose = true 
)
inlinestatic

This method computes for each site and for each branch the probability that at least one jump occurred.

Here 'jump' refer to a change in the model state. Depending on the model, this might not be the same as a substitution (an alphabet state change).

Definition at line 309 of file SubstitutionMappingTools.h.

References computeCounts(), and bpp::LikelihoodCalculationSingleProcess::getStateMap().

◆ getCountsForBranchPerType()

Vdouble SubstitutionMappingTools::getCountsForBranchPerType ( const ProbabilisticSubstitutionMapping counts,
uint  branchId 
)
static

Sum all sites substitutions for each type of a given branch.

Parameters
countsThe substitution map to use.
branchIdThe id of the branch of the substitution tree for which the counts should be computed.
Returns
A std::vector will all counts summed for each type of substitutions.

Definition at line 908 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdge(), bpp::AbstractMapping::getNumberOfSites(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::ProbabilisticSubstitutionMapping::getSiteIndex().

Referenced by getCountsPerBranchPerType(), and getCountsPerTypePerBranch().

◆ getCountsForSitePerBranch() [1/2]

◆ getCountsForSitePerBranch() [2/2]

Vdouble SubstitutionMappingTools::getCountsForSitePerBranch ( const ProbabilisticSubstitutionMapping counts,
size_t  site 
)
static

Sum all type of substitutions for each branch of a given position.

Parameters
countsThe substitution map to use.
siteThe site for which the counts should be computed.
Returns
A std::vector will all counts for all types of substitutions summed.

Definition at line 814 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::allEdgesIterator(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeIndex(), bpp::ProbabilisticSubstitutionMapping::getNumberOfBranches(), bpp::ProbabilisticSubstitutionMapping::getSiteIndex(), and bpp::VectorTools::sum().

Referenced by getCountsPerSitePerBranch().

◆ getCountsForSitePerType() [1/3]

Vdouble SubstitutionMappingTools::getCountsForSitePerType ( const ProbabilisticSubstitutionMapping counts,
const ProbabilisticSubstitutionMapping factors,
size_t  site,
bool  perTimeUnit,
uint  siteSize = 1 
)
static

Sum and normalize all type of substitutions for each type of a given position on all nodes.

Parameters
countsThe substitution map to use.
factorsThe substitution normalization to use.
siteThe site for which the counts should be computed.
perTimeUnitIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
siteSizeThe length of a site, as considered as a counting unit (default = 1)
Returns
A std::vector will all counts for all types of substitutions summed.

Definition at line 1050 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::allEdgesIterator(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::ProbabilisticSubstitutionMapping::getSiteIndex().

◆ getCountsForSitePerType() [2/3]

Vdouble SubstitutionMappingTools::getCountsForSitePerType ( const ProbabilisticSubstitutionMapping counts,
const ProbabilisticSubstitutionMapping factors,
size_t  site,
const std::vector< uint > &  ids,
bool  perTimeUnit,
uint  siteSize = 1 
)
static

Sum and normalize all type of substitutions for each type of a given position on a set of nodes.

Parameters
countsThe substitution map to use.
factorsThe substitution normalization to use.
siteThe site for which the counts should be computed.
idsThe ids of the branches where the the substitutions are counted (default : all ids)
perTimeUnitIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
siteSizeThe length of a site, as considered as a counting unit (default = 1)
Returns
A std::vector will all counts for all types of substitutions summed.

Definition at line 1096 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdge(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::ProbabilisticSubstitutionMapping::getSiteIndex().

◆ getCountsForSitePerType() [3/3]

Vdouble SubstitutionMappingTools::getCountsForSitePerType ( const ProbabilisticSubstitutionMapping counts,
size_t  site,
const std::vector< uint > &  ids = Vuint(0) 
)
static

Methods that sum on branches need raw mapping trees, or raw mapping trees and normalization trees (ie computed with computeCounts and computeNormalizations).

Sum all type of substitutions for each type of a given position.

Parameters
countsThe substitution map to use.
siteThe site for which the counts should be computed.
idsThe ids of the branches where the the substitutions are counted (default : all ids)
Returns
A std::vector will all counts for all types of substitutions summed.

Definition at line 1027 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdge(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::ProbabilisticSubstitutionMapping::getSiteIndex().

Referenced by getCountsPerSitePerType().

◆ getCountsPerBranchPerType()

VVdouble SubstitutionMappingTools::getCountsPerBranchPerType ( const ProbabilisticSubstitutionMapping counts,
const std::vector< uint > &  ids = Vuint(0) 
)
static

Sum all sites substitutions for each branch for each type.

Parameters
countsThe substitution map to use.
idsThe ids of the branches where the the substitutions are counted (default : all ids)
Returns
A std::vector will all counts for all branches for all types of substitutions summed.

Definition at line 930 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), and getCountsForBranchPerType().

◆ getCountsPerSitePerBranch() [1/2]

VVdouble SubstitutionMappingTools::getCountsPerSitePerBranch ( const ProbabilisticSubstitutionMapping counts,
const ProbabilisticSubstitutionMapping factors,
const std::vector< uint > &  ids = Vuint(0) 
)
static

◆ getCountsPerSitePerBranch() [2/2]

VVdouble SubstitutionMappingTools::getCountsPerSitePerBranch ( const ProbabilisticSubstitutionMapping counts,
const std::vector< uint > &  ids = Vuint(0) 
)
static

Sum all type of substitutions for each site for each branch.

Parameters
countsThe substitution map to use.
idsThe ids of the branches where the the substitutions are counted (default : all ids)
Returns
A std::vector will all counts for all types of substitutions summed.

Definition at line 855 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), getCountsForSitePerBranch(), bpp::AbstractMapping::getNumberOfSites(), and bpp::VectorTools::resize2().

◆ getCountsPerSitePerBranchPerType()

VVVdouble SubstitutionMappingTools::getCountsPerSitePerBranchPerType ( const ProbabilisticSubstitutionMapping counts,
const std::vector< uint > &  ids = Vuint(0) 
)
static

Methods to get std::vectors of counts.

PER BRANCH methods can use raw or normalized counting trees (ie computed with computeCounts and computeNormalizedCounts methods).

Sum all type of substitutions for each site for each branch for each type.

Parameters
countsThe substitution map to use.
idsThe ids of the branches where the the substitutions are counted (default : all ids)
Returns
A std::vector will all counts for all types of substitutions.

Definition at line 778 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), bpp::AbstractMapping::getNumberOfSites(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), bpp::ProbabilisticSubstitutionMapping::getSiteIndex(), and bpp::VectorTools::resize3().

◆ getCountsPerSitePerType() [1/3]

VVdouble SubstitutionMappingTools::getCountsPerSitePerType ( const ProbabilisticSubstitutionMapping counts,
const ProbabilisticSubstitutionMapping factors,
bool  perTimeUnit,
uint  siteSize = 1 
)
static

Sum and normalize all type of substitutions for each site for each type on all nodes.

Parameters
countsThe substitution map to use.
factorsThe substitution normalization to use.
perTimeUnitIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
siteSizeThe length of a site, as considered as a counting unit (default = 1)
Returns
A std::vector will all counts for all types of substitutions summed.

Definition at line 1145 of file SubstitutionMappingTools.cpp.

References getCountsForSitePerType(), bpp::AbstractMapping::getNumberOfSites(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::VectorTools::resize2().

◆ getCountsPerSitePerType() [2/3]

VVdouble SubstitutionMappingTools::getCountsPerSitePerType ( const ProbabilisticSubstitutionMapping counts,
const ProbabilisticSubstitutionMapping factors,
const std::vector< uint > &  ids,
bool  perTimeUnit,
uint  siteSize = 1 
)
static

Sum and normalize all type of substitutions for each site for each type on a set of nodes.

Parameters
countsThe substitution map to use.
factorsThe substitution normalization to use.
idsThe ids of the branches where the the substitutions are counted (default: all ids)
perTimeUnitIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
siteSizeThe length of a site, as considered as a counting unit (default = 1)
Returns
A std::vector will all counts for all types of substitutions summed.

Definition at line 1185 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), getCountsForSitePerType(), bpp::AbstractMapping::getNumberOfSites(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::VectorTools::resize2().

◆ getCountsPerSitePerType() [3/3]

VVdouble SubstitutionMappingTools::getCountsPerSitePerType ( const ProbabilisticSubstitutionMapping counts,
const std::vector< uint > &  ids = Vuint(0) 
)
static

Sum all type of substitutions for each site for each type.

Parameters
countsThe substitution map to use.
idsThe ids of the branches where the the substitutions are counted (default: all ids)
Returns
A std::vector will all counts for all types of substitutions summed.

Definition at line 1166 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::getAllEdgesIndexes(), getCountsForSitePerType(), bpp::AbstractMapping::getNumberOfSites(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::VectorTools::resize2().

◆ getCountsPerTypePerBranch()

◆ getNormForSite()

double SubstitutionMappingTools::getNormForSite ( const ProbabilisticSubstitutionMapping counts,
size_t  site 
)
static

Compute the norm of a substitution std::vector for a given position.

The norm is computed as: $ N_i = \sqrt{\left(\sum_l {\left(\sum_t n_{l, i, t}\right)}^2\right)}$, where $n_{l, i, t}$ is the number of substitutions of type t on site i on branch l, obtained using the () operator for the SubstitutionMapping object.

Parameters
countsThe substitution map to use.
siteThe position for which the norm should be computed.
Returns
The norm of the substitution std::vector.

Definition at line 1209 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::allEdgesIterator(), bpp::AbstractSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::ProbabilisticSubstitutionMapping::getSiteIndex().

◆ getTreeForType() [1/2]

unique_ptr< PhyloTree > SubstitutionMappingTools::getTreeForType ( const ProbabilisticSubstitutionMapping counts,
const ProbabilisticSubstitutionMapping factors,
size_t  type 
)
static

Sum all sites substitutions a given type.

Parameters
countsThe substitution map to use.
factorsThe substitution normalization to use.
typeThe number of the type
Returns
A PhyloTree where branch lengths carry the branch counts.

Definition at line 744 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::allEdgesIterator(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdge(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeIndex(), bpp::AbstractMapping::getNumberOfSites(), and bpp::ProbabilisticSubstitutionMapping::getSiteIndex().

◆ getTreeForType() [2/2]

unique_ptr< PhyloTree > SubstitutionMappingTools::getTreeForType ( const ProbabilisticSubstitutionMapping counts,
size_t  type 
)
static

Methods to get trees of counts. These methods can use raw or normalized counting trees (ie computed with computeCounts and computeNormalizedCounts methods).

Sum all sites substitutions a given type.

Parameters
countsThe substitution map to use.
typeThe number of the type
Returns
A PhyloTree where branch lengths carry the branch counts.

Definition at line 717 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::allEdgesIterator(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeIndex(), bpp::AbstractMapping::getNumberOfSites(), and bpp::ProbabilisticSubstitutionMapping::getSiteIndex().

◆ outputPerSitePerBranch()

void SubstitutionMappingTools::outputPerSitePerBranch ( const std::string &  filename,
const std::vector< uint > &  ids,
const AlignmentDataInterface sites,
const VVdouble counts 
)
static

Outputs of counts.

Output Per Site Per Branch in SGED format.

Definition at line 1235 of file SubstitutionMappingTools.cpp.

References bpp::CoreSiteInterface::getCoordinate(), and bpp::TemplateAlignmentDataInterface< class >::site().

◆ outputPerSitePerBranchPerType()

void SubstitutionMappingTools::outputPerSitePerBranchPerType ( const std::string &  filenamePrefix,
const std::vector< uint > &  ids,
const SubstitutionRegisterInterface reg,
const AlignmentDataInterface sites,
const VVVdouble counts 
)
static

◆ outputPerSitePerType()

void SubstitutionMappingTools::outputPerSitePerType ( const std::string &  filename,
const SubstitutionRegisterInterface reg,
const AlignmentDataInterface sites,
const VVdouble counts 
)
static

◆ outputPerType()

void SubstitutionMappingTools::outputPerType ( const std::string &  filename,
const SubstitutionRegisterInterface reg,
const AlignmentDataInterface sites,
const VVdouble counts 
)
static

Output Per Type.

Definition at line 1310 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegisterInterface::getTypeName().

◆ readFromStream()

void SubstitutionMappingTools::readFromStream ( std::istream &  in,
ProbabilisticSubstitutionMapping substitutions,
size_t  type 
)
static

Read the substitutions std::vectors from a stream.

Parameters
inThe input stream where to read the std::vectors.
substitutionsThe mapping object to fill.
typeThe type of substitutions that are read. Should be in supported by the substitution count object associated to the mapping, if any.
Exceptions
IOExceptionIf an input error happens.

Definition at line 1432 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::allEdgesIterator(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeIndex(), bpp::DataTable::read(), bpp::ProbabilisticSubstitutionMapping::setNumberOfSites(), bpp::AbstractMapping::setSitePosition(), bpp::TextTools::toDouble(), and bpp::Exception::what().

◆ writeToStream()

void SubstitutionMappingTools::writeToStream ( const ProbabilisticSubstitutionMapping substitutions,
const AlignmentDataInterface sites,
size_t  type,
std::ostream &  out 
)
static

Write the substitutions std::vectors to a stream.

Parameters
substitutionsThe substitutions std::vectors to write.
sitesThe dataset associated to the std::vectors (needed to know the position of each site in the dataset).
typeThe type of substitutions to be output. See SubstitutionCount class. Only one type of substitution can be output at a time.
outThe output stream where to write the std::vectors.
Exceptions
IOExceptionIf an output error happens.

Definition at line 1397 of file SubstitutionMappingTools.cpp.

References bpp::AssociationTreeGraphImplObserver< class, class, class >::allEdgesIterator(), bpp::CoreSiteInterface::getCoordinate(), bpp::AssociationTreeGraphImplObserver< class, class, class >::getEdgeIndex(), bpp::AbstractMapping::getNumberOfSites(), bpp::ProbabilisticSubstitutionMapping::getSiteIndex(), and bpp::TemplateAlignmentDataInterface< class >::site().

Member Data Documentation

◆ UNRESOLVED_AVERAGE

const short bpp::SubstitutionMappingTools::UNRESOLVED_AVERAGE = 2
static

◆ UNRESOLVED_ONE

const short bpp::SubstitutionMappingTools::UNRESOLVED_ONE = 1
static

Definition at line 49 of file SubstitutionMappingTools.h.

◆ UNRESOLVED_ZERO

const short bpp::SubstitutionMappingTools::UNRESOLVED_ZERO = 0
static

Constants describing how unresolved characters are counted:

UNRESOLVED_ZERO: Considered as gaps, so no counted (default). UNRESOLVED_AVERAGE: Considered as unresolved, so all matching states share a uniform probability in conditioned likelihood vector. UNRESOLVED_ONE: Considered as whateverunresolved, so all matching states have probability 1 in conditioned likelihood vector.

Definition at line 47 of file SubstitutionMappingTools.h.

Referenced by computeCounts(), computeNormalizations(), and bpp::RewardMappingTools::computeRewardVectors().


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