SingleCellExperiment 0.4.3__tar.gz → 0.4.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/.pre-commit-config.yaml +3 -3
  2. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/PKG-INFO +5 -1
  3. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/setup.cfg +4 -0
  4. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/setup.py +1 -0
  5. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/SingleCellExperiment.egg-info/PKG-INFO +5 -1
  6. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/SingleCellExperiment.egg-info/requires.txt +4 -0
  7. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/singlecellexperiment/SingleCellExperiment.py +13 -22
  8. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/singlecellexperiment/io/tenx.py +6 -9
  9. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/test_sce_io.py +10 -0
  10. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/.coveragerc +0 -0
  11. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/.github/workflows/pypi-publish.yml +0 -0
  12. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/.github/workflows/pypi-test.yml +0 -0
  13. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/.gitignore +0 -0
  14. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/.readthedocs.yml +0 -0
  15. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/AUTHORS.md +0 -0
  16. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/CHANGELOG.md +0 -0
  17. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/CONTRIBUTING.md +0 -0
  18. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/LICENSE.txt +0 -0
  19. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/README.md +0 -0
  20. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/Makefile +0 -0
  21. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/_static/.gitignore +0 -0
  22. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/authors.md +0 -0
  23. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/changelog.md +0 -0
  24. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/conf.py +0 -0
  25. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/contributing.md +0 -0
  26. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/index.md +0 -0
  27. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/license.md +0 -0
  28. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/readme.md +0 -0
  29. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/requirements.txt +0 -0
  30. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/docs/tutorial.md +0 -0
  31. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/pyproject.toml +0 -0
  32. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/SingleCellExperiment.egg-info/SOURCES.txt +0 -0
  33. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/SingleCellExperiment.egg-info/dependency_links.txt +0 -0
  34. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/SingleCellExperiment.egg-info/not-zip-safe +0 -0
  35. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/SingleCellExperiment.egg-info/top_level.txt +0 -0
  36. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/singlecellexperiment/__init__.py +0 -0
  37. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/singlecellexperiment/_combineutils.py +0 -0
  38. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/singlecellexperiment/_ioutils.py +0 -0
  39. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/singlecellexperiment/io/__init__.py +0 -0
  40. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/src/singlecellexperiment/io/h5ad.py +0 -0
  41. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/conftest.py +0 -0
  42. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/data/adata.h5ad +0 -0
  43. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/data/mocks.py +0 -0
  44. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/data/tenx.sub.h5 +0 -0
  45. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/test_sce.py +0 -0
  46. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/test_sce_combine_cols.py +0 -0
  47. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/test_sce_combine_rows.py +0 -0
  48. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/test_sce_methods.py +0 -0
  49. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tests/test_sce_slice.py +0 -0
  50. {SingleCellExperiment-0.4.3 → singlecellexperiment-0.4.5}/tox.ini +0 -0
@@ -2,7 +2,7 @@ exclude: '^docs/conf.py'
2
2
 
3
3
  repos:
4
4
  - repo: https://github.com/pre-commit/pre-commit-hooks
5
- rev: v4.5.0
5
+ rev: v4.6.0
6
6
  hooks:
7
7
  - id: trailing-whitespace
8
8
  - id: check-added-large-files
@@ -26,14 +26,14 @@ repos:
26
26
  # --config, ./pyproject.toml
27
27
 
28
28
  - repo: https://github.com/psf/black
29
- rev: 23.12.1
29
+ rev: 24.4.0
30
30
  hooks:
31
31
  - id: black
32
32
  language_version: python3
33
33
 
34
34
  - repo: https://github.com/astral-sh/ruff-pre-commit
35
35
  # Ruff version.
36
- rev: v0.1.14
36
+ rev: v0.3.7
37
37
  hooks:
38
38
  - id: ruff
39
39
  args: [--fix, --exit-non-zero-on-fix]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: SingleCellExperiment
3
- Version: 0.4.3
3
+ Version: 0.4.5
4
4
  Summary: Container class for single-cell experiments
5
5
  Home-page: https://github.com/BiocPy/SingleCellExperiment
6
6
  Author: jkanche
@@ -19,6 +19,8 @@ Provides-Extra: optional
19
19
  Requires-Dist: anndata; extra == "optional"
20
20
  Requires-Dist: h5py; extra == "optional"
21
21
  Requires-Dist: mudata; extra == "optional"
22
+ Requires-Dist: delayedarray; extra == "optional"
23
+ Requires-Dist: hdf5array; extra == "optional"
22
24
  Provides-Extra: testing
23
25
  Requires-Dist: setuptools; extra == "testing"
24
26
  Requires-Dist: pytest; extra == "testing"
@@ -26,6 +28,8 @@ Requires-Dist: pytest-cov; extra == "testing"
26
28
  Requires-Dist: anndata; extra == "testing"
27
29
  Requires-Dist: h5py; extra == "testing"
28
30
  Requires-Dist: mudata; extra == "testing"
31
+ Requires-Dist: delayedarray; extra == "testing"
32
+ Requires-Dist: hdf5array; extra == "testing"
29
33
 
30
34
  [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
31
35
  [![PyPI-Server](https://img.shields.io/pypi/v/SingleCellExperiment.svg)](https://pypi.org/project/SingleCellExperiment/)
@@ -36,6 +36,8 @@ optional =
36
36
  anndata
37
37
  h5py
38
38
  mudata
39
+ delayedarray
40
+ hdf5array
39
41
  testing =
40
42
  setuptools
41
43
  pytest
@@ -43,6 +45,8 @@ testing =
43
45
  anndata
44
46
  h5py
45
47
  mudata
48
+ delayedarray
49
+ hdf5array
46
50
 
47
51
  [options.entry_points]
48
52
 
@@ -4,6 +4,7 @@ This file was generated with PyScaffold 4.5.
4
4
  PyScaffold helps you to put up the scaffold of your new Python project.
5
5
  Learn more under: https://pyscaffold.org/
6
6
  """
7
+
7
8
  from setuptools import setup
8
9
 
9
10
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: SingleCellExperiment
3
- Version: 0.4.3
3
+ Version: 0.4.5
4
4
  Summary: Container class for single-cell experiments
5
5
  Home-page: https://github.com/BiocPy/SingleCellExperiment
6
6
  Author: jkanche
@@ -19,6 +19,8 @@ Provides-Extra: optional
19
19
  Requires-Dist: anndata; extra == "optional"
20
20
  Requires-Dist: h5py; extra == "optional"
21
21
  Requires-Dist: mudata; extra == "optional"
22
+ Requires-Dist: delayedarray; extra == "optional"
23
+ Requires-Dist: hdf5array; extra == "optional"
22
24
  Provides-Extra: testing
23
25
  Requires-Dist: setuptools; extra == "testing"
24
26
  Requires-Dist: pytest; extra == "testing"
@@ -26,6 +28,8 @@ Requires-Dist: pytest-cov; extra == "testing"
26
28
  Requires-Dist: anndata; extra == "testing"
27
29
  Requires-Dist: h5py; extra == "testing"
28
30
  Requires-Dist: mudata; extra == "testing"
31
+ Requires-Dist: delayedarray; extra == "testing"
32
+ Requires-Dist: hdf5array; extra == "testing"
29
33
 
30
34
  [![Project generated with PyScaffold](https://img.shields.io/badge/-PyScaffold-005CA0?logo=pyscaffold)](https://pyscaffold.org/)
31
35
  [![PyPI-Server](https://img.shields.io/pypi/v/SingleCellExperiment.svg)](https://pypi.org/project/SingleCellExperiment/)
@@ -7,6 +7,8 @@ importlib-metadata
7
7
  anndata
8
8
  h5py
9
9
  mudata
10
+ delayedarray
11
+ hdf5array
10
12
 
11
13
  [testing]
12
14
  setuptools
@@ -15,3 +17,5 @@ pytest-cov
15
17
  anndata
16
18
  h5py
17
19
  mudata
20
+ delayedarray
21
+ hdf5array
@@ -4,7 +4,6 @@ from warnings import warn
4
4
 
5
5
  import biocframe
6
6
  import biocutils as ut
7
- from genomicranges import GenomicRanges
8
7
  from summarizedexperiment._combineutils import (
9
8
  check_assays_are_equal,
10
9
  merge_assays,
@@ -984,25 +983,16 @@ class SingleCellExperiment(RangedSummarizedExperiment):
984
983
  Returns:
985
984
  A tuple with ``AnnData`` main experiment and a list of alternative experiments.
986
985
  """
987
- from anndata import AnnData
986
+ obj = super().to_anndata()
988
987
 
989
- layers = OrderedDict()
990
- for asy, mat in self.assays.items():
991
- layers[asy] = mat.transpose()
988
+ if self.reduced_dims is not None:
989
+ obj.obsm = self.reduced_dims
992
990
 
993
- trows = self.row_data
994
- if isinstance(self.row_data, GenomicRanges):
995
- trows = self.row_data.to_pandas()
996
-
997
- obj = AnnData(
998
- obs=self.col_data,
999
- var=trows,
1000
- uns=self.metadata,
1001
- obsm=self.reduced_dims,
1002
- layers=layers,
1003
- varp=self.row_pairs,
1004
- obsp=self.column_pairs,
1005
- )
991
+ if self.row_pairs is not None:
992
+ obj.varp = self.row_pairs
993
+
994
+ if self.column_pairs is not None:
995
+ obj.obsp = self.column_pairs
1006
996
 
1007
997
  if include_alternative_experiments is True:
1008
998
  adatas = None
@@ -1014,8 +1004,6 @@ class SingleCellExperiment(RangedSummarizedExperiment):
1014
1004
  ) in self.alternative_experiments.items():
1015
1005
  adatas[alt_name] = alternative_experiment.to_anndata()
1016
1006
 
1017
- return obj, adatas
1018
-
1019
1007
  return obj, None
1020
1008
 
1021
1009
  @classmethod
@@ -1027,7 +1015,9 @@ class SingleCellExperiment(RangedSummarizedExperiment):
1027
1015
  Input data.
1028
1016
 
1029
1017
  Returns:
1030
- A ``SingleCellExperiment`` object.
1018
+ A ``SingleCellExperiment`` object. If the input contains any data
1019
+ in the ``uns`` attribute, the `metadata` slot of the ``SingleCellExperiment``
1020
+ will contain a key ``uns``.
1031
1021
  """
1032
1022
 
1033
1023
  layers = OrderedDict()
@@ -1040,12 +1030,13 @@ class SingleCellExperiment(RangedSummarizedExperiment):
1040
1030
  obsm = _to_normal_dict(input.obsm)
1041
1031
  varp = _to_normal_dict(input.varp)
1042
1032
  obsp = _to_normal_dict(input.obsp)
1033
+ _metadata = {"uns": input.uns} if input.uns is not None else None
1043
1034
 
1044
1035
  return cls(
1045
1036
  assays=layers,
1046
1037
  row_data=biocframe.BiocFrame.from_pandas(input.var),
1047
1038
  column_data=biocframe.BiocFrame.from_pandas(input.obs),
1048
- metadata=input.uns,
1039
+ metadata=_metadata,
1049
1040
  reduced_dims=obsm,
1050
1041
  row_pairs=varp,
1051
1042
  column_pairs=obsp,
@@ -58,7 +58,7 @@ def read_tenx_h5(path: str) -> SingleCellExperiment:
58
58
  """
59
59
 
60
60
  import h5py
61
- from scipy.sparse import csc_matrix, csr_matrix
61
+ from hdf5array import Hdf5CompressedSparseMatrix
62
62
 
63
63
  h5 = h5py.File(path, mode="r")
64
64
 
@@ -68,16 +68,11 @@ def read_tenx_h5(path: str) -> SingleCellExperiment:
68
68
  groups = h5["matrix"].keys()
69
69
 
70
70
  # read the matrix
71
- data = h5["matrix"]["data"][:]
72
- indices = h5["matrix"]["indices"][:]
73
- indptr = h5["matrix"]["indptr"][:]
74
71
  shape = tuple(h5["matrix"]["shape"][:])
75
72
 
76
- counts = None
77
- if len(indptr) == shape[1] + 1:
78
- counts = csc_matrix((data, indices, indptr), shape=shape)
79
- else:
80
- counts = csr_matrix((data, indices, indptr), shape=shape)
73
+ counts = Hdf5CompressedSparseMatrix(
74
+ path=path, group_name="matrix", by_column=True, shape=shape
75
+ )
81
76
 
82
77
  # read features
83
78
  features = None
@@ -106,6 +101,8 @@ def read_tenx_h5(path: str) -> SingleCellExperiment:
106
101
  barcodes["barcodes"] = [x.decode("ascii") for x in h5["matrix"]["barcodes"]]
107
102
  barcodes = BiocFrame(barcodes, number_of_rows=counts.shape[1])
108
103
 
104
+ h5.close()
105
+
109
106
  return SingleCellExperiment(
110
107
  assays={"counts": counts}, row_data=features, column_data=barcodes
111
108
  )
@@ -61,6 +61,8 @@ def test_SCE_to_anndata():
61
61
  adata = tse.to_anndata()
62
62
  assert adata is not None
63
63
  assert isinstance(adata[0], anndata.AnnData)
64
+ assert adata[0].shape[0] == counts.shape[1]
65
+ assert adata[0].shape[1] == counts.shape[0]
64
66
 
65
67
 
66
68
  def test_SCE_fromH5AD():
@@ -127,6 +129,14 @@ def test_SCE_randomAnnData():
127
129
  assert tse is not None
128
130
  assert isinstance(tse, SingleCellExperiment)
129
131
 
132
+ # to avoid unknown mapping types;
133
+ # ran into an issue with anndata.compat._overloaded_dict.OverloadedDict when loading a h5ad
134
+ adata.uns = {".internal": [f"obs_{i+1}" for i in range(n)]}
135
+ tse = singlecellexperiment.SingleCellExperiment.from_anndata(adata)
136
+
137
+ assert tse is not None
138
+ assert isinstance(tse, SingleCellExperiment)
139
+
130
140
 
131
141
  def test_SCE_to_mudata():
132
142
  tse = SingleCellExperiment(