Skip to content

fix: respect n_bins for flavor='cell_ranger' in pp.highly_variable_genes - #4530

Draft
Zethson wants to merge 2 commits into
mainfrom
fix/hvg-cell-ranger-n-bins
Draft

Zethson wants to merge 2 commits into
mainfrom
fix/hvg-cell-ranger-n-bins

Conversation

@Zethson

@Zethson Zethson commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Closes #888.
n_bins is now respected by pp.highly_variable_genes with flavor="cell_ranger", and the default output is unchanged.
Supersedes #624.

LLM usage

  • LLM or coding agent used: Claude Fable 5.2 via Claude Code
  • If one was used, I, a human, have reviewed, understood and tested every changed line
  • Tests included or not required because: included

…le_genes`

The percentile edges 10, 15, ..., 100 were hardcoded from the Zheng et al. 2017 R code, so `n_bins` was ignored.
They are now `k * 100 / n_bins` for `k = 2..n_bins`, the same sequence at the default `n_bins=20`, so default results do not change.
Results change for callers that already passed a non-default `n_bins` with this flavor.

Closes #888.
Supersedes #624.

Co-authored-by: Etienne Sollier <[email protected]>
@Zethson Zethson added this to the 1.13.1 milestone Nov 17, 2026
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.11%. Comparing base (5c7d839) to head (b3c9dea).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4530   +/-   ##
=======================================
  Coverage   85.11%   85.11%           
=======================================
  Files         140      140           
  Lines       12523    12524    +1     
=======================================
+ Hits        10659    10660    +1     
  Misses       1864     1864           
Flag Coverage Δ
hatch-test.low-vers 80.34% <100.00%> (+<0.01%) ⬆️
hatch-test.pre 84.90% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
src/scanpy/preprocessing/_highly_variable_genes.py 93.66% <100.00%> (+0.02%) ⬆️

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.

n_bins not respected in highly_variable_genes(..., flavour='cell_ranger')

1 participant