Skip to content

Backport categorical ComBat reference coding to 1.12.x - #4496

Open
sylvesterkaczmarek wants to merge 2 commits into
scverse:1.12.xfrom
sylvesterkaczmarek:backport/4454-combat-categorical-1.12
Open

sylvesterkaczmarek wants to merge 2 commits into
scverse:1.12.xfrom
sylvesterkaczmarek:backport/4454-combat-categorical-1.12

Conversation

@sylvesterkaczmarek

@sylvesterkaczmarek sylvesterkaczmarek commented Nov 7, 2026 •

Copy link
Copy Markdown

Refs #4454. Targets 1.12.x, not main.

Backport the categorical-covariate reference coding already accepted in #4389. The current 1.12 maintenance branch still constructs a full set of categorical dummy columns alongside all batch indicators, introducing a redundant column. Use the same treatment coding as main and remove its intercept before combining the matrices.

This is a targeted backport of the existing correction, with new regression coverage. No solver, numerical threshold, dependency or unrelated function changes are included. Main and 1.11.x are not changed. Designs confounded for other reasons are outside this fix.

Validation

  • All seven new cases fail against the original maintenance-branch implementation.
  • The corrected branch passes all 12 tests: seven new cases and all five existing ComBat tests, with no errors or skips.
  • Coverage includes one or two categorical covariates alongside a numeric covariate, full-rank design, dense/CSR input, in-place and returned results, and a single-level categorical covariate.
  • Corrected output matches explicit numeric reference coding to rtol=atol=1e-10; returned-result calls preserve the input expression matrix.
  • The new tests pass Ruff and formatting checks; git diff --check passes.

Validation ran on the exact pinned source in the contributor fork's Linux/Python 3.12 workflow. The validation helpers and workflow are on a separate branch and are not included in this proposed diff. This is not upstream CI. The full repository suite, documentation build, other platforms and the reporter's dataset were not tested.

Fork evidence: https://github.com/sylvesterkaczmarek/scanpy/actions/runs/42367545452

Post-submission verification

The release-note fragment has been renamed to 4496.fix.md. The targeted tests were independently rerun after the filename change and passed: 12 tests. Human review of the latest changes remains pending.

LLM usage

  • LLM or coding agent used: GPT-6 via ChatGPT and Codex CLI v0.166.0 assisted with code, tests, documentation, and review. The Codex model version used for the original implementation was not independently recorded.

  • If one was used, I, a human, have reviewed, understood and tested every changed line.

  • Tests included.

  • Issue reference included above; this change is limited to the 1.12 maintenance branch.

  • Release notes not necessary because:

A release note is included as 4496.fix.md, matching the assigned PR number.

@read-the-docs-business

read-the-docs-business Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.76%. Comparing base (f044749) to head (45a7d26).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           1.12.x    #4496      +/-   ##
==========================================
+ Coverage   78.73%   78.76%   +0.03%     
==========================================
  Files         121      121              
  Lines       12760    12760              
==========================================
+ Hits        10046    10051       +5     
+ Misses       2714     2709       -5     
Flag Coverage Δ
hatch-test.low-vers 77.83% <ø> (+0.03%) ⬆️
hatch-test.pre 78.65% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/scanpy/preprocessing/_combat.py 92.06% <ø> (+3.96%) ⬆️

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.

1 participant