EmpiricalSubstitutionModel: normalize empirical frequencies#75
Merged
Conversation
Empirical amino-acid models published in the literature (e.g. FLU, LG, WAG) report stationary frequencies rounded to a fixed number of decimal places, so the values do not sum to exactly 1.0 (typical delta ~1e-7). The Simplex isValid() check uses a 1e-10 tolerance, which rejects them as invalid. Normalize the values before constructing the SimplexParam so the empirical frequencies pass Simplex validation. The normalization is a no-op when the values already sum to within 1e-10 of 1.0. Surfaced while migrating obama where every OBAMA_<aa> empirical model hits this on initialisation.
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.
Summary
Simplex.isValid()uses a 1e-10 tolerance; the rounding error is ~1e-7, so every empirical model fails initialisation when its frequencies are wrapped into aSimplexParam.SimplexParam. No-op when the values already sum to within 1e-10 of 1.0.Arose while migrating obama where all 16
OBAMA_<aa>empirical models hit this.Test plan
examples/testOBAMA.xmlon the obama beast3-migration branch) and confirm it parses pastEmpiricalSubstitutionModel.getEmpericalFrequencieValues().[0.25, 0.25, 0.25, 0.25]) are unchanged.