bpp-phyl3  3.0.0
bpp::LegacySubstitutionMappingTools Class Reference

Provide methods to compute substitution mappings. More...

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

Public Member Functions

 LegacySubstitutionMappingTools ()
 
virtual ~LegacySubstitutionMappingTools ()
 

Static Public Member Functions

static std::unique_ptr< LegacyProbabilisticSubstitutionMappingcomputeSubstitutionVectors (std::shared_ptr< const DRTreeLikelihoodInterface > drtl, std::shared_ptr< SubstitutionCountInterface > substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static std::unique_ptr< LegacyProbabilisticSubstitutionMappingcomputeSubstitutionVectors (std::shared_ptr< const DRTreeLikelihoodInterface > drtl, const std::vector< int > &nodeIds, std::shared_ptr< SubstitutionCountInterface > substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static std::unique_ptr< LegacyProbabilisticSubstitutionMappingcomputeSubstitutionVectors (std::shared_ptr< const DRTreeLikelihoodInterface > drtl, const SubstitutionModelSet &modelSet, const std::vector< int > &nodeIds, std::shared_ptr< SubstitutionCountInterface > substitutionCount, bool verbose=true)
 
static std::unique_ptr< LegacyProbabilisticSubstitutionMappingcomputeSubstitutionVectorsNoAveraging (std::shared_ptr< const DRTreeLikelihoodInterface > drtl, std::shared_ptr< SubstitutionCountInterface > substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static std::unique_ptr< LegacyProbabilisticSubstitutionMappingcomputeSubstitutionVectorsNoAveragingMarginal (std::shared_ptr< const DRTreeLikelihoodInterface > drtl, std::shared_ptr< SubstitutionCountInterface > substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static std::unique_ptr< LegacyProbabilisticSubstitutionMappingcomputeSubstitutionVectorsMarginal (std::shared_ptr< const DRTreeLikelihoodInterface > drtl, std::shared_ptr< SubstitutionCountInterface > substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static std::unique_ptr< LegacyProbabilisticSubstitutionMappingcomputeOneJumpProbabilityVectors (std::shared_ptr< const DRTreeLikelihoodInterface > drtl, bool verbose=true)
 This method computes for each site and for each branch the probability that at least one jump occurred. More...
 
static void writeToStream (const LegacyProbabilisticSubstitutionMapping &substitutions, const SiteContainerInterface &sites, size_t type, std::ostream &out)
 Write the substitutions vectors to a stream. More...
 
static void readFromStream (std::istream &in, LegacyProbabilisticSubstitutionMapping &substitutions, size_t type)
 Read the substitutions vectors from a stream. More...
 
static std::vector< double > computeTotalSubstitutionVectorForSitePerBranch (const LegacySubstitutionMappingInterface &smap, size_t siteIndex)
 Sum all type of substitutions for each branch of a given position (specified by its index). More...
 
static std::vector< double > computeTotalSubstitutionVectorForSitePerType (const LegacySubstitutionMappingInterface &smap, size_t siteIndex)
 Sum all type of substitutions for each type of a given position (specified by its index). More...
 
static double computeNormForSite (const LegacySubstitutionMappingInterface &smap, size_t siteIndex)
 Compute the norm of a substitution vector for a given position (specified by its index). More...
 
static std::vector< double > computeSumForBranch (const LegacySubstitutionMappingInterface &smap, size_t branchIndex)
 Sum all substitutions for each type of a given branch (specified by its index). More...
 
static std::vector< double > computeSumForSite (const LegacySubstitutionMappingInterface &smap, size_t siteIndex)
 Sum all substitutions for each type of a given site (specified by its index). More...
 
static std::vector< std::vector< double > > getCountsPerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, double threshold=-1, bool verbose=true)
 Per Branch methods. More...
 
static std::vector< std::vector< double > > getCountsPerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, const SubstitutionModelSet &modelSet, std::shared_ptr< const SubstitutionRegisterInterface > reg, double threshold=-1, bool verbose=true)
 
static std::vector< std::vector< double > > getNormalizationsPerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< const SubstitutionModelInterface > nullModel, const SubstitutionRegisterInterface &reg, bool verbose=true)
 Returns the normalization factors due to the null model on each branch, for each register. More...
 
static std::vector< std::vector< double > > getNormalizationsPerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< const SubstitutionModelSet > nullModelSet, const SubstitutionRegisterInterface &reg, bool verbose=true)
 Returns the normalization factors due to the set of null models on each branch, for each register. More...
 
static std::vector< std::vector< double > > getRelativeCountsPerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, double threshold=-1, bool verbose=true)
 Returns the counts relative to the frequency of the states in case of non-stationarity. More...
 
static std::vector< std::vector< double > > getNormalizedCountsPerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< SubstitutionModelInterface > nullModel, std::shared_ptr< const SubstitutionRegisterInterface > reg, bool perTime, bool perWord, bool verbose=true)
 Returns the counts normalized by a null model. More...
 
static std::vector< std::vector< double > > getNormalizedCountsPerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelSet > modelSet, std::shared_ptr< SubstitutionModelSet > nullModelSet, std::shared_ptr< const SubstitutionRegisterInterface > reg, bool perTime, bool perWord, bool verbose=true)
 Returns the counts normalized by a null model set. More...
 
static void computeCountsPerSitePerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVdouble &array)
 Per Branch Per Site methods. More...
 
static void computeCountsPerTypePerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVdouble &result, double threshold=-1, bool verbose=true)
 Per Type Per Branch methods. More...
 
static void computeCountsPerTypePerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< SubstitutionModelInterface > nullModel, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVdouble &result, bool perTime, bool perWord, bool verbose=true)
 Compute the sum over all branches of the normalized counts per type per branch. More...
 
static void computeCountsPerTypePerBranch (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelSet > modelSet, std::shared_ptr< SubstitutionModelSet > nullModelSet, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVdouble &result, bool perTime, bool perWord, bool verbose=true)
 Compute the sum over all branches of the normalized counts per type per branch. More...
 
static void computeCountsPerSitePerType (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVdouble &result)
 Per Type Per Site methods. More...
 
static void computeCountsPerSitePerType (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< SubstitutionModelInterface > nullModel, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVdouble &result, bool perTime, bool perWord)
 Compute the sum over all branches of the normalized counts per site per type. More...
 
static void computeCountsPerSitePerType (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelSet > modelSet, std::shared_ptr< SubstitutionModelSet > nullModelSet, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVdouble &result, bool perTime, bool perWord)
 Compute the sum over all branches of the normalized counts per site per type. More...
 
static void computeCountsPerSitePerBranchPerType (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVVdouble &result)
 Per Branch Per Site Per Type methods. More...
 
static void computeCountsPerSitePerBranchPerType (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelInterface > model, std::shared_ptr< SubstitutionModelInterface > nullModel, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVVdouble &result, bool perTime, bool perWord)
 Compute normalized counts per site per branch per type. More...
 
static void computeCountsPerSitePerBranchPerType (std::shared_ptr< DRTreeLikelihoodInterface > drtl, const std::vector< int > &ids, std::shared_ptr< SubstitutionModelSet > modelSet, std::shared_ptr< SubstitutionModelSet > nullModelSet, std::shared_ptr< const SubstitutionRegisterInterface > reg, VVVdouble &result, bool perTime, bool perWord)
 Compute normalized counts per site per branch per type. More...
 
static void outputPerSitePerBranch (const std::string &filename, const std::vector< int > &ids, const VVdouble &counts)
 Outputs of counts. More...
 
static void outputPerSitePerType (const std::string &filename, const SubstitutionRegisterInterface &reg, const VVdouble &counts)
 Output Per Site Per Type. More...
 
static void outputPerSitePerBranchPerType (const std::string &filenamePrefix, const std::vector< int > &ids, const SubstitutionRegisterInterface &reg, const VVVdouble &counts)
 Output Per Site Per Branch Per Type. More...
 

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 30 of file SubstitutionMappingTools.h.

Constructor & Destructor Documentation

◆ LegacySubstitutionMappingTools()

bpp::LegacySubstitutionMappingTools::LegacySubstitutionMappingTools ( )
inline

Definition at line 33 of file SubstitutionMappingTools.h.

◆ ~LegacySubstitutionMappingTools()

virtual bpp::LegacySubstitutionMappingTools::~LegacySubstitutionMappingTools ( )
inlinevirtual

Definition at line 34 of file SubstitutionMappingTools.h.

Member Function Documentation

◆ computeCountsPerSitePerBranch()

void LegacySubstitutionMappingTools::computeCountsPerSitePerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVdouble array 
)
static

Per Branch Per Site methods.

Compute the sum over all types of the counts per site per branch.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
regThe Substitution Register
arrayThe resulted counts as an tabular site X branchid

Definition at line 1856 of file SubstitutionMappingTools.cpp.

References computeSubstitutionVectors(), computeTotalSubstitutionVectorForSitePerBranch(), count(), and bpp::VectorTools::resize2().

◆ computeCountsPerSitePerBranchPerType() [1/3]

void LegacySubstitutionMappingTools::computeCountsPerSitePerBranchPerType ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVVdouble result 
)
static

Per Branch Per Site Per Type methods.

Compute counts per site per branch per type.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
regthe Substitution Register
resultthe resulted counts as an tabular site X branchid X typeId
Author
Iakov Davydov

Definition at line 2164 of file SubstitutionMappingTools.cpp.

References computeSubstitutionVectors(), count(), and bpp::VectorTools::resize3().

◆ computeCountsPerSitePerBranchPerType() [2/3]

void LegacySubstitutionMappingTools::computeCountsPerSitePerBranchPerType ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< SubstitutionModelInterface nullModel,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVVdouble result,
bool  perTime,
bool  perWord 
)
static

Compute normalized counts per site per branch per type.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
nullModelThe null model used for normalization.
regthe Substitution Register
resultthe resulted counts as an tabular site X branchid * Typeid
perTimeIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
perWordIf true, normalized counts are per unit of length (otherwise they are divided per word length).

Definition at line 2196 of file SubstitutionMappingTools.cpp.

References bpp::LegacyRewardMappingTools::computeRewardVectors(), computeSubstitutionVectors(), count(), bpp::TreeTemplate< N >::getNode(), bpp::VectorTools::resize2(), and bpp::VectorTools::resize3().

◆ computeCountsPerSitePerBranchPerType() [3/3]

void LegacySubstitutionMappingTools::computeCountsPerSitePerBranchPerType ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelSet modelSet,
std::shared_ptr< SubstitutionModelSet nullModelSet,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVVdouble result,
bool  perTime,
bool  perWord 
)
static

Compute normalized counts per site per branch per type.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelSetThe modelset on which the SubstitutionCount is built
nullModelSetThe null modelSet used for normalization.
regthe Substitution Register
resultthe resulted counts as an tabular site X branchid * Typeid
perTimeIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
perWordIf true, normalized counts are per unit of length (otherwise they are divided per word length).

Definition at line 2294 of file SubstitutionMappingTools.cpp.

References bpp::LegacyRewardMappingTools::computeRewardVectors(), computeSubstitutionVectors(), count(), bpp::TreeTemplate< N >::getNode(), bpp::VectorTools::resize2(), bpp::VectorTools::resize3(), and bpp::VectorTools::vectorIntersection().

◆ computeCountsPerSitePerType() [1/3]

void LegacySubstitutionMappingTools::computeCountsPerSitePerType ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVdouble result 
)
static

Per Type Per Site methods.

Compute the sum over all branches of the counts per type per site,

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
regthe Substitution Register
resultthe resulted counts as an tabular site X TypeId

Definition at line 1892 of file SubstitutionMappingTools.cpp.

References computeSubstitutionVectors(), computeTotalSubstitutionVectorForSitePerType(), count(), and bpp::VectorTools::resize2().

◆ computeCountsPerSitePerType() [2/3]

void LegacySubstitutionMappingTools::computeCountsPerSitePerType ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< SubstitutionModelInterface nullModel,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVdouble result,
bool  perTime,
bool  perWord 
)
static

Compute the sum over all branches of the normalized counts per site per type.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
nullModelThe null model used for normalization.
regthe Substitution Register
resultthe resulted counts as an tabular site X TypeId
perTimeIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
perWordIf true, normalized counts are per unit of length (otherwise they are divided per word length).

Definition at line 1925 of file SubstitutionMappingTools.cpp.

References bpp::LegacyRewardMappingTools::computeRewardVectors(), computeSubstitutionVectors(), computeTotalSubstitutionVectorForSitePerType(), count(), bpp::TreeTemplate< N >::getNode(), and bpp::VectorTools::resize2().

◆ computeCountsPerSitePerType() [3/3]

void LegacySubstitutionMappingTools::computeCountsPerSitePerType ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelSet modelSet,
std::shared_ptr< SubstitutionModelSet nullModelSet,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVdouble result,
bool  perTime,
bool  perWord 
)
static

Compute the sum over all branches of the normalized counts per site per type.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelSetThe modelset on which the SubstitutionCount is built
nullModelSetThe null modelSet used for normalization.
regthe Substitution Register
resultthe resulted counts as an tabular site X TypeId
perTimeIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
perWordIf true, normalized counts are per unit of length (otherwise they are divided per word length).

Definition at line 2038 of file SubstitutionMappingTools.cpp.

References bpp::LegacyRewardMappingTools::computeRewardVectors(), computeSubstitutionVectors(), computeTotalSubstitutionVectorForSitePerType(), count(), bpp::TreeTemplate< N >::getNode(), bpp::VectorTools::resize2(), and bpp::VectorTools::vectorIntersection().

◆ computeCountsPerTypePerBranch() [1/3]

void LegacySubstitutionMappingTools::computeCountsPerTypePerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVdouble result,
double  threshold = -1,
bool  verbose = true 
)
static

Per Type Per Branch methods.

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

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
regthe Substitution Register
resultthe resulted counts as an tabular TypeId X branchId
thresholdvalue above which counts are considered saturated (default: -1 means no threshold).
verboseDisplay progress messages.

Definition at line 1812 of file SubstitutionMappingTools.cpp.

References bpp::DRTreeLikelihoodTools::getPosteriorStateFrequencies(), and bpp::VectorTools::sum().

Referenced by getNormalizedCountsPerBranch(), and getRelativeCountsPerBranch().

◆ computeCountsPerTypePerBranch() [2/3]

void LegacySubstitutionMappingTools::computeCountsPerTypePerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< SubstitutionModelInterface nullModel,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVdouble result,
bool  perTime,
bool  perWord,
bool  verbose = true 
)
static

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

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
nullModelThe null model used for normalization.
regthe Substitution Register
resultthe resulted counts as an tabular TypeId X branchId
perTimeIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
perWordIf true, normalized counts are per unit of length (otherwise they are divided per word length).
verboseDisplay progress messages.

Definition at line 1705 of file SubstitutionMappingTools.cpp.

References bpp::TreeTemplate< N >::getNode().

◆ computeCountsPerTypePerBranch() [3/3]

void LegacySubstitutionMappingTools::computeCountsPerTypePerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelSet modelSet,
std::shared_ptr< SubstitutionModelSet nullModelSet,
std::shared_ptr< const SubstitutionRegisterInterface reg,
VVdouble result,
bool  perTime,
bool  perWord,
bool  verbose = true 
)
static

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

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelSetThe modelset on which the SubstitutionCount is built
nullModelSetThe null modelSet used for normalization.
regthe Substitution Register
resultthe resulted counts as an tabular TypeId X branchId
perTimeIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches). time (otherwise they are multiplied by
perWordIf true, normalized counts are per unit of length (otherwise they are divided per word length).
verboseDisplay progress messages.

Definition at line 1759 of file SubstitutionMappingTools.cpp.

References bpp::TreeTemplate< N >::getNode().

◆ computeNormForSite()

double LegacySubstitutionMappingTools::computeNormForSite ( const LegacySubstitutionMappingInterface smap,
size_t  siteIndex 
)
static

Compute the norm of a substitution vector for a given position (specified by its index).

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
smapThe substitution map to use.
siteIndexThe index of the substitution vector for which the norm should be computed.
Returns
The norm of the substitution vector.

Definition at line 1326 of file SubstitutionMappingTools.cpp.

References bpp::LegacyMappingInterface::getNumberOfBranches(), and bpp::LegacySubstitutionMappingInterface::getNumberOfSubstitutionTypes().

◆ computeOneJumpProbabilityVectors()

static std::unique_ptr<LegacyProbabilisticSubstitutionMapping> bpp::LegacySubstitutionMappingTools::computeOneJumpProbabilityVectors ( std::shared_ptr< const DRTreeLikelihoodInterface drtl,
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 160 of file SubstitutionMappingTools.h.

References computeSubstitutionVectors().

◆ computeSubstitutionVectors() [1/3]

unique_ptr< LegacyProbabilisticSubstitutionMapping > LegacySubstitutionMappingTools::computeSubstitutionVectors ( std::shared_ptr< const DRTreeLikelihoodInterface drtl,
const std::vector< int > &  nodeIds,
std::shared_ptr< SubstitutionCountInterface substitutionCount,
bool  verbose = true 
)
static

Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation.

Parameters
drtlA DRTreeLikelihood object.
nodeIdsThe Ids of the nodes the substitutions are counted on. If empty, count substitutions on all nodes.
substitutionCountThe SubstitutionCount to use.
verbosePrint info to screen.
Returns
A vector of substitutions vectors (one for each site).
Exceptions
ExceptionIf the likelihood object is not initialized.

Definition at line 28 of file SubstitutionMappingTools.cpp.

References bpp::VectorTools::contains(), bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeTemplate< N >::getNodes(), bpp::Node::getNumberOfSons(), bpp::TreeTemplate< N >::getRootId(), bpp::Node::getSon(), bpp::Node::hasFather(), and bpp::ApplicationTools::message.

◆ computeSubstitutionVectors() [2/3]

◆ computeSubstitutionVectors() [3/3]

static std::unique_ptr<LegacyProbabilisticSubstitutionMapping> bpp::LegacySubstitutionMappingTools::computeSubstitutionVectors ( std::shared_ptr< const DRTreeLikelihoodInterface drtl,
std::shared_ptr< SubstitutionCountInterface substitutionCount,
bool  verbose = true 
)
inlinestatic

Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation.

Parameters
drtlA DRTreeLikelihood object.
substitutionCountThe SubstitutionCount to use.
verbosePrint info to screen.
Returns
A vector of substitutions vectors (one for each site).
Exceptions
ExceptionIf the likelihood object is not initialized.

Definition at line 47 of file SubstitutionMappingTools.h.

Referenced by computeCountsPerSitePerBranch(), computeCountsPerSitePerBranchPerType(), computeCountsPerSitePerType(), computeOneJumpProbabilityVectors(), and getCountsPerBranch().

◆ computeSubstitutionVectorsMarginal()

unique_ptr< LegacyProbabilisticSubstitutionMapping > LegacySubstitutionMappingTools::computeSubstitutionVectorsMarginal ( std::shared_ptr< const DRTreeLikelihoodInterface drtl,
std::shared_ptr< SubstitutionCountInterface substitutionCount,
bool  verbose = true 
)
static

Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation.

The marginal probability is used for weighting, i.e. the product of probabilities for the pair.

This function is mainly for testing purpose (see Dutheil et al. 2005). For practical use, consider using the 'getSubstitutionVectors' method instead.

Parameters
drtlA DRTreeLikelihood object.
substitutionCountThe substitutionsCount to use.
verbosePrint info to screen.
Returns
A vector of substitutions vectors (one for each site).
Exceptions
ExceptionIf the likelihood object is not initialized.

Definition at line 1070 of file SubstitutionMappingTools.cpp.

References bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeTemplate< N >::getNodes(), bpp::DRTreeLikelihoodTools::getPosteriorProbabilitiesPerStatePerRate(), and bpp::ApplicationTools::message.

◆ computeSubstitutionVectorsNoAveraging()

unique_ptr< LegacyProbabilisticSubstitutionMapping > LegacySubstitutionMappingTools::computeSubstitutionVectorsNoAveraging ( std::shared_ptr< const DRTreeLikelihoodInterface drtl,
std::shared_ptr< SubstitutionCountInterface substitutionCount,
bool  verbose = true 
)
static

Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation.

In this method, substitution counts are computed using the pair of ancestral states with maximum likelihood. This is a kind of joint-pair ancestral reconstruction, as in Galtier and Boursot (1998). This reconstruction possibly takes into account several rate classes, and substitution counts are averaged over all rate classes, weighted by their conditional likelihood.

This function is mainly for testing purpose (see Dutheil et al. 2005). For practical use, consider using the 'getSubstitutionVectors' method instead.

Parameters
drtlA DRTreeLikelihood object.
substitutionCountThe substitutionsCount to use.
verbosePrint info to screen.
Returns
A vector of substitutions vectors (one for each site).
Exceptions
ExceptionIf the likelihood object is not initialized.

Definition at line 647 of file SubstitutionMappingTools.cpp.

References bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::MatrixTools::fill(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeTemplate< N >::getNodes(), bpp::Node::getNumberOfSons(), bpp::Node::getSon(), bpp::Node::hasFather(), bpp::ApplicationTools::message, and bpp::MatrixTools::whichMax().

◆ computeSubstitutionVectorsNoAveragingMarginal()

unique_ptr< LegacyProbabilisticSubstitutionMapping > LegacySubstitutionMappingTools::computeSubstitutionVectorsNoAveragingMarginal ( std::shared_ptr< const DRTreeLikelihoodInterface drtl,
std::shared_ptr< SubstitutionCountInterface substitutionCount,
bool  verbose = true 
)
static

Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation.

In this method, all ancestral states are estimated using marginal likelihoods, putatively intregated over several rate classes. For each branch, the number of substitution given marginal states is used. This method, used with a SimpleSubstitutionCount object is equivalent to Tufféry and Darlu's (2000) computation of substitution vectors.

Use with another substitution count object is in most cases irrelevant.

Parameters
drtlA DRTreeLikelihood object.
substitutionCountThe substitutionsCount to use.
verbosePrint info to screen.
Returns
A vector of substitutions vectors (one for each site).
Exceptions
ExceptionIf the likelihood object is not initialized.

Definition at line 940 of file SubstitutionMappingTools.cpp.

References bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::LegacyMarginalAncestralStateReconstruction::getAllAncestralStates(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeTemplate< N >::getNodes(), and bpp::ApplicationTools::message.

◆ computeSumForBranch()

vector< double > LegacySubstitutionMappingTools::computeSumForBranch ( const LegacySubstitutionMappingInterface smap,
size_t  branchIndex 
)
static

Sum all substitutions for each type of a given branch (specified by its index).

Parameters
smapThe substitution map to use.
branchIndexThe index of the substitution vector for which the counts should be computed.
Returns
A vector will all counts summed for each types of substitutions.

Definition at line 1345 of file SubstitutionMappingTools.cpp.

References bpp::LegacyMappingInterface::getNumberOfSites(), and bpp::LegacySubstitutionMappingInterface::getNumberOfSubstitutionTypes().

◆ computeSumForSite()

vector< double > LegacySubstitutionMappingTools::computeSumForSite ( const LegacySubstitutionMappingInterface smap,
size_t  siteIndex 
)
static

Sum all substitutions for each type of a given site (specified by its index).

Parameters
smapThe substitution map to use.
siteIndexThe index of the substitution vector for which the counts should be computed.
Returns
A vector will all counts summed for each types of substitutions.

Definition at line 1364 of file SubstitutionMappingTools.cpp.

References bpp::LegacyMappingInterface::getNumberOfBranches(), and bpp::LegacySubstitutionMappingInterface::getNumberOfSubstitutionTypes().

◆ computeTotalSubstitutionVectorForSitePerBranch()

vector< double > LegacySubstitutionMappingTools::computeTotalSubstitutionVectorForSitePerBranch ( const LegacySubstitutionMappingInterface smap,
size_t  siteIndex 
)
static

Sum all type of substitutions for each branch of a given position (specified by its index).

Parameters
smapThe substitution map to use.
siteIndexThe index of the substitution vector for which the counts should be computed.
Returns
A vector will all counts for all types of substitutions summed.

Definition at line 1286 of file SubstitutionMappingTools.cpp.

References bpp::LegacyMappingInterface::getNumberOfBranches(), and bpp::LegacySubstitutionMappingInterface::getNumberOfSubstitutionTypes().

Referenced by computeCountsPerSitePerBranch().

◆ computeTotalSubstitutionVectorForSitePerType()

vector< double > LegacySubstitutionMappingTools::computeTotalSubstitutionVectorForSitePerType ( const LegacySubstitutionMappingInterface smap,
size_t  siteIndex 
)
static

Sum all type of substitutions for each type of a given position (specified by its index).

Parameters
smapThe substitution map to use.
siteIndexThe index of the substitution vector for which the counts should be computed.
Returns
A vector will all counts for all branches summed.

Definition at line 1306 of file SubstitutionMappingTools.cpp.

References bpp::LegacyMappingInterface::getNumberOfBranches(), and bpp::LegacySubstitutionMappingInterface::getNumberOfSubstitutionTypes().

Referenced by computeCountsPerSitePerType().

◆ getCountsPerBranch() [1/2]

vector< vector< double > > LegacySubstitutionMappingTools::getCountsPerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
const SubstitutionModelSet modelSet,
std::shared_ptr< const SubstitutionRegisterInterface reg,
double  threshold = -1,
bool  verbose = true 
)
static

◆ getCountsPerBranch() [2/2]

vector< vector< double > > LegacySubstitutionMappingTools::getCountsPerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< const SubstitutionRegisterInterface reg,
double  threshold = -1,
bool  verbose = true 
)
static

◆ getNormalizationsPerBranch() [1/2]

vector< vector< double > > LegacySubstitutionMappingTools::getNormalizationsPerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< const SubstitutionModelInterface nullModel,
const SubstitutionRegisterInterface reg,
bool  verbose = true 
)
static

Returns the normalization factors due to the null model on each branch, for each register.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
nullModelThe model on which the SubstitutionCount is built
regthe Substitution Register
verboseDisplay progress messages.
Returns
A vector of normalization vectors (one per branch per type).

Definition at line 1542 of file SubstitutionMappingTools.cpp.

References bpp::LegacyRewardMappingTools::computeRewardVectors(), bpp::ApplicationTools::displayWarning(), bpp::SubstitutionRegisterInterface::getNumberOfSubstitutionTypes(), bpp::SubstitutionRegisterInterface::getType(), bpp::SubstitutionRegisterInterface::getTypeName(), and bpp::TextTools::toString().

◆ getNormalizationsPerBranch() [2/2]

vector< vector< double > > LegacySubstitutionMappingTools::getNormalizationsPerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< const SubstitutionModelSet nullModelSet,
const SubstitutionRegisterInterface reg,
bool  verbose = true 
)
static

Returns the normalization factors due to the set of null models on each branch, for each register.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
nullModelSetThe model on which the SubstitutionCount is built
regthe Substitution Register
verboseDisplay progress messages.
Returns
A vector of normalization vectors (one per branch per type).

Definition at line 1615 of file SubstitutionMappingTools.cpp.

References bpp::LegacyRewardMappingTools::computeRewardVectors(), bpp::ApplicationTools::displayWarning(), bpp::SubstitutionRegisterInterface::getNumberOfSubstitutionTypes(), bpp::SubstitutionRegisterInterface::getType(), bpp::SubstitutionRegisterInterface::getTypeName(), bpp::TextTools::toString(), bpp::VectorTools::vectorIntersection(), and bpp::VectorTools::which().

◆ getNormalizedCountsPerBranch() [1/2]

static std::vector<std::vector<double> > bpp::LegacySubstitutionMappingTools::getNormalizedCountsPerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< SubstitutionModelInterface nullModel,
std::shared_ptr< const SubstitutionRegisterInterface reg,
bool  perTime,
bool  perWord,
bool  verbose = true 
)
inlinestatic

Returns the counts normalized by a null model.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
nullModelThe null model used for normalization.
regthe Substitution Register
perTimeIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
perWordIf true, normalized counts are per unit of length (otherwise they are divided per word length).
verboseDisplay progress messages.

Definition at line 362 of file SubstitutionMappingTools.h.

References computeCountsPerTypePerBranch().

◆ getNormalizedCountsPerBranch() [2/2]

static std::vector<std::vector<double> > bpp::LegacySubstitutionMappingTools::getNormalizedCountsPerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelSet modelSet,
std::shared_ptr< SubstitutionModelSet nullModelSet,
std::shared_ptr< const SubstitutionRegisterInterface reg,
bool  perTime,
bool  perWord,
bool  verbose = true 
)
inlinestatic

Returns the counts normalized by a null model set.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelSetThe model set on which the SubstitutionCount is built
nullModelSetThe null model set used for normalization.
regthe Substitution Register
perTimeIf true, normalized counts are per unit of time (otherwise they are multiplied by the length of the branches).
perWordIf true, normalized counts are per unit of length (otherwise they are divided per word length).
verboseDisplay progress messages.

Definition at line 393 of file SubstitutionMappingTools.h.

References computeCountsPerTypePerBranch().

◆ getRelativeCountsPerBranch()

static std::vector<std::vector<double> > bpp::LegacySubstitutionMappingTools::getRelativeCountsPerBranch ( std::shared_ptr< DRTreeLikelihoodInterface drtl,
const std::vector< int > &  ids,
std::shared_ptr< SubstitutionModelInterface model,
std::shared_ptr< const SubstitutionRegisterInterface reg,
double  threshold = -1,
bool  verbose = true 
)
inlinestatic

Returns the counts relative to the frequency of the states in case of non-stationarity.

Parameters
drtlA DRTreeLikelihood object.
idsThe numbers of the nodes of the tree
modelThe model on which the SubstitutionCount is built
regthe Substitution Register
      If the SubstitutionRegister is a non-stationary
      CategorySubstitutionRegister, a correction is made.
thresholdvalue above which counts are considered saturated (default: -1 means no threshold).
verboseDisplay progress messages.

Definition at line 333 of file SubstitutionMappingTools.h.

References computeCountsPerTypePerBranch().

◆ outputPerSitePerBranch()

void LegacySubstitutionMappingTools::outputPerSitePerBranch ( const std::string &  filename,
const std::vector< int > &  ids,
const VVdouble counts 
)
static

Outputs of counts.

Output Per Site Per Branch

Definition at line 2405 of file SubstitutionMappingTools.cpp.

◆ outputPerSitePerBranchPerType()

void LegacySubstitutionMappingTools::outputPerSitePerBranchPerType ( const std::string &  filenamePrefix,
const std::vector< int > &  ids,
const SubstitutionRegisterInterface reg,
const VVVdouble counts 
)
static

◆ outputPerSitePerType()

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

Output Per Site Per Type.

Definition at line 2441 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegisterInterface::getTypeName().

◆ readFromStream()

void LegacySubstitutionMappingTools::readFromStream ( std::istream &  in,
LegacyProbabilisticSubstitutionMapping substitutions,
size_t  type 
)
static

Read the substitutions vectors from a stream.

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

Definition at line 1242 of file SubstitutionMappingTools.cpp.

References bpp::LegacyAbstractMapping::getNodeIndex(), bpp::DataTable::read(), bpp::LegacyProbabilisticSubstitutionMapping::setNumberOfSites(), bpp::LegacyAbstractMapping::setSitePosition(), bpp::TextTools::toDouble(), bpp::TextTools::toInt(), and bpp::Exception::what().

◆ writeToStream()

void LegacySubstitutionMappingTools::writeToStream ( const LegacyProbabilisticSubstitutionMapping substitutions,
const SiteContainerInterface sites,
size_t  type,
std::ostream &  out 
)
static

Write the substitutions vectors to a stream.

Parameters
substitutionsThe substitutions vectors to write.
sitesThe dataset associated to the 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 vectors.
Exceptions
IOExceptionIf an output error happens.

Definition at line 1213 of file SubstitutionMappingTools.cpp.

References bpp::Site::getCoordinate(), bpp::Node::getDistanceToFather(), bpp::Node::getId(), bpp::LegacyAbstractMapping::getNode(), bpp::LegacyAbstractMapping::getNumberOfBranches(), bpp::LegacyAbstractMapping::getNumberOfSites(), and TemplateSiteContainerInterface< Site, Sequence, std::string >::site().


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