Repository navigation
Conversation
ldaFunction() added the signed class-mean difference to the unsigned (absolute) scaled LDA coefficient. For features enriched in the first factor level this gave (coeff - |diff|) / 2 instead of -(|diff| + coeff) / 2, shrinking the score or flipping it to the other class when coeff > |diff|, so results depended on level order. Average the magnitudes as in LEfSe and apply the sign of the mean difference. Update the ldaFunction unit test, which encoded the biased value (0 instead of -9), and add a level-reversal check. Closes #104 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Code change in
No exported-function documentation changes are needed ( |
This branch has not been deployed
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.
Closes #104
Problem
ldaFunction()combined a signed class-mean difference with an unsigned LDA coefficient:For features enriched in the first (reference) level, the score became
(coeff - |diff|) / 2instead of-(|diff| + coeff) / 2. The magnitude was too small, and whencoeff > |diff|the sign flipped, assigning the feature to the wrong class. Results therefore depended on the factor level order.Fix
Average the magnitudes as in LEfSe and apply the sign of the mean difference:
Tests
ldaFunctionunit test encoded the biased value. Its two features are mirror images, yet the one enriched in classAscored0while the one enriched inBscored9. It now expects-9/9.testthatsuite passes locally.Impact on real data
On the
zeller14CRC vs control example, the same 61 features are selected, with no sign changes and a maximum score change of 0.0002 (log10 scale). At relative-abundance scale (1e6),|diff|is usually much larger thancoeff, so the existing expected values intest-lefser.Rstill hold. With the fix, results are now exactly invariant to level order (previously up to 0.0002 off). Larger effects are expected whencoeffis comparable to|diff|, e.g. low-abundance features or rescaled inputs.Version:is not bumped.🤖 Generated with Claude Code