Skip to content

Preserve dispersion regularization in optimizer fallback - #471

Open
Intron7 wants to merge 1 commit into
scverse:mainfrom
Intron7:codex/fix-dispersion-grid-objective
Open

Intron7 wants to merge 1 commit into
scverse:mainfrom
Intron7:codex/fix-dispersion-grid-objective

Conversation

@Intron7

@Intron7 Intron7 commented Sep 23, 2026

Copy link
Copy Markdown
Member

When dispersion optimization fails, fit_alpha_mle calls grid_fit_alpha without forwarding its regularization settings. The grid therefore enables Cox-Reid correction and disables the dispersion prior regardless of the requested objective. In particular, MAP fallback silently drops its prior.

Forward prior_disp_var, cr_reg, and prior_reg so fallback continues minimizing the configured objective. Default gene-wise fallback behavior and the unsuccessful convergence flag are unchanged.

The regression forces optimizer failure for BFGS and L-BFGS-B across all four Cox-Reid/prior combinations. It compares the result with an independently minimized negative-binomial log-PMF plus the requested penalties. Six cases fail before the fix; all eight pass afterward.

Validation: full upstream suite passes (73 tests); Ruff lint, formatting, and mypy pass.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.05%. Comparing base (95ace12) to head (485dfae).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #471   +/-   ##
=======================================
  Coverage   86.05%   86.05%           
=======================================
  Files          15       15           
  Lines        1276     1276           
=======================================
  Hits         1098     1098           
  Misses        178      178           
Files with missing lines Coverage Δ
src/pydeseq2/dispersions.py 96.84% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

2 participants