JonathanShor / DoubletDetection

Doublet detection in single-cell RNA-seq data.
https://doubletdetection.readthedocs.io/en/stable/
MIT License
86 stars 23 forks source link

Error for clf.fit #158

Open AdotaLover opened 3 months ago

AdotaLover commented 3 months ago

Hi!Thank you for your tool! But when i execute this commend doublets = clf.fit(adata.X).predict(p_thresh=1e-16, voter_thresh=0.5) an error below: { "name": "AttributeError", "message": "'csr_matrix' object has no attribute 'A'", "stack": "--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[37], line 1 ----> 1 adatas_pp = [pp(ad) for ad in adatas]

Cell In[37], line 1, in (.0) ----> 1 adatas_pp = [pp(ad) for ad in adatas]

Cell In[36], line 11, in pp(adata) 9 adata.uns['cells_removed'] = sum(bool_vector) 10 # 检测双重细胞 ---> 11 doublets = clf.fit(adata.X).predict(p_thresh=1e-16, voter_thresh=0.5) 12 doublet_score = clf.doublet_score()
13 # 保存双重细胞信息

File ~/miniconda3/envs/scanpy/lib/python3.10/site-packages/doubletdetection/doubletdetection.py:208, in BoostClassifier.fit(self, raw_counts) 206 if self.verbose: 207 print(\"Iteration {:3}/{}\".format(i + 1, self.n_iters)) --> 208 self.allscores[i], self.all_log_pvalues[i] = self._one_fit() 209 allcommunities[i] = self.communities 210 allparents.append(self.parents)

File ~/miniconda3/envs/scanpy/lib/python3.10/site-packages/doubletdetection/doubletdetection.py:308, in BoostClassifier._one_fit(self) 306 scaled_aug_counts = aug_counts * np.median(aug_lib_size) 307 if self.pseudocount != 1: --> 308 aug_counts = np.log(scaled_aug_counts.A + 0.1) 309 else: 310 aug_counts = np.log1p(scaled_aug_counts)

AttributeError: 'csr_matrix' object has no attribute 'A'" } But your update shows that it supports csr_matrix!Looking foward to your reply!Thanks!

jefferyUstc commented 3 months ago

The same problem

adamgayoso commented 3 months ago

The issue is that we need to change .A with .toarray(). A temporary fix is to downgrade your scipy version

Ma-hz commented 2 weeks ago

The issue is that we need to change .A with .toarray(). A temporary fix is to downgrade your scipy version

What version of 'scipy' do you use?

jefferyUstc commented 2 weeks ago

My version is scipy 1.13.1. It works

Motoufiq commented 4 days ago

I got the same issue as reported. I downgraded to scipy 1.13.1. It worked.