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
322 stars 51 forks source link

unexpected error #62

Closed rachel662 closed 10 months ago

rachel662 commented 2 years ago

Hi there

I gotan unexpected error when trying to run cellphonedb, on my terminal it says the following

[ ][CORE][20/09/22-15:14:08][INFO] Initializing SqlAlchemy CellPhoneDB Core
[ ][CORE][20/09/22-15:14:08][INFO] Using custom database at C:\Users\mfbx4rf4\.cpdb\releases\v4.0.0\cellphone.db
[ ][APP][20/09/22-15:14:08][INFO] Launching Method cpdb_statistical_analysis_local_method_launcher
[ ][APP][20/09/22-15:14:08][INFO] Launching Method _set_paths
[ ][APP][20/09/22-15:14:08][INFO] Launching Method _load_meta_counts
[ ][APP][20/09/22-15:14:35][INFO] Launching Method _check_counts_data
[ ][CORE][20/09/22-15:14:35][INFO] Launching Method cpdb_statistical_analysis_launcher
[ ][CORE][20/09/22-15:14:35][INFO] Launching Method _counts_validations
[ ][CORE][20/09/22-15:14:36][INFO] Launching Method get_interactions_genes_complex
[ ][CORE][20/09/22-15:14:38][INFO] [Cluster Statistical Analysis] Threshold:0.1 Iterations:1000 Debug-seed:-1 Threads:4 Precision:3
[ ][APP][20/09/22-15:14:43][ERROR] Unexpected error
Traceback (most recent call last):
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\cellphonedb\src\api_endpoints\terminal_api\method_terminal_api_endpoints\method_terminal_commands.py", line 150, in statistical_analysis
    debug,
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\cellphonedb\src\local_launchers\local_method_launcher.py", line 75, in cpdb_statistical_analysis_local_method_launcher
    output_path
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\cellphonedb\src\core\methods\method_launcher.py", line 111, in cpdb_statistical_analysis_launcher
    output_path)
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\cellphonedb\src\core\methods\cpdb_statistical_analysis_method.py", line 43, in call
    output_path
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\cellphonedb\src\core\methods\cpdb_statistical_analysis_complex_method.py", line 61, in call
    clusters = cpdb_statistical_analysis_helper.build_clusters(meta, counts_filtered, complex_composition_filtered, skip_percent=False)
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\cellphonedb\src\core\methods\cpdb_statistical_analysis_helper.py", line 141, in build_clusters
    npg.aggregate(meta[CELL_TYPE].cat.codes, counts.values, func='mean', axis=1),
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\numpy_groupies\aggregate_numba.py", line 492, in aggregate
    return func(group_idx, a, size, fill_value, order, dtype, axis, **kwargs)
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\numpy_groupies\aggregate_numba.py", line 42, in __call__
    iv = input_validation(group_idx, a, size=size, order=order, axis=axis, check_bounds=False, func=self.func)
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\numpy_groupies\utils_numpy.py", line 311, in input_validation
    group_idx, size = _ravel_group_idx(group_idx, a, axis, size, order, method=method)
  File "C:\Anaconda3\envs\cpdb\lib\site-packages\numpy_groupies\utils_numpy.py", line 231, in _ravel_group_idx
    mode='raise')
  File "<__array_function__ internals>", line 6, in ravel_multi_index
ValueError: invalid entry in coordinates array

would anyone be able to advise me on what the issue is? Cheers Rachel

prete commented 2 years ago

Hi @rachel662, thank you for using CellPhoneDB. Can't say what's up off the top of my head but can we quickly double check: a) The command you used to launch CellPhoneDB? b) That all your barcodes (cells) are in your meta file?

rachel662 commented 2 years ago

Hi there, thanks for getting back to me so quicly the command i used to launch cellphonedb after installing it via pip and activating an environment was

cellphonedb method statistical_analysis metadata.txt counts.txt

from opening the txt file I can see that the barcodes are in my meta file

Cheers, Rachel

prete commented 2 years ago

Hi Rachel, the error is usually related to NA values in your cell type annotation (meta file). Can you double check that or is there a way you could share those files with us so we can check directly?

rachel662 commented 2 years ago

Hi there, I've noticed I have one fewer row in my metadata than columns in my counts - i think this could also be the issue? I had to convert from mouse to human ensembl gene names so perhaps this has caused the problem?

rachel662 commented 2 years ago

I have also checked and I do have 3 NAs in one of my metadata columns

rachel662 commented 2 years ago

Would you have any suggestions for how to remove these NAs?

prete commented 2 years ago

Hi @rachel662 you can use python and pandas to read your metadata file as a csv (df = pd.read_csv('metadata.txt', sep='\t')) and afterwards use df.dropna() to remove any NAs there. Alternatively if you're using R you can use either na.omit(metadata.frame) or drop_na(metadata) if you're using tidyr.

rachel662 commented 2 years ago

hi there, I've done this and also deleted the relevant columns in the metadata but i still get theis error AttributeError: Can only use .str accessor with string values!

would you be able to help at all? thanks, Rachel

ZheFrench commented 2 years ago

I ve got exactly the same issue. I have no NA. I finally find out. One value for class in meta file was emtpy :/

kfijan commented 1 year ago

Hi, I am also getting this error, AttributeError: Can only use .str accessor with string values! but it's related to my counts data not meta data. Has anyone figured out how to fix this issue? There are no NA's in my counts data.

@prete - do you have any suggestions?

prete commented 1 year ago

@rachel662 @kfijan could you please double check that:

a) You don't have any N/A in your meta file b) You don't have any missing clusters/classes in your meta file c) All the clusters/classes in your meta file are strings (not just numbers)

singlece commented 1 year ago

Have you solved the problem? I got the same situation today. Thanks.

prete commented 1 year ago

Hi @singlece, like the previous answer, have you checked that you don't have any N/A in your meta file and that all the clusters/classes in your meta file are strings (not just numbers — if they are 1,2,3 rename them as c1,c2,c3)