-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from Intron7/v0.3.3
V0.3.3
- Loading branch information
Showing
14 changed files
with
546 additions
and
482 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
from . import decoupler_gpu as dcg | ||
from . import scanpy_gpu as tl | ||
|
||
__version__ = '0.3.2' | ||
__version__ = '0.3.3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,52 @@ | ||
import cupy as cp | ||
from ..cunnData import cunnData | ||
from typing import Optional | ||
|
||
def scale(cudata:cunnData, max_value=10): | ||
|
||
def scale(cudata:cunnData, | ||
max_value=10, | ||
layer: Optional[str] = None, | ||
inplace = True): | ||
""" | ||
Scales matrix to unit variance and clips values | ||
Parameters | ||
---------- | ||
cudata: | ||
cunnData object | ||
max_value : int | ||
After scaling matrix to unit variance, | ||
values will be clipped to this number | ||
of std deviations. | ||
After scaling matrix to unit variance, | ||
values will be clipped to this number | ||
of std deviations. | ||
layer : Optional[str] (default: None) | ||
Layer to use as input instead of X. If None, X is used. | ||
inplace : bool (default: True) | ||
If True, update cunnData with results. Otherwise, return results. See below for details of what is returned. | ||
Return | ||
------ | ||
updates cunndata object with a scaled cunndata.X | ||
Returns a sacled copy or updates `cudata` with a scaled version of the | ||
original `cudata.X` and `cudata.layers['layer']`, depending on `inplace`. | ||
""" | ||
if type(cudata.X) is not cp._core.core.ndarray: | ||
X = cudata.layers[layer] if layer is not None else cudata.X | ||
|
||
if type(X) is not cp._core.core.ndarray: | ||
print("densifying _.X") | ||
X = cudata.X.toarray() | ||
X = X.toarray() | ||
else: | ||
X =cudata.X | ||
mean = X.mean(axis=0) | ||
X =X.copy() | ||
mean = X.sum(axis=0).flatten() / X.shape[0] | ||
X -= mean | ||
del mean | ||
stddev = cp.sqrt(X.var(axis=0)) | ||
X /= stddev | ||
del stddev | ||
cudata.X = cp.clip(X,a_max=max_value) | ||
X= cp.clip(X,a_max=max_value) | ||
if inplace: | ||
if layer: | ||
cudata.layers[layer] = X | ||
else: | ||
cudata.X = X | ||
else: | ||
return X |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters