Skip to content

Separate Mixscape min_cells from min_de_genes to match Seurat - #1189

Merged
Zethson merged 2 commits into
scverse:mainfrom
kkkklck:fix/mixscape-min-cells
Nov 2, 2026
Merged

Zethson merged 2 commits into
scverse:mainfrom
kkkklck:fix/mixscape-min-cells

Conversation

@kkkklck

@kkkklck kkkklck commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

LLM usage

  • LLM or coding agent used: GPT-5.6 Sol via ChatGPT
  • If one was used, I, a human, have reviewed, understood and tested every changed line

PR Checklist

  • If you've fixed a bug or added code that should be tested, add tests!

Description of changes

Mixscape.mixscape() currently uses min_de_genes for two independent thresholds:

  1. the minimum number of DE genes required to classify a perturbation, and
  2. the minimum number of cells that must remain assigned to the perturbed class during the iterative KO/NP classification.

The current Seurat reference implementation separates these concepts as min.de.genes and min.cells. Seurat fixed the same coupling in satijalab/seurat#10299 in February 2026.

This PR adds min_cells=5 to Mixscape.mixscape() and uses it for the cell-count safeguard while leaving min_de_genes responsible only for the DE-gene threshold. The default is 5, matching Seurat, so default behavior is unchanged.

A regression test deliberately sets min_de_genes and min_cells to different values and verifies that changing one no longer changes the semantics of the other.

Technical details

The behavioral change is limited to calls that explicitly use a non-default min_de_genes value. Previously, for example, min_de_genes=10 also implicitly required at least 10 cells to remain classified as perturbed. After this change, the cell threshold is controlled independently through min_cells.

Validation completed:

  • upstream CI test matrix passes on Python 3.13 stable, Python 3.14 stable, and Python 3.14 pre-release dependencies
  • Codecov reports all modified and coverable lines are covered by tests
  • ruff check passes
  • ruff format passes
  • build and tutorial workflows pass

The remaining Pre-commit checks failure is unrelated to this PR: mypy currently fails while parsing PyQt6/QtGui.pyi with 16 syntax errors. The same failure is present on the current main branch scheduled Test workflow at commit 9b5c53b.

Additional context

Reference fix in Seurat: satijalab/seurat#10299.

@codecov-commenter

codecov-commenter commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.12%. Comparing base (e4f0802) to head (d81224a).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1189      +/-   ##
==========================================
+ Coverage   74.06%   74.12%   +0.05%     
==========================================
  Files          57       57              
  Lines        8895     8895              
==========================================
+ Hits         6588     6593       +5     
+ Misses       2307     2302       -5     
Files with missing lines Coverage Δ
...c/pertpy/tools/_perturbation_efficacy/_mixscape.py 66.78% <100.00%> (+1.39%) ⬆️

... and 1 file with indirect coverage changes

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

@kkkklck
kkkklck marked this pull request as ready for review November 2, 2026 07:52

@Zethson Zethson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much!

@Zethson
Zethson disabled auto-merge November 2, 2026 10:43
@Zethson
Zethson merged commit 1502cf0 into scverse:main Nov 2, 2026
19 checks passed
Zethson added a commit to scverse/rapids-singlecell that referenced this pull request Nov 2, 2026
* Add min_cells to Mixscape instead of reusing min_de_genes

Mixscape collapsed a target gene to NP when fewer than `min_de_genes` cells
stayed classified as perturbed, a typo inherited from Seurat's RunMixscape
and fixed there in satijalab/seurat#10299 and in pertpy in scverse/pertpy#1189.
The cell threshold is now its own `min_cells` parameter, default 5 like Seurat,
so results only change for calls that set a non-default `min_de_genes`.

* Reference the PR in the release note
@kkkklck
kkkklck deleted the fix/mixscape-min-cells branch November 2, 2026 11:01
Zethson added a commit that referenced this pull request Nov 3, 2026
Adds the changelog for 1.5.0 and bumps the release drafter templates.
The version itself comes from the git tag via hatch-vcs.
The v1.5.0 section gains the guide assignment rework (#1172, #1173), the Mixscape min_cells fix (#1189), the Python 3.13 requirement and the CI and template PRs (#1165, #1184, #1185, #1190), and its two Maintenance blocks are merged in the 1.4.0 section order.
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.

3 participants