Skip to content

Commit b5a158b

Browse files
authored
Merge branch 'master' into pc_revamp
2 parents be0c648 + 1aded0c commit b5a158b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[![Documentation Status](https://readthedocs.org/projects/pysinglecellnet/badge/?version=latest)](https://pysinglecellnet.readthedocs.io/en/latest/?badge=latest)
22

33
# PySingleCellNet: classify scRNAseq data in Python
4-
54
PySingleCellNet (PySCN) predicts the 'cell type' of query scRNA-seq data by Random forest multi-class classification. See [Tan & Cahan 2019] for more details. PySCN includes functionality to aid in the analysis of engineered cell populations (i.e. cells derived via directed differentiation of pluripotent stem cells or via direct conversion).
65

76
[Tan & Cahan 2019]: https://doi.org/10.1016/j.cels.2019.06.004

pySingleCellNet/scn_train.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ def scn_train(aTrain,dLevel,nTopGenes = 100,nTopGenePairs = 100,nRand = 100, nTr
153153

154154
print("HVG")
155155
if limitToHVG:
156-
sc.pp.highly_variable_genes(adNorm, min_mean=0.0125, max_mean=6, min_disp=0.25)
156+
try:
157+
sc.pp.highly_variable_genes(adNorm, min_mean=0.0125, max_mean=4, min_disp=0.5)
158+
except Exception as e:
159+
raise ValueError(f"PySCN encountered an error when selecting variable genes. This may be avoided if you do not call scale or regress_out on the training data. Original error text: {repr(e)}")
157160
adNorm = adNorm[:, adNorm.var.highly_variable]
158161

159162
sc.pp.scale(adNorm, max_value=scaleMax)
@@ -204,7 +207,7 @@ def check_adX(adata: AnnData) -> AnnData:
204207
def add_classRes(adata: AnnData, adClassRes, copy=False) -> AnnData:
205208
cNames = adClassRes.var_names
206209
for cname in cNames:
207-
adata.obs[cname] = adClassRes[:,cname].X
210+
adata.obs[cname] = adClassRes[:,cname].X.toarray()
208211
# adata.obs['category'] = adClassRes.obs['category']
209212
adata.obs['SCN_class'] = adClassRes.obs['SCN_class']
210213
return adata if copy else None

0 commit comments

Comments
 (0)