fix: run t-test on log values regardless of mean_in_log_space - #4337
Open
cindykrafft wants to merge 2 commits into
Open
cindykrafft wants to merge 2 commits into
cindykrafft wants to merge 2 commits into
Conversation
added 2 commits
September 2, 2026 22:54
rank_genes_groups(method='t-test' | 't-test_overestim_var', mean_in_log_space=False) computed the per-group means and variances on expm1(X) and fed them to Welch's test, so the test ran on linear-scale values while the docstring and release note describe mean_in_log_space as a fold-change option only. Compute the test statistics on X, then (if requested) the exponentiated means for the fold change, as the wilcoxon branch already does. Adds a test asserting scores and p-values are identical for both settings.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4337 +/- ##
=======================================
Coverage 81.98% 81.98%
=======================================
Files 134 134
Lines 13235 13237 +2
=======================================
+ Hits 10851 10853 +2
Misses 2384 2384
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
rank_genes_groups(method="t-test", mean_in_log_space=False)runs the t-test on exponentiated values #4336test_mean_in_log_space_does_not_change_ttestassertsscoresandpvalsare identical formean_in_log_space=True/Falsewith both t-test methods onpbmc68k_reduced; it fails onmainand passes with the fix.tests/test_rank_genes_groups.pypasses.docs/release-notes/+ttest-log-space.fix.mdincluded; will rename to this PR's number)On
main(and the 1.13 pre-releases; 1.12.4 is unaffected),compute_statisticscomputed the per-group means and variances onexpm1(X)for the t-test methods whenevermean_in_log_space=False, so Welch's test ran on linear-scale values.mean_in_log_spaceis documented as a fold-change option only (#4037 release note), and the function expects log data. This computes the test statistics onX, materializes the test results, and only then recomputes the means onexpm1(X)forlogfoldchangeswhen requested, the same order thewilcoxonbranch uses.logfoldchangesare unchanged (the existingtest_mean_in_log_spacestill passes).Generated by Claude Code