Skip to content

Commit

Permalink
aggregate the anndata object (#100)
Browse files Browse the repository at this point in the history
* move utils to get

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* switch utils to get

* fix for docs

* release notes

* added kernels

* added aggregate templates

* fixed releasenotes

* update kernel

* updates _mean_var_major

* updated kernel

* updated Aggregate

* updates docs

* updates docstrings

* removes small

* adds scanpy-1.10 as dep

* updated test

* added dense_kernel

* changed utils test

* remove singledispatch

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Intron7 and pre-commit-ci[bot] committed Feb 26, 2024
1 parent dc43ac2 commit 61feacf
Show file tree
Hide file tree
Showing 21 changed files with 751 additions and 34 deletions.
6 changes: 3 additions & 3 deletions docs/Usage_Principles.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ adata.X = cpx.scipy.sparse.csr_matrix(adata.X) # moves `.X` to the GPU
adata.X = adata.X.get() # moves `.X` back to the CPU
```

You can also use {mod}`rapids_singlecell.utils` to move arrays and matrices.
You can also use {mod}`rapids_singlecell.get` to move arrays and matrices.

```
rsc.utils.anndata_to_GPU(adata) # moves `.X` to the GPU
rsc.utils.anndata_to_CPU(adata) # moves `.X` to the CPU
rsc.get.anndata_to_GPU(adata) # moves `.X` to the GPU
rsc.get.anndata_to_CPU(adata) # moves `.X` to the CPU
```

### Preprocessing
Expand Down
9 changes: 5 additions & 4 deletions docs/api/utils.md → docs/api/get.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Utils
# Get object from `AnnData`: `get`

These functions offer convineant ways to move arrays and matrices from and to the GPU.

```{eval-rst}
.. module:: rapids_singlecell.utils
.. module:: rapids_singlecell.get
.. currentmodule:: rapids_singlecell
.. autosummary::
:toctree: generated
utils.anndata_to_GPU
utils.anndata_to_CPU
get.aggregate
get.anndata_to_GPU
get.anndata_to_CPU
```
2 changes: 1 addition & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import rapids_singlecell as rsc
scanpy_gpu
squidpy_gpu
decoupler_gpu
utils
get
cunndata
```
4 changes: 2 additions & 2 deletions docs/notebooks/demo_gpu-PR.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_GPU(adata)"
"rsc.get.anndata_to_GPU(adata)"
]
},
{
Expand Down Expand Up @@ -735,7 +735,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_CPU(adata, convert_all=True)"
"rsc.get.anndata_to_CPU(adata, convert_all=True)"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions docs/notebooks/demo_gpu-seuratv3-brain-1M.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_GPU(adata)"
"rsc.get.anndata_to_GPU(adata)"
]
},
{
Expand Down Expand Up @@ -630,7 +630,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_CPU(adata, layer=\"counts\")"
"rsc.get.anndata_to_CPU(adata, layer=\"counts\")"
]
},
{
Expand Down Expand Up @@ -868,7 +868,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_CPU(adata)"
"rsc.get.anndata_to_CPU(adata)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/demo_gpu-seuratv3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_GPU(adata)"
"rsc.get.anndata_to_GPU(adata)"
]
},
{
Expand Down Expand Up @@ -859,7 +859,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_CPU(adata, convert_all=True)"
"rsc.get.anndata_to_CPU(adata, convert_all=True)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/demo_gpu.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_GPU(adata)"
"rsc.get.anndata_to_GPU(adata)"
]
},
{
Expand Down Expand Up @@ -659,7 +659,7 @@
],
"source": [
"%%time\n",
"rsc.utils.anndata_to_CPU(adata)"
"rsc.get.anndata_to_CPU(adata)"
]
},
{
Expand Down
8 changes: 8 additions & 0 deletions docs/release-notes/0.10.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
### 0.10.0 {small}`the future`

```{rubric} Features
```

* added `get` module {pr}`100` {smaller}`S Dicks`
* switch `utils` functions to get {pr}`100` {smaller}`S Dicks`
* added `get.aggregated` to create condensed `anndata` objects {pr}`100` {smaller}`S Dicks`
2 changes: 1 addition & 1 deletion docs/release-notes/0.9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* added support for GPU enabled {class}`~anndata.AnnData` {pr}`60` {smaller}`S Dicks`
* added support for dense `cupy.ndarray` {pr}`60` {smaller}`S Dicks`
* added support for 64 bit floats {pr}`60` {smaller}`S Dicks`
* added {mod}`~rapids_singlecell.utils` to help with {class}`~anndata.AnnData` GPU conversion {pr}`60` {smaller}`S Dicks`
* added `rapids_singlecell.utils` to help with {class}`~anndata.AnnData` GPU conversion {pr}`60` {smaller}`S Dicks`
* renamed `cunndata_funcs` to {mod}`~rapids_singlecell.pp` {pr}`60` {smaller}`S Dicks`
* renamed `scanpy_gpu` to {mod}`~rapids_singlecell.tl` {pr}`60` {smaller}`S Dicks`
* switched {func}`~rapids_singlecell.pp.neighbors` to {mod}`~rapids_singlecell.pp` {pr}`60` {smaller}`S Dicks`
Expand Down
2 changes: 1 addition & 1 deletion docs/release-notes/0.9.6.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 0.9.6 {small}
### 0.9.6

```{rubric} Bug fixes
```
Expand Down
5 changes: 5 additions & 0 deletions docs/release-notes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

# Release notes

## Version 0.10.0

```{include} /release-notes/0.10.0.md
``````

## Version 0.9.0
```{include} /release-notes/0.9.6.md
``````
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dynamic = ["version"]

dependencies = [
"anndata>=0.10.0",
"scanpy>=1.9.3",
"scanpy>=1.10.0rc2",
"numpy>=1.17.0",
"decoupler>=1.3.2",
"scipy>=1.4",
Expand Down Expand Up @@ -82,6 +82,7 @@ ignore = [
"docs/*" = ["I"]
"tests/*" = ["D"]
"*/__init__.py" = ["F401"]
"src/rapids_singlecell/get/_aggregated.py" = ["F811"]

[tool.hatch.build]
# exclude big files that don’t need to be installed
Expand Down
2 changes: 1 addition & 1 deletion src/rapids_singlecell/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from . import cunnData, dcg, gr, pp, tl, utils
from . import cunnData, dcg, get, gr, pp, tl
from ._version import __version__
2 changes: 2 additions & 0 deletions src/rapids_singlecell/get/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ._aggregated import aggregate
from ._anndata import anndata_to_CPU, anndata_to_GPU

0 comments on commit 61feacf

Please sign in to comment.