Skip to content

Commit

Permalink
update PCA
Browse files Browse the repository at this point in the history
  • Loading branch information
Intron7 committed Nov 26, 2024
1 parent 9df9037 commit 3e24c96
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/rapids_singlecell/preprocessing/_scrublet/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import cupy as cp
import numpy as np
from cupyx import cusparse
from cupyx.scipy import sparse

from rapids_singlecell.preprocessing._utils import _get_mean_var
from rapids_singlecell.preprocessing._utils import _get_mean_var, _sparse_to_dense

from .sparse_utils import sparse_multiply, sparse_zscore

Expand Down Expand Up @@ -60,10 +59,10 @@ def truncated_svd(

self._counts_obs_norm = self._counts_obs_norm.astype(cp.float32)
self._counts_sim_norm = self._counts_sim_norm.astype(cp.float32)
X_obs = cusparse.sparseToDense(self._counts_obs_norm)
X_obs = _sparse_to_dense(self._counts_obs_norm)
svd = TruncatedSVD(n_components=n_prin_comps, random_state=random_state).fit(X_obs)
X_obs = svd.transform(X_obs)
X_sim = svd.transform(cusparse.sparseToDense(self._counts_sim_norm))
X_sim = svd.transform(_sparse_to_dense(self._counts_sim_norm))
self.set_manifold(X_obs, X_sim)


Expand All @@ -80,10 +79,11 @@ def pca(

self._counts_obs_norm = self._counts_obs_norm.astype(cp.float32)
self._counts_sim_norm = self._counts_sim_norm.astype(cp.float32)
X_obs = cusparse.sparseToDense(self._counts_obs_norm)
pca = PCA(n_components=n_prin_comps, random_state=random_state).fit(X_obs)
X_obs = pca.transform(X_obs)
X_sim = pca.transform(cusparse.sparseToDense(self._counts_sim_norm))
pca = PCA(n_components=n_prin_comps, random_state=random_state).fit(
self._counts_obs_norm
)
X_obs = pca.transform(self._counts_obs_norm)
X_sim = pca.transform(self._counts_sim_norm)
self.set_manifold(X_obs, X_sim)


Expand Down

0 comments on commit 3e24c96

Please sign in to comment.