Skip to content

Commit

Permalink
Handle scalar datasets too (scverse#2344)
Browse files Browse the repository at this point in the history
* Handle scalar datasets too

After @ivirshup's pytables PR (scverse#2064) we started having issues with loading h5 files with scalar datasets, such as those created by CellBender (broadinstitute/CellBender#128). It is currently not an issue for the 10X h5 files for now since they don't have any scalars, however it'd be good to just handle scalars as well as arrays 1- to fix the cellbender file loading problem 2- to fix potential problems we might end up having if 10X h5 format includes scalar datasets.

* Add a scalar to the multiple_genomes.h5 test file

* Fixes scverse#2203
  • Loading branch information
gokceneraslan authored Oct 10, 2022
1 parent ec54473 commit 3b2fd00
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scanpy/readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def _read_legacy_10x_h5(filename, *, genome=None, start=None):
def _collect_datasets(dsets: dict, group: h5py.Group):
for k, v in group.items():
if isinstance(v, h5py.Dataset):
dsets[k] = v[:]
dsets[k] = v[()]
else:
_collect_datasets(dsets, v)

Expand Down
Binary file modified scanpy/tests/_data/10x_data/1.2.0/multiple_genomes.h5
Binary file not shown.

0 comments on commit 3b2fd00

Please sign in to comment.