Skip to content

Commit

Permalink
Merge pull request #164 from scottgigante/patch-2
Browse files Browse the repository at this point in the history
Coerce to Csparsematrix for C++ conversion efficiency
  • Loading branch information
LuckyMD authored Sep 25, 2020
2 parents b2b87e2 + d06233f commit 20b18f1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scIB/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,16 @@ def normalize(adata, min_mean = 0.1, log=True):
sc.pp.pca(adata_pp, n_comps=15, svd_solver='arpack')
sc.pp.neighbors(adata_pp)
sc.tl.louvain(adata_pp, key_added='groups', resolution=0.5)

ro.globalenv['data_mat'] = adata.X.T

X = adata.X.T
# convert to CSC if possible. See https://github.com/MarioniLab/scran/issues/70
if sparse.issparse(X):
if X.nnz > 2**31-1:
X = X.tocoo()
else:
X = X.tocsc()

ro.globalenv['data_mat'] = X
ro.globalenv['input_groups'] = adata_pp.obs['groups']
size_factors = ro.r('sizeFactors(computeSumFactors(SingleCellExperiment('
'list(counts=data_mat)), clusters = input_groups,'
Expand Down

0 comments on commit 20b18f1

Please sign in to comment.