morris-lab / CellOracle

This is the alpha version of the CellOracle package
Other
312 stars 56 forks source link

AttributeError following co.data_conversion.seurat_object_to_anndata( #170

Closed A-legac45 closed 10 months ago

A-legac45 commented 10 months ago

Hello,

I am using this following command to transform a seurat obeject but I got an error how can I manage it ? AttributeError?

co.data_conversion.seurat_object_to_anndata("/Users/alegac/Desktop/celloralce_test/MAITS_ssTCR.sub_atac_0.9_archr_signature.rds", delete_tmp_file=True)

{'RNA': AnnData object with n_obs × n_vars = 3733 × 32043 obs: 'orig.ident', 'nCount_RNA', 'nFeature_RNA', 'nCount_ATAC_CELLranger', 'nFeature_ATAC_CELLranger', 'nucleosome_signal', 'nucleosome_percentile', 'TSS.enrichment', 'TSS.percentile', 'percent.mt', 'high.tss', 'nCount_peaks_MACS2', 'nFeature_peaks_MACS2', 'nucleosome_group', 'seurat_clusters', 'cellnames_archr', 'Clusters.res_RNA0.9_arch', 'sub_cluster', 'MAIT0_LegouxNI2019', 'CL7_LegouxNI2019', 'MAIT_17a_LegouxNI2019', 'MAIT_17b_LegouxNI2019', 'Cycling_S_LegouxNI2019', 'CL7A_LegouxNI2019', 'CL7B_LegouxNI2019', 'CL7C_LegouxNI2019', 'MAIT_1B_LegouxNI2019', 'MAIT1_SignatureHeleneFromJEM', 'MAIT1_17_OMA', 'MAIT1_17_from_HelMar', 'Circulating_Common_Mackay2016Milner', 'Circulating_JEM2019', 'Cycling_S_LegouxNI2019.1', 'Cycling_G2M_LegouxNI2019', 'MAIT17_Baranek', 'IFNBaranek', 'TGFb', 'mait0_precurseur_Linda_CL5', 'mait0_mature_Linda_CL9', 'IL17_Brien', 'TCR', 'active_ident' var: 'variable_gene' uns: 'sub_cluster_colors', 'active_ident_colors' obsm: 'X_umap.rna', 'X_umap', 'X_pca' layers: 'raw_count'}


AttributeError Traceback (most recent call last) Cell In[41], line 3 1 # Check data shape ----> 3 print(f"Cell number is :{adata.shape[0]}") 4 print(f"Gene number is :{adata.shape[1]}")

AttributeError: 'dict' object has no attribute 'shape'

KenjiKamimoto-ac commented 10 months ago

The function seurat_object_to_anndata returns a dictionary of anndata rather than anndata object itself. It seems your adata object is a dictionary. For a quick solution, you can solve your problem as follows.

anndata_dict = co.data_conversion.seurat_object_to_anndata("/Users/alegac/Desktop/celloralce_test/MAITS_ssTCR.sub_atac_0.9_archr_signature.rds", delete_tmp_file=True)
adata = anndata_dict["RNA"]

It seems the function seurat_object_to_anndata itself is working as expected now, However, the data conversion function is deprecated and not maintained anymore.