bpp-phyl  2.4.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 ProbabilisticSubstitutionMappingcomputeSubstitutionVectors (const DRTreeLikelihood &drtl, SubstitutionCount &substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static ProbabilisticSubstitutionMappingcomputeSubstitutionVectors (const DRTreeLikelihood &drtl, const std::vector< int > &nodeIds, SubstitutionCount &substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static ProbabilisticSubstitutionMappingcomputeSubstitutionVectors (const DRTreeLikelihood &drtl, const SubstitutionModelSet &modelSet, const std::vector< int > &nodeIds, SubstitutionCount &substitutionCount, bool verbose=true)
 
static ProbabilisticSubstitutionMappingcomputeSubstitutionVectorsNoAveraging (const DRTreeLikelihood &drtl, SubstitutionCount &substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static ProbabilisticSubstitutionMappingcomputeSubstitutionVectorsNoAveragingMarginal (const DRTreeLikelihood &drtl, SubstitutionCount &substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static ProbabilisticSubstitutionMappingcomputeSubstitutionVectorsMarginal (const DRTreeLikelihood &drtl, SubstitutionCount &substitutionCount, bool verbose=true)
 Compute the substitutions vectors for a particular dataset using the double-recursive likelihood computation. More...
 
static ProbabilisticSubstitutionMappingcomputeOneJumpProbabilityVectors (const DRTreeLikelihood &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 ProbabilisticSubstitutionMapping &substitutions, const SiteContainer &sites, size_t type, std::ostream &out)
 Write the substitutions vectors to a stream. More...
 
static void readFromStream (std::istream &in, ProbabilisticSubstitutionMapping &substitutions, size_t type)
 Read the substitutions vectors from a stream. More...
 
static std::vector< double > computeTotalSubstitutionVectorForSitePerBranch (const SubstitutionMapping &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 SubstitutionMapping &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 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 &reg, double threshold=-1, bool verbose=true)
 
static std::vector< std::vector< double > > getCountsPerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, const SubstitutionModelSet &modelSet, const SubstitutionRegister &reg, 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 &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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, const SubstitutionModelSet *nullModelSet, const SubstitutionRegister &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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister &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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, SubstitutionModel *nullModel, const SubstitutionRegister &reg, bool perTime, bool perWord, 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 &reg, bool perTime, bool perWord, bool verbose=true)
 Returns the counts normalized by a null model set. More...
 
static void computeCountsPerSitePerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister &reg, VVdouble &array)
 Compute the sum over all types of the counts per site per branch. More...
 
static void computeCountsPerTypePerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister &reg, VVdouble &result, double threshold=-1, bool verbose=true)
 Compute the sum over all branches of the counts per type per branch. More...
 
static void computeCountsPerTypePerBranch (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, SubstitutionModel *nullModel, const SubstitutionRegister &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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModelSet *modelSet, SubstitutionModelSet *nullModelSet, const SubstitutionRegister &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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister &reg, VVdouble &result)
 Compute the sum over all branches of the counts per type per site,. More...
 
static void computeCountsPerSitePerType (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, SubstitutionModel *nullModel, const SubstitutionRegister &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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModelSet *modelSet, SubstitutionModelSet *nullModelSet, const SubstitutionRegister &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 (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, const SubstitutionRegister &reg, VVVdouble &result)
 Compute counts per site per branch per type. More...
 
static void computeCountsPerSitePerBranchPerType (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModel *model, SubstitutionModel *nullModel, const SubstitutionRegister &reg, VVVdouble &result, bool perTime, bool perWord)
 Compute normalized counts per site per branch per type. More...
 
static void computeCountsPerSitePerBranchPerType (DRTreeLikelihood &drtl, const std::vector< int > &ids, SubstitutionModelSet *modelSet, SubstitutionModelSet *nullModelSet, const SubstitutionRegister &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)
 Output Per Site Per Branch. More...
 
static void outputPerSitePerType (const std::string &filename, const SubstitutionRegister &reg, const VVdouble &counts)
 Output Per Site Per Type. More...
 
static void outputPerSitePerBranchPerType (const std::string &filenamePrefix, const std::vector< int > &ids, const SubstitutionRegister &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 63 of file SubstitutionMappingTools.h.

Constructor & Destructor Documentation

bpp::SubstitutionMappingTools::SubstitutionMappingTools ( )
inline

Definition at line 66 of file SubstitutionMappingTools.h.

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

Definition at line 67 of file SubstitutionMappingTools.h.

Member Function Documentation

void SubstitutionMappingTools::computeCountsPerSitePerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
const SubstitutionRegister reg,
VVdouble array 
)
static

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

@ brief Per Branch Per Site methods

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 1891 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegister::clone(), computeSubstitutionVectors(), computeTotalSubstitutionVectorForSitePerBranch(), count(), bpp::AbstractMapping::getNodeIndex(), bpp::AbstractMapping::getNumberOfSites(), and bpp::VectorTools::resize2().

Referenced by getNormalizedCountsPerBranch().

void SubstitutionMappingTools::computeCountsPerSitePerBranchPerType ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
const SubstitutionRegister reg,
VVVdouble result 
)
static

Compute counts per site per branch per type.

@ brief Per Branch Per Site Per Type methods

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 2193 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegister::clone(), computeSubstitutionVectors(), count(), bpp::AbstractMapping::getNodeIndex(), bpp::AbstractMapping::getNumberOfSites(), bpp::SubstitutionRegister::getNumberOfSubstitutionTypes(), and bpp::VectorTools::resize3().

Referenced by getNormalizedCountsPerBranch().

void SubstitutionMappingTools::computeCountsPerSitePerBranchPerType ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
SubstitutionModel nullModel,
const SubstitutionRegister 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 2225 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegister::clone(), bpp::RewardMappingTools::computeRewardVectors(), computeSubstitutionVectors(), count(), bpp::TransitionModel::getAlphabet(), bpp::TransitionModel::getAlphabetStates(), bpp::CoreWordAlphabet::getLength(), bpp::AbstractMapping::getNodeIndex(), bpp::AbstractMapping::getNumberOfSites(), bpp::ProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes(), bpp::Alphabet::getSize(), bpp::TreeLikelihood::getTree(), bpp::SubstitutionRegister::getType(), bpp::SubstitutionModel::Qij(), bpp::VectorTools::resize2(), and bpp::VectorTools::resize3().

void SubstitutionMappingTools::computeCountsPerSitePerBranchPerType ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModelSet modelSet,
SubstitutionModelSet nullModelSet,
const SubstitutionRegister 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 2323 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegister::clone(), bpp::RewardMappingTools::computeRewardVectors(), computeSubstitutionVectors(), count(), bpp::SubstitutionModelSet::getAlphabet(), bpp::TransitionModel::getAlphabetStates(), bpp::CoreWordAlphabet::getLength(), bpp::AbstractMapping::getNodeIndex(), bpp::SubstitutionModelSet::getNodesWithModel(), bpp::SubstitutionModelSet::getNumberOfModels(), bpp::AbstractMapping::getNumberOfSites(), bpp::ProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes(), bpp::Alphabet::getSize(), bpp::SubstitutionModelSet::getSubstitutionModel(), bpp::TreeLikelihood::getTree(), bpp::SubstitutionRegister::getType(), bpp::SubstitutionModel::Qij(), bpp::VectorTools::resize2(), bpp::VectorTools::resize3(), and bpp::VectorTools::vectorIntersection().

void SubstitutionMappingTools::computeCountsPerSitePerType ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
const SubstitutionRegister reg,
VVdouble result 
)
static

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

@ brief Per Type Per Site methods

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 1925 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegister::clone(), computeSubstitutionVectors(), computeTotalSubstitutionVectorForSitePerType(), count(), bpp::AbstractMapping::getNumberOfSites(), bpp::ProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes(), and bpp::VectorTools::resize2().

Referenced by getNormalizedCountsPerBranch().

void SubstitutionMappingTools::computeCountsPerSitePerType ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
SubstitutionModel nullModel,
const SubstitutionRegister 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 1956 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegister::clone(), bpp::RewardMappingTools::computeRewardVectors(), computeSubstitutionVectors(), computeTotalSubstitutionVectorForSitePerType(), count(), bpp::TransitionModel::getAlphabet(), bpp::TransitionModel::getAlphabetStates(), bpp::CoreWordAlphabet::getLength(), bpp::TreeTemplate< N >::getNode(), bpp::AbstractMapping::getNodeIndex(), bpp::AbstractMapping::getNumberOfSites(), bpp::ProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes(), bpp::Alphabet::getSize(), bpp::TreeLikelihood::getTree(), bpp::SubstitutionRegister::getType(), bpp::SubstitutionModel::Qij(), and bpp::VectorTools::resize2().

void SubstitutionMappingTools::computeCountsPerSitePerType ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModelSet modelSet,
SubstitutionModelSet nullModelSet,
const SubstitutionRegister 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 2068 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegister::clone(), bpp::RewardMappingTools::computeRewardVectors(), computeSubstitutionVectors(), computeTotalSubstitutionVectorForSitePerType(), count(), bpp::SubstitutionModelSet::getAlphabet(), bpp::TransitionModel::getAlphabetStates(), bpp::CoreWordAlphabet::getLength(), bpp::TreeTemplate< N >::getNode(), bpp::AbstractMapping::getNodeIndex(), bpp::SubstitutionModelSet::getNodesWithModel(), bpp::SubstitutionModelSet::getNumberOfModels(), bpp::AbstractMapping::getNumberOfSites(), bpp::ProbabilisticSubstitutionMapping::getNumberOfSubstitutionTypes(), bpp::Alphabet::getSize(), bpp::SubstitutionModelSet::getSubstitutionModel(), bpp::TreeLikelihood::getTree(), bpp::SubstitutionRegister::getType(), bpp::SubstitutionModel::Qij(), bpp::VectorTools::resize2(), and bpp::VectorTools::vectorIntersection().

void SubstitutionMappingTools::computeCountsPerTypePerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
const SubstitutionRegister reg,
VVdouble result,
double  threshold = -1,
bool  verbose = true 
)
static

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

@ brief Per Type Per Branch methods

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 1847 of file SubstitutionMappingTools.cpp.

References bpp::CategorySubstitutionRegister::getCategory(), bpp::CategorySubstitutionRegister::getCategoryFrom(), bpp::CategorySubstitutionRegister::getNumberOfCategories(), bpp::DRTreeLikelihoodTools::getPosteriorStateFrequencies(), bpp::CategorySubstitutionRegister::isStationary(), and bpp::VectorTools::sum().

Referenced by getNormalizedCountsPerBranch(), and getRelativeCountsPerBranch().

void SubstitutionMappingTools::computeCountsPerTypePerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
SubstitutionModel nullModel,
const SubstitutionRegister 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 1739 of file SubstitutionMappingTools.cpp.

References bpp::TransitionModel::getAlphabet(), bpp::CoreWordAlphabet::getLength(), bpp::TreeTemplate< N >::getNode(), and bpp::TreeLikelihood::getTree().

void SubstitutionMappingTools::computeCountsPerTypePerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModelSet modelSet,
SubstitutionModelSet nullModelSet,
const SubstitutionRegister 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 1794 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionModelSet::getAlphabet(), bpp::CoreWordAlphabet::getLength(), bpp::TreeTemplate< N >::getNode(), and bpp::TreeLikelihood::getTree().

double SubstitutionMappingTools::computeNormForSite ( const SubstitutionMapping 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 1367 of file SubstitutionMappingTools.cpp.

References bpp::Mapping::getNumberOfBranches(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().

Referenced by computeOneJumpProbabilityVectors().

static ProbabilisticSubstitutionMapping* bpp::SubstitutionMappingTools::computeOneJumpProbabilityVectors ( const DRTreeLikelihood 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 193 of file SubstitutionMappingTools.h.

References computeNormForSite(), computeSubstitutionVectors(), computeSumForBranch(), computeSumForSite(), computeTotalSubstitutionVectorForSitePerBranch(), computeTotalSubstitutionVectorForSitePerType(), getCountsPerBranch(), bpp::Tree::getNodesId(), getNormalizationsPerBranch(), bpp::TreeLikelihood::getTree(), readFromStream(), and writeToStream().

static ProbabilisticSubstitutionMapping* bpp::SubstitutionMappingTools::computeSubstitutionVectors ( const DRTreeLikelihood drtl,
SubstitutionCount 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 80 of file SubstitutionMappingTools.h.

References computeSubstitutionVectorsMarginal(), computeSubstitutionVectorsNoAveraging(), and computeSubstitutionVectorsNoAveragingMarginal().

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

ProbabilisticSubstitutionMapping * SubstitutionMappingTools::computeSubstitutionVectors ( const DRTreeLikelihood drtl,
const std::vector< int > &  nodeIds,
SubstitutionCount 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 63 of file SubstitutionMappingTools.cpp.

References bpp::DRTreeLikelihood::computeLikelihoodAtNode(), bpp::VectorTools::contains(), bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::SubstitutionCount::getAllNumbersOfSubstitutions(), bpp::DiscreteDistribution::getCategories(), bpp::TreeLikelihood::getData(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::DRASDRTreeLikelihoodData::getLikelihoodArray(), bpp::DRTreeLikelihood::getLikelihoodData(), bpp::TreeLikelihood::getNewBranchModelIterator(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::DiscreteDistribution::getNumberOfCategories(), bpp::DRASDRTreeLikelihoodData::getNumberOfDistinctSites(), bpp::Node::getNumberOfSons(), bpp::SubstitutionCount::getNumberOfSubstitutionTypes(), bpp::DiscreteDistribution::getProbabilities(), bpp::DiscreteDistribution::getProbability(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getRateDistribution(), bpp::AbstractTreeLikelihoodData::getRootArrayPositions(), bpp::TreeLikelihood::getRootFrequencies(), bpp::Node::getSon(), bpp::TreeLikelihood::ConstBranchModelDescription::getSubstitutionModel(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getTransitionProbabilitiesPerRateClass(), bpp::TreeLikelihood::getTree(), bpp::Node::hasFather(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), bpp::TreeLikelihood::isInitialized(), bpp::ApplicationTools::message, bpp::TreeLikelihood::ConstBranchModelIterator::next(), and bpp::SubstitutionCount::setSubstitutionModel().

ProbabilisticSubstitutionMapping * SubstitutionMappingTools::computeSubstitutionVectors ( const DRTreeLikelihood drtl,
const SubstitutionModelSet modelSet,
const std::vector< int > &  nodeIds,
SubstitutionCount substitutionCount,
bool  verbose = true 
)
static

Definition at line 375 of file SubstitutionMappingTools.cpp.

References bpp::DRTreeLikelihood::computeLikelihoodAtNode(), bpp::VectorTools::contains(), bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::SubstitutionCount::getAllNumbersOfSubstitutions(), bpp::DiscreteDistribution::getCategories(), bpp::TreeLikelihood::getData(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::DRASDRTreeLikelihoodData::getLikelihoodArray(), bpp::DRTreeLikelihood::getLikelihoodData(), bpp::TreeLikelihood::getNewBranchModelIterator(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::DiscreteDistribution::getNumberOfCategories(), bpp::DRASDRTreeLikelihoodData::getNumberOfDistinctSites(), bpp::Node::getNumberOfSons(), bpp::SubstitutionCount::getNumberOfSubstitutionTypes(), bpp::DiscreteDistribution::getProbabilities(), bpp::DiscreteDistribution::getProbability(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getRateDistribution(), bpp::AbstractTreeLikelihoodData::getRootArrayPositions(), bpp::TreeLikelihood::getRootFrequencies(), bpp::Node::getSon(), bpp::SubstitutionModelSet::getSubstitutionModelForNode(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getTransitionProbabilitiesPerRateClass(), bpp::TreeLikelihood::getTree(), bpp::Node::hasFather(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), bpp::TreeLikelihood::isInitialized(), bpp::ApplicationTools::message, bpp::TreeLikelihood::ConstBranchModelIterator::next(), and bpp::SubstitutionCount::setSubstitutionModel().

ProbabilisticSubstitutionMapping * SubstitutionMappingTools::computeSubstitutionVectorsMarginal ( const DRTreeLikelihood drtl,
SubstitutionCount 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 1115 of file SubstitutionMappingTools.cpp.

References bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::SubstitutionCount::getAllNumbersOfSubstitutions(), bpp::DiscreteDistribution::getCategories(), bpp::TreeLikelihood::getData(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::DRTreeLikelihood::getLikelihoodData(), bpp::TreeLikelihood::getNewBranchModelIterator(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::DiscreteDistribution::getNumberOfCategories(), bpp::DRASDRTreeLikelihoodData::getNumberOfDistinctSites(), bpp::SubstitutionCount::getNumberOfSubstitutionTypes(), bpp::DRTreeLikelihoodTools::getPosteriorProbabilitiesForEachStateForEachRate(), bpp::DiscreteDistribution::getProbabilities(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getRateDistribution(), bpp::AbstractTreeLikelihoodData::getRootArrayPositions(), bpp::TreeLikelihood::ConstBranchModelDescription::getSubstitutionModel(), bpp::TreeLikelihood::getTree(), bpp::TreeLikelihood::isInitialized(), bpp::ApplicationTools::message, and bpp::SubstitutionCount::setSubstitutionModel().

Referenced by computeSubstitutionVectors().

ProbabilisticSubstitutionMapping * SubstitutionMappingTools::computeSubstitutionVectorsNoAveraging ( const DRTreeLikelihood drtl,
SubstitutionCount 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 687 of file SubstitutionMappingTools.cpp.

References bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::MatrixTools::fill(), bpp::SubstitutionCount::getAllNumbersOfSubstitutions(), bpp::DiscreteDistribution::getCategories(), bpp::TreeLikelihood::getData(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::DRASDRTreeLikelihoodData::getLikelihoodArray(), bpp::DRTreeLikelihood::getLikelihoodData(), bpp::TreeLikelihood::getNewBranchModelIterator(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::DiscreteDistribution::getNumberOfCategories(), bpp::DRASDRTreeLikelihoodData::getNumberOfDistinctSites(), bpp::Node::getNumberOfSons(), bpp::SubstitutionCount::getNumberOfSubstitutionTypes(), bpp::DiscreteDistribution::getProbability(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getRateDistribution(), bpp::AbstractTreeLikelihoodData::getRootArrayPositions(), bpp::TreeLikelihood::getRootFrequencies(), bpp::Node::getSon(), bpp::TreeLikelihood::ConstBranchModelDescription::getSubstitutionModel(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getTransitionProbabilitiesPerRateClass(), bpp::TreeLikelihood::getTree(), bpp::Node::hasFather(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), bpp::TreeLikelihood::isInitialized(), bpp::ApplicationTools::message, bpp::TreeLikelihood::ConstBranchModelIterator::next(), bpp::SubstitutionCount::setSubstitutionModel(), and bpp::MatrixTools::whichMax().

Referenced by computeSubstitutionVectors().

ProbabilisticSubstitutionMapping * SubstitutionMappingTools::computeSubstitutionVectorsNoAveragingMarginal ( const DRTreeLikelihood drtl,
SubstitutionCount 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 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.

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 984 of file SubstitutionMappingTools.cpp.

References bpp::ApplicationTools::displayGauge(), bpp::ApplicationTools::displayTask(), bpp::ApplicationTools::displayTaskDone(), bpp::MarginalAncestralStateReconstruction::getAllAncestralStates(), bpp::SubstitutionCount::getAllNumbersOfSubstitutions(), bpp::DiscreteDistribution::getCategories(), bpp::TreeLikelihood::getData(), bpp::Node::getDistanceToFather(), bpp::Node::getFather(), bpp::Node::getId(), bpp::DRTreeLikelihood::getLikelihoodData(), bpp::TreeLikelihood::getNewBranchModelIterator(), bpp::TreeLikelihood::ConstBranchModelDescription::getNewSiteIterator(), bpp::DRASDRTreeLikelihoodData::getNumberOfDistinctSites(), bpp::SubstitutionCount::getNumberOfSubstitutionTypes(), bpp::DiscreteRatesAcrossSitesTreeLikelihood::getRateDistribution(), bpp::AbstractTreeLikelihoodData::getRootArrayPositions(), bpp::Alphabet::getSize(), bpp::TreeLikelihood::ConstBranchModelDescription::getSubstitutionModel(), bpp::TreeLikelihood::getTree(), bpp::TreeLikelihood::ConstBranchModelIterator::hasNext(), bpp::TreeLikelihood::isInitialized(), bpp::ApplicationTools::message, bpp::TreeLikelihood::ConstBranchModelIterator::next(), and bpp::SubstitutionCount::setSubstitutionModel().

Referenced by computeSubstitutionVectors().

vector< double > SubstitutionMappingTools::computeSumForBranch ( const SubstitutionMapping 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 1384 of file SubstitutionMappingTools.cpp.

References bpp::Mapping::getNumberOfSites(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().

Referenced by computeOneJumpProbabilityVectors().

vector< double > SubstitutionMappingTools::computeSumForSite ( const SubstitutionMapping 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 1401 of file SubstitutionMappingTools.cpp.

References bpp::Mapping::getNumberOfBranches(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().

Referenced by computeOneJumpProbabilityVectors().

vector< double > SubstitutionMappingTools::computeTotalSubstitutionVectorForSitePerBranch ( const SubstitutionMapping 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 1332 of file SubstitutionMappingTools.cpp.

References bpp::Mapping::getNumberOfBranches(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().

Referenced by computeCountsPerSitePerBranch(), and computeOneJumpProbabilityVectors().

vector< double > SubstitutionMappingTools::computeTotalSubstitutionVectorForSitePerType ( const SubstitutionMapping 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 1350 of file SubstitutionMappingTools.cpp.

References bpp::Mapping::getNumberOfBranches(), and bpp::SubstitutionMapping::getNumberOfSubstitutionTypes().

Referenced by computeCountsPerSitePerType(), and computeOneJumpProbabilityVectors().

vector< vector< double > > SubstitutionMappingTools::getCountsPerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
const SubstitutionRegister reg,
double  threshold = -1,
bool  verbose = true 
)
static
vector< vector< double > > SubstitutionMappingTools::getCountsPerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
const SubstitutionModelSet modelSet,
const SubstitutionRegister reg,
double  threshold = -1,
bool  verbose = true 
)
static
vector< vector< double > > SubstitutionMappingTools::getNormalizationsPerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
const SubstitutionModel nullModel,
const SubstitutionRegister 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 1582 of file SubstitutionMappingTools.cpp.

References bpp::RewardMappingTools::computeRewardVectors(), bpp::ApplicationTools::displayWarning(), bpp::TransitionModel::getAlphabet(), bpp::TransitionModel::getAlphabetStates(), bpp::TreeLikelihood::getNumberOfSites(), bpp::SubstitutionRegister::getNumberOfSubstitutionTypes(), bpp::Alphabet::getSize(), bpp::SubstitutionRegister::getType(), bpp::SubstitutionRegister::getTypeName(), bpp::SubstitutionModel::Qij(), and bpp::TextTools::toString().

Referenced by computeOneJumpProbabilityVectors().

vector< vector< double > > SubstitutionMappingTools::getNormalizationsPerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
const SubstitutionModelSet nullModelSet,
const SubstitutionRegister reg,
bool  verbose = true 
)
static
static std::vector< std::vector<double> > bpp::SubstitutionMappingTools::getNormalizedCountsPerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
SubstitutionModel nullModel,
const SubstitutionRegister 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 396 of file SubstitutionMappingTools.h.

References computeCountsPerTypePerBranch().

static std::vector< std::vector<double> > bpp::SubstitutionMappingTools::getNormalizedCountsPerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModelSet modelSet,
SubstitutionModelSet nullModelSet,
const SubstitutionRegister 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 427 of file SubstitutionMappingTools.h.

References computeCountsPerSitePerBranch(), computeCountsPerSitePerBranchPerType(), computeCountsPerSitePerType(), computeCountsPerTypePerBranch(), outputPerSitePerBranch(), outputPerSitePerBranchPerType(), and outputPerSitePerType().

static std::vector< std::vector<double> > bpp::SubstitutionMappingTools::getRelativeCountsPerBranch ( DRTreeLikelihood drtl,
const std::vector< int > &  ids,
SubstitutionModel model,
const SubstitutionRegister 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 367 of file SubstitutionMappingTools.h.

References computeCountsPerTypePerBranch().

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

Output Per Site Per Branch.

Definition at line 2431 of file SubstitutionMappingTools.cpp.

Referenced by getNormalizedCountsPerBranch().

void SubstitutionMappingTools::outputPerSitePerBranchPerType ( const std::string &  filenamePrefix,
const std::vector< int > &  ids,
const SubstitutionRegister reg,
const VVVdouble counts 
)
static
void SubstitutionMappingTools::outputPerSitePerType ( const std::string &  filename,
const SubstitutionRegister reg,
const VVdouble counts 
)
static

Output Per Site Per Type.

Definition at line 2467 of file SubstitutionMappingTools.cpp.

References bpp::SubstitutionRegister::getTypeName().

Referenced by getNormalizedCountsPerBranch().

void SubstitutionMappingTools::readFromStream ( std::istream &  in,
ProbabilisticSubstitutionMapping 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 obect assiciated to the mapping, if any.
Exceptions
IOExceptionIf an input error happens.

Definition at line 1289 of file SubstitutionMappingTools.cpp.

References bpp::DataTable::deleteColumn(), bpp::DataTable::getColumn(), bpp::DataTable::getColumnName(), bpp::AbstractMapping::getNodeIndex(), bpp::DataTable::getNumberOfColumns(), bpp::DataTable::getNumberOfRows(), bpp::DataTable::read(), bpp::ProbabilisticSubstitutionMapping::setNumberOfSites(), bpp::AbstractMapping::setSitePosition(), bpp::TextTools::toDouble(), bpp::TextTools::toInt(), and bpp::Exception::what().

Referenced by computeOneJumpProbabilityVectors().

void SubstitutionMappingTools::writeToStream ( const ProbabilisticSubstitutionMapping substitutions,
const SiteContainer 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 1260 of file SubstitutionMappingTools.cpp.

References bpp::Node::getDistanceToFather(), bpp::Node::getId(), bpp::AbstractMapping::getNode(), bpp::AbstractMapping::getNumberOfBranches(), bpp::AbstractMapping::getNumberOfSites(), bpp::Site::getPosition(), and bpp::SiteContainer::getSite().

Referenced by computeOneJumpProbabilityVectors().


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