scverse / scverse/scanpy

Type comparison issue when using read_h5ad in backed mode

Open
#650 7 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

If I read a file with read_h5ad() and then process with

sc.pp.filter_genes(adata, min_cells=int(foo))
Things work as intended.

But if I change that read line to be read_h5ad(h5_path, backed='r') then when I attempt to filter I get this error instead:

File "/opt/Python-3.7.3/lib/python3.7/site-packages/scanpy/preprocessing/_simple.py", line 228, in filter_genes:
else X > 0, axis=0):
TypeError: '>' not supported between instances of 'SparseDataset' and 'int'

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

Start in scanpy/preprocessing/_simple.py around filter_genes, using the reported line where SparseDataset is compared with an integer. Reproduce the difference between read_h5ad() and read_h5ad(..., backed='r') with sc.pp.filter_genes(adata, min_cells=int(foo)). Done means the backed case no longer raises this TypeError and filtering behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
bioinformatics, data
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.