fix(cytovi): stabilize log-median probability aggregation - #4040
Closed
sofoklis326 wants to merge 1 commit into
Closed
sofoklis326 wants to merge 1 commit into
sofoklis326 wants to merge 1 commit into
Conversation
Collaborator
|
was solved here: #4048 |
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.
CytoVI's
log_median()currently computes:np.log(np.median(np.exp(x), axis=axis))
The input already contains log probabilities. Exponentiating very
negative values underflows to zero, while very positive values overflow
to infinity. This can produce non-finite differential-abundance scores.
For example, groups with constant log scores of -900 and -880 should
produce a DA difference of -20. The current calculation instead produces
-inf - (-inf), yielding NaN.
This PR selects the central values directly in log space and combines
them using
np.logaddexp. It preserves the probability-space mediandefinition for both odd and even sample counts.
Compatibility checks cover aggregation axes, missing values, infinities,
empty reductions, and preservation of the input array.
Validation:
38 passing tests in total.
This fix is independent of the other CytoVI fixes proposed separately.
The full upstream CI matrix has not been run locally.