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: 'gene_synonym_to_gene_name' #113

Closed YinCY123 closed 1 year ago

YinCY123 commented 1 year ago

Hello, thanks for this great package!

I'm now try to use this package for my single cell data, but when I'm running the example of cpdb_statistical_analysis_method, there rise the following error. How can i fix it?

from cellphonedb.src.core.methods import cpdb_statistical_analysis_method

deconvoluted, means, pvalue, significant_means = cpdb_statistical_analysis_method.call( cpdb_file_path = "/home/yincy/git/data/cellphonedb/v4.0.0/cellphonedb_v4.0.0.zip", meta_file_path = "../github/CellphoneDB/example_data/test_meta.txt", counts_file_path = "../github/CellphoneDB/example_data/test_counts.txt", counts_data = "ensembl", output_path = "/home/yincy/git/mouse-kidney/cpdb_outs/", threshold = 0.1, threads = 4 )

KeyError Traceback (most recent call last) Cell In[3], line 3 1 from cellphonedb.src.core.methods import cpdb_statistical_analysis_method ----> 3 deconvoluted, means, pvalue, significant_means = cpdb_statistical_analysis_method.call( 4 cpdb_file_path = "/home/yincy/git/data/cellphonedb/v4.0.0/cellphonedb_v4.0.0.zip", 5 meta_file_path = "../github/CellphoneDB/example_data/test_meta.txt", 6 counts_file_path = "../github/CellphoneDB/example_data/test_counts.txt", 7 counts_data = "ensembl", 8 output_path = "/home/yincy/git/mouse-kidney/cpdb_outs/", 9 threshold = 0.1, 10 threads = 4 11 )

File ~/venvs/biopy/lib/python3.9/site-packages/cellphonedb/src/core/methods/cpdb_statistical_analysis_method.py:95, in call(cpdb_file_path, meta_file_path, counts_file_path, counts_data, output_path, microenvs_file_path, iterations, threshold, threads, debug_seed, result_precision, pvalue, subsampling, subsampling_log, subsampling_num_pc, subsampling_num_cells, separator, debug, output_suffix) 90 raise MissingRequiredArgumentsException(description="All of the following arguments need to be provided: {}".format( \ 91 "cpdb_file_path, meta_file_path, counts_file_path, counts_data, output_path")) 93 # Load into memory CellphoneDB data 94 interactions, genes, complex_composition, complex_expanded, gene_synonym2gene_name = \ ---> 95 db_utils.get_interactions_genes_complex(cpdb_file_path) 97 # Load user files into memory 98 counts, meta, microenvs, degs = file_utils.get_user_files( \ 99 counts_fp=counts_file_path, meta_fp=meta_file_path, microenvs_fp=microenvs_file_path, \ 100 gene_synonym2gene_name=gene_synonym2gene_name, counts_data=counts_data)

File ~/venvs/biopy/lib/python3.9/site-packages/cellphonedb/utils/db_utils.py:46, in get_interactions_genes_complex(cpdb_file_path) 43 dbTableDFs = extract_dataframes_from_db(cpdb_file_path) 44 # Convert dbTableDFs into interactions, genes, complex_composition, complex_expanded data frames 45 # and gene_synonym2gene_name dict ---> 46 gs2gn = dbTableDFs['gene_synonym_to_gene_name'] 47 gene_synonym2gene_name = dict(zip(gs2gn['Gene Synonym'], gs2gn['Gene Name'])) 49 mtTable = dbTableDFs['multidata_table']

KeyError: 'gene_synonym_to_gene_name'

ktroule commented 1 year ago

Hi,

A couple of checks to understand your issue.

1) Are you using mice id as input? 2) Have you converted the database to match your mouse ids to the human ids in the database? 3) Do you have the source files in the same folder where you have the database zip?

Thanks

YinCY123 commented 1 year ago

Actually, I'm running statistical_analysis_method with the sample data located in the Ventolab/CellPhonedb/example_data/. Those files have the right human ids in the database.

But I'm not sure if the database zip file is correct. I download the five database files and zip those files into a folder.

The modules I'm installed as follows:

anndata 0.9.1 biopython 1.81 CellphoneDB 4.0.0 certifi 2023.5.7 charset-normalizer 3.1.0 contourpy 1.0.7 cycler 0.11.0 fbpca 1.0 fonttools 4.39.3 geosketch 1.2 h5py 3.8.0 idna 3.4 importlib-resources 5.12.0 joblib 1.2.0 kiwisolver 1.4.4 ktplotspy 0.1.10 matplotlib 3.7.1 mizani 0.9.0 natsort 8.3.1 numpy 1.24.3 numpy-groupies 0.9.20 packaging 23.1 pandas 2.0.1 patsy 0.5.3 Pillow 9.5.0 pip 23.1.2 plotnine 0.10.1 pyparsing 3.0.9 python-circos 0.3.0 python-dateutil 2.8.2 pytz 2023.3 requests 2.30.0 scikit-learn 0.24.0 scipy 1.10.1 seaborn 0.12.2 setuptools 67.6.1 six 1.16.0 statsmodels 0.14.0 threadpoolctl 3.1.0 tqdm 4.65.0 tzdata 2023.3 urllib3 2.0.2 wheel 0.40.0 zipp 3.15.0

Thanks for your reply!

ktroule commented 1 year ago

In order to download the database check this notebook.

YinCY123 commented 1 year ago

Thank you for your help, the problem has been solved, it is the database's problem.