Skip to content

fix: respect n_top_genes with duplicate variable names - #4409

Open
benjaminkramer510 wants to merge 2 commits into
scverse:mainfrom
benjaminkramer510:fix/hvg-duplicate-var-names
Open

benjaminkramer510 wants to merge 2 commits into
scverse:mainfrom
benjaminkramer510:fix/hvg-duplicate-var-names

Conversation

@benjaminkramer510

Copy link
Copy Markdown

With duplicate variable names, seurat_v3 and seurat_v3_paper can select more than n_top_genes genes because .loc selects every occurrence of a selected name.

Select by position instead. The regression test checks that changing gene names leaves the selected genes and statistics unchanged, across both flavors, batching, inplace, and subset.

Validation: python -m pytest tests/test_highly_variable_genes.py -q — 237 passed, 1 xfailed, 280 subtests passed. The new test reproduced 39 selected genes instead of 30 before the fix; all 16 cases now pass. Repository hooks pass.

LLM usage

A release note is included.

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.

highly_variable_genes(flavor="seurat_v3") flags more than n_top_genes genes when var_names contain duplicates

1 participant