From 3b2fd00960ff8ea6004101893284dbbd4b7940cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=B6k=C3=A7en=20Eraslan?= Date: Mon, 10 Oct 2022 14:49:28 -0700 Subject: [PATCH] Handle scalar datasets too (#2344) * Handle scalar datasets too After @ivirshup's pytables PR (#2064) we started having issues with loading h5 files with scalar datasets, such as those created by CellBender (https://github.com/broadinstitute/CellBender/issues/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 #2203 --- scanpy/readwrite.py | 2 +- .../_data/10x_data/1.2.0/multiple_genomes.h5 | Bin 52082 -> 54138 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/scanpy/readwrite.py b/scanpy/readwrite.py index 5ff556ddc5..742595987e 100644 --- a/scanpy/readwrite.py +++ b/scanpy/readwrite.py @@ -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) diff --git a/scanpy/tests/_data/10x_data/1.2.0/multiple_genomes.h5 b/scanpy/tests/_data/10x_data/1.2.0/multiple_genomes.h5 index 3d04d4e909c5ac4570351a5eb0d9767bc60ccddd..c1834ed0bdde874bd4f8fa0336f9d573f90169dd 100644 GIT binary patch delta 182 zcmew~jrrFy<_Q{1RhKtvEze?1*nBA~l!=jJvPSMlt^fuIC^|iHquk^P+#Hh?^At8` z=0#Xa7AGg>Bo@V|B$gx=rXI0u6SSd^Ku=rY6@h^om8%SG5PSJ)&oFihAS$lJ=!!34Dh0L+ai