Skip to content

Commit

Permalink
Merge pull request #4 from Intron7/v0.2.2
Browse files Browse the repository at this point in the history
v.0.2.2
  • Loading branch information
Intron7 authored Aug 22, 2022
2 parents bc331a1 + fa2b10e commit 9546295
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ The functions are analogous versions of functions that can be found within [scan

## Requirements

To run the code in this repository you need a conda environment with rapids and scanpy installed. To use the full functionality of this repo please use `rapids-22.04` or `rapids-22.06`. You also need an Nvidia GPU.
To run the code in this repository you need a conda environment with rapids and scanpy installed. To use the full functionality of this repo please use `rapids-22.08`. You also need an Nvidia GPU.
```
conda create -n rapids_singelcell -f conda/rapids_singecell.yml
conda activate rapids_singelcell
ipython kernel install --user --name=rapids_singelcell
```
After you set up the enviroment you can install this package from this wheel into the enviroment. The wheel doesn't install any dependencies
```
pip install https://github.com/Intron7/rapids_singlecell/releases/download/v0.2.1/rapids_singlecell-0.2.1-py3-none-any.whl
pip install https://github.com/Intron7/rapids_singlecell/releases/download/v0.2.2/rapids_singlecell-0.2.2-py3-none-any.whl
```

With this enviroment, you should be able to run the notebooks. So far I have tested these Notebooks on an A100 80GB, a Quadro RTX 6000 and a RTX 3090.

To view a full guide how to set up a fully functioned single cell GPU accelerated conda environment visit [GPU_SingleCell_Setup](https://github.com/Intron7/GPU_SingleCell_Setup)

## Citation

If you use this code, please cite: [![DOI](https://zenodo.org/badge/364573913.svg)](https://zenodo.org/badge/latestdoi/364573913)
Expand Down
2 changes: 1 addition & 1 deletion rapids_singlecell/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import cunnData
from . import scanpy_gpu_funcs

__version__ = '0.2.1'
__version__ = '0.2.2'
3 changes: 2 additions & 1 deletion rapids_singlecell/cunnData.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ def normalize_pearson_residuals(self,
X = X - mu
X = X / cp.sqrt( mu + mu**2 / theta)
X = cp.clip(X, a_min=-clip, a_max=clip)
X = cp.array(X, dtype= cp.float32)
if inplace == True:
if layer:
self.layers[layer]= X
Expand Down Expand Up @@ -1433,4 +1434,4 @@ def _check_nonnegative_integers(X):
elif cp.any(~cp.equal(cp.mod(data, 1), 0)):
return False
else:
return True
return True
9 changes: 8 additions & 1 deletion rapids_singlecell/scanpy_gpu_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from cuml.cluster import KMeans
from cuml.decomposition import PCA

from scipy.sparse import issparse
import warnings


def _select_groups(labels, groups_order_subset='all'):
Expand Down Expand Up @@ -345,6 +347,11 @@ def pca(adata: AnnData,
covariance matrix.
"""
X = adata.layers[layer] if layer is not None else adata.X
if issparse(X):
warnings.warn(
"Your Countmatrix seems to be sparse, this can lead to a massive performance penalty.",
UserWarning,
)
pca_func = PCA(n_components=n_comps, output_type="numpy")
adata.obsm["X_pca"] = pca_func.fit_transform(X)
adata.uns['pca'] ={'variance':pca_func.explained_variance_, 'variance_ratio':pca_func.explained_variance_ratio_}
Expand Down Expand Up @@ -907,4 +914,4 @@ def harmony_integrate(
from . import harmonpy_gpu
harmony_out = harmonpy_gpu.run_harmony(adata.obsm[basis], adata.obs, key, **kwargs)

adata.obsm[adjusted_basis] = harmony_out.Z_corr.T.get()
adata.obsm[adjusted_basis] = harmony_out.Z_corr.T.get()

0 comments on commit 9546295

Please sign in to comment.