Skip to content

Re-establish audit fixes (B-001/B-002/M-003/N-001, v0.8.0) against main#13

Closed
settylab-dotto-bot[bot] wants to merge 5 commits into
mainfrom
dominik/audit-fixes-2026-05-28-rebased
Closed

Re-establish audit fixes (B-001/B-002/M-003/N-001, v0.8.0) against main#13
settylab-dotto-bot[bot] wants to merge 5 commits into
mainfrom
dominik/audit-fixes-2026-05-28-rebased

Conversation

@settylab-dotto-bot
Copy link
Copy Markdown
Contributor

Re-establish audit fixes against main

This PR re-proposes the audit-fix changeset that was prematurely merged via #11
and then reverted via #12 to restore main to its pre-#11 state (v0.7.0).
The fixes are now offered cleanly against main for proper review.

Why a fresh branch

#11 was reverted with a git revert -m 1 merge (#12). Because the original
audit-fix commit is already an ancestor of main through the reverted merge
commit, a PR from the original head branch (dominik/audit-fixes-2026-05-28)
shows an empty diff ("already merged") even though the revert undid its
effect — the classic reverting-a-merge caveat. To produce a clean, reviewable
diff, the audit-fix commit was cherry-picked onto the post-revert main into a
new branch, dominik/audit-fixes-2026-05-28-rebased. The original head branch is
left intact. Diff scope is identical to the original changeset (12 files,
+314/-18).

What this restores

  • B-001 — Mahalanobis distance: correct sum reduction.
  • B-002 — one-sided differential-abundance PTP.
  • M-003use_empirical_variance=False default behavior.
  • N-001 — version bump to 0.8.0.
  • New regression coverage in tests/test_audit_fixes.py; CHANGELOG.md,
    pyproject.toml, and kompot/version.py updated accordingly.

Caveat

Should #11's merge ever be re-merged later, re-merging the reverted commit
would not re-apply these changes (same merge-revert caveat) — this fresh branch
sidesteps that.

Left open for review.

katosh and others added 5 commits May 28, 2026 18:09
Three statistical corrections + one default-value harmonization;
all called out in the manuscript-vs-implementation review.

* Mahalanobis denominator sums the two posterior covariances
  (cov1 + cov2) instead of averaging them. The manuscript defines
  D(a,b) = sqrt((mu_a - mu_b)^T (Sigma_a + Sigma_b)^(-1) (mu_a - mu_b)),
  i.e. the variance of the difference of two independent posterior
  estimators. The GP-only branch in differential_expression.py was
  computing (cov1 + cov2) / 2 even though the sample-variance branch
  at the same call site was already summing.
  Effect: D shrinks by sqrt(2) in the GP-only regime. Relative
  rankings unchanged; FDR re-calibrates against the null. The
  resource-estimation comment is brought in line too.

* Differential-abundance posterior tail probability is one-sided:
  PTP = Phi(-|z|), matching the manuscript prose ("probability that
  the true density difference has the opposite sign to the estimated
  change") and the one-sided formula. The implementation was
  emitting 2 * Phi(-|z|) via a spurious + np.log(2).
  Effect: PTPs are halved; neg_log10_fold_change_ptp increases by
  log10(2). A previously-published cutoff of PTP < 1e-3 corresponded
  to |z| >= 3.29 (two-sided) and now corresponds to |z| >= 3.09
  (one-sided). Re-tune any ptp_threshold chosen against 0.7.0.

* use_empirical_variance defaults to False everywhere. The
  recommended kompot.de() path already defaulted to False via
  GPSettings; the deprecated wrappers (compute_differential_expression,
  compute_smoothed_expression), DifferentialExpression.__init__,
  ExpressionModel.__init__, smooth_expression(gp=None), and
  smooth_config_template.yaml all defaulted to True. Now consistent
  with the manuscript's "empirical variance is disabled by default"
  statement. Opt in via use_empirical_variance=True / GPSettings.

Regression coverage in tests/test_audit_fixes.py:
* monkeypatches compute_mahalanobis_distances to capture the
  combined-covariance kwarg from a controlled-kernel fit and
  asserts equality with cov1 + cov2 (not the average);
* replicates the ln_ptp formula and asserts equality with the
  closed-form Phi(-|z|) both directly and end-to-end through
  DifferentialAbundance.fit().predict();
* introspects every public entry point's signature and asserts
  the default is False; also parses both CLI YAML templates.

tests/test_empirical_variance.py::test_default_is_on was the only
pre-existing test pinning the old default; it has been flipped and
renamed test_default_is_off.

pyproject.toml and kompot/version.py bumped to 0.8.0; CHANGELOG
entry under [0.8.0] - 2026-05-28 documents the migration notes
above. Release tag is not cut by this commit.
align Mahalanobis and DA PTP with manuscript; harmonize use_empirical_variance default; bump to 0.8.0
…-05-28"

This reverts commit dd40808, reversing
changes made to 62e83b6.
Revert: audit-fix merge (#11) — premature; code stays on dominik/audit-fixes-2026-05-28
Three statistical corrections + one default-value harmonization;
all called out in the manuscript-vs-implementation review.

* Mahalanobis denominator sums the two posterior covariances
  (cov1 + cov2) instead of averaging them. The manuscript defines
  D(a,b) = sqrt((mu_a - mu_b)^T (Sigma_a + Sigma_b)^(-1) (mu_a - mu_b)),
  i.e. the variance of the difference of two independent posterior
  estimators. The GP-only branch in differential_expression.py was
  computing (cov1 + cov2) / 2 even though the sample-variance branch
  at the same call site was already summing.
  Effect: D shrinks by sqrt(2) in the GP-only regime. Relative
  rankings unchanged; FDR re-calibrates against the null. The
  resource-estimation comment is brought in line too.

* Differential-abundance posterior tail probability is one-sided:
  PTP = Phi(-|z|), matching the manuscript prose ("probability that
  the true density difference has the opposite sign to the estimated
  change") and the one-sided formula. The implementation was
  emitting 2 * Phi(-|z|) via a spurious + np.log(2).
  Effect: PTPs are halved; neg_log10_fold_change_ptp increases by
  log10(2). A previously-published cutoff of PTP < 1e-3 corresponded
  to |z| >= 3.29 (two-sided) and now corresponds to |z| >= 3.09
  (one-sided). Re-tune any ptp_threshold chosen against 0.7.0.

* use_empirical_variance defaults to False everywhere. The
  recommended kompot.de() path already defaulted to False via
  GPSettings; the deprecated wrappers (compute_differential_expression,
  compute_smoothed_expression), DifferentialExpression.__init__,
  ExpressionModel.__init__, smooth_expression(gp=None), and
  smooth_config_template.yaml all defaulted to True. Now consistent
  with the manuscript's "empirical variance is disabled by default"
  statement. Opt in via use_empirical_variance=True / GPSettings.

Regression coverage in tests/test_audit_fixes.py:
* monkeypatches compute_mahalanobis_distances to capture the
  combined-covariance kwarg from a controlled-kernel fit and
  asserts equality with cov1 + cov2 (not the average);
* replicates the ln_ptp formula and asserts equality with the
  closed-form Phi(-|z|) both directly and end-to-end through
  DifferentialAbundance.fit().predict();
* introspects every public entry point's signature and asserts
  the default is False; also parses both CLI YAML templates.

tests/test_empirical_variance.py::test_default_is_on was the only
pre-existing test pinning the old default; it has been flipped and
renamed test_default_is_off.

pyproject.toml and kompot/version.py bumped to 0.8.0; CHANGELOG
entry under [0.8.0] - 2026-05-28 documents the migration notes
above. Release tag is not cut by this commit.
@settylab-dotto-bot settylab-dotto-bot Bot requested a review from katosh as a code owner May 29, 2026 19:47
@katosh katosh force-pushed the main branch 2 times, most recently from 096fa2a to 62e83b6 Compare May 29, 2026 22:50
@settylab-dotto-bot
Copy link
Copy Markdown
Contributor Author

Superseded by #14.

main was restored to the genuine pre-#11 commit 62e83b6 ("plot: add dotplot #9"), and #14 re-opens the original #11 content cleanly against it: a single commit, the exact 12-file audit-fix changeset. Closing this rebased re-establishment in favor of #14.

The branch dominik/audit-fixes-2026-05-28-rebased is left intact (not deleted).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant