ventolab / CellphoneDB

CellPhoneDB can be used to search for a particular ligand/receptor, or interrogate your own HUMAN single-cell transcriptomics data.
https://www.cellphonedb.org/
MIT License
320 stars 51 forks source link

KeyError: 'significant_means' #186

Closed shenhanjing closed 4 months ago

shenhanjing commented 4 months ago

hello,

I'm running my data on cpdb_statistical_analysis_method.call() function.

from cellphonedb.src.core.methods import cpdb_statistical_analysis_method

cpdb_results  = cpdb_statistical_analysis_method.call(
        cpdb_file_path = "./input/cellphonedb.zip",
        meta_file_path = "./input/immune_meta.txt",
        counts_file_path = "./input/immune_count.h5ad",
        counts_data = 'hgnc_symbol',
        output_path = "./output/")

I got the following error.

Reading user files...
The following user files were loaded successfully:
./input/immune_count.h5ad
./input/immune_meta.txt
[ ][CORE][11/05/24-23:47:43][INFO] [Cluster Statistical Analysis] Threshold:0.1 Iterations:1000 Debug-seed:-1 Threads:4 Precision:3
[ ][CORE][11/05/24-23:47:44][INFO] No CellphoneDB interactions found in this input.
Traceback (most recent call last):
  File "immune_cells.py", line 3, in <module>
    cpdb_results  = cpdb_statistical_analysis_method.call(
  File "/data/shenhj/.anaconda3/envs/cpdb/lib/python3.8/site-packages/cellphonedb/src/core/methods/cpdb_statistical_analysis_method.py", line 148, in call
    significant_means = analysis_result['significant_means']
KeyError: 'significant_means'

Could you please explain the reason of this error?

Thx : )

shenhanjing commented 4 months ago

As some additions:

The input files are generated in R by the following method.

# R
# ztt.immune_cells is a seuratObj (version: seurat=v5.0.1)
immune_meta <- ztt.immune_cells@meta.data %>% 
  rownames_to_column("Cell") %>% 
  select(Cell,celltype) 
write.table(immune_meta, paste0(immune_cells_out_path, 'immune_meta.txt'), sep='\t', quote=F, row.names=F)

## save seuratObj as .h5ad file
library(SeuratData)
library(SeuratDisk)

options(Seurat.object.assay.version = "v3")
ztt.immune_cells_v3 = CreateSeuratObject(counts = GetAssayData(ztt.immune_cells, assay="RNA", layer = "counts"),
                            #data = GetAssayData(seurat.all.cc, assay="RNA", layer = "data"),
                            meta.data = ztt.immune_cells@meta.data)

SaveH5Seurat(ztt.immune_cells_v3, filename = paste0(immune_cells_out_path, "immune_count.h5Seurat"), overwrite = TRUE)
Convert(paste0(immune_cells_out_path, "immune_count.h5Seurat"), dest = "h5ad", overwrite = TRUE)
cakirb commented 4 months ago

Hi @shenhanjing,

To be able to debug the issue, could you send the input files you are using to contact@cellphonedb.org? If the files are too big to share via email, you can also send us the link to access them.

Best, Batu

shenhanjing commented 4 months ago

Hi @cakirb ,

The input file has been sent to your email, please check it.

Thanks, Hanjing

cakirb commented 4 months ago

Hi @shenhanjing,

Sorry about the delay! Before your error message, the function shows that no CellphoneDB interactions could be found. And when we checked your input object, we found out that it includes mouse genes. We explicitly advise users to use human genes, or convert the genes from different species to their corresponding human orthologues. You can check details in our documentation: https://cellphonedb.readthedocs.io/en/latest/RESULTS-DOCUMENTATION.html#counts-file

Hope this helps!!

Best, Batu

shenhanjing commented 4 months ago

Hi @shenhanjing,

Sorry about the delay! Before your error message, the function shows that no CellphoneDB interactions could be found. And when we checked your input object, we found out that it includes mouse genes. We explicitly advise users to use human genes, or convert the genes from different species to their corresponding human orthologues. You can check details in our documentation: https://cellphonedb.readthedocs.io/en/latest/RESULTS-DOCUMENTATION.html#counts-file

Hope this helps!!

Best, Batu

Thank you for your reply. It works now.