Fix submodel indexing logic in ModelMarkov functions, fix likelihood calculations in AlignmentPairwise - #194
Open
StefanFlaumberg wants to merge 3 commits into
Open
Fix submodel indexing logic in ModelMarkov functions, fix likelihood calculations in AlignmentPairwise#194StefanFlaumberg wants to merge 3 commits into
StefanFlaumberg wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces the following changes:
In
ModelSubst:1.0 / (num_states-1)instead of1.0/3ingetQMatrix().multiplyWithInvEigenvector()function toModelMarkovto prevent accessing nullptrs.ModelSubstis a half-dead-code class. It is not used directly anywhere, but only as a base-class pointer forModelMarkov. Since the JC model is a Markov model itself, making this class the base class ofModelMarkovbreaks the common sense in the inheritance logic. This class should be merged into theModelMarkovclass in the future, maybe, as a special case representing the default behaviour.In
ModelMarkovand its derived classes:setFullRateMatrix()tosetQMatrix()for clarity and callsetStateFrequency()in it independently of the model reversibility.computeTrans()overload.computeTrans()overloads that lacked themodel_idargument and add this argument to the bothModelFactory::computeTrans()functions, which work as wrappers for the remainingcomputeTrans()overloads.ModelMarkovfunctions (fixes the problem discussed in Bug fix for PMSF+I combinations #168 (comment)):-- Both remaining
computeTrans()overloads,computeTransMatrix(), andcomputeTransDerv()now have themodel_idargument defaulted to-1. In simple models the argument is unused. InModelMixtureandModelSet, the argument selects the respective submodel to redirect the function call to it, the default argument explicitly leads to a failed assertion. Conversely, the upstream version used0as the default, thus permitting calls without the argument that implicitly used the front model -- a behaviour clearly unwanted.--
getStateFrequency(),getRateMatrix(),getQMatrix()now all have themodel_idargument defaulted to-1. In simple models the argument is unused. InModelMixtureandModelSet, non-default values call the function for the respective submodels, whereas the default value leads to a failed assertion forgetRateMatrix()andgetQMatrix(). The default value results in the mean class frequencies inModelMixtureand in the +F frequencies inModelSetforgetStateFrequency()as it did before. The rationale is that forModelMixtureandModelSetthere exist no notion of the default rate matrix in the general case.--
setStateFrequency(),setRateMatrix(),setQMatrix()don't have the themodel_idargument and (except foradaptStateFrequency()inModelMixture) fail when called for mixture models orModelSet. These functions should be directly called for the submodels by classes that have access to these submodels, so the rationale is encapsulation.WARNING: the
PhyloTree::computeMarginalAncestralState()function is left not adapted forModelSet(incorrect call ofgetStateFrequency()) because it uses the nonrev kernel anyway; similarly,PhyloTree::computeAncestralLikelihood()remains incompatible withModelMixtureandModelSet(incorrect call ofgetStateFrequency()andcomputeTransMatrix()) because the function is an unused code. This should probably be solved later.In
AlignmentPairwise:isRateCategorizedand the "usual rates" cases insetSequenceNumbers(). Fix settingtotal_sizein the constructor.computeFunction()andcomputeFuncDerv()into a private template function. Remove thesum_trans_matmember buffer, as it was playing the same role as thesum_transbuffer.WARNING: This may affect the distance matrices and trees calculated under such commonly used models as
LG+Cxx+G4andLG+SSF[Cxx]+G4.