cellarr 0.2.2__tar.gz → 0.2.4__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.
- {cellarr-0.2.2 → cellarr-0.2.4}/.github/workflows/pypi-publish.yml +2 -2
- {cellarr-0.2.2 → cellarr-0.2.4}/.github/workflows/pypi-test.yml +2 -2
- {cellarr-0.2.2 → cellarr-0.2.4}/.gitignore +2 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/CHANGELOG.md +6 -1
- {cellarr-0.2.2 → cellarr-0.2.4}/PKG-INFO +53 -3
- {cellarr-0.2.2 → cellarr-0.2.4}/README.md +52 -2
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/tutorial.md +49 -0
- cellarr-0.2.4/src/cellarr/autoencoder.py +444 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/build_cellarrdataset.py +45 -12
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/build_options.py +10 -5
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/buildutils_tiledb_array.py +6 -6
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/queryutils_tiledb_frame.py +1 -1
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/utils_anndata.py +45 -7
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr.egg-info/PKG-INFO +53 -3
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr.egg-info/SOURCES.txt +1 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/tests/test_anndata_utils.py +10 -1
- {cellarr-0.2.2 → cellarr-0.2.4}/tests/test_build.py +62 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/tests/test_dataloader.py +54 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/.coveragerc +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/.pre-commit-config.yaml +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/.readthedocs.yml +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/AUTHORS.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/CONTRIBUTING.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/LICENSE.txt +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/assets/cellarr.jpg +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/assets/cellarr.png +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/assets/cellarr.svg +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/Makefile +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/_static/.gitignore +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/authors.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/changelog.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/conf.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/contributing.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/index.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/license.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/notes.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/readme.md +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/docs/requirements.txt +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/pyproject.toml +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/setup.cfg +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/setup.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/CellArrDataset.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/CellArrDatasetSlice.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/__init__.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/buildutils_tiledb_frame.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr/dataloader.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr.egg-info/dependency_links.txt +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr.egg-info/not-zip-safe +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr.egg-info/requires.txt +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/src/cellarr.egg-info/top_level.txt +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/tests/conftest.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/tests/data/adata.h5ad +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/tests/test_query.py +0 -0
- {cellarr-0.2.2 → cellarr-0.2.4}/tox.ini +0 -0
|
@@ -13,9 +13,9 @@ jobs:
|
|
|
13
13
|
runs-on: ubuntu-latest
|
|
14
14
|
|
|
15
15
|
steps:
|
|
16
|
-
- uses: actions/checkout@
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
17
|
- name: Set up Python 3.9
|
|
18
|
-
uses: actions/setup-python@
|
|
18
|
+
uses: actions/setup-python@v5
|
|
19
19
|
with:
|
|
20
20
|
python-version: 3.9
|
|
21
21
|
- name: Install dependencies
|
|
@@ -19,9 +19,9 @@ jobs:
|
|
|
19
19
|
|
|
20
20
|
name: Python ${{ matrix.python-version }}
|
|
21
21
|
steps:
|
|
22
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@v4
|
|
23
23
|
- name: Setup Python
|
|
24
|
-
uses: actions/setup-python@
|
|
24
|
+
uses: actions/setup-python@v5
|
|
25
25
|
with:
|
|
26
26
|
python-version: ${{ matrix.python-version }}
|
|
27
27
|
cache: 'pip'
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Version 0.2.2
|
|
4
|
+
|
|
5
|
+
- Provide options to consistently extract cell metadata columns across datasets.
|
|
6
|
+
- Update documentation and tests.
|
|
7
|
+
|
|
3
8
|
## Version 0.2.1
|
|
4
9
|
|
|
5
10
|
* Implement dunder methods `__len__`, `__repr__` and `__str__` for the `CellArrDatasetSlice` class
|
|
@@ -19,6 +24,6 @@ for single cells expression profiles, training labels, and study labels. The dat
|
|
|
19
24
|
This is the first release of the package to support both creation and access to large
|
|
20
25
|
collection of files based on TileDB.
|
|
21
26
|
|
|
22
|
-
- Provide a build method to create the
|
|
27
|
+
- Provide a build method to create the TileDB collection from a series of data objects.
|
|
23
28
|
- Provides `CellArrDataset` class to query these objects on disk.
|
|
24
29
|
- Implements access and coerce methods to interop with other experimental data packages.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cellarr
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: TileDB-based array storage for genomics data collections.
|
|
5
5
|
Home-page: https://github.com/BiocPy/cellarr
|
|
6
6
|
Author: Jayaram Kancherla
|
|
@@ -57,7 +57,8 @@ Building a `CellArrDataset` generates 4 TileDB files in the specified output dir
|
|
|
57
57
|
- `cell_metadata`: A TileDB file containing cell metadata including mapping to the samples
|
|
58
58
|
they are tagged with in ``sample_metadata``.
|
|
59
59
|
- A matrix TileDB file named by the `layer_matrix_name` parameter. This allows the package
|
|
60
|
-
to store multiple different matrices, e.g. normalized, scaled for the same cell,
|
|
60
|
+
to store multiple different matrices, e.g. 'counts', 'normalized', 'scaled' for the same cell,
|
|
61
|
+
gene, sample metadata attributes.
|
|
61
62
|
|
|
62
63
|
The organization is inspired by the [MultiAssayExperiment](https://bioconductor.org/packages/release/bioc/html/MultiAssayExperiment.html) data structure.
|
|
63
64
|
|
|
@@ -77,7 +78,8 @@ import numpy as np
|
|
|
77
78
|
import tempfile
|
|
78
79
|
from cellarr import build_cellarrdataset, CellArrDataset, MatrixOptions
|
|
79
80
|
|
|
80
|
-
# Create a temporary directory
|
|
81
|
+
# Create a temporary directory, this is where the
|
|
82
|
+
# output files are created. Pick your location here.
|
|
81
83
|
tempdir = tempfile.mkdtemp()
|
|
82
84
|
|
|
83
85
|
# Read AnnData objects
|
|
@@ -114,6 +116,28 @@ some genes are unmeasured or ordered differently in the original experiments.
|
|
|
114
116
|
***Note: The objects to build the `CellArrDataset` are expected to be fairly consistent, especially along the feature dimension.
|
|
115
117
|
if these are `AnnData` or `H5AD`objects, all objects must contain an index (in the `var` slot) specifying the gene symbols.***
|
|
116
118
|
|
|
119
|
+
#### Optionally provide cell metadata columns
|
|
120
|
+
|
|
121
|
+
If the cell metadata is inconsistent across datasets, you can provide a list of
|
|
122
|
+
columns to standardize during extraction. Any missing columns will be filled with
|
|
123
|
+
the default value `'NA'`, and their data type should be specified as `'ascii'` in
|
|
124
|
+
`CellMetadataOptions`. For example, this build process will create a TileDB store
|
|
125
|
+
for cell metadata containing the columns `'cellids'` and `'tissue'`. If any dataset
|
|
126
|
+
lacks one of these columns, the missing values will be automatically filled with `'NA'`.
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
dataset = build_cellarrdataset(
|
|
130
|
+
output_path=tempdir,
|
|
131
|
+
files=[adata1, adata2],
|
|
132
|
+
matrix_options=MatrixOptions(dtype=np.float32),
|
|
133
|
+
cell_metadata_options=CellMetadataOptions(
|
|
134
|
+
column_types={"cellids": "ascii", "tissue": "ascii"}
|
|
135
|
+
),
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
print(dataset)
|
|
139
|
+
```
|
|
140
|
+
|
|
117
141
|
Check out the [documentation](https://biocpy.github.io/cellarr/tutorial.html) for more details.
|
|
118
142
|
|
|
119
143
|
### Query a `CellArrDataset`
|
|
@@ -165,6 +189,32 @@ datamodule = DataModule(
|
|
|
165
189
|
)
|
|
166
190
|
```
|
|
167
191
|
|
|
192
|
+
The package also includes a simple autoencoder in the `pytorch-lightning` which makes use of the dataloader. This can be used as a template to create custom architectures and models.
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
import pytorch_lightning as pl
|
|
196
|
+
from cellarr.autoencoder import AutoEncoder
|
|
197
|
+
|
|
198
|
+
autoencoder = AutoEncoder(
|
|
199
|
+
n_genes=len(datamodule.gene_indices),
|
|
200
|
+
latent_dim=128,
|
|
201
|
+
hidden_dim=[1024, 1024, 1024],
|
|
202
|
+
dropout=0.5,
|
|
203
|
+
input_dropout=0.4,
|
|
204
|
+
residual=False,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
model_path = "/path/to/model/mymodel/"
|
|
208
|
+
params = {
|
|
209
|
+
"max_epochs": 500,
|
|
210
|
+
"logger": True,
|
|
211
|
+
"log_every_n_steps": 1,
|
|
212
|
+
"limit_train_batches": 100, # to specify number of batches per epoch
|
|
213
|
+
}
|
|
214
|
+
trainer = pl.Trainer(**params)
|
|
215
|
+
trainer.fit(autoencoder, datamodule=datamodule)
|
|
216
|
+
autoencoder.save_all(model_path=model_path)
|
|
217
|
+
```
|
|
168
218
|
<!-- pyscaffold-notes -->
|
|
169
219
|
|
|
170
220
|
## Note
|
|
@@ -27,7 +27,8 @@ Building a `CellArrDataset` generates 4 TileDB files in the specified output dir
|
|
|
27
27
|
- `cell_metadata`: A TileDB file containing cell metadata including mapping to the samples
|
|
28
28
|
they are tagged with in ``sample_metadata``.
|
|
29
29
|
- A matrix TileDB file named by the `layer_matrix_name` parameter. This allows the package
|
|
30
|
-
to store multiple different matrices, e.g. normalized, scaled for the same cell,
|
|
30
|
+
to store multiple different matrices, e.g. 'counts', 'normalized', 'scaled' for the same cell,
|
|
31
|
+
gene, sample metadata attributes.
|
|
31
32
|
|
|
32
33
|
The organization is inspired by the [MultiAssayExperiment](https://bioconductor.org/packages/release/bioc/html/MultiAssayExperiment.html) data structure.
|
|
33
34
|
|
|
@@ -47,7 +48,8 @@ import numpy as np
|
|
|
47
48
|
import tempfile
|
|
48
49
|
from cellarr import build_cellarrdataset, CellArrDataset, MatrixOptions
|
|
49
50
|
|
|
50
|
-
# Create a temporary directory
|
|
51
|
+
# Create a temporary directory, this is where the
|
|
52
|
+
# output files are created. Pick your location here.
|
|
51
53
|
tempdir = tempfile.mkdtemp()
|
|
52
54
|
|
|
53
55
|
# Read AnnData objects
|
|
@@ -84,6 +86,28 @@ some genes are unmeasured or ordered differently in the original experiments.
|
|
|
84
86
|
***Note: The objects to build the `CellArrDataset` are expected to be fairly consistent, especially along the feature dimension.
|
|
85
87
|
if these are `AnnData` or `H5AD`objects, all objects must contain an index (in the `var` slot) specifying the gene symbols.***
|
|
86
88
|
|
|
89
|
+
#### Optionally provide cell metadata columns
|
|
90
|
+
|
|
91
|
+
If the cell metadata is inconsistent across datasets, you can provide a list of
|
|
92
|
+
columns to standardize during extraction. Any missing columns will be filled with
|
|
93
|
+
the default value `'NA'`, and their data type should be specified as `'ascii'` in
|
|
94
|
+
`CellMetadataOptions`. For example, this build process will create a TileDB store
|
|
95
|
+
for cell metadata containing the columns `'cellids'` and `'tissue'`. If any dataset
|
|
96
|
+
lacks one of these columns, the missing values will be automatically filled with `'NA'`.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
dataset = build_cellarrdataset(
|
|
100
|
+
output_path=tempdir,
|
|
101
|
+
files=[adata1, adata2],
|
|
102
|
+
matrix_options=MatrixOptions(dtype=np.float32),
|
|
103
|
+
cell_metadata_options=CellMetadataOptions(
|
|
104
|
+
column_types={"cellids": "ascii", "tissue": "ascii"}
|
|
105
|
+
),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
print(dataset)
|
|
109
|
+
```
|
|
110
|
+
|
|
87
111
|
Check out the [documentation](https://biocpy.github.io/cellarr/tutorial.html) for more details.
|
|
88
112
|
|
|
89
113
|
### Query a `CellArrDataset`
|
|
@@ -135,6 +159,32 @@ datamodule = DataModule(
|
|
|
135
159
|
)
|
|
136
160
|
```
|
|
137
161
|
|
|
162
|
+
The package also includes a simple autoencoder in the `pytorch-lightning` which makes use of the dataloader. This can be used as a template to create custom architectures and models.
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
import pytorch_lightning as pl
|
|
166
|
+
from cellarr.autoencoder import AutoEncoder
|
|
167
|
+
|
|
168
|
+
autoencoder = AutoEncoder(
|
|
169
|
+
n_genes=len(datamodule.gene_indices),
|
|
170
|
+
latent_dim=128,
|
|
171
|
+
hidden_dim=[1024, 1024, 1024],
|
|
172
|
+
dropout=0.5,
|
|
173
|
+
input_dropout=0.4,
|
|
174
|
+
residual=False,
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
model_path = "/path/to/model/mymodel/"
|
|
178
|
+
params = {
|
|
179
|
+
"max_epochs": 500,
|
|
180
|
+
"logger": True,
|
|
181
|
+
"log_every_n_steps": 1,
|
|
182
|
+
"limit_train_batches": 100, # to specify number of batches per epoch
|
|
183
|
+
}
|
|
184
|
+
trainer = pl.Trainer(**params)
|
|
185
|
+
trainer.fit(autoencoder, datamodule=datamodule)
|
|
186
|
+
autoencoder.save_all(model_path=model_path)
|
|
187
|
+
```
|
|
138
188
|
<!-- pyscaffold-notes -->
|
|
139
189
|
|
|
140
190
|
## Note
|
|
@@ -139,6 +139,28 @@ is automatically created. Hence the sample information provided must match
|
|
|
139
139
|
the number of input files.
|
|
140
140
|
:::
|
|
141
141
|
|
|
142
|
+
## Optionally provide cell metadata columns
|
|
143
|
+
|
|
144
|
+
If the cell metadata is inconsistent across datasets, you can provide a list of
|
|
145
|
+
columns to standardize during extraction. Any missing columns will be filled with
|
|
146
|
+
the default value `'NA'`, and their data type should be specified as `'ascii'` in
|
|
147
|
+
`CellMetadataOptions`. For example, this build process will create a TileDB store
|
|
148
|
+
for cell metadata containing the columns `'cellids'` and `'tissue'`. If any dataset
|
|
149
|
+
lacks one of these columns, the missing values will be automatically filled with `'NA'`.
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
dataset = build_cellarrdataset(
|
|
153
|
+
output_path=tempdir,
|
|
154
|
+
files=[adata1, adata2],
|
|
155
|
+
matrix_options=MatrixOptions(dtype=np.float32),
|
|
156
|
+
cell_metadata_options=CellMetadataOptions(
|
|
157
|
+
column_types={"cellids": "ascii", "tissue": "ascii"}
|
|
158
|
+
),
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
print(dataset)
|
|
162
|
+
```
|
|
163
|
+
|
|
142
164
|
# Query a `CellArrDataset`
|
|
143
165
|
|
|
144
166
|
Users have the option to reuse the `dataset` object retuned when building the dataset or by creating a `CellArrDataset` object by initializing it to the path where the files were created.
|
|
@@ -237,6 +259,33 @@ batch = next(iter(dataloader))
|
|
|
237
259
|
expression, labels, studies = batch
|
|
238
260
|
```
|
|
239
261
|
|
|
262
|
+
The dataloader can then be used in training models. The package provides a simple autoencoder to serve as a template for the user's own models.
|
|
263
|
+
|
|
264
|
+
```python
|
|
265
|
+
import pytorch_lightning as pl
|
|
266
|
+
from cellarr.autoencoder import AutoEncoder
|
|
267
|
+
|
|
268
|
+
autoencoder = AutoEncoder(
|
|
269
|
+
n_genes=len(datamodule.gene_indices),
|
|
270
|
+
latent_dim=128,
|
|
271
|
+
hidden_dim=[1024, 1024, 1024],
|
|
272
|
+
dropout=0.5,
|
|
273
|
+
input_dropout=0.4,
|
|
274
|
+
residual=False,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
model_path = "/path/to/model/mymodel/"
|
|
278
|
+
params = {
|
|
279
|
+
"max_epochs": 500,
|
|
280
|
+
"logger": True,
|
|
281
|
+
"log_every_n_steps": 1,
|
|
282
|
+
"limit_train_batches": 100, # to specify number of batches per epoch
|
|
283
|
+
}
|
|
284
|
+
trainer = pl.Trainer(**params)
|
|
285
|
+
trainer.fit(autoencoder, datamodule=datamodule)
|
|
286
|
+
autoencoder.save_all(model_path=model_path)
|
|
287
|
+
```
|
|
288
|
+
|
|
240
289
|
---
|
|
241
290
|
|
|
242
291
|
Check out the [documentation](https://biocpy.github.io/cellarr/api/modules.html) for more details.
|