Skip to content

Honor the requested coefficient in shrinkage grid fallback - #472

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

Intron7 wants to merge 1 commit into
scverse:mainfrom
Intron7:codex/fix-shrink-grid-coefficient

Conversation

@Intron7

@Intron7 Intron7 commented Sep 23, 2026

Copy link
Copy Markdown
Member

When a two-coefficient shrinkage fit does not converge, nbinomGLM falls back to a grid that always applies the Cauchy prior to coefficient 1. A request to shrink coefficient 0 therefore changes its objective during recovery.

Pass the requested coefficient through the fallback and into nbinomFn. The new shrink_index=1 argument is appended to grid_fit_shrink_beta, preserving existing positional calls and default behavior.

The regression forces optimizer failure, compares the grid result with an independently optimized negative-binomial log-PMF plus priors, and verifies that permuting design columns while adjusting the requested index preserves the fit. Both parameterized cases fail before the fix and pass afterward.

Validation: full upstream suite passes (67 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 87.53%. Comparing base (95ace12) to head (9f5147a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #472      +/-   ##
==========================================
+ Coverage   86.05%   87.53%   +1.48%     
==========================================
  Files          15       15              
  Lines        1276     1276              
==========================================
+ Hits         1098     1117      +19     
+ Misses        178      159      -19     
Files with missing lines Coverage Δ
src/pydeseq2/distributions.py 100.00% <ø> (+1.81%) ⬆️
src/pydeseq2/grid_search.py 70.00% <ø> (+25.71%) ⬆️
🚀 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