Teichlab / cellphonedb

MIT License
342 stars 105 forks source link

Error processing Meta data #371

Closed Zaein closed 2 years ago

Zaein commented 2 years ago

Good morning!

I am having troubles running CellphoneDB and I was hoping someone here could help me out. I was able to successfully run the test data.

My count data is 23,169 x 3,635:

Screen Shot 2022-05-05 at 8 33 55 AM

My meta.data is 3,635 x 2:

Screen Shot 2022-05-05 at 8 36 15 AM

I am writing both of these .csv files to .txt using this function: write.table(df, "/x/name", append = FALSE, sep = " ", dec = ".", row.names = FALSE, col.names = TRUE, quote=FALSE)

This is the command I am using to run CellPhoneDB: cellphonedb method analysis /x/meta.data1.txt /x/huOrtho.txt

This is the output and error that I am getting:

[ ][APP][05/05/22-08:28:02][WARNING] Latest local available version is v2.0.0, using it
[ ][APP][05/05/22-08:28:02][WARNING] User selected downloaded database v2.0.0 is available, using it
[ ][CORE][05/05/22-08:28:02][INFO] Initializing SqlAlchemy CellPhoneDB Core
[ ][CORE][05/05/22-08:28:02][INFO] Using custom database at /home/schweir3/.cpdb/releases/v2.0.0/cellphone.db
[ ][APP][05/05/22-08:28:02][INFO] Launching Method cpdb_analysis_local_method_launcher
[ ][APP][05/05/22-08:28:02][INFO] Launching Method _set_paths
[ ][APP][05/05/22-08:28:02][WARNING] Output directory (/home/schweir3/out) exist and is not empty. Result can overwrite old results
[ ][APP][05/05/22-08:28:02][INFO] Launching Method _load_meta_counts
[ ][APP][05/05/22-08:28:04][INFO] Launching Method _check_counts_data
[ ][CORE][05/05/22-08:28:04][INFO] Launching Method cpdb_method_analysis_launcher
[ ][APP][05/05/22-08:28:04][ERROR] Unexpected error
Traceback (most recent call last):
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/cellphonedb/src/core/preprocessors/method_preprocessors.py", line 28, in meta_preprocessor
    meta = pd.DataFrame(data={'cell_type': meta_raw.iloc[:, 1]})
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/pandas/core/indexing.py", line 873, in __getitem__
    return self._getitem_tuple(key)
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/pandas/core/indexing.py", line 1443, in _getitem_tuple
    self._has_valid_tuple(tup)
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/pandas/core/indexing.py", line 702, in _has_valid_tuple
    self._validate_key(k, i)
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/pandas/core/indexing.py", line 1352, in _validate_key
    self._validate_integer(key, axis)
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/pandas/core/indexing.py", line 1437, in _validate_integer
    raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/cellphonedb/src/api_endpoints/terminal_api/method_terminal_api_endpoints/method_terminal_commands.py", line 216, in analysis
    debug,
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/cellphonedb/src/local_launchers/local_method_launcher.py", line 119, in cpdb_analysis_local_method_launcher
    output_path)
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/cellphonedb/src/core/methods/method_launcher.py", line 132, in cpdb_method_analysis_launcher
    meta = method_preprocessors.meta_preprocessor(raw_meta)
  File "/home/schweir3/anaconda3/envs/cpdb/lib/python3.7/site-packages/cellphonedb/src/core/preprocessors/method_preprocessors.py", line 35, in meta_preprocessor
    raise ProcessMetaException
cellphonedb.src.core.exceptions.ProcessMetaException.ProcessMetaException: Error processing Meta data

Thank you to anyone that can help me out!

Zaein commented 2 years ago

I figured out the issue! It was with how I was creating the .txt files.

The R code to correctly create the .txt file from the .csv was: write.table(df, "/x/df.txt", append = FALSE, sep = "\t", dec = ".", row.names = FALSE, col.names = TRUE, quote=FALSE)

Things needed to be separated with tab apparently.