Skip to content

Take n_bins into account for the cell_ranger flavor of highly_variable_genes - #624

Closed
e-sollier wants to merge 7 commits into
scverse:mainfrom
e-sollier:master
Closed

e-sollier wants to merge 7 commits into
scverse:mainfrom
e-sollier:master

Conversation

@e-sollier

@e-sollier e-sollier commented Apr 26, 2019 •

Copy link
Copy Markdown

I've changed one line in the highly_variable_genes function, so that n_bins is taken into account with the cell_ranger flavor (currently only the seurat flavor uses this parameter).

Additionally, I have noticed that, in the current version, the bins are slightly offset: after -INF, it starts at 10, instead of 5, which results in the first bin containing twice as many genes as the other bins. I don't know if this is intentional (for example, to exactly reproduce the results of cell ranger) or not.
In the version that I suggest, I have removed this offset. As a consequence, with the default parameter of n_bins=20, my new version does not exactly reproduce the results of the previous version. In order to exactly reproduce the current results, we would have to keep this offset by doing range(2,n_bins+1) instead of range(1,n_bins).

@codecov

codecov Bot commented Jan 19, 2024 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.72%. Comparing base (86b85ee) to head (f233d75).
⚠️ Report is 553 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #624   +/-   ##
=======================================
  Coverage   72.72%   72.72%           
=======================================
  Files         111      111           
  Lines       12384    12384           
=======================================
  Hits         9006     9006           
  Misses       3378     3378           
Files with missing lines Coverage Δ
scanpy/preprocessing/_highly_variable_genes.py 96.17% <ø> (ø)

@Zethson

Zethson commented Nov 17, 2026

Copy link
Copy Markdown
Member

Superseded by #4530, which uses the backwards-compatible variant from this PR's description (range(2, n_bins + 1)), so n_bins takes effect while default results stay unchanged.
Thanks for the fix!

@Zethson Zethson closed this Nov 17, 2026
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.

4 participants