Teichlab / cellphonedb

MIT License
337 stars 105 forks source link

Need help: Recurrent error "TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U21') dtype('<U21') dtype('<U21')" #361

Closed hjbp0610 closed 2 years ago

hjbp0610 commented 2 years ago

Hi, all

I'm and trying to analyze my mouse scSeq data (which was converted to human orthologs) with CellPhoneDB. I asked for help through cellphonedb.org web page, but there was no reply, so I'm trying here github.

My original data was analyzed through Seurat, and I prepared the meta and count files extracted from Seurat object.

I used execution code as "cellphonedb method statistical_analysis cellphonedb_meta.txt cellphonedb_count.txt --counts-data=hgnc_symbol", and got the following error. I'm quite new to Python, so I have no idea what to do with this error code. I'm not sure if this means I need my count data as "string" or I currently have "string", which is wrong datatype.

============================================================================ [ ][APP][20/01/22-12:47:52][WARNING] Latest local available version is v2.0.0, using it [ ][APP][20/01/22-12:47:52][WARNING] User selected downloaded database v2.0.0 is available, using it [ ][CORE][20/01/22-12:47:52][INFO] Initializing SqlAlchemy CellPhoneDB Core [ ][CORE][20/01/22-12:47:52][INFO] Using custom database at C:\Users\hjbp0.cpdb\releases\v2.0.0\cellphone.db [ ][APP][20/01/22-12:47:52][INFO] Launching Method cpdb_statistical_analysis_local_method_launcher [ ][APP][20/01/22-12:47:52][INFO] Launching Method _set_paths [ ][APP][20/01/22-12:47:52][INFO] Launching Method _load_meta_counts [ ][APP][20/01/22-13:03:30][INFO] Launching Method _check_counts_data [ ][CORE][20/01/22-13:03:30][INFO] Launching Method cpdb_statistical_analysis_launcher [ ][CORE][20/01/22-13:03:30][INFO] Launching Method _counts_validations [ ][CORE][20/01/22-13:03:31][INFO] Launching Method get_interactions_genes_complex [ ][CORE][20/01/22-13:03:44][INFO] [Cluster Statistical Analysis] Threshold:0.1 Iterations:1000 Debug-seed:-1 Threads:4 Precision:3 [ ][CORE][20/01/22-13:03:51][INFO] Running Real Analysis [ ][APP][20/01/22-13:03:51][ERROR] Unexpected error Traceback (most recent call last): File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\pandas\core\ops\array_ops.py", line 143, in na_arithmetic_op result = expressions.evaluate(op, left, right) File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\pandas\core\computation\expressions.py", line 233, in evaluate return _evaluate(op, op_str, a, b) # type: ignore File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\pandas\core\computation\expressions.py", line 68, in _evaluate_standard return op(a, b) TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U21') dtype('<U21') dtype('<U21')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\hjbp0\AppData\Local\R-MINI~1\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:\Users\hjbp0\AppData\Local\R-MINI~1\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:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\cellphonedb\src\core\methods\method_launcher.py", line 111, in cpdb_statistical_analysis_launcher output_path) File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\cellphonedb\src\core\methods\cpdb_statistical_analysis_method.py", line 43, in call output_path File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\cellphonedb\src\core\methods\cpdb_statistical_analysis_complex_method.py", line 73, in call separator) File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\cellphonedb\src\core\methods\cpdb_statistical_analysis_helper.py", line 361, in mean_analysis columns=(pd.Series(cluster1_names) + separator + pd.Series(cluster2_names)).values) File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\pandas\core\ops\common.py", line 65, in new_method return method(self, other) File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\pandas\core\ops__init__.py", line 343, in wrapper result = arithmetic_op(lvalues, rvalues, op) File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\pandas\core\ops\array_ops.py", line 190, in arithmetic_op res_values = na_arithmetic_op(lvalues, rvalues, op) File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\pandas\core\ops\array_ops.py", line 150, in na_arithmetic_op result = masked_arith_op(left, right, op) File "C:\Users\hjbp0\AppData\Local\R-MINI~1\envs\cpdb\lib\site-packages\pandas\core\ops\array_ops.py", line 112, in masked_arith_op result[mask] = op(xrav[mask], y) TypeError: ufunc 'add' did not contain a loop with signature matching types dtype('<U21') dtype('<U21') dtype('<U21')

==============================================================

When I run the same code in Mac, the error code is a little more in detail, saying " numpy.core.exceptions. UFuncNoLoopError: ufunc 'add' did not contain a loop with signature matching types (dtype('<U21'), dtype('<U21')) -> dtype('<U21')".

Could anybody please give some insight for me? Thank you very much for your help, in advance.

hjbp0610 commented 2 years ago

I resolved the issue myself :)

I was using cluster instead of cell types (because the annotation is not yet complete), so metadata included number, instead string. I changed the datatype into string, and finished the analysis.