Skip to content

Commit

Permalink
Fix legacy 10x loader when more than one genome exists (scverse#2248)
Browse files Browse the repository at this point in the history
* Fix bug with legacy 10x loader for multiple genomes

* Add test and small test data h5

* black
  • Loading branch information
sjfleming authored Sep 29, 2022
1 parent 11d0b8e commit ec54473
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scanpy/readwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def _read_legacy_10x_h5(filename, *, genome=None, start=None):
)

dsets = {}
_collect_datasets(dsets, f)
_collect_datasets(dsets, f[genome])

# AnnData works with csr matrices
# 10x stores the transposed data, so we do the transposition right away
Expand Down
Binary file not shown.
17 changes: 17 additions & 0 deletions scanpy/tests/test_read_10x.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,23 @@ def test_read_10x_h5_v1():
assert_anndata_equal(spec_genome_v1, nospec_genome_v1)


def test_read_10x_h5_v2_multiple_genomes():
genome1_v1 = sc.read_10x_h5(
ROOT / '1.2.0' / 'multiple_genomes.h5',
genome='hg19_chr21',
)
genome2_v1 = sc.read_10x_h5(
ROOT / '1.2.0' / 'multiple_genomes.h5',
genome='another_genome',
)
# the test data are such that X is the same shape for both "genomes",
# but the values are different
assert (genome1_v1.X != genome2_v1.X).sum() > 0, (
'loading data from two different genomes in 10x v2 format. '
'should be different, but is the same. '
)


def test_read_10x_h5():
spec_genome_v3 = sc.read_10x_h5(
ROOT / '3.0.0' / 'filtered_feature_bc_matrix.h5',
Expand Down

0 comments on commit ec54473

Please sign in to comment.