bpp-phyl
2.2.0
|
Provide methods to compute substitution mappings. More...
#include <Bpp/Phyl/Mapping/SubstitutionMappingTools.h>
Public Member Functions | |
SubstitutionMappingTools () | |
virtual | ~SubstitutionMappingTools () |
Static Public Member Functions | |
static ProbabilisticSubstitutionMapping * | computeSubstitutionVectors (const DRTreeLikelihood &drtl, SubstitutionCount &substitutionCount, bool verbose=true) throw (Exception) |
Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More... | |
static ProbabilisticSubstitutionMapping * | computeSubstitutionVectors (const DRTreeLikelihood &drtl, const std::vector< int > &nodeIds, SubstitutionCount &substitutionCount, bool verbose=true) throw (Exception) |
Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More... | |
static ProbabilisticSubstitutionMapping * | computeSubstitutionVectors (const DRTreeLikelihood &drtl, const SubstitutionModelSet &modelSet, const std::vector< int > &nodeIds, SubstitutionCount &substitutionCount, bool verbose=true) throw (Exception) |
static ProbabilisticSubstitutionMapping * | computeSubstitutionVectorsNoAveraging (const DRTreeLikelihood &drtl, SubstitutionCount &substitutionCount, bool verbose=true) throw (Exception) |
Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More... | |
static ProbabilisticSubstitutionMapping * | computeSubstitutionVectorsNoAveragingMarginal (const DRTreeLikelihood &drtl, SubstitutionCount &substitutionCount, bool verbose=true) throw (Exception) |
Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More... | |
static ProbabilisticSubstitutionMapping * | computeSubstitutionVectorsMarginal (const DRTreeLikelihood &drtl, SubstitutionCount &substitutionCount, bool verbose=true) throw (Exception) |
Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More... | |
static ProbabilisticSubstitutionMapping * | computeOneJumpProbabilityVectors (const DRTreeLikelihood &drtl, bool verbose=true) throw (Exception) |
This method computes for each site and for each branch the probability that at least one jump occurred. More... | |
static void | writeToStream (const ProbabilisticSubstitutionMapping &substitutions, const SiteContainer &sites, size_t type, std::ostream &out) throw (IOException) |
Write the substitutions vectors to a stream. More... | |
static void | readFromStream (std::istream &in, ProbabilisticSubstitutionMapping &substitutions, size_t type) throw (IOException) |
Read the substitutions vectors from a stream. More... | |
static std::vector< double > | computeTotalSubstitutionVectorForSite (const SubstitutionMapping &smap, size_t siteIndex) |
Sum all type of substitutions for each branch of a given position (specified by its index). More... | |
static double | computeNormForSite (const SubstitutionMapping &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 SubstitutionMapping &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 SubstitutionMapping &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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister ®, double threshold=-1, bool verbose=true) |
Returns the counts on each branch. More... | |
static std::vector< std::vector< double > > | getCountsPerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, const SubstitutionModelSet &modelSet, const SubstitutionRegister ®, double threshold=-1, bool verbose=true) |
static std::vector< std::vector< double > > | getNormalizationsPerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, const SubstitutionModel *nullModel, const SubstitutionRegister ®, 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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, const SubstitutionModelSet *nullModelSet, const SubstitutionRegister ®, 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 > > | getNormalizedCountsPerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, SubstitutionModel *nullModel, const SubstitutionRegister ®, bool verbose=true) |
Returns the counts normalized by a null model. More... | |
static std::vector< std::vector< double > > | getNormalizedCountsPerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModelSet *modelSet, SubstitutionModelSet *nullModelSet, const SubstitutionRegister ®, bool verbose=true) |
Returns the counts normalized by a null model set. More... | |
static std::vector< std::vector< double > > | getRelativeCountsPerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister ®, bool stationarity=true, double threshold=-1) |
Returns the counts relative to the frequency of the states in case of non-stationarity. More... | |
static void | outputTotalCountsPerBranchPerSite (std::string &filename, DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister ®) |
Output the sum of the counts par branch per site, in a file. More... | |
static void | outputIndividualCountsPerBranchPerSite (const std::string &filenamePrefix, DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister ®) |
Output individual counts par branch per site, in files. More... | |
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.
Definition at line 62 of file SubstitutionMappingTools.h.
|
inline |
Definition at line 65 of file SubstitutionMappingTools.h.
|
inlinevirtual |
Definition at line 66 of file SubstitutionMappingTools.h.
|
static |
Compute the norm of a substitution vector for a given position (specified by its index).
The norm is computed as: , where
is the number of substitutions of type t on site i on branch l, obtained using the () operator for the SubstitutionMapping object.
smap | The substitution map to use. |
siteIndex | The index of the substitution vector for which the norm should be computed. |
Definition at line 1350 of file SubstitutionMappingTools.cpp.
References bpp::Mapping::getNumberOfBranches(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().
|
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 192 of file SubstitutionMappingTools.h.
References computeSubstitutionVectors().
|
inlinestatic |
Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation.
drtl | A DRTreeLikelihood object. |
substitutionCount | The SubstitutionCount to use. |
verbose | Print info to screen. |
Exception | If the likelihood object is not initialized. |
Definition at line 79 of file SubstitutionMappingTools.h.
Referenced by computeOneJumpProbabilityVectors(), getCountsPerBranch(), outputIndividualCountsPerBranchPerSite(), and outputTotalCountsPerBranchPerSite().
|
static |
Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation.
drtl | A DRTreeLikelihood object. |
nodeIds | The Ids of the nodes the substitutions are counted on. If empty, count substitutions on all nodes. |
substitutionCount | The SubstitutionCount to use. |
verbose | Print info to screen. |
Exception | If the likelihood object is not initialized. |
Definition at line 63 of file SubstitutionMappingTools.cpp.
References bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeLikelihood::ConstBranchModelDescription::getModel(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::TreeTemplate< N >::getNodes(), bpp::Node::getNumberOfSons(), bpp::Node::getSon(), bpp::Node::hasFather(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), and bpp::TreeLikelihood::ConstBranchModelIterator::next().
|
static |
Definition at line 373 of file SubstitutionMappingTools.cpp.
References bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::TreeTemplate< N >::getNodes(), bpp::Node::getNumberOfSons(), bpp::Node::getSon(), bpp::Node::hasFather(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), and bpp::TreeLikelihood::ConstBranchModelIterator::next().
|
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.
drtl | A DRTreeLikelihood object. |
substitutionCount | The substitutionsCount to use. |
verbose | Print info to screen. |
Exception | If the likelihood object is not initialized. |
Definition at line 1113 of file SubstitutionMappingTools.cpp.
References bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeLikelihood::ConstBranchModelDescription::getModel(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::TreeTemplate< N >::getNodes(), and bpp::DRTreeLikelihoodTools::getPosteriorProbabilitiesForEachStateForEachRate().
|
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.
drtl | A DRTreeLikelihood object. |
substitutionCount | The substitutionsCount to use. |
verbose | Print info to screen. |
Exception | If the likelihood object is not initialized. |
Definition at line 685 of file SubstitutionMappingTools.cpp.
References bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeLikelihood::ConstBranchModelDescription::getModel(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::TreeTemplate< N >::getNodes(), bpp::Node::getNumberOfSons(), bpp::Node::getSon(), bpp::Node::hasFather(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), and bpp::TreeLikelihood::ConstBranchModelIterator::next().
|
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 objet is equivalent to Tufféry and Darlu's (2000) computation of substitution vectors.
Use with another substitution count objet is in most cases irrelevent.
drtl | A DRTreeLikelihood object. |
substitutionCount | The substitutionsCount to use. |
verbose | Print info to screen. |
Exception | If the likelihood object is not initialized. |
Definition at line 982 of file SubstitutionMappingTools.cpp.
References bpp::MarginalAncestralStateReconstruction::getAllAncestralStates(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::TreeLikelihood::ConstBranchModelDescription::getModel(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::TreeTemplate< N >::getNodes(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), and bpp::TreeLikelihood::ConstBranchModelIterator::next().
|
static |
Sum all substitutions for each type of a given branch (specified by its index).
smap | The substitution map to use. |
branchIndex | The index of the substitution vector for which the counts should be computed. |
Definition at line 1367 of file SubstitutionMappingTools.cpp.
References bpp::Mapping::getNumberOfSites(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().
|
static |
Sum all substitutions for each type of a given site (specified by its index).
smap | The substitution map to use. |
siteIndex | The index of the substitution vector for which the counts should be computed. |
Definition at line 1384 of file SubstitutionMappingTools.cpp.
References bpp::Mapping::getNumberOfBranches(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().
|
static |
Sum all type of substitutions for each branch of a given position (specified by its index).
smap | The substitution map to use. |
siteIndex | The index of the substitution vector for which the counts should be computed. |
Definition at line 1332 of file SubstitutionMappingTools.cpp.
References bpp::Mapping::getNumberOfBranches(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().
Referenced by outputTotalCountsPerBranchPerSite().
|
static |
Returns the counts on each branch.
drtl | A DRTreeLikelihood object. |
ids | The numbers of the nodes of the tree |
model | The model on which the SubstitutionCount is built |
reg | the Substitution Register |
threshold | value above which counts are considered saturated (default: -1 means no threshold). |
verbose | Display progress messages. |
Definition at line 1400 of file SubstitutionMappingTools.cpp.
References bpp::SubstitutionRegister::clone(), computeSubstitutionVectors(), bpp::AbstractMapping::getNodeIndex(), bpp::AbstractMapping::getNumberOfSites(), and bpp::ProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes().
|
static |
Definition at line 1482 of file SubstitutionMappingTools.cpp.
References bpp::SubstitutionRegister::clone(), computeSubstitutionVectors(), bpp::SubstitutionModelSet::getModel(), bpp::AbstractMapping::getNodeIndex(), bpp::AbstractMapping::getNumberOfSites(), and bpp::ProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes().
|
static |
Returns the normalization factors due to the null model on each branch, for each register.
drtl | A DRTreeLikelihood object. |
ids | The numbers of the nodes of the tree |
nullModel | The model on which the SubstitutionCount is built |
reg | the Substitution Register |
verbose | Display progress messages. |
Definition at line 1564 of file SubstitutionMappingTools.cpp.
References bpp::RewardMappingTools::computeRewardVectors(), bpp::SubstitutionModel::getAlphabet(), bpp::SubstitutionModel::getAlphabetStates(), bpp::TreeLikelihood::getNumberOfSites(), bpp::SubstitutionRegister::getNumberOfSubstitutionTypes(), bpp::SubstitutionRegister::getType(), bpp::SubstitutionRegister::getTypeName(), and bpp::SubstitutionModel::Qij().
|
static |
Returns the normalization factors due to the set of null models on each branch, for each register.
drtl | A DRTreeLikelihood object. |
ids | The numbers of the nodes of the tree |
nullModelSet | The model on which the SubstitutionCount is built |
reg | the Substitution Register |
verbose | Display progress messages. |
Definition at line 1631 of file SubstitutionMappingTools.cpp.
References bpp::RewardMappingTools::computeRewardVectors(), bpp::SubstitutionModelSet::getAlphabet(), bpp::SubstitutionModel::getAlphabetStates(), bpp::SubstitutionModelSet::getModel(), bpp::AbstractMapping::getNodeIndex(), bpp::SubstitutionModelSet::getNodesWithModel(), bpp::SubstitutionModelSet::getNumberOfModels(), bpp::TreeLikelihood::getNumberOfSites(), bpp::SubstitutionRegister::getNumberOfSubstitutionTypes(), bpp::SubstitutionRegister::getType(), bpp::SubstitutionRegister::getTypeName(), and bpp::SubstitutionModel::Qij().
|
static |
Returns the counts normalized by a null model.
drtl | A DRTreeLikelihood object. |
ids | The numbers of the nodes of the tree |
model | The model on which the SubstitutionCount is built |
nullModel | The null model used for normalization. |
reg | the Substitution Register |
verbose | Display progress messages. |
Definition at line 1716 of file SubstitutionMappingTools.cpp.
References bpp::TreeTemplate< N >::getNode(), and bpp::TreeLikelihood::getTree().
|
static |
Returns the counts normalized by a null model set.
drtl | A DRTreeLikelihood object. |
ids | The numbers of the nodes of the tree |
modelSet | The model set on which the SubstitutionCount is built |
nullModelSet | The null model set used for normalization. |
reg | the Substitution Register |
verbose | Display progress messages. |
Definition at line 1759 of file SubstitutionMappingTools.cpp.
References bpp::SubstitutionModelSet::getModel(), bpp::TreeTemplate< N >::getNode(), and bpp::TreeLikelihood::getTree().
|
static |
Returns the counts relative to the frequency of the states in case of non-stationarity.
drtl | A DRTreeLikelihood object. |
ids | The numbers of the nodes of the tree |
model | The model on which the SubstitutionCount is built |
reg | the Substitution Register |
stationarity | if false, a correction is made if the SubstitutionRegister is a CategorySubstitutionRegister |
threshold | value above which counts are considered saturated (default: -1 means no threshold). |
Definition at line 1802 of file SubstitutionMappingTools.cpp.
References bpp::CategorySubstitutionRegister::getCategory(), bpp::CategorySubstitutionRegister::getCategoryFrom(), bpp::CategorySubstitutionRegister::getNumberOfCategories(), and bpp::DRTreeLikelihoodTools::getPosteriorStateFrequencies().
|
static |
Output individual counts par branch per site, in files.
filenamePrefix | The filename prefix |
drtl | A DRTreeLikelihood object. |
ids | The numbers of the nodes of the tree |
model | The model on which the SubstitutionCount is built |
reg | the Substitution Register |
Definition at line 1899 of file SubstitutionMappingTools.cpp.
References bpp::SubstitutionRegister::clone(), computeSubstitutionVectors(), bpp::AbstractMapping::getNodeIndex(), bpp::AbstractMapping::getNumberOfSites(), and bpp::SubstitutionRegister::getNumberOfSubstitutionTypes().
|
static |
Output the sum of the counts par branch per site, in a file.
filename | The name of the output file |
drtl | A DRTreeLikelihood object. |
ids | The numbers of the nodes of the tree |
model | The model on which the SubstitutionCount is built |
reg | the Substitution Register |
Definition at line 1855 of file SubstitutionMappingTools.cpp.
References bpp::SubstitutionRegister::clone(), computeSubstitutionVectors(), computeTotalSubstitutionVectorForSite(), bpp::AbstractMapping::getNodeIndex(), and bpp::AbstractMapping::getNumberOfSites().
|
static |
Read the substitutions vectors from a stream.
in | The input stream where to read the vectors. |
substitutions | The mapping object to fill. |
type | The type of substitutions that are read. Should be in supported by the substittuion count obect assiciated to the mapping, if any. |
IOException | If an input error happens. |
Definition at line 1288 of file SubstitutionMappingTools.cpp.
|
static |
Write the substitutions vectors to a stream.
substitutions | The substitutions vectors to write. |
sites | The dataset associated to the vectors (needed to know the position of each site in the dataset). |
type | The type of substitutions to be output. See SubstitutionCount class. Only one type of substitution can be output at a time. |
out | The output stream where to write the vectors. |
IOException | If an output error happens. |
Definition at line 1258 of file SubstitutionMappingTools.cpp.