SingleCellExperiment 0.5.6__tar.gz → 0.5.8__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 (53) hide show
  1. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/.pre-commit-config.yaml +1 -1
  2. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/AUTHORS.md +1 -0
  3. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/CHANGELOG.md +13 -4
  4. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/PKG-INFO +3 -3
  5. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/README.md +2 -2
  6. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/authors.md +1 -0
  7. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/changelog.md +13 -4
  8. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/readme.md +2 -2
  9. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/SingleCellExperiment.egg-info/PKG-INFO +3 -3
  10. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/SingleCellExperiment.egg-info/SOURCES.txt +4 -1
  11. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/singlecellexperiment/SingleCellExperiment.py +28 -6
  12. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/singlecellexperiment/io/tenx.py +18 -5
  13. singlecellexperiment-0.5.8/tests/data/raw_feature_bc_matrix/barcodes.tsv +50 -0
  14. singlecellexperiment-0.5.8/tests/data/raw_feature_bc_matrix/features.tsv +50 -0
  15. singlecellexperiment-0.5.8/tests/data/raw_feature_bc_matrix/matrix.mtx +340 -0
  16. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/test_sce.py +45 -0
  17. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/test_sce_io.py +25 -2
  18. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/.coveragerc +0 -0
  19. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/.github/workflows/publish-pypi.yml +0 -0
  20. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/.github/workflows/run-tests.yml +0 -0
  21. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/.gitignore +0 -0
  22. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/.readthedocs.yml +0 -0
  23. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/CONTRIBUTING.md +0 -0
  24. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/LICENSE.txt +0 -0
  25. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/Makefile +0 -0
  26. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/_static/.gitignore +0 -0
  27. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/conf.py +0 -0
  28. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/contributing.md +0 -0
  29. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/index.md +0 -0
  30. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/license.md +0 -0
  31. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/requirements.txt +0 -0
  32. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/docs/tutorial.md +0 -0
  33. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/pyproject.toml +0 -0
  34. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/setup.cfg +0 -0
  35. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/setup.py +0 -0
  36. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/SingleCellExperiment.egg-info/dependency_links.txt +0 -0
  37. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/SingleCellExperiment.egg-info/not-zip-safe +0 -0
  38. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/SingleCellExperiment.egg-info/requires.txt +0 -0
  39. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/SingleCellExperiment.egg-info/top_level.txt +0 -0
  40. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/singlecellexperiment/__init__.py +0 -0
  41. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/singlecellexperiment/_combineutils.py +0 -0
  42. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/singlecellexperiment/_ioutils.py +0 -0
  43. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/singlecellexperiment/io/__init__.py +0 -0
  44. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/src/singlecellexperiment/io/h5ad.py +0 -0
  45. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/conftest.py +0 -0
  46. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/data/adata.h5ad +0 -0
  47. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/data/mocks.py +0 -0
  48. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/data/tenx.sub.h5 +0 -0
  49. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/test_sce_combine_cols.py +0 -0
  50. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/test_sce_combine_rows.py +0 -0
  51. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/test_sce_methods.py +0 -0
  52. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tests/test_sce_slice.py +0 -0
  53. {singlecellexperiment-0.5.6 → singlecellexperiment-0.5.8}/tox.ini +0 -0
@@ -33,7 +33,7 @@ repos:
33
33
 
34
34
  - repo: https://github.com/astral-sh/ruff-pre-commit
35
35
  # Ruff version.
36
- rev: v0.8.6
36
+ rev: v0.9.10
37
37
  hooks:
38
38
  - id: ruff
39
39
  args: [--fix, --exit-non-zero-on-fix]
@@ -1,3 +1,4 @@
1
1
  # Contributors
2
2
 
3
3
  * jkanche <jayaram.kancherla@gmail.com>
4
+ * keviny2 <kevinyang10@gmail.com>
@@ -1,12 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.5.8
4
+
5
+ - Rename `reduced_dims` to `reduced_dimensions`. Constructor accepts both these arguments for backwards compatibility.
6
+ - Additionally, SCE's constructor takes kwargs for future proofing any additional attributes in the upstream classes.
7
+
8
+ ## Version 0.5.7
9
+
10
+ - Support reading outputs from CellRanger version 3 and later in `read_tenx_mtx`.
11
+ - Handle both `genes.csv` and `features.csv` for gene annotations.
12
+
3
13
  ## Version 0.5.6
4
14
 
5
- - Check if the column names of the alternative experiments match with the column names of the main experiment. This is the equivalent to the ``withDimnames`` parameter in the R implementation.
15
+ - Check if the column names of the alternative experiments match with the column names of the main experiment. This is the equivalent to the `withDimnames` parameter in the R implementation.
6
16
  - On **getters** of alternative experiments, if `with_dim_names` is True, column names of the alternative experiment are **replaced** with the
7
- column names of the main experiment.
17
+ column names of the main experiment.
8
18
  - On **setters** of alternative experiments, if `with_dim_names` is True, column names of the alternative experiment are **checked** with the
9
- column names of the main experiment and an Exception is raised if they do not match.
19
+ column names of the main experiment and an Exception is raised if they do not match.
10
20
 
11
21
  ## Version 0.5.1 - 0.5.5
12
22
 
@@ -15,7 +25,6 @@
15
25
  - Add getters and setters to replace a specific alternative experiment or reduced dimension.
16
26
  - Fixed an issue with numpy arrays as slice arguments. Code now uses Biocutils's subset functions to perform these operations.
17
27
 
18
-
19
28
  ## Version 0.5.0
20
29
 
21
30
  - chore: Remove Python 3.8 (EOL)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: SingleCellExperiment
3
- Version: 0.5.6
3
+ Version: 0.5.8
4
4
  Summary: Container class for single-cell experiments
5
5
  Home-page: https://github.com/BiocPy/SingleCellExperiment
6
6
  Author: jkanche
@@ -58,7 +58,7 @@ pip install singlecellexperiment
58
58
 
59
59
  ## Usage
60
60
 
61
- The `SingleCellExperiment` extends [RangeSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
61
+ The `SingleCellExperiment` extends [RangedSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
62
62
 
63
63
  - `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
64
64
  - `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
@@ -98,7 +98,7 @@ tse = SingleCellExperiment(
98
98
  )
99
99
  ```
100
100
 
101
- Since `SingleCellExperiment` extends `RangeSummarizedExperiment`, most methods especially slicing and accessors are applicable here.
101
+ Since `SingleCellExperiment` extends `RangedSummarizedExperiment`, most methods especially slicing and accessors are inherited from the parent classes.
102
102
  Checkout the [documentation](https://biocpy.github.io/SingleCellExperiment/) for more info.
103
103
 
104
104
  <!-- pyscaffold-notes -->
@@ -17,7 +17,7 @@ pip install singlecellexperiment
17
17
 
18
18
  ## Usage
19
19
 
20
- The `SingleCellExperiment` extends [RangeSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
20
+ The `SingleCellExperiment` extends [RangedSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
21
21
 
22
22
  - `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
23
23
  - `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
@@ -57,7 +57,7 @@ tse = SingleCellExperiment(
57
57
  )
58
58
  ```
59
59
 
60
- Since `SingleCellExperiment` extends `RangeSummarizedExperiment`, most methods especially slicing and accessors are applicable here.
60
+ Since `SingleCellExperiment` extends `RangedSummarizedExperiment`, most methods especially slicing and accessors are inherited from the parent classes.
61
61
  Checkout the [documentation](https://biocpy.github.io/SingleCellExperiment/) for more info.
62
62
 
63
63
  <!-- pyscaffold-notes -->
@@ -1,3 +1,4 @@
1
1
  # Contributors
2
2
 
3
3
  * jkanche <jayaram.kancherla@gmail.com>
4
+ * keviny2 <kevinyang10@gmail.com>
@@ -1,12 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## Version 0.5.8
4
+
5
+ - Rename `reduced_dims` to `reduced_dimensions`. Constructor accepts both these arguments for backwards compatibility.
6
+ - Additionally, SCE's constructor takes kwargs for future proofing any additional attributes in the upstream classes.
7
+
8
+ ## Version 0.5.7
9
+
10
+ - Support reading outputs from CellRanger version 3 and later in `read_tenx_mtx`.
11
+ - Handle both `genes.csv` and `features.csv` for gene annotations.
12
+
3
13
  ## Version 0.5.6
4
14
 
5
- - Check if the column names of the alternative experiments match with the column names of the main experiment. This is the equivalent to the ``withDimnames`` parameter in the R implementation.
15
+ - Check if the column names of the alternative experiments match with the column names of the main experiment. This is the equivalent to the `withDimnames` parameter in the R implementation.
6
16
  - On **getters** of alternative experiments, if `with_dim_names` is True, column names of the alternative experiment are **replaced** with the
7
- column names of the main experiment.
17
+ column names of the main experiment.
8
18
  - On **setters** of alternative experiments, if `with_dim_names` is True, column names of the alternative experiment are **checked** with the
9
- column names of the main experiment and an Exception is raised if they do not match.
19
+ column names of the main experiment and an Exception is raised if they do not match.
10
20
 
11
21
  ## Version 0.5.1 - 0.5.5
12
22
 
@@ -15,7 +25,6 @@
15
25
  - Add getters and setters to replace a specific alternative experiment or reduced dimension.
16
26
  - Fixed an issue with numpy arrays as slice arguments. Code now uses Biocutils's subset functions to perform these operations.
17
27
 
18
-
19
28
  ## Version 0.5.0
20
29
 
21
30
  - chore: Remove Python 3.8 (EOL)
@@ -17,7 +17,7 @@ pip install singlecellexperiment
17
17
 
18
18
  ## Usage
19
19
 
20
- The `SingleCellExperiment` extends [RangeSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
20
+ The `SingleCellExperiment` extends [RangedSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
21
21
 
22
22
  - `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
23
23
  - `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
@@ -57,7 +57,7 @@ tse = SingleCellExperiment(
57
57
  )
58
58
  ```
59
59
 
60
- Since `SingleCellExperiment` extends `RangeSummarizedExperiment`, most methods especially slicing and accessors are applicable here.
60
+ Since `SingleCellExperiment` extends `RangedSummarizedExperiment`, most methods especially slicing and accessors are inherited from the parent classes.
61
61
  Checkout the [documentation](https://biocpy.github.io/SingleCellExperiment/) for more info.
62
62
 
63
63
  <!-- pyscaffold-notes -->
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: SingleCellExperiment
3
- Version: 0.5.6
3
+ Version: 0.5.8
4
4
  Summary: Container class for single-cell experiments
5
5
  Home-page: https://github.com/BiocPy/SingleCellExperiment
6
6
  Author: jkanche
@@ -58,7 +58,7 @@ pip install singlecellexperiment
58
58
 
59
59
  ## Usage
60
60
 
61
- The `SingleCellExperiment` extends [RangeSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
61
+ The `SingleCellExperiment` extends [RangedSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
62
62
 
63
63
  - `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
64
64
  - `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
@@ -98,7 +98,7 @@ tse = SingleCellExperiment(
98
98
  )
99
99
  ```
100
100
 
101
- Since `SingleCellExperiment` extends `RangeSummarizedExperiment`, most methods especially slicing and accessors are applicable here.
101
+ Since `SingleCellExperiment` extends `RangedSummarizedExperiment`, most methods especially slicing and accessors are inherited from the parent classes.
102
102
  Checkout the [documentation](https://biocpy.github.io/SingleCellExperiment/) for more info.
103
103
 
104
104
  <!-- pyscaffold-notes -->
@@ -46,4 +46,7 @@ tests/test_sce_methods.py
46
46
  tests/test_sce_slice.py
47
47
  tests/data/adata.h5ad
48
48
  tests/data/mocks.py
49
- tests/data/tenx.sub.h5
49
+ tests/data/tenx.sub.h5
50
+ tests/data/raw_feature_bc_matrix/barcodes.tsv
51
+ tests/data/raw_feature_bc_matrix/features.tsv
52
+ tests/data/raw_feature_bc_matrix/matrix.mtx
@@ -38,7 +38,7 @@ def _validate_reduced_dims(reduced_dims, shape):
38
38
  for rdname, mat in reduced_dims.items():
39
39
  if not hasattr(mat, "shape"):
40
40
  raise TypeError(
41
- f"Reduced dimension: '{rdname}' must be a matrix-like object." "Does not contain a `shape` property."
41
+ f"Reduced dimension: '{rdname}' must be a matrix-like object.Does not contain a `shape` property."
42
42
  )
43
43
 
44
44
  if shape[1] != mat.shape[0]:
@@ -60,7 +60,7 @@ def _validate_alternative_experiments(alternative_experiments, shape, column_nam
60
60
  )
61
61
 
62
62
  if shape[1] != alternative_experiment.shape[1]:
63
- raise ValueError(f"Alternative experiment: '{alt_name}' does not contain same number of" " cells.")
63
+ raise ValueError(f"Alternative experiment: '{alt_name}' does not contain same number of cells.")
64
64
 
65
65
  _alt_cnames = alternative_experiment.get_column_names()
66
66
  _alt_cnames = None if _alt_cnames is None else list(_alt_cnames)
@@ -94,7 +94,7 @@ class SingleCellExperiment(RangedSummarizedExperiment):
94
94
  parent experiment. Otherwise, these cells do not share the same sample or annotations
95
95
  and cannot be set in alternative experiments!
96
96
 
97
- Note: Validation checks do not apply to ``row_pairs`` or ``col_pairs``.
97
+ Note: Validation checks do not apply to ``row_pairs`` or ``column_pairs``.
98
98
  """
99
99
 
100
100
  def __init__(
@@ -106,13 +106,15 @@ class SingleCellExperiment(RangedSummarizedExperiment):
106
106
  row_names: Optional[List[str]] = None,
107
107
  column_names: Optional[List[str]] = None,
108
108
  metadata: Optional[dict] = None,
109
- reduced_dims: Optional[Dict[str, Any]] = None,
109
+ reduced_dimensions: Optional[Dict[str, Any]] = None,
110
+ reduced_dims: Optional[Dict[str, Any]] = None, # deprecated name
110
111
  main_experiment_name: Optional[str] = None,
111
112
  alternative_experiments: Optional[Dict[str, Any]] = None,
112
113
  row_pairs: Optional[Any] = None,
113
114
  column_pairs: Optional[Any] = None,
114
115
  alternative_experiment_check_dim_names: bool = True,
115
116
  validate: bool = True,
117
+ **kwargs,
116
118
  ) -> None:
117
119
  """Initialize a single-cell experiment.
118
120
 
@@ -157,7 +159,7 @@ class SingleCellExperiment(RangedSummarizedExperiment):
157
159
  Additional experimental metadata describing the methods.
158
160
  Defaults to None.
159
161
 
160
- reduced_dims:
162
+ reduced_dimensions:
161
163
  Slot for low-dimensionality embeddings.
162
164
 
163
165
  Usually a dictionary with the embedding method as keys (e.g., t-SNE, UMAP)
@@ -165,6 +167,9 @@ class SingleCellExperiment(RangedSummarizedExperiment):
165
167
 
166
168
  Embeddings may be represented as a matrix or a data frame, must contain a shape.
167
169
 
170
+ reduced_dims:
171
+ Will be deprecated in the future versions. Use py:attr:`~reduced_dimensions` instead.
172
+
168
173
  main_experiment_name:
169
174
  A string, specifying the main experiment name.
170
175
 
@@ -195,6 +200,9 @@ class SingleCellExperiment(RangedSummarizedExperiment):
195
200
 
196
201
  validate:
197
202
  Internal use only.
203
+
204
+ kwargs:
205
+ Additional arguments.
198
206
  """
199
207
 
200
208
  super().__init__(
@@ -206,10 +214,20 @@ class SingleCellExperiment(RangedSummarizedExperiment):
206
214
  column_names=column_names,
207
215
  metadata=metadata,
208
216
  validate=validate,
217
+ **kwargs,
209
218
  )
210
219
  self._main_experiment_name = main_experiment_name
211
220
 
212
- self._reduced_dims = reduced_dims if reduced_dims is not None else {}
221
+ _dims = None
222
+ if reduced_dimensions is not None and reduced_dims is not None:
223
+ raise ValueError("Either 'reduced_dims' or 'reduced_dimensions' should be provided, but not both.")
224
+ elif reduced_dims is not None:
225
+ warn("'reduced_dims' is deprecated, use 'reduced_dimensions' instead.", DeprecationWarning)
226
+ _dims = reduced_dims
227
+ elif reduced_dimensions is not None:
228
+ _dims = reduced_dimensions
229
+
230
+ self._reduced_dims = _dims if _dims is not None else {}
213
231
 
214
232
  self._alternative_experiments = alternative_experiments if alternative_experiments is not None else {}
215
233
 
@@ -551,6 +569,10 @@ class SingleCellExperiment(RangedSummarizedExperiment):
551
569
  """Alias for :py:meth:`~get_reduced_dimension`, for back-compatibility."""
552
570
  return self.get_reduced_dimension(name=name)
553
571
 
572
+ def reduced_dimension(self, name: Union[str, int]) -> Any:
573
+ """Alias for :py:meth:`~get_reduced_dimension`, for back-compatibility."""
574
+ return self.get_reduced_dimension(name=name)
575
+
554
576
  def set_reduced_dimension(self, name: str, embedding: Any, in_place: bool = False) -> "SingleCellExperiment":
555
577
  """Add or replace :py:attr:`~singlecellexperiment.SingleCellExperiment.reduced_dimension`'s.
556
578
 
@@ -1,11 +1,12 @@
1
+ import os
1
2
  from warnings import warn
2
3
 
3
4
  from biocframe import BiocFrame, from_pandas
4
5
 
5
6
  from ..SingleCellExperiment import SingleCellExperiment
6
7
 
7
- __author__ = "jkanche"
8
- __copyright__ = "jkanche"
8
+ __author__ = "jkanche, keviny2"
9
+ __copyright__ = "jkanche, keviny2"
9
10
  __license__ = "MIT"
10
11
 
11
12
 
@@ -17,8 +18,9 @@ def read_tenx_mtx(path: str) -> SingleCellExperiment:
17
18
  Path to 10X MTX directory.
18
19
 
19
20
  Directory must contain `matrix.mtx`, and optionally
20
- a `genes.tsv` to represent featires and `barcodes.tsv` for cell
21
- annotations.
21
+ `genes.tsv` (CellRanger version 2) or
22
+ `features.tsv` (CellRanger version 3 and later) to
23
+ represent features and `barcodes.tsv` for cell annotations.
22
24
 
23
25
  Returns:
24
26
  A single-cell experiment object.
@@ -31,7 +33,18 @@ def read_tenx_mtx(path: str) -> SingleCellExperiment:
31
33
  mat = mmread(f"{path}/matrix.mtx")
32
34
  mat = csr_matrix(mat)
33
35
 
34
- genes = pd.read_csv(path + "/genes.tsv", header=None, sep="\t")
36
+ features_path = path + "/features.tsv"
37
+ genes_path = path + "/genes.tsv"
38
+ if os.path.exists(features_path) and os.path.exists(genes_path):
39
+ warn(
40
+ "Both 'features.tsv' and 'genes.tsv' files are present in the directory. "
41
+ "Prioritizing 'features.tsv' for processing."
42
+ )
43
+
44
+ if os.path.exists(features_path):
45
+ genes = pd.read_csv(features_path, header=None, sep="\t", usecols=[0, 1])
46
+ else:
47
+ genes = pd.read_csv(genes_path, header=None, sep="\t")
35
48
  genes.columns = ["gene_ids", "gene_symbols"]
36
49
 
37
50
  cells = pd.read_csv(path + "/barcodes.tsv", header=None, sep="\t")
@@ -0,0 +1,50 @@
1
+ AAACAACGAATAGTTC-1
2
+ AAACAAGTATCTCCCA-1
3
+ AAACAATCTACTAGCA-1
4
+ AAACACCAATAACTGC-1
5
+ AAACAGAGCGACTCCT-1
6
+ AAACAGCTTTCAGAAG-1
7
+ AAACAGGGTCTATATT-1
8
+ AAACAGTGTTCCTGGG-1
9
+ AAACATGGTGAGAGGA-1
10
+ AAACATTTCCCGGATT-1
11
+ AAACCACTACACAGAT-1
12
+ AAACCCGAACGAAATC-1
13
+ AAACCGGAAATGTTAA-1
14
+ AAACCGGGTAGGTACC-1
15
+ AAACCGTTCGTCCAGG-1
16
+ AAACCTAAGCAGCCGG-1
17
+ AAACCTCATGAAGTTG-1
18
+ AAACGAAGAACATACC-1
19
+ AAACGAAGATGGAGTA-1
20
+ AAACGACAGTCTTGCC-1
21
+ AAACGAGACGGTTGAT-1
22
+ AAACGCCCGAGATCGG-1
23
+ AAACGCTGGGCACGAC-1
24
+ AAACGGGCGTACGGGT-1
25
+ AAACGGGTTGGTATCC-1
26
+ AAACGGTTGCGAACTG-1
27
+ AAACGTGTTCGCCCTA-1
28
+ AAACTAACGTGGCGAC-1
29
+ AAACTCGGTTCGCAAT-1
30
+ AAACTCGTGATATAAG-1
31
+ AAACTGCTGGCTCCAA-1
32
+ AAACTTAATTGCACGC-1
33
+ AAACTTGCAAACGTAT-1
34
+ AAAGAATGACCTTAGA-1
35
+ AAAGAATGTGGACTAA-1
36
+ AAAGACATGAAGTTTA-1
37
+ AAAGACCCAAGTCGCG-1
38
+ AAAGACTGGGCGCTTT-1
39
+ AAAGCTTGCCTACATA-1
40
+ AAAGGCCCTATAATAC-1
41
+ AAAGGCTACGGACCAT-1
42
+ AAAGGCTCTCGCGCCG-1
43
+ AAAGGGATGTAGCAAG-1
44
+ AAAGGGCAGCTTGAAT-1
45
+ AAAGGTAAGCTGTACC-1
46
+ AAAGGTCAACGACATG-1
47
+ AAAGTAGCATTGCTCA-1
48
+ AAAGTCACTGATGTAA-1
49
+ AAAGTCGACCCTCAGT-1
50
+ AAAGTGCCATCAATTA-1
@@ -0,0 +1,50 @@
1
+ ENSMUSG00000051951 Xkr4 Gene Expression
2
+ ENSMUSG00000089699 Gm1992 Gene Expression
3
+ ENSMUSG00000102343 Gm37381 Gene Expression
4
+ ENSMUSG00000025900 Rp1 Gene Expression
5
+ ENSMUSG00000025902 Sox17 Gene Expression
6
+ ENSMUSG00000104328 Gm37323 Gene Expression
7
+ ENSMUSG00000033845 Mrpl15 Gene Expression
8
+ ENSMUSG00000025903 Lypla1 Gene Expression
9
+ ENSMUSG00000104217 Gm37988 Gene Expression
10
+ ENSMUSG00000033813 Tcea1 Gene Expression
11
+ ENSMUSG00000002459 Rgs20 Gene Expression
12
+ ENSMUSG00000085623 Gm16041 Gene Expression
13
+ ENSMUSG00000033793 Atp6v1h Gene Expression
14
+ ENSMUSG00000025905 Oprk1 Gene Expression
15
+ ENSMUSG00000033774 Npbwr1 Gene Expression
16
+ ENSMUSG00000025907 Rb1cc1 Gene Expression
17
+ ENSMUSG00000090031 4732440D04Rik Gene Expression
18
+ ENSMUSG00000087247 Alkal1 Gene Expression
19
+ ENSMUSG00000033740 St18 Gene Expression
20
+ ENSMUSG00000051285 Pcmtd1 Gene Expression
21
+ ENSMUSG00000097797 Gm26901 Gene Expression
22
+ ENSMUSG00000103067 Gm30414 Gene Expression
23
+ ENSMUSG00000025909 Sntg1 Gene Expression
24
+ ENSMUSG00000061024 Rrs1 Gene Expression
25
+ ENSMUSG00000025911 Adhfe1 Gene Expression
26
+ ENSMUSG00000067879 3110035E14Rik Gene Expression
27
+ ENSMUSG00000099827 Gm29520 Gene Expression
28
+ ENSMUSG00000025912 Mybl1 Gene Expression
29
+ ENSMUSG00000045210 Vcpip1 Gene Expression
30
+ ENSMUSG00000097893 1700034P13Rik Gene Expression
31
+ ENSMUSG00000025915 Sgk3 Gene Expression
32
+ ENSMUSG00000046101 Mcmdc2 Gene Expression
33
+ ENSMUSG00000098234 Snhg6 Gene Expression
34
+ ENSMUSG00000099032 Tcf24 Gene Expression
35
+ ENSMUSG00000025916 Ppp1r42 Gene Expression
36
+ ENSMUSG00000087199 Gm15818 Gene Expression
37
+ ENSMUSG00000025917 Cops5 Gene Expression
38
+ ENSMUSG00000056763 Cspp1 Gene Expression
39
+ ENSMUSG00000067851 Arfgef1 Gene Expression
40
+ ENSMUSG00000042501 Cpa6 Gene Expression
41
+ ENSMUSG00000048960 Prex2 Gene Expression
42
+ ENSMUSG00000057715 A830018L16Rik Gene Expression
43
+ ENSMUSG00000097171 Gm17644 Gene Expression
44
+ ENSMUSG00000101314 Gm29663 Gene Expression
45
+ ENSMUSG00000016918 Sulf1 Gene Expression
46
+ ENSMUSG00000025938 Slco5a1 Gene Expression
47
+ ENSMUSG00000099498 Gm29283 Gene Expression
48
+ ENSMUSG00000042414 Prdm14 Gene Expression
49
+ ENSMUSG00000005886 Ncoa2 Gene Expression
50
+ ENSMUSG00000101476 Gm29570 Gene Expression
@@ -0,0 +1,340 @@
1
+ %%MatrixMarket matrix coordinate integer general
2
+ 50 50 338
3
+ 13 1 1
4
+ 16 1 1
5
+ 26 1 1
6
+ 29 1 1
7
+ 37 1 3
8
+ 38 1 1
9
+ 45 1 1
10
+ 7 2 1
11
+ 8 2 1
12
+ 10 2 2
13
+ 13 2 4
14
+ 16 2 1
15
+ 20 2 3
16
+ 24 2 1
17
+ 25 2 2
18
+ 33 2 1
19
+ 40 2 1
20
+ 41 2 2
21
+ 42 2 2
22
+ 49 2 1
23
+ 7 3 1
24
+ 8 3 1
25
+ 10 3 1
26
+ 13 3 2
27
+ 26 3 1
28
+ 33 3 1
29
+ 38 3 1
30
+ 41 3 2
31
+ 42 3 1
32
+ 10 4 2
33
+ 13 4 1
34
+ 16 4 2
35
+ 20 4 1
36
+ 24 4 1
37
+ 29 4 1
38
+ 33 4 2
39
+ 37 4 4
40
+ 38 4 1
41
+ 39 4 2
42
+ 41 4 2
43
+ 42 4 1
44
+ 13 5 6
45
+ 16 5 1
46
+ 20 5 1
47
+ 25 5 1
48
+ 26 5 3
49
+ 29 5 1
50
+ 33 5 3
51
+ 41 5 1
52
+ 42 5 1
53
+ 16 6 1
54
+ 10 7 1
55
+ 20 7 1
56
+ 25 7 2
57
+ 37 7 1
58
+ 41 7 1
59
+ 49 7 1
60
+ 13 8 1
61
+ 41 8 1
62
+ 29 9 1
63
+ 10 10 1
64
+ 26 10 2
65
+ 16 12 1
66
+ 7 14 2
67
+ 10 14 1
68
+ 16 14 4
69
+ 25 14 1
70
+ 33 14 4
71
+ 37 14 2
72
+ 41 14 1
73
+ 49 14 1
74
+ 7 15 2
75
+ 8 15 1
76
+ 10 15 1
77
+ 13 15 4
78
+ 16 15 1
79
+ 20 15 1
80
+ 25 15 1
81
+ 26 15 1
82
+ 28 15 2
83
+ 29 15 3
84
+ 31 15 1
85
+ 33 15 1
86
+ 37 15 2
87
+ 39 15 3
88
+ 13 16 2
89
+ 26 16 1
90
+ 5 17 1
91
+ 7 17 3
92
+ 8 17 3
93
+ 10 17 6
94
+ 11 17 3
95
+ 13 17 5
96
+ 14 17 2
97
+ 16 17 6
98
+ 20 17 3
99
+ 23 17 2
100
+ 25 17 1
101
+ 26 17 1
102
+ 29 17 2
103
+ 31 17 1
104
+ 32 17 1
105
+ 33 17 2
106
+ 37 17 8
107
+ 39 17 1
108
+ 41 17 1
109
+ 45 17 7
110
+ 1 18 1
111
+ 7 18 1
112
+ 10 18 2
113
+ 11 18 1
114
+ 13 18 6
115
+ 16 18 6
116
+ 20 18 3
117
+ 24 18 1
118
+ 26 18 4
119
+ 29 18 4
120
+ 31 18 1
121
+ 33 18 3
122
+ 37 18 1
123
+ 39 18 2
124
+ 45 18 1
125
+ 5 21 1
126
+ 7 21 4
127
+ 10 21 1
128
+ 11 21 3
129
+ 16 21 3
130
+ 19 21 1
131
+ 20 21 1
132
+ 23 21 1
133
+ 24 21 1
134
+ 26 21 2
135
+ 28 21 1
136
+ 29 21 2
137
+ 33 21 5
138
+ 37 21 2
139
+ 39 21 1
140
+ 42 21 1
141
+ 49 21 1
142
+ 29 22 1
143
+ 7 25 1
144
+ 10 25 1
145
+ 13 25 1
146
+ 16 25 1
147
+ 26 25 1
148
+ 8 26 1
149
+ 11 26 1
150
+ 13 26 1
151
+ 16 26 2
152
+ 23 26 1
153
+ 25 26 1
154
+ 26 26 1
155
+ 33 26 3
156
+ 37 26 3
157
+ 41 26 1
158
+ 42 26 2
159
+ 46 26 1
160
+ 26 27 2
161
+ 37 27 1
162
+ 41 27 1
163
+ 7 29 2
164
+ 8 29 1
165
+ 20 29 1
166
+ 38 29 1
167
+ 41 29 1
168
+ 42 29 1
169
+ 45 29 1
170
+ 1 31 1
171
+ 5 31 1
172
+ 7 31 1
173
+ 10 31 1
174
+ 13 31 1
175
+ 16 31 3
176
+ 19 31 1
177
+ 26 31 1
178
+ 29 31 1
179
+ 33 31 3
180
+ 38 31 1
181
+ 39 31 1
182
+ 41 31 2
183
+ 49 31 1
184
+ 7 32 1
185
+ 15 32 1
186
+ 16 32 1
187
+ 28 32 1
188
+ 33 32 1
189
+ 39 32 1
190
+ 45 32 2
191
+ 7 33 2
192
+ 8 33 1
193
+ 10 33 2
194
+ 11 33 1
195
+ 13 33 4
196
+ 14 33 2
197
+ 20 33 1
198
+ 24 33 1
199
+ 26 33 1
200
+ 29 33 1
201
+ 33 33 3
202
+ 39 33 1
203
+ 41 33 3
204
+ 45 33 2
205
+ 11 34 1
206
+ 16 34 1
207
+ 20 35 1
208
+ 16 36 1
209
+ 26 36 1
210
+ 5 37 1
211
+ 8 37 2
212
+ 10 37 3
213
+ 11 37 1
214
+ 13 37 8
215
+ 16 37 1
216
+ 20 37 3
217
+ 21 37 1
218
+ 25 37 1
219
+ 26 37 7
220
+ 29 37 2
221
+ 33 37 4
222
+ 37 37 3
223
+ 39 37 2
224
+ 41 37 1
225
+ 42 37 3
226
+ 49 37 2
227
+ 1 38 1
228
+ 13 38 2
229
+ 20 38 1
230
+ 29 38 1
231
+ 39 38 2
232
+ 7 40 4
233
+ 10 40 3
234
+ 13 40 6
235
+ 14 40 3
236
+ 16 40 2
237
+ 20 40 1
238
+ 24 40 1
239
+ 29 40 2
240
+ 33 40 1
241
+ 37 40 7
242
+ 38 40 1
243
+ 39 40 2
244
+ 42 40 1
245
+ 45 40 2
246
+ 49 40 2
247
+ 7 41 3
248
+ 10 41 2
249
+ 13 41 9
250
+ 14 41 1
251
+ 16 41 2
252
+ 20 41 1
253
+ 26 41 1
254
+ 29 41 3
255
+ 33 41 3
256
+ 37 41 6
257
+ 38 41 1
258
+ 39 41 4
259
+ 41 41 2
260
+ 42 41 1
261
+ 49 41 1
262
+ 8 42 1
263
+ 10 42 4
264
+ 13 42 1
265
+ 19 42 1
266
+ 20 42 1
267
+ 24 42 1
268
+ 25 42 1
269
+ 33 42 2
270
+ 37 42 2
271
+ 45 42 1
272
+ 8 43 1
273
+ 13 43 1
274
+ 16 43 1
275
+ 26 43 1
276
+ 31 43 1
277
+ 39 43 1
278
+ 45 43 1
279
+ 49 43 1
280
+ 1 44 1
281
+ 7 44 3
282
+ 10 44 4
283
+ 13 44 6
284
+ 16 44 1
285
+ 19 44 1
286
+ 20 44 3
287
+ 24 44 1
288
+ 26 44 6
289
+ 29 44 2
290
+ 32 44 1
291
+ 33 44 9
292
+ 37 44 4
293
+ 39 44 3
294
+ 41 44 1
295
+ 42 44 1
296
+ 49 44 1
297
+ 13 45 1
298
+ 37 45 1
299
+ 16 46 1
300
+ 10 47 2
301
+ 13 47 2
302
+ 16 47 1
303
+ 20 47 1
304
+ 24 47 1
305
+ 29 47 4
306
+ 31 47 2
307
+ 37 47 3
308
+ 39 47 1
309
+ 42 47 1
310
+ 49 47 1
311
+ 7 48 5
312
+ 8 48 1
313
+ 10 48 3
314
+ 11 48 1
315
+ 13 48 17
316
+ 16 48 5
317
+ 20 48 4
318
+ 23 48 1
319
+ 24 48 2
320
+ 26 48 19
321
+ 28 48 1
322
+ 29 48 2
323
+ 31 48 1
324
+ 33 48 4
325
+ 37 48 10
326
+ 39 48 3
327
+ 41 48 1
328
+ 42 48 3
329
+ 49 48 4
330
+ 5 49 1
331
+ 7 49 1
332
+ 8 49 1
333
+ 10 49 2
334
+ 11 49 1
335
+ 13 49 1
336
+ 14 49 1
337
+ 20 49 1
338
+ 33 49 2
339
+ 37 49 2
340
+ 39 49 1
@@ -172,3 +172,48 @@ def test_SCE_different_alt_names():
172
172
  column_data=pd.DataFrame(index = ["ChIP", "Input", "Input"] * 2),
173
173
  alternative_experiments={"alt": rse},
174
174
  )
175
+
176
+ def test_SCE_dims():
177
+ embeds = np.random.rand(counts.shape[1], 4)
178
+ tse = SingleCellExperiment(
179
+ assays={"counts": counts},
180
+ row_data=row_data,
181
+ column_data=col_data,
182
+ reduced_dimensions={
183
+ "something": embeds
184
+ }
185
+ )
186
+
187
+ assert tse is not None
188
+ assert isinstance(tse, sce)
189
+ assert tse.get_reduced_dimension_names() == ["something"]
190
+
191
+ tse2 = SingleCellExperiment(
192
+ assays={"counts": counts},
193
+ row_data=row_data,
194
+ column_data=col_data,
195
+ reduced_dims={
196
+ "something": embeds
197
+ }
198
+ )
199
+
200
+ assert tse2 is not None
201
+ assert isinstance(tse2, sce)
202
+ assert tse2.get_reduced_dimension_names() == ["something"]
203
+
204
+ print(tse.get_reduced_dimension("something"), tse2.get_reduced_dimension("something"))
205
+
206
+ assert np.allclose(tse.get_reduced_dimension("something"), tse2.get_reduced_dimension("something"))
207
+
208
+ with pytest.raises(Exception, match="Either 'reduced_dims' or 'reduced_dimensions' should be provided, but not both."):
209
+ SingleCellExperiment(
210
+ assays={"counts": counts},
211
+ row_data=row_data,
212
+ column_data=col_data,
213
+ reduced_dims={
214
+ "something": embeds
215
+ },
216
+ reduced_dimensions={
217
+ "something": embeds
218
+ }
219
+ )
@@ -12,8 +12,8 @@ import singlecellexperiment
12
12
  from singlecellexperiment.SingleCellExperiment import SingleCellExperiment
13
13
  from hdf5array import Hdf5CompressedSparseMatrix
14
14
 
15
- __author__ = "jkanche"
16
- __copyright__ = "jkanche"
15
+ __author__ = "jkanche, keviny2"
16
+ __copyright__ = "jkanche, keviny2"
17
17
  __license__ = "MIT"
18
18
 
19
19
 
@@ -90,6 +90,29 @@ def test_SCE_fromH5AD():
90
90
  assert sliced.shape == (10, 4)
91
91
 
92
92
 
93
+ def test_SCE_from10x_mtx():
94
+ tse = singlecellexperiment.read_tenx_mtx("tests/data/raw_feature_bc_matrix")
95
+
96
+ assert tse is not None
97
+ assert isinstance(tse, SingleCellExperiment)
98
+
99
+ assert tse.assays is not None
100
+ assert tse.row_data is not None
101
+ assert tse.col_data is not None
102
+
103
+ # slice
104
+ sliced = tse[0:10, 1:5]
105
+
106
+ assert sliced is not None
107
+ assert isinstance(sliced, SingleCellExperiment)
108
+
109
+ assert sliced.assays is not None
110
+ assert sliced.row_data is not None
111
+ assert sliced.col_data is not None
112
+
113
+ assert sliced.shape == (10, 4)
114
+
115
+
93
116
  def test_SCE_from10xH5():
94
117
  tse = singlecellexperiment.read_tenx_h5("tests/data/tenx.sub.h5")
95
118