scverse / scverse/scanpy

HVG by cell_ranger flavor, n_top_genes not working

Open
#662 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.6k
Forks
779
Avg merge
1d 4h
Merged PRs (30d)
27

Description

Hi,

Im using scanpy 1.4.2 to analyze my data, using the following command:

sc.pp.highly_variable_genes(heart_cmc, flavor = 'cell_ranger', n_top_genes = 1000)

However, instead of getting 1000 HVG, it reports 1488 HVG. Similar thing happens with higher numbers of HVG (e.g. n_top_genes = 2000 returns 1999).

The scaling then fails with a following error:
ValueError: The first guess on the deviance function returned a nan. This could be a boundary problem and should be reported.

Any suggestions on how to fix it? When I dont specify n_top_genes, the thing runs without problems.
Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with scanpy 1.4.2 using sc.pp.highly_variable_genes(..., flavor='cell_ranger', n_top_genes=1000) on a comparable dataset. Start at the highly_variable_genes entry point and inspect how the cell_ranger flavor selects genes; compare its result with the subsequent scaling step. Done means the requested gene count is handled consistently and scaling no longer fails for this case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.