SingleCellExperiment 0.4.5__tar.gz → 0.4.7__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.
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/.pre-commit-config.yaml +2 -2
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/CHANGELOG.md +11 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/PKG-INFO +26 -11
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/README.md +12 -5
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/changelog.md +11 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/conf.py +10 -5
- singlecellexperiment-0.4.7/docs/index.md +37 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/readme.md +12 -5
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/requirements.txt +2 -0
- singlecellexperiment-0.4.7/docs/tutorial.md +331 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/setup.cfg +13 -5
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/SingleCellExperiment.egg-info/PKG-INFO +26 -11
- singlecellexperiment-0.4.7/src/SingleCellExperiment.egg-info/requires.txt +37 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/io/tenx.py +9 -1
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/test_sce_io.py +8 -0
- singlecellexperiment-0.4.5/docs/index.md +0 -37
- singlecellexperiment-0.4.5/docs/tutorial.md +0 -116
- singlecellexperiment-0.4.5/src/SingleCellExperiment.egg-info/requires.txt +0 -21
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/.coveragerc +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/.github/workflows/pypi-publish.yml +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/.github/workflows/pypi-test.yml +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/.gitignore +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/.readthedocs.yml +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/AUTHORS.md +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/CONTRIBUTING.md +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/LICENSE.txt +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/Makefile +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/_static/.gitignore +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/authors.md +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/contributing.md +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/docs/license.md +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/pyproject.toml +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/setup.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/SingleCellExperiment.egg-info/SOURCES.txt +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/SingleCellExperiment.egg-info/dependency_links.txt +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/SingleCellExperiment.egg-info/not-zip-safe +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/SingleCellExperiment.egg-info/top_level.txt +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/SingleCellExperiment.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/__init__.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/_combineutils.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/_ioutils.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/io/__init__.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/io/h5ad.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/conftest.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/data/adata.h5ad +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/data/mocks.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/data/tenx.sub.h5 +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/test_sce.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/test_sce_combine_cols.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/test_sce_combine_rows.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/test_sce_methods.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tests/test_sce_slice.py +0 -0
- {singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/tox.ini +0 -0
|
@@ -26,14 +26,14 @@ repos:
|
|
|
26
26
|
# --config, ./pyproject.toml
|
|
27
27
|
|
|
28
28
|
- repo: https://github.com/psf/black
|
|
29
|
-
rev: 24.4.
|
|
29
|
+
rev: 24.4.2
|
|
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.
|
|
36
|
+
rev: v0.5.0
|
|
37
37
|
hooks:
|
|
38
38
|
- id: ruff
|
|
39
39
|
args: [--fix, --exit-non-zero-on-fix]
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 0.4.7
|
|
4
|
+
|
|
5
|
+
- Fix package version issues to support Python<=3.9. Mostly related to how anndata dependencies are versioned in the MuData package discussed [here](https://github.com/scverse/mudata/issues/82).
|
|
6
|
+
- The package now enforces the versions of mudata, anndata and numpy that are compatible with each other.
|
|
7
|
+
|
|
8
|
+
## Version 0.4.2 - 0.4.6
|
|
9
|
+
|
|
10
|
+
- Fix issue coercing `SummarizedExperiments` to `AnnData` objects and vice-versa.
|
|
11
|
+
- Handling coercions when matrices are delayed arrays or backed (for `AnnData`).
|
|
12
|
+
- Update sphinx configuration to run snippets in the documentation.
|
|
13
|
+
|
|
3
14
|
## Version 0.4.0 to 0.4.1
|
|
4
15
|
|
|
5
16
|
This is a complete rewrite of the package, following the functional paradigm from our [developer notes](https://github.com/BiocPy/developer_guide#use-functional-discipline).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: SingleCellExperiment
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.7
|
|
4
4
|
Summary: Container class for single-cell experiments
|
|
5
5
|
Home-page: https://github.com/BiocPy/SingleCellExperiment
|
|
6
6
|
Author: jkanche
|
|
@@ -14,22 +14,30 @@ Requires-Python: >=3.8
|
|
|
14
14
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
15
15
|
License-File: LICENSE.txt
|
|
16
16
|
Requires-Dist: importlib-metadata; python_version < "3.8"
|
|
17
|
-
Requires-Dist: summarizedexperiment
|
|
17
|
+
Requires-Dist: summarizedexperiment>=0.4.5
|
|
18
18
|
Provides-Extra: optional
|
|
19
|
-
Requires-Dist: anndata; extra == "optional"
|
|
19
|
+
Requires-Dist: anndata==0.9.2; python_version <= "3.9" and extra == "optional"
|
|
20
|
+
Requires-Dist: anndata>0.9.2; python_version > "3.9" and extra == "optional"
|
|
20
21
|
Requires-Dist: h5py; extra == "optional"
|
|
21
|
-
Requires-Dist: mudata; extra == "optional"
|
|
22
|
+
Requires-Dist: mudata==0.2.3; python_version <= "3.9" and extra == "optional"
|
|
23
|
+
Requires-Dist: mudata>0.2.3; python_version > "3.9" and extra == "optional"
|
|
22
24
|
Requires-Dist: delayedarray; extra == "optional"
|
|
23
25
|
Requires-Dist: hdf5array; extra == "optional"
|
|
26
|
+
Requires-Dist: numpy==1.24.4; python_version <= "3.9" and extra == "optional"
|
|
27
|
+
Requires-Dist: numpy>1.24.4; python_version > "3.9" and extra == "optional"
|
|
24
28
|
Provides-Extra: testing
|
|
25
29
|
Requires-Dist: setuptools; extra == "testing"
|
|
26
30
|
Requires-Dist: pytest; extra == "testing"
|
|
27
31
|
Requires-Dist: pytest-cov; extra == "testing"
|
|
28
|
-
Requires-Dist: anndata; extra == "testing"
|
|
32
|
+
Requires-Dist: anndata==0.9.2; python_version <= "3.9" and extra == "testing"
|
|
33
|
+
Requires-Dist: anndata>0.9.2; python_version > "3.9" and extra == "testing"
|
|
29
34
|
Requires-Dist: h5py; extra == "testing"
|
|
30
|
-
Requires-Dist: mudata; extra == "testing"
|
|
35
|
+
Requires-Dist: mudata==0.2.3; python_version <= "3.9" and extra == "testing"
|
|
36
|
+
Requires-Dist: mudata>0.2.3; python_version > "3.9" and extra == "testing"
|
|
31
37
|
Requires-Dist: delayedarray; extra == "testing"
|
|
32
38
|
Requires-Dist: hdf5array; extra == "testing"
|
|
39
|
+
Requires-Dist: numpy==1.24.4; python_version <= "3.9" and extra == "testing"
|
|
40
|
+
Requires-Dist: numpy>1.24.4; python_version > "3.9" and extra == "testing"
|
|
33
41
|
|
|
34
42
|
[](https://pyscaffold.org/)
|
|
35
43
|
[](https://pypi.org/project/SingleCellExperiment/)
|
|
@@ -37,20 +45,26 @@ Requires-Dist: hdf5array; extra == "testing"
|
|
|
37
45
|
|
|
38
46
|
# SingleCellExperiment
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
This package provides container class to represent single-cell experimental data as 2-dimensional matrices. In these matrices, the rows typically denote features or genomic regions of interest, while columns represent cells. In addition, a `SingleCellExperiment` (SCE) object may contain low-dimensionality embeddings, alternative experiments performed on same sample or set of cells. Follows Bioconductor's [SingleCellExperiment](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html).
|
|
41
49
|
|
|
42
50
|
|
|
43
51
|
## Install
|
|
44
52
|
|
|
45
|
-
|
|
53
|
+
To get started, install the package from [PyPI](https://pypi.org/project/singlecellexperiment/)
|
|
46
54
|
|
|
47
|
-
```
|
|
55
|
+
```bash
|
|
48
56
|
pip install singlecellexperiment
|
|
49
57
|
```
|
|
50
58
|
|
|
51
59
|
## Usage
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
The `SingleCellExperiment` extends [RangeSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
|
|
62
|
+
|
|
63
|
+
- `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
|
|
64
|
+
- `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
|
|
65
|
+
- `row_pairs` or `column_pairs`: Stores relationships between features or cells.
|
|
66
|
+
|
|
67
|
+
Readers are available to parse h5ad or `AnnData` objects to SCE:
|
|
54
68
|
|
|
55
69
|
```python
|
|
56
70
|
import singlecellexperiment
|
|
@@ -84,7 +98,8 @@ tse = SingleCellExperiment(
|
|
|
84
98
|
)
|
|
85
99
|
```
|
|
86
100
|
|
|
87
|
-
Since `SingleCellExperiment` extends `
|
|
101
|
+
Since `SingleCellExperiment` extends `RangeSummarizedExperiment`, most methods especially slicing and accessors are applicable here.
|
|
102
|
+
Checkout the [documentation](https://biocpy.github.io/SingleCellExperiment/) for more info.
|
|
88
103
|
|
|
89
104
|
<!-- pyscaffold-notes -->
|
|
90
105
|
|
|
@@ -4,20 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
# SingleCellExperiment
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This package provides container class to represent single-cell experimental data as 2-dimensional matrices. In these matrices, the rows typically denote features or genomic regions of interest, while columns represent cells. In addition, a `SingleCellExperiment` (SCE) object may contain low-dimensionality embeddings, alternative experiments performed on same sample or set of cells. Follows Bioconductor's [SingleCellExperiment](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html).
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
To get started, install the package from [PyPI](https://pypi.org/project/singlecellexperiment/)
|
|
13
13
|
|
|
14
|
-
```
|
|
14
|
+
```bash
|
|
15
15
|
pip install singlecellexperiment
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
The `SingleCellExperiment` extends [RangeSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
|
|
21
|
+
|
|
22
|
+
- `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
|
|
23
|
+
- `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
|
|
24
|
+
- `row_pairs` or `column_pairs`: Stores relationships between features or cells.
|
|
25
|
+
|
|
26
|
+
Readers are available to parse h5ad or `AnnData` objects to SCE:
|
|
21
27
|
|
|
22
28
|
```python
|
|
23
29
|
import singlecellexperiment
|
|
@@ -51,7 +57,8 @@ tse = SingleCellExperiment(
|
|
|
51
57
|
)
|
|
52
58
|
```
|
|
53
59
|
|
|
54
|
-
Since `SingleCellExperiment` extends `
|
|
60
|
+
Since `SingleCellExperiment` extends `RangeSummarizedExperiment`, most methods especially slicing and accessors are applicable here.
|
|
61
|
+
Checkout the [documentation](https://biocpy.github.io/SingleCellExperiment/) for more info.
|
|
55
62
|
|
|
56
63
|
<!-- pyscaffold-notes -->
|
|
57
64
|
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 0.4.7
|
|
4
|
+
|
|
5
|
+
- Fix package version issues to support Python<=3.9. Mostly related to how anndata dependencies are versioned in the MuData package discussed [here](https://github.com/scverse/mudata/issues/82).
|
|
6
|
+
- The package now enforces the versions of mudata, anndata and numpy that are compatible with each other.
|
|
7
|
+
|
|
8
|
+
## Version 0.4.2 - 0.4.6
|
|
9
|
+
|
|
10
|
+
- Fix issue coercing `SummarizedExperiments` to `AnnData` objects and vice-versa.
|
|
11
|
+
- Handling coercions when matrices are delayed arrays or backed (for `AnnData`).
|
|
12
|
+
- Update sphinx configuration to run snippets in the documentation.
|
|
13
|
+
|
|
3
14
|
## Version 0.4.0 to 0.4.1
|
|
4
15
|
|
|
5
16
|
This is a complete rewrite of the package, following the functional paradigm from our [developer notes](https://github.com/BiocPy/developer_guide#use-functional-discipline).
|
|
@@ -72,6 +72,7 @@ extensions = [
|
|
|
72
72
|
"sphinx.ext.ifconfig",
|
|
73
73
|
"sphinx.ext.mathjax",
|
|
74
74
|
"sphinx.ext.napoleon",
|
|
75
|
+
"sphinx_autodoc_typehints",
|
|
75
76
|
]
|
|
76
77
|
|
|
77
78
|
# Add any paths that contain templates here, relative to this directory.
|
|
@@ -79,7 +80,8 @@ templates_path = ["_templates"]
|
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
# Enable markdown
|
|
82
|
-
extensions.append("myst_parser")
|
|
83
|
+
# extensions.append("myst_parser")
|
|
84
|
+
extensions.append("myst_nb")
|
|
83
85
|
|
|
84
86
|
# Configure MyST-Parser
|
|
85
87
|
myst_enable_extensions = [
|
|
@@ -167,9 +169,11 @@ pygments_style = "sphinx"
|
|
|
167
169
|
todo_emit_warnings = True
|
|
168
170
|
|
|
169
171
|
autodoc_default_options = {
|
|
170
|
-
'
|
|
171
|
-
'
|
|
172
|
-
|
|
172
|
+
# 'members': 'var1, var2',
|
|
173
|
+
# 'member-order': 'bysource',
|
|
174
|
+
"special-members": True,
|
|
175
|
+
"undoc-members": True,
|
|
176
|
+
"exclude-members": "__weakref__, __dict__, __str__, __module__",
|
|
173
177
|
}
|
|
174
178
|
|
|
175
179
|
autosummary_generate = True
|
|
@@ -309,7 +313,8 @@ intersphinx_mapping = {
|
|
|
309
313
|
"pyscaffold": ("https://pyscaffold.org/en/stable", None),
|
|
310
314
|
"biocframe": ("https://biocpy.github.io/BiocFrame", None),
|
|
311
315
|
"genomicranges": ("https://biocpy.github.io/GenomicRanges", None),
|
|
312
|
-
"
|
|
316
|
+
"summarizedexperiment": ("https://biocpy.github.io/SummarizedExperiment", None),
|
|
317
|
+
"biocutils": ("https://biocpy.github.io/BiocUtils", None),
|
|
313
318
|
}
|
|
314
319
|
|
|
315
320
|
print(f"loading configurations for {project} {version} ...", file=sys.stderr)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# SingleCellExperiment
|
|
2
|
+
|
|
3
|
+
This package provides container class to represent single-cell experimental data as 2-dimensional matrices. In these matrices, the rows typically denote features or genomic regions of interest, while columns represent cells. In addition, a `SingleCellExperiment` (SCE) object may contain low-dimensionality embeddings, alternative experiments performed on same sample or set of cells. Follows Bioconductor's [SingleCellExperiment](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html).
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Install
|
|
7
|
+
|
|
8
|
+
To get started, install the package from [PyPI](https://pypi.org/project/singlecellexperiment/)
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install singlecellexperiment
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Contents
|
|
15
|
+
|
|
16
|
+
```{toctree}
|
|
17
|
+
:maxdepth: 2
|
|
18
|
+
|
|
19
|
+
Overview <tutorial>
|
|
20
|
+
Module Reference <api/modules>
|
|
21
|
+
Contributions & Help <contributing>
|
|
22
|
+
License <license>
|
|
23
|
+
Authors <authors>
|
|
24
|
+
Changelog <changelog>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Indices and tables
|
|
29
|
+
|
|
30
|
+
- {ref}`genindex`
|
|
31
|
+
- {ref}`modindex`
|
|
32
|
+
- {ref}`search`
|
|
33
|
+
|
|
34
|
+
[Sphinx]: http://www.sphinx-doc.org/
|
|
35
|
+
[Markdown]: https://daringfireball.net/projects/markdown/
|
|
36
|
+
[reStructuredText]: http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
|
|
37
|
+
[MyST]: https://myst-parser.readthedocs.io/en/latest/
|
|
@@ -4,20 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
# SingleCellExperiment
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This package provides container class to represent single-cell experimental data as 2-dimensional matrices. In these matrices, the rows typically denote features or genomic regions of interest, while columns represent cells. In addition, a `SingleCellExperiment` (SCE) object may contain low-dimensionality embeddings, alternative experiments performed on same sample or set of cells. Follows Bioconductor's [SingleCellExperiment](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html).
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
To get started, install the package from [PyPI](https://pypi.org/project/singlecellexperiment/)
|
|
13
13
|
|
|
14
|
-
```
|
|
14
|
+
```bash
|
|
15
15
|
pip install singlecellexperiment
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
The `SingleCellExperiment` extends [RangeSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
|
|
21
|
+
|
|
22
|
+
- `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
|
|
23
|
+
- `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
|
|
24
|
+
- `row_pairs` or `column_pairs`: Stores relationships between features or cells.
|
|
25
|
+
|
|
26
|
+
Readers are available to parse h5ad or `AnnData` objects to SCE:
|
|
21
27
|
|
|
22
28
|
```python
|
|
23
29
|
import singlecellexperiment
|
|
@@ -51,7 +57,8 @@ tse = SingleCellExperiment(
|
|
|
51
57
|
)
|
|
52
58
|
```
|
|
53
59
|
|
|
54
|
-
Since `SingleCellExperiment` extends `
|
|
60
|
+
Since `SingleCellExperiment` extends `RangeSummarizedExperiment`, most methods especially slicing and accessors are applicable here.
|
|
61
|
+
Checkout the [documentation](https://biocpy.github.io/SingleCellExperiment/) for more info.
|
|
55
62
|
|
|
56
63
|
<!-- pyscaffold-notes -->
|
|
57
64
|
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
furo
|
|
2
|
+
myst-nb
|
|
2
3
|
# Requirements file for ReadTheDocs, check .readthedocs.yml.
|
|
3
4
|
# To build the module reference correctly, make sure every external package
|
|
4
5
|
# under `install_requires` in `setup.cfg` is also listed here!
|
|
5
6
|
# sphinx_rtd_theme
|
|
6
7
|
myst-parser[linkify]
|
|
7
8
|
sphinx>=3.2.1
|
|
9
|
+
sphinx-autodoc-typehints
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
---
|
|
2
|
+
file_format: mystnb
|
|
3
|
+
kernelspec:
|
|
4
|
+
name: python
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Represent single-cell experiments
|
|
8
|
+
|
|
9
|
+
This package provides container class to represent single-cell experimental data as 2-dimensional matrices. In these matrices, the rows typically denote features or genomic regions of interest, while columns represent cells. In addition, a `SingleCellExperiment` (SCE) object may contain low-dimensionality embeddings, alternative experiments performed on same sample or set of cells.
|
|
10
|
+
|
|
11
|
+
:::{important}
|
|
12
|
+
The design of `SingleCellExperiment` class and its derivates adheres to the R/Bioconductor specification, where rows correspond to features, and columns represent cells.
|
|
13
|
+
:::
|
|
14
|
+
|
|
15
|
+
:::{note}
|
|
16
|
+
These classes follow a functional paradigm for accessing or setting properties, with further details discussed in [functional paradigm](https://biocpy.github.io/tutorial/chapters/philosophy.html#functional-discipline) section.
|
|
17
|
+
:::
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
To get started, install the package from [PyPI](https://pypi.org/project/singlecellexperiment/)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install singlecellexperiment
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Construction
|
|
28
|
+
|
|
29
|
+
The `SingleCellExperiment` extends `RangeSummarizedExperiment` and contains additional attributes:
|
|
30
|
+
|
|
31
|
+
- `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
|
|
32
|
+
- `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
|
|
33
|
+
- `row_pairs` or `column_pairs`: Stores relationships between features or cells.
|
|
34
|
+
|
|
35
|
+
:::{note}
|
|
36
|
+
In contrast to R, matrices in Python are unnamed and do not contain row or column names. Hence, these matrices cannot be directly used as values in assays or alternative experiments. We strictly enforce type checks in these cases. To relax these restrictions for alternative experiments, set `type_check_alternative_experiments` to `False`.
|
|
37
|
+
:::
|
|
38
|
+
|
|
39
|
+
:::{important}
|
|
40
|
+
If you are using the `alternative_experiments` slot, the number of cells must match the parent experiment. Otherwise, the expectation is that the cells do not share the same sample or annotations and cannot be set in alternative experiments!
|
|
41
|
+
:::
|
|
42
|
+
|
|
43
|
+
Before we construct a `SingleCellExperiment` object, lets generate information about rows, columns and a mock experimental data from single-cell rna-seq experiments:
|
|
44
|
+
|
|
45
|
+
```{code-cell}
|
|
46
|
+
|
|
47
|
+
import pandas as pd
|
|
48
|
+
import numpy as np
|
|
49
|
+
from scipy import sparse as sp
|
|
50
|
+
from biocframe import BiocFrame
|
|
51
|
+
from genomicranges import GenomicRanges
|
|
52
|
+
from random import random
|
|
53
|
+
|
|
54
|
+
nrows = 200
|
|
55
|
+
ncols = 6
|
|
56
|
+
counts = sp.rand(nrows, ncols, density=0.2, format="csr")
|
|
57
|
+
row_data = BiocFrame(
|
|
58
|
+
{
|
|
59
|
+
"seqnames": [
|
|
60
|
+
"chr1",
|
|
61
|
+
"chr2",
|
|
62
|
+
"chr2",
|
|
63
|
+
"chr2",
|
|
64
|
+
"chr1",
|
|
65
|
+
"chr1",
|
|
66
|
+
"chr3",
|
|
67
|
+
"chr3",
|
|
68
|
+
"chr3",
|
|
69
|
+
"chr3",
|
|
70
|
+
]
|
|
71
|
+
* 20,
|
|
72
|
+
"starts": range(100, 300),
|
|
73
|
+
"ends": range(110, 310),
|
|
74
|
+
"strand": ["-", "+", "+", "*", "*", "+", "+", "+", "-", "-"] * 20,
|
|
75
|
+
"score": range(0, 200),
|
|
76
|
+
"GC": [random() for _ in range(10)] * 20,
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
col_data = pd.DataFrame(
|
|
81
|
+
{
|
|
82
|
+
"celltype": ["cluster1", "cluster2"] * 3,
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Now lets create the `SingleCellExperiment` instance:
|
|
88
|
+
|
|
89
|
+
```{code-cell}
|
|
90
|
+
from singlecellexperiment import SingleCellExperiment
|
|
91
|
+
|
|
92
|
+
sce = SingleCellExperiment(
|
|
93
|
+
assays={"counts": counts}, row_data=row_data, column_data=col_data,
|
|
94
|
+
reduced_dims = {"random_embeds": np.random.rand(ncols, 4)}
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
print(sce)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
:::{tip}
|
|
102
|
+
You can also use delayed or file-backed arrays for representing experimental data, check out [this section](./summarized_experiment.qmd#delayed-or-file-backed-arrays) from summarized experiment.
|
|
103
|
+
:::
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
### Interop with `anndata`
|
|
107
|
+
|
|
108
|
+
We provide convenient methods for loading an `AnnData` or `h5ad` file into `SingleCellExperiment` objects.
|
|
109
|
+
|
|
110
|
+
For example, lets create an `AnnData` object,
|
|
111
|
+
|
|
112
|
+
```{code-cell}
|
|
113
|
+
import anndata as ad
|
|
114
|
+
from scipy import sparse as sp
|
|
115
|
+
|
|
116
|
+
counts = sp.csr_matrix(np.random.poisson(1, size=(100, 2000)), dtype=np.float32)
|
|
117
|
+
adata = ad.AnnData(counts)
|
|
118
|
+
print(adata)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Converting `AnnData` as `SingleCellExperiment` is straightforward:
|
|
122
|
+
|
|
123
|
+
```{code-cell}
|
|
124
|
+
sce_adata = SingleCellExperiment.from_anndata(adata)
|
|
125
|
+
print(sce_adata)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
and vice-verse. All assays from SCE are represented in the `layers` slot of the `AnnData` object:
|
|
130
|
+
|
|
131
|
+
```{code-cell}
|
|
132
|
+
adata2 = sce_adata.to_anndata()
|
|
133
|
+
print(adata2)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Similarly, one can load a h5ad file:
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
```python
|
|
140
|
+
from singlecellexperiment import read_h5ad
|
|
141
|
+
sce_h5 = read_h5ad("../../assets/data/adata.h5ad")
|
|
142
|
+
print(sce_h5)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### From 10X formats
|
|
146
|
+
|
|
147
|
+
In addition, we also provide convenient methods to load a [10X Genomics HDF5 Feature-Barcode Matrix Format](https://www.10xgenomics.com/support/software/cell-ranger/latest/analysis/outputs/cr-outputs-h5-matrices) file.
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from singlecellexperiment import read_tenx_h5
|
|
151
|
+
sce_h5 = read_tenx_h5("../../assets/data/tenx.sub.h5")
|
|
152
|
+
print(sce_h5)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
:::{note}
|
|
156
|
+
Methods are also available to read a 10x matrix market directory using the `read_tenx_mtx` function.
|
|
157
|
+
:::
|
|
158
|
+
|
|
159
|
+
## Getters/Setters
|
|
160
|
+
|
|
161
|
+
Getters are available to access various attributes using either the property notation or functional style.
|
|
162
|
+
|
|
163
|
+
Since `SingleCellExperiment` extends `RangedSummarizedExperiment`, all getters and setters from the base class are accessible here; more details [here](./summarized_experiment.qmd).
|
|
164
|
+
|
|
165
|
+
```{code-cell}
|
|
166
|
+
# access assay names
|
|
167
|
+
print("reduced dim names (as property): ", sce.reduced_dim_names)
|
|
168
|
+
print("reduced dim names (functional style): ", sce.get_reduced_dim_names())
|
|
169
|
+
|
|
170
|
+
# access row data
|
|
171
|
+
print(sce.row_data)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
#### Access a reduced dimension
|
|
175
|
+
|
|
176
|
+
One can access an reduced dimension by index or name:
|
|
177
|
+
|
|
178
|
+
```{code-cell}
|
|
179
|
+
sce.reduced_dim(0) # same as se.reduced_dim("random_embeds")
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Subset experiments
|
|
183
|
+
|
|
184
|
+
You can subset experimental data by using the subset (`[]`) operator. This operation accepts different slice input types, such as a boolean vector, a `slice` object, a list of indices, or names (if available) to subset.
|
|
185
|
+
|
|
186
|
+
In our previous example, we didn't include row or column names. Let's create another `SingleCellExperiment` object that includes names.
|
|
187
|
+
|
|
188
|
+
```{code-cell}
|
|
189
|
+
subset_sce = sce[0:10, 0:3]
|
|
190
|
+
print(subset_sce)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
## Combining experiments
|
|
195
|
+
|
|
196
|
+
`SingleCellExperiment` implements methods for the `combine` generic from [**BiocUtils**](https://github.com/BiocPy/biocutils).
|
|
197
|
+
|
|
198
|
+
These methods enable the merging or combining of multiple `SingleCellExperiment` objects, allowing users to aggregate data from different experiments or conditions. Note: `row_pairs` and `column_pairs` are not ignored as part of this operation.
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
To demonstrate, let's create multiple `SingleCellExperiment` objects (read more about this in [combine section from `SummarizedExperiment`](./summarized_experiment.qmd#combining-experiments)).
|
|
202
|
+
|
|
203
|
+
```{code-cell}
|
|
204
|
+
|
|
205
|
+
ncols = 10
|
|
206
|
+
nrows = 100
|
|
207
|
+
sce1 = SingleCellExperiment(
|
|
208
|
+
assays={"counts": np.random.poisson(lam=10, size=(nrows, ncols))},
|
|
209
|
+
row_data=BiocFrame({"A": [1] * nrows}),
|
|
210
|
+
column_data=BiocFrame({"A": [1] * ncols}),
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
sce2 = SingleCellExperiment(
|
|
214
|
+
assays={
|
|
215
|
+
"counts": np.random.poisson(lam=10, size=(nrows, ncols)),
|
|
216
|
+
# "normalized": np.random.normal(size=(nrows, ncols)),
|
|
217
|
+
},
|
|
218
|
+
row_data=BiocFrame({"A": [3] * nrows}),
|
|
219
|
+
column_data=BiocFrame({"A": [3] * ncols}),
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
rowdata1 = pd.DataFrame(
|
|
223
|
+
{
|
|
224
|
+
"seqnames": ["chr_5", "chr_3", "chr_2"],
|
|
225
|
+
"start": [500, 300, 200],
|
|
226
|
+
"end": [510, 310, 210],
|
|
227
|
+
},
|
|
228
|
+
index=["HER2", "BRCA1", "TPFK"],
|
|
229
|
+
)
|
|
230
|
+
coldata1 = pd.DataFrame(
|
|
231
|
+
{
|
|
232
|
+
"sample": ["SAM_1", "SAM_2", "SAM_3"],
|
|
233
|
+
"disease": ["True", "True", "True"],
|
|
234
|
+
"doublet_score": [0.15, 0.62, 0.18],
|
|
235
|
+
},
|
|
236
|
+
index=["cell_1", "cell_2", "cell_3"],
|
|
237
|
+
)
|
|
238
|
+
sce_alts1 = SingleCellExperiment(
|
|
239
|
+
assays={
|
|
240
|
+
"counts": np.random.poisson(lam=5, size=(3, 3)),
|
|
241
|
+
"lognorm": np.random.lognormal(size=(3, 3)),
|
|
242
|
+
},
|
|
243
|
+
row_data=rowdata1,
|
|
244
|
+
column_data=coldata1,
|
|
245
|
+
row_names=["HER2", "BRCA1", "TPFK"],
|
|
246
|
+
column_names=["cell_1", "cell_2", "cell_3"],
|
|
247
|
+
metadata={"seq_type": "paired"},
|
|
248
|
+
reduced_dims={"PCA": np.random.poisson(lam=10, size=(3, 5))},
|
|
249
|
+
alternative_experiments={
|
|
250
|
+
"modality1": SingleCellExperiment(
|
|
251
|
+
assays={"counts2": np.random.poisson(lam=10, size=(3, 3))},
|
|
252
|
+
)
|
|
253
|
+
},
|
|
254
|
+
)
|
|
255
|
+
|
|
256
|
+
rowdata2 = pd.DataFrame(
|
|
257
|
+
{
|
|
258
|
+
"seqnames": ["chr_5", "chr_3", "chr_2"],
|
|
259
|
+
"start": [500, 300, 200],
|
|
260
|
+
"end": [510, 310, 210],
|
|
261
|
+
},
|
|
262
|
+
index=["HER2", "BRCA1", "TPFK"],
|
|
263
|
+
)
|
|
264
|
+
coldata2 = pd.DataFrame(
|
|
265
|
+
{
|
|
266
|
+
"sample": ["SAM_4", "SAM_5", "SAM_6"],
|
|
267
|
+
"disease": ["True", "False", "True"],
|
|
268
|
+
"doublet_score": [0.05, 0.23, 0.54],
|
|
269
|
+
},
|
|
270
|
+
index=["cell_4", "cell_5", "cell_6"],
|
|
271
|
+
)
|
|
272
|
+
sce_alts2 = SingleCellExperiment(
|
|
273
|
+
assays={
|
|
274
|
+
"counts": np.random.poisson(lam=5, size=(3, 3)),
|
|
275
|
+
# "lognorm": np.random.lognormal(size=(3, 3)),
|
|
276
|
+
},
|
|
277
|
+
row_data=rowdata2,
|
|
278
|
+
column_data=coldata2,
|
|
279
|
+
metadata={"seq_platform": "Illumina NovaSeq 6000"},
|
|
280
|
+
reduced_dims={"PCA": np.random.poisson(lam=5, size=(3, 5))},
|
|
281
|
+
alternative_experiments={
|
|
282
|
+
"modality1": SingleCellExperiment(
|
|
283
|
+
assays={"counts2": np.random.poisson(lam=5, size=(3, 3))},
|
|
284
|
+
)
|
|
285
|
+
},
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
The `combine_rows` or `combine_columns` operations, expect all experiments to contain the same assay names. To combine experiments by row:
|
|
291
|
+
|
|
292
|
+
```{code-cell}
|
|
293
|
+
from biocutils import relaxed_combine_columns, combine_columns, combine_rows, relaxed_combine_rows
|
|
294
|
+
sce_combined = combine_rows(sce2, sce1)
|
|
295
|
+
print(sce_combined)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Similarly to combine by column:
|
|
299
|
+
|
|
300
|
+
```{code-cell}
|
|
301
|
+
sce_combined = combine_columns(sce2, sce1)
|
|
302
|
+
print(sce_combined)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
:::{note}
|
|
306
|
+
You can use `relaxed_combine_columns` or `relaxed_combined_rows` when there's mismatch in the number of features or samples. Missing rows or columns in any object are filled in with appropriate placeholder values before combining, e.g. missing assay's are replaced with a masked numpy array.
|
|
307
|
+
:::
|
|
308
|
+
|
|
309
|
+
```{code-cell}
|
|
310
|
+
# sce_alts1 contains an additional assay not present in sce_alts2
|
|
311
|
+
sce_relaxed_combine = relaxed_combine_columns(sce_alts1, sce_alts2)
|
|
312
|
+
print(sce_relaxed_combine)
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
## Export as `AnnData` or `MuData`
|
|
317
|
+
|
|
318
|
+
The package also provides methods to convert a `SingleCellExperiment` object into a `MuData` representation:
|
|
319
|
+
|
|
320
|
+
```{code-cell}
|
|
321
|
+
mdata = sce.to_mudata()
|
|
322
|
+
mdata
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
or coerce to an `AnnData` object:
|
|
326
|
+
|
|
327
|
+
```{code-cell}
|
|
328
|
+
adata, alts = sce.to_anndata()
|
|
329
|
+
print("main experiment: ", adata)
|
|
330
|
+
print("alternative experiments: ", alts)
|
|
331
|
+
```
|
|
@@ -24,7 +24,7 @@ package_dir =
|
|
|
24
24
|
python_requires = >=3.8
|
|
25
25
|
install_requires =
|
|
26
26
|
importlib-metadata; python_version<"3.8"
|
|
27
|
-
summarizedexperiment>=0.4.
|
|
27
|
+
summarizedexperiment>=0.4.5
|
|
28
28
|
|
|
29
29
|
[options.packages.find]
|
|
30
30
|
where = src
|
|
@@ -33,20 +33,28 @@ exclude =
|
|
|
33
33
|
|
|
34
34
|
[options.extras_require]
|
|
35
35
|
optional =
|
|
36
|
-
anndata
|
|
36
|
+
anndata==0.9.2; python_version<="3.9"
|
|
37
|
+
anndata>0.9.2; python_version>"3.9"
|
|
37
38
|
h5py
|
|
38
|
-
mudata
|
|
39
|
+
mudata==0.2.3; python_version<="3.9"
|
|
40
|
+
mudata>0.2.3; python_version>"3.9"
|
|
39
41
|
delayedarray
|
|
40
42
|
hdf5array
|
|
43
|
+
numpy==1.24.4; python_version<="3.9"
|
|
44
|
+
numpy>1.24.4; python_version>"3.9"
|
|
41
45
|
testing =
|
|
42
46
|
setuptools
|
|
43
47
|
pytest
|
|
44
48
|
pytest-cov
|
|
45
|
-
anndata
|
|
49
|
+
anndata==0.9.2; python_version<="3.9"
|
|
50
|
+
anndata>0.9.2; python_version>"3.9"
|
|
46
51
|
h5py
|
|
47
|
-
mudata
|
|
52
|
+
mudata==0.2.3; python_version<="3.9"
|
|
53
|
+
mudata>0.2.3; python_version>"3.9"
|
|
48
54
|
delayedarray
|
|
49
55
|
hdf5array
|
|
56
|
+
numpy==1.24.4; python_version<="3.9"
|
|
57
|
+
numpy>1.24.4; python_version>"3.9"
|
|
50
58
|
|
|
51
59
|
[options.entry_points]
|
|
52
60
|
|
{singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/SingleCellExperiment.egg-info/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: SingleCellExperiment
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.7
|
|
4
4
|
Summary: Container class for single-cell experiments
|
|
5
5
|
Home-page: https://github.com/BiocPy/SingleCellExperiment
|
|
6
6
|
Author: jkanche
|
|
@@ -14,22 +14,30 @@ Requires-Python: >=3.8
|
|
|
14
14
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
15
15
|
License-File: LICENSE.txt
|
|
16
16
|
Requires-Dist: importlib-metadata; python_version < "3.8"
|
|
17
|
-
Requires-Dist: summarizedexperiment
|
|
17
|
+
Requires-Dist: summarizedexperiment>=0.4.5
|
|
18
18
|
Provides-Extra: optional
|
|
19
|
-
Requires-Dist: anndata; extra == "optional"
|
|
19
|
+
Requires-Dist: anndata==0.9.2; python_version <= "3.9" and extra == "optional"
|
|
20
|
+
Requires-Dist: anndata>0.9.2; python_version > "3.9" and extra == "optional"
|
|
20
21
|
Requires-Dist: h5py; extra == "optional"
|
|
21
|
-
Requires-Dist: mudata; extra == "optional"
|
|
22
|
+
Requires-Dist: mudata==0.2.3; python_version <= "3.9" and extra == "optional"
|
|
23
|
+
Requires-Dist: mudata>0.2.3; python_version > "3.9" and extra == "optional"
|
|
22
24
|
Requires-Dist: delayedarray; extra == "optional"
|
|
23
25
|
Requires-Dist: hdf5array; extra == "optional"
|
|
26
|
+
Requires-Dist: numpy==1.24.4; python_version <= "3.9" and extra == "optional"
|
|
27
|
+
Requires-Dist: numpy>1.24.4; python_version > "3.9" and extra == "optional"
|
|
24
28
|
Provides-Extra: testing
|
|
25
29
|
Requires-Dist: setuptools; extra == "testing"
|
|
26
30
|
Requires-Dist: pytest; extra == "testing"
|
|
27
31
|
Requires-Dist: pytest-cov; extra == "testing"
|
|
28
|
-
Requires-Dist: anndata; extra == "testing"
|
|
32
|
+
Requires-Dist: anndata==0.9.2; python_version <= "3.9" and extra == "testing"
|
|
33
|
+
Requires-Dist: anndata>0.9.2; python_version > "3.9" and extra == "testing"
|
|
29
34
|
Requires-Dist: h5py; extra == "testing"
|
|
30
|
-
Requires-Dist: mudata; extra == "testing"
|
|
35
|
+
Requires-Dist: mudata==0.2.3; python_version <= "3.9" and extra == "testing"
|
|
36
|
+
Requires-Dist: mudata>0.2.3; python_version > "3.9" and extra == "testing"
|
|
31
37
|
Requires-Dist: delayedarray; extra == "testing"
|
|
32
38
|
Requires-Dist: hdf5array; extra == "testing"
|
|
39
|
+
Requires-Dist: numpy==1.24.4; python_version <= "3.9" and extra == "testing"
|
|
40
|
+
Requires-Dist: numpy>1.24.4; python_version > "3.9" and extra == "testing"
|
|
33
41
|
|
|
34
42
|
[](https://pyscaffold.org/)
|
|
35
43
|
[](https://pypi.org/project/SingleCellExperiment/)
|
|
@@ -37,20 +45,26 @@ Requires-Dist: hdf5array; extra == "testing"
|
|
|
37
45
|
|
|
38
46
|
# SingleCellExperiment
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
This package provides container class to represent single-cell experimental data as 2-dimensional matrices. In these matrices, the rows typically denote features or genomic regions of interest, while columns represent cells. In addition, a `SingleCellExperiment` (SCE) object may contain low-dimensionality embeddings, alternative experiments performed on same sample or set of cells. Follows Bioconductor's [SingleCellExperiment](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html).
|
|
41
49
|
|
|
42
50
|
|
|
43
51
|
## Install
|
|
44
52
|
|
|
45
|
-
|
|
53
|
+
To get started, install the package from [PyPI](https://pypi.org/project/singlecellexperiment/)
|
|
46
54
|
|
|
47
|
-
```
|
|
55
|
+
```bash
|
|
48
56
|
pip install singlecellexperiment
|
|
49
57
|
```
|
|
50
58
|
|
|
51
59
|
## Usage
|
|
52
60
|
|
|
53
|
-
|
|
61
|
+
The `SingleCellExperiment` extends [RangeSummarizedExperiment](https://github.com/BiocPy/SummarizedExperiment) and contains additional attributes:
|
|
62
|
+
|
|
63
|
+
- `reduced_dims`: Slot for low-dimensionality embeddings for each cell.
|
|
64
|
+
- `alternative_experiments`: Manages multi-modal experiments performed on the same sample or set of cells.
|
|
65
|
+
- `row_pairs` or `column_pairs`: Stores relationships between features or cells.
|
|
66
|
+
|
|
67
|
+
Readers are available to parse h5ad or `AnnData` objects to SCE:
|
|
54
68
|
|
|
55
69
|
```python
|
|
56
70
|
import singlecellexperiment
|
|
@@ -84,7 +98,8 @@ tse = SingleCellExperiment(
|
|
|
84
98
|
)
|
|
85
99
|
```
|
|
86
100
|
|
|
87
|
-
Since `SingleCellExperiment` extends `
|
|
101
|
+
Since `SingleCellExperiment` extends `RangeSummarizedExperiment`, most methods especially slicing and accessors are applicable here.
|
|
102
|
+
Checkout the [documentation](https://biocpy.github.io/SingleCellExperiment/) for more info.
|
|
88
103
|
|
|
89
104
|
<!-- pyscaffold-notes -->
|
|
90
105
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
summarizedexperiment>=0.4.5
|
|
2
|
+
|
|
3
|
+
[:python_version < "3.8"]
|
|
4
|
+
importlib-metadata
|
|
5
|
+
|
|
6
|
+
[optional]
|
|
7
|
+
h5py
|
|
8
|
+
delayedarray
|
|
9
|
+
hdf5array
|
|
10
|
+
|
|
11
|
+
[optional:python_version <= "3.9"]
|
|
12
|
+
anndata==0.9.2
|
|
13
|
+
mudata==0.2.3
|
|
14
|
+
numpy==1.24.4
|
|
15
|
+
|
|
16
|
+
[optional:python_version > "3.9"]
|
|
17
|
+
anndata>0.9.2
|
|
18
|
+
mudata>0.2.3
|
|
19
|
+
numpy>1.24.4
|
|
20
|
+
|
|
21
|
+
[testing]
|
|
22
|
+
setuptools
|
|
23
|
+
pytest
|
|
24
|
+
pytest-cov
|
|
25
|
+
h5py
|
|
26
|
+
delayedarray
|
|
27
|
+
hdf5array
|
|
28
|
+
|
|
29
|
+
[testing:python_version <= "3.9"]
|
|
30
|
+
anndata==0.9.2
|
|
31
|
+
mudata==0.2.3
|
|
32
|
+
numpy==1.24.4
|
|
33
|
+
|
|
34
|
+
[testing:python_version > "3.9"]
|
|
35
|
+
anndata>0.9.2
|
|
36
|
+
mudata>0.2.3
|
|
37
|
+
numpy>1.24.4
|
{singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/io/tenx.py
RENAMED
|
@@ -44,7 +44,7 @@ def read_tenx_mtx(path: str) -> SingleCellExperiment:
|
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
def read_tenx_h5(path: str) -> SingleCellExperiment:
|
|
47
|
+
def read_tenx_h5(path: str, realize_assays: bool = False) -> SingleCellExperiment:
|
|
48
48
|
"""Read 10X H5 file as :py:class:`~singlecellexperiment.SingleCellExperiment.SingleCellExperiment`.
|
|
49
49
|
|
|
50
50
|
Note: Currently only supports version 3 of the 10X H5 format.
|
|
@@ -53,10 +53,15 @@ def read_tenx_h5(path: str) -> SingleCellExperiment:
|
|
|
53
53
|
path:
|
|
54
54
|
Path to 10x H5 file.
|
|
55
55
|
|
|
56
|
+
realize_assays:
|
|
57
|
+
Whether to realize assays into memory.
|
|
58
|
+
Defaults to False.
|
|
59
|
+
|
|
56
60
|
Returns:
|
|
57
61
|
A single-cell experiment object.
|
|
58
62
|
"""
|
|
59
63
|
|
|
64
|
+
import delayedarray as da
|
|
60
65
|
import h5py
|
|
61
66
|
from hdf5array import Hdf5CompressedSparseMatrix
|
|
62
67
|
|
|
@@ -74,6 +79,9 @@ def read_tenx_h5(path: str) -> SingleCellExperiment:
|
|
|
74
79
|
path=path, group_name="matrix", by_column=True, shape=shape
|
|
75
80
|
)
|
|
76
81
|
|
|
82
|
+
if realize_assays is True:
|
|
83
|
+
counts = da.to_scipy_sparse_matrix(counts, "csr")
|
|
84
|
+
|
|
77
85
|
# read features
|
|
78
86
|
features = None
|
|
79
87
|
ignore_list = []
|
|
@@ -6,9 +6,11 @@ from biocframe import BiocFrame
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
import pandas as pd
|
|
8
8
|
from mudata import MuData
|
|
9
|
+
from scipy import sparse
|
|
9
10
|
|
|
10
11
|
import singlecellexperiment
|
|
11
12
|
from singlecellexperiment.SingleCellExperiment import SingleCellExperiment
|
|
13
|
+
from hdf5array import Hdf5CompressedSparseMatrix
|
|
12
14
|
|
|
13
15
|
__author__ = "jkanche"
|
|
14
16
|
__copyright__ = "jkanche"
|
|
@@ -95,6 +97,7 @@ def test_SCE_from10xH5():
|
|
|
95
97
|
assert isinstance(tse, SingleCellExperiment)
|
|
96
98
|
|
|
97
99
|
assert tse.assays is not None
|
|
100
|
+
assert isinstance(tse.assay(0), Hdf5CompressedSparseMatrix)
|
|
98
101
|
assert tse.row_data is not None
|
|
99
102
|
assert tse.col_data is not None
|
|
100
103
|
|
|
@@ -110,6 +113,11 @@ def test_SCE_from10xH5():
|
|
|
110
113
|
|
|
111
114
|
assert sliced.shape == (10, 4)
|
|
112
115
|
|
|
116
|
+
tse = singlecellexperiment.read_tenx_h5(
|
|
117
|
+
"tests/data/tenx.sub.h5", realize_assays=True
|
|
118
|
+
)
|
|
119
|
+
assert isinstance(tse.assay(0), sparse.spmatrix)
|
|
120
|
+
|
|
113
121
|
|
|
114
122
|
def test_SCE_randomAnnData():
|
|
115
123
|
np.random.seed(1)
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# SingleCellExperiment
|
|
2
|
-
|
|
3
|
-
Container class for representing data from single-cell experiments; follows Bioconductor's [SingleCellExperiment](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html).
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## Install
|
|
7
|
-
|
|
8
|
-
Package is published to [PyPI](https://pypi.org/project/singlecellexperiment/)
|
|
9
|
-
|
|
10
|
-
```shell
|
|
11
|
-
pip install singlecellexperiment
|
|
12
|
-
```
|
|
13
|
-
## Contents
|
|
14
|
-
|
|
15
|
-
```{toctree}
|
|
16
|
-
:maxdepth: 2
|
|
17
|
-
|
|
18
|
-
Overview <readme>
|
|
19
|
-
Tutorial <tutorial>
|
|
20
|
-
Module Reference <api/modules>
|
|
21
|
-
Contributions & Help <contributing>
|
|
22
|
-
License <license>
|
|
23
|
-
Authors <authors>
|
|
24
|
-
Changelog <changelog>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## Indices and tables
|
|
29
|
-
|
|
30
|
-
- {ref}`genindex`
|
|
31
|
-
- {ref}`modindex`
|
|
32
|
-
- {ref}`search`
|
|
33
|
-
|
|
34
|
-
[Sphinx]: http://www.sphinx-doc.org/
|
|
35
|
-
[Markdown]: https://daringfireball.net/projects/markdown/
|
|
36
|
-
[reStructuredText]: http://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
|
|
37
|
-
[MyST]: https://myst-parser.readthedocs.io/en/latest/
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# Tutorial
|
|
2
|
-
|
|
3
|
-
Container class to represent single-cell experiments; follows Bioconductor's [SingleCellExperiment](https://bioconductor.org/packages/release/bioc/html/SingleCellExperiment.html).
|
|
4
|
-
|
|
5
|
-
# Import as `SingleCellExperiment`
|
|
6
|
-
|
|
7
|
-
Readers are available to read `AnnData`, `H5AD` or `10x (MTX, H5) V3` formats as `SingleCellExperiment` objects.
|
|
8
|
-
|
|
9
|
-
```python
|
|
10
|
-
import singlecellexperiment
|
|
11
|
-
|
|
12
|
-
sce = singlecellexperiment.read_h5ad("tests/data/adata.h5ad")
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Similarly `read_tenx_h5`, `read_tenx_mtx` and `from_anndata` methods are available to read various formats.
|
|
16
|
-
|
|
17
|
-
# Construct a `SingleCellExperiment` object
|
|
18
|
-
|
|
19
|
-
`SingleCellExperiment` extends `SummarizedExperiment`, so it must contain `assays`, `row_data` and `column_data` objects. Additionally
|
|
20
|
-
`SingleCellExperiment` objects may contain dimensionality embeddings (e.g tSNE, UMAP etc), alternative experiment for multi-modal experiments and row/column pairings.
|
|
21
|
-
|
|
22
|
-
```python
|
|
23
|
-
import pandas as pd
|
|
24
|
-
import numpy as np
|
|
25
|
-
from biocframe import BiocFrame
|
|
26
|
-
from genomicranges import GenomicRanges
|
|
27
|
-
|
|
28
|
-
nrows = 200
|
|
29
|
-
ncols = 6
|
|
30
|
-
counts = np.random.rand(nrows, ncols)
|
|
31
|
-
row_data = BiocFrame(
|
|
32
|
-
{
|
|
33
|
-
"seqnames": [
|
|
34
|
-
"chr1",
|
|
35
|
-
"chr2",
|
|
36
|
-
"chr2",
|
|
37
|
-
"chr2",
|
|
38
|
-
"chr1",
|
|
39
|
-
"chr1",
|
|
40
|
-
"chr3",
|
|
41
|
-
"chr3",
|
|
42
|
-
"chr3",
|
|
43
|
-
"chr3",
|
|
44
|
-
]
|
|
45
|
-
* 20,
|
|
46
|
-
"starts": range(100, 300),
|
|
47
|
-
"ends": range(110, 310),
|
|
48
|
-
"strand": ["-", "+", "+", "*", "*", "+", "+", "+", "-", "-"] * 20,
|
|
49
|
-
"score": range(0, 200),
|
|
50
|
-
"GC": [random() for _ in range(10)] * 20,
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
col_data = pd.DataFrame(
|
|
55
|
-
{
|
|
56
|
-
"celltype": ["cluster1", "cluster2"] * 3,
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
Finally construct the object,
|
|
62
|
-
|
|
63
|
-
```python
|
|
64
|
-
from singlecellexperiment import SingleCellExperiment
|
|
65
|
-
|
|
66
|
-
tse = SingleCellExperiment(
|
|
67
|
-
assays={"counts": counts}, row_data=row_data, column_data=col_data
|
|
68
|
-
)
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
# Accessors
|
|
72
|
-
|
|
73
|
-
Multiple methods are available to access various slots of a `SingleCellExperiment` object
|
|
74
|
-
|
|
75
|
-
```python
|
|
76
|
-
tse.assays
|
|
77
|
-
tse.row_data
|
|
78
|
-
tse.column_data
|
|
79
|
-
tse.reduced_dims
|
|
80
|
-
tse.alternative_experiments
|
|
81
|
-
tse.row_pairs
|
|
82
|
-
tse.column_pairs
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
### Access specific sets
|
|
86
|
-
|
|
87
|
-
For reduced dimension and alternative experiment slots, one can also access specific objects
|
|
88
|
-
|
|
89
|
-
```python
|
|
90
|
-
tse.reduced_dim("tSNE")
|
|
91
|
-
|
|
92
|
-
tse.alternative_experiment("crop-seq")
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
# Subset experiment
|
|
96
|
-
|
|
97
|
-
Similar to `SummarizedExperiment`, you can subset by index
|
|
98
|
-
|
|
99
|
-
```python
|
|
100
|
-
# subset the first 10 rows and the first 3 samples
|
|
101
|
-
subset_tse = tse[0:10, 0:3]
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
# Export as AnnData objects
|
|
105
|
-
|
|
106
|
-
Methods are available to convert `SingleCellExperiment` objects as `AnnData`
|
|
107
|
-
|
|
108
|
-
```python
|
|
109
|
-
adata = tse.to_anndata()
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
or an `MuData`
|
|
113
|
-
|
|
114
|
-
```python
|
|
115
|
-
mdata = tse.to_mudata()
|
|
116
|
-
```
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
summarizedexperiment<0.5.0,>=0.4.0
|
|
2
|
-
|
|
3
|
-
[:python_version < "3.8"]
|
|
4
|
-
importlib-metadata
|
|
5
|
-
|
|
6
|
-
[optional]
|
|
7
|
-
anndata
|
|
8
|
-
h5py
|
|
9
|
-
mudata
|
|
10
|
-
delayedarray
|
|
11
|
-
hdf5array
|
|
12
|
-
|
|
13
|
-
[testing]
|
|
14
|
-
setuptools
|
|
15
|
-
pytest
|
|
16
|
-
pytest-cov
|
|
17
|
-
anndata
|
|
18
|
-
h5py
|
|
19
|
-
mudata
|
|
20
|
-
delayedarray
|
|
21
|
-
hdf5array
|
|
File without changes
|
{singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/.github/workflows/pypi-publish.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/__init__.py
RENAMED
|
File without changes
|
{singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/_combineutils.py
RENAMED
|
File without changes
|
{singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/_ioutils.py
RENAMED
|
File without changes
|
{singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/io/__init__.py
RENAMED
|
File without changes
|
{singlecellexperiment-0.4.5 → singlecellexperiment-0.4.7}/src/singlecellexperiment/io/h5ad.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|