theislab / scib

Benchmarking analysis of data integration tools
MIT License
283 stars 62 forks source link

AttributeError: can't set attribute 'categories' #388

Open BillyChen123 opened 9 months ago

BillyChen123 commented 9 months ago

Why did I run desc method has a attribute issue? I have never met it before.


datasets = sc.read_h5ad(filepath)
datasets.obs['Batch'] = pd.CategoricalIndex(datasets.obs['Batch'])
datasets.obs['Batch2'] = pd.CategoricalIndex(datasets.obs['Batch2'])
datasets.obs['Group'] = pd.CategoricalIndex(datasets.obs['Group'])
sc.pp.normalize_total(datasets,target_sum= 1e4)
sc.pp.log1p(datasets)
sc.pp.highly_variable_genes(datasets)
#sc.pl.highly_variable_genes(datasets)
adata = scib.integration.desc(datasets,'Batch2',res = 0.8)```

AttributeError                            Traceback (most recent call last)
/home/chenyz/Matrix_Factorization/rank/Untitled-1.ipynb 单元格 2 line 1
      [8](vscode-notebook-cell://ssh-remote%2B10.181.6.84/home/chenyz/Matrix_Factorization/rank/Untitled-1.ipynb#W5sdnNjb2RlLXJlbW90ZQ%3D%3D?line=7) sc.pp.highly_variable_genes(datasets)
      [9](vscode-notebook-cell://ssh-remote%2B10.181.6.84/home/chenyz/Matrix_Factorization/rank/Untitled-1.ipynb#W5sdnNjb2RlLXJlbW90ZQ%3D%3D?line=8) #sc.pl.highly_variable_genes(datasets)
---> [10](vscode-notebook-cell://ssh-remote%2B10.181.6.84/home/chenyz/Matrix_Factorization/rank/Untitled-1.ipynb#W5sdnNjb2RlLXJlbW90ZQ%3D%3D?line=9) adata = scib.integration.desc(datasets,'Batch2',res = 0.8)

File [~/anaconda3/envs/MOBA_Billy/lib/python3.10/site-packages/scib/integration.py:449](https://vscode-remote+ssh-002dremote-002b10-002e181-002e6-002e84.vscode-resource.vscode-cdn.net/home/chenyz/Matrix_Factorization/rank/~/anaconda3/envs/MOBA_Billy/lib/python3.10/site-packages/scib/integration.py:449), in desc(adata, batch, res, ncores, tmp_dir, use_gpu)
    445 adata_out = adata.copy()
    447 adata_out = desc.scale_bygroup(adata_out, groupby=batch, max_value=6)
--> 449 adata_out = desc.train(
    450     adata_out,
    451     dims=[adata.shape[1], 128, 32],
    452     tol=0.001,
    453     n_neighbors=10,
    454     batch_size=256,
    455     louvain_resolution=res,
    456     save_encoder_weights=False,
    457     save_dir=tmp_dir,
    458     do_tsne=False,
    459     use_GPU=use_gpu,
    460     num_Cores=ncores,
    461     use_ae_weights=False,
    462     do_umap=False,
    463 )
...
File [~/anaconda3/envs/MOBA_Billy/lib/python3.10/site-packages/pandas/core/arrays/categorical.py:2867](https://vscode-remote+ssh-002dremote-002b10-002e181-002e6-002e84.vscode-resource.vscode-cdn.net/home/chenyz/Matrix_Factorization/rank/~/anaconda3/envs/MOBA_Billy/lib/python3.10/site-packages/pandas/core/arrays/categorical.py:2867), in CategoricalAccessor._delegate_property_set(self, name, new_values)
   2866 def _delegate_property_set(self, name: str, new_values):  # type: ignore[override]
-> 2867     return setattr(self._parent, name, new_values)

AttributeError: can't set attribute 'categories'
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?1599f676-8fcd-4683-a362-9a7106fbf73d) or open in a [text editor](command:workbench.action.openLargeOutput?1599f676-8fcd-4683-a362-9a7106fbf73d). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...