Open zcaiwei opened 8 months ago
there is no 'celltype' in your adata.obs. Maybe you can try to set the 'seurat_clusters'.
cdutil.adata_to_df_with_embed(adata, us_para=['Mu','Ms'], cell_type_para='seurat_clusters', embed_para='X_umap', save_path='cell_type_u_s.csv', gene_list=gene_list)
Thanks for your reply!
Hi, When I'm running
cdutil.adata_to_df_with_embed(adata, us_para=['Mu','Ms'], cell_type_para='celltype', embed_para='X_umap', save_path='cell_type_u_s.csv', gene_list=gene_list)
there is something wrong happened like "KeyError Traceback (most recent call last) /tmp/ipykernel_3331/2728164412.py in
4 embed_para='X_umap',
5 save_path='cell_type_u_s.csv',
----> 6 gene_list=gene_list)
/opt/conda/envs/cellDancer/lib/python3.7/site-packages/celldancer/utilities.py in adata_to_df_with_embed(adata, us_para, cell_type_para, embed_para, save_path, gene_list) 208 209 for i,gene in enumerate(tqdm(gene_list)): --> 210 data_onegene = adata_to_raw_one_gene(adata, us_para=us_para, gene=gene) 211 if i==0: 212 data_onegene.to_csv(save_path,header=True,index=False)
/opt/conda/envs/cellDancer/lib/python3.7/site-packages/celldancer/utilities.py in adata_to_raw_one_gene(data, us_para, gene) 200 ''' 201 data2 = data[:, data.var.index.isin([gene])].copy() --> 202 u0 = data2.layers[us_para[0]][:,0].copy().astype(np.float32) 203 s0 = data2.layers[us_para[1]][:,0].copy().astype(np.float32) 204 raw_data = pd.DataFrame({'gene_name':gene, 'unsplice':u0, 'splice':s0})
/opt/conda/envs/cellDancer/lib/python3.7/site-packages/anndata/_core/aligned_mapping.py in getitem(self, key) 146 147 def getitem(self, key: str) -> V: --> 148 return self._data[key] 149 150 def setitem(self, key: str, value: V):
KeyError: 'Mu'"
We don't know how to debug this question above. The information of my adata is following:
AnnData object with n_obs × n_vars = 6837 × 1681 obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', 'percent.mt', 'pANN_0.25_0.22_780', 'DF.classifications_0.25_0.22_780', 'RNA_snn_res.0.1', 'seurat_clusters', 'RNA_snn_res.0.6', 'subcluster', 'subcluster_new', 'initial_size_unspliced', 'initial_size_spliced', 'initial_size', 'n_counts' var: 'vst.mean', 'vst.variance', 'vst.variance.expected', 'vst.variance.standardized', 'vst.variable', 'Accession', 'Chromosome', 'End', 'Start', 'Strand' uns: 'neighbors' obsm: 'X_Phate', 'X_pca', 'X_umap' varm: 'PCs' layers: 'matrix', 'ambiguous', 'spliced', 'unspliced', 'Ms', 'Mu' obsp: 'distances', 'connectivities'
Please give me some advice to make this command run successfully. Thank you very much!