调用infercnvpy的cnv_score函数时持续出现AttributeError: 'Series' object has no attribute 'nonzero'错误的求助
调用infercnvpy的cnv_score函数时持续出现AttributeError: 'Series' object has no attribute 'nonzero'错误的求助
我在分析GSE214966的单细胞RNA-seq数据时,调用infercnvpy包的cnv_score()函数遇到了棘手的问题——它一直抛出AttributeError: 'Series' object has no attribute 'nonzero'错误。
我甚至尝试复现官方教程里的示例,结果还是出现完全相同的错误。这说明问题大概率出在我这边,但我翻来覆去找不到原因:已经试过重新安装所有相关包,甚至重装了Python,都没能解决问题。
错误提示说Pandas的Series对象没有nonzero属性,这确实是事实,但这是包内函数的逻辑问题,我完全不知道该从哪里入手修复。有没有大佬能帮我看看?
错误详情
AttributeError Traceback (most recent call last) ~\AppData\Local\Temp\ipykernel_9248\2255080222.py in ?() 1 import infercnvpy as cnv ----> 2 cnv.tl.cnv_score(adata, groupby="leiden") d:\Datos de usuario\Desktop\Single Cell Analysis\Glioblastoma (GSE214966)\Glioblastoma-GSE214966\.venv\Lib\site-packages\infercnvpy\tl\_scores.py in ?(adata, groupby, use_rep, key_added, inplace, obs_key) 61 groupby = obs_key 62 63 if groupby not in adata.obs.columns and groupby == "cnv_leiden": 64 raise ValueError("`cnv_leiden` not found in `adata.obs`. Did you run `tl.leiden`?") ---> 65 cluster_score = { 66 cluster: np.mean(np.abs(adata.obsm[f"X_{use_rep}"][adata.obs[groupby] == cluster, :])) 67 for cluster in adata.obs[groupby].unique() 68 } d:\Datos de usuario\Desktop\Single Cell Analysis\Glioblastoma (GSE214966)\Glioblastoma-GSE214966\.venv\Lib\site-packages\scipy\sparse\_index.py in ?(self, key) 29 def __getitem__(self, key): ---> 30 index, new_shape = self._validate_indices(key) 31 32 # 1D array 33 if len(index) == 1: d:\Datos de usuario\Desktop\Single Cell Analysis\Glioblastoma (GSE214966)\Glioblastoma-GSE214966\.venv\Lib\site-packages\scipy\sparse\_index.py in ?(self, key) 265 if ix.shape != mid_shape: 266 raise IndexError( 267 f"bool index {i} has shape {mid_shape} instead of {ix.shape}" 268 ) ---> 269 index.extend(ix.nonzero()) 270 array_indices.extend(range(index_ndim, tmp_ndim)) 271 index_ndim = tmp_ndim 272 else: # dense array d:\Datos de usuario\Desktop\Single Cell Analysis\Glioblastoma (GSE214966)\Glioblastoma-GSE214966\.venv\Lib\site-packages\pandas\core\generic.py in ?(self, name) 6295 and name not in self._accessors 6296 and self._info_axis._can_hold_identifiers_and_holds_name(name) 6297 ): 6298 return self[name] -> 6299 return object.__getattribute__(self, name) AttributeError: 'Series' object has no attribute 'nonzero'
环境信息
----- anndata 0.11.3 infercnvpy 0.5.0 matplotlib 3.10.0 numpy 1.26.4 openpyxl 3.1.5 pandas 2.2.3 scanpy 1.10.4 scipy 1.15.1 session_info 1.0.0 sklearn 1.6.1 ----- PIL 11.1.0 asttokens NA attr 24.3.0 attrs 24.3.0 cairo 1.27.0 cattr NA cattrs NA certifi 2024.12.14 charset_normalizer 3.4.1 colorama 0.4.6 comm 0.2.2 cycler 0.12.1 ... Python 3.12.6 (tags/v3.12.6:a4a2d2b, Sep 6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)] Windows-10-10.0.19045-SP0 ----- Session information updated at 2025-01-16 16:27
备注:内容来源于stack exchange,提问作者Ferrixer14
相关产品推荐
相关产品推荐

