Open kollo97 opened 3 months ago
Hi,
first of all I want to say that this is a great tool!
I ran into an error related to the recently released scipy version 1.14.0. When trying to calculate the kBET score of an integration, I currently get the following error:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[49], line 17 1 selected_metrics = { 2 'ari_' : True, 3 'nmi_' : True, (...) 15 'n_cores' : 20 16 } ---> 17 metrics_seurat_all = scib.metrics.metrics(adata, adata_seurat, batch_key, label_key, embed = 'X_pca', **selected_metrics) 18 metrics_harmony_all = scib.metrics.metrics(adata, adata_harmony, batch_key, label_key, embed = 'X_harmony', **selected_metrics) 19 metrics_hvg_all = scib.metrics.metrics(adata, adata_hvg, batch_key, label_key, embed = 'X_pca', **selected_metrics) File ~/miniforge3/envs/angl_BM/lib/python3.12/site-packages/scib/metrics/metrics.py:407, in metrics(adata, adata_int, batch_key, label_key, embed, cluster_key, cluster_nmi, ari_, nmi_, nmi_method, nmi_dir, silhouette_, si_metric, pcr_, cell_cycle_, organism, hvg_score_, isolated_labels_, isolated_labels_f1_, isolated_labels_asw_, n_isolated, graph_conn_, trajectory_, kBET_, lisi_graph_, ilisi_, clisi_, subsample, n_cores, type_, verbose) 405 if kBET_: 406 print("kBET...") --> 407 kbet_score = kBET( 408 adata_int, 409 batch_key=batch_key, 410 label_key=label_key, 411 type_=type_, 412 embed=embed, 413 scaled=True, 414 verbose=verbose, 415 ) 416 else: 417 kbet_score = np.nan File ~/miniforge3/envs/angl_BM/lib/python3.12/site-packages/scib/metrics/kbet.py:173, in kBET(adata, batch_key, label_key, type_, embed, scaled, return_df, verbose) 170 nn_index_tmp[:] = np.nan 172 try: --> 173 nn_index_tmp[idx_nonan] = diffusion_nn( 174 adata_sub_sub, k=k0 175 ).astype("float") 176 # call kBET 177 score = kBET_single( 178 matrix=matrix, 179 batch=adata_sub.obs[batch_key], (...) 183 k0=k0, 184 ) File ~/miniforge3/envs/angl_BM/lib/python3.12/site-packages/scib/metrics/utils.py:141, in diffusion_nn(adata, k, max_iterations) 134 raise NeighborsError( 135 f"could not find {k} nearest neighbors in {max_iterations}" 136 "diffusion steps.\n Please increase max_iterations or reduce" 137 " k.\n" 138 ) 140 M.setdiag(0) --> 141 k_indices = np.argpartition(M.A, -k, axis=1)[:, -k:] 143 return k_indices AttributeError: 'csr_matrix' object has no attribute 'A'
After a quick search, I found that this was most likely related to my currently installed scipy version 1.14.0. As described in the following issue and release notes of scipy v1.14.0, the .A attribute of a csr_matrix has been deprecated in this release. https://github.com/scipy/scipy/issues/21049 https://github.com/scipy/scipy/releases/tag/v1.14.0
.A
Downgrading the scipy version to v1.13.0 solved the issue for me.
Best regards!
Just encountered this issue in OpenProblems as well!
Thanks for posting a workaround, @kollo97 !
Hi,
first of all I want to say that this is a great tool!
I ran into an error related to the recently released scipy version 1.14.0. When trying to calculate the kBET score of an integration, I currently get the following error:
After a quick search, I found that this was most likely related to my currently installed scipy version 1.14.0. As described in the following issue and release notes of scipy v1.14.0, the
.A
attribute of a csr_matrix has been deprecated in this release. https://github.com/scipy/scipy/issues/21049 https://github.com/scipy/scipy/releases/tag/v1.14.0Downgrading the scipy version to v1.13.0 solved the issue for me.
Best regards!