Skip to content

Commit

Permalink
Fix reading of non gene expression data from 10x h5 files
Browse files Browse the repository at this point in the history
My bad.
  • Loading branch information
ivirshup committed Mar 11, 2020
1 parent f963a7a commit 8d26ad5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scanpy/readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,10 @@ def read_10x_h5(
list(map(lambda x: x == 'Gene Expression', adata.var['feature_types'])),
]
if adata.is_view:
return adata.copy()
adata = adata.copy()
else:
return _read_legacy_10x_h5(filename, genome=genome, start=start)
adata = _read_legacy_10x_h5(filename, genome=genome, start=start)
return adata


def _read_legacy_10x_h5(filename, *, genome=None, start=None):
Expand Down
8 changes: 8 additions & 0 deletions scanpy/tests/test_read_10x.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,11 @@ def test_read_visium_counts():
spec_genome_v3 = sc.read_10x_h5(h5_pth, genome='GRCh38')
nospec_genome_v3 = sc.read_10x_h5(h5_pth)
assert_anndata_equal(spec_genome_v3, nospec_genome_v3)


def test_10x_h5_gex():
# Tests that gex option doesn't, say, make the function return None
h5_pth = ROOT / '3.0.0' / 'filtered_feature_bc_matrix.h5'
assert_anndata_equal(
sc.read_10x_h5(h5_pth, gex_only=True), sc.read_10x_h5(h5_pth, gex_only=False)
)

0 comments on commit 8d26ad5

Please sign in to comment.