Teichlab / cellphonedb

MIT License
339 stars 105 forks source link

statistical_analysis does not work #259

Closed nagendraKU closed 3 years ago

nagendraKU commented 3 years ago

Installed cellphonedb as recommended, and was able to run the non-statistical analysis successfully. Running the following command shows error message. Same failure with python 3.7.3 & 3.8.3

cellphonedb method statistical_analysis test_meta.txt test_counts.txt

Output:

/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/sklearn/utils/deprecation.py:144: FutureWarning: The sklearn.cluster.kmeans module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.cluster. Anything that cannot be imported from sklearn.cluster is now part of the private API. warnings.warn(message, FutureWarning) [ ][APP][01/02/21-01:02:19][WARNING] Latest local available version is v2.0.0, using it [ ][APP][01/02/21-01:02:19][WARNING] User selected downloaded database v2.0.0 is available, using it [ ][CORE][01/02/21-01:02:19][INFO] Initializing SqlAlchemy CellPhoneDB Core [ ][CORE][01/02/21-01:02:19][INFO] Using custom database at /Users/kuuser/.cpdb/releases/v2.0.0/cellphone.db [ ][APP][01/02/21-01:02:19][INFO] Launching Method cpdb_statistical_analysis_local_method_launcher [ ][APP][01/02/21-01:02:19][INFO] Launching Method _set_paths [ ][APP][01/02/21-01:02:19][INFO] Launching Method _load_meta_counts [ ][CORE][01/02/21-01:02:20][INFO] Launching Method cpdb_statistical_analysis_launcher [ ][CORE][01/02/21-01:02:20][INFO] Launching Method _counts_validations [ ][CORE][01/02/21-01:02:20][INFO] [Cluster Statistical Analysis] Threshold:0.1 Iterations:1000 Debug-seed:-1 Threads:4 Precision:3 /Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/cellphonedb/src/core/methods/cpdb_statistical_analysis_helper.py:88: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy lambda protein: clusters['means'].at[protein, cluster_name]) [ ][CORE][01/02/21-01:02:20][INFO] Running Real Analysis [ ][APP][01/02/21-01:02:21][ERROR] Unexpected error Traceback (most recent call last): File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/cellphonedb/src/api_endpoints/terminal_api/method_terminal_api_endpoints/method_terminal_commands.py", line 144, in statistical_analysis subsampler, File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/cellphonedb/src/local_launchers/local_method_launcher.py", line 64, in cpdb_statistical_analysis_local_method_launcher subsampler File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/cellphonedb/src/core/methods/method_launcher.py", line 75, in cpdb_statistical_analysis_launcher self.separator) File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/cellphonedb/src/core/methods/cpdb_statistical_analysis_method.py", line 36, in call result_precision, File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/cellphonedb/src/core/methods/cpdb_statistical_analysis_complex_method.py", line 85, in call separator) File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/cellphonedb/src/core/methods/cpdb_statistical_analysis_helper.py", line 260, in percent_analysis percents = pd.DataFrame(columns=clusters['names'], index=clusters['means'].index) File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/pandas/core/frame.py", line 411, in init mgr = init_dict(data, index, columns, dtype=dtype) File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/pandas/core/internals/construction.py", line 242, in init_dict val = construct_1d_arraylike_from_scalar(np.nan, len(index), nan_dtype) File "/Users/kuuser/Downloads/cfiles/cellphonedb/cphdbenv/lib/python3.7/site-packages/pandas/core/dtypes/cast.py", line 1221, in construct_1d_arraylike_from_scalar dtype = dtype.dtype AttributeError: type object 'object' has no attribute 'dtype'

cechlauren commented 3 years ago

I am also getting the same issue, but with different line references for all but the last, which is what is producing the dtype error I believe. Using python3.8, my own data and cpdb-venv.

Charlesyip2016 commented 3 years ago

I am also facing the same issue. Using python3.8,conda-env

davidecui commented 3 years ago

I faced the exactly same stacktrace today, from a script that used to work until last friday. The cause seems a recent update of numpy, from 1.19.5 to 1.20.0. I solved with forcing the previous version in the requirements.txt

numpy==1.19.5

cechlauren commented 3 years ago

numpy==1.19.5

Thank you, updated my cpdb-venv with "python -m pip install numpy==1.19.5" and got it to work! Cheers.

nagendraKU commented 3 years ago

I faced the exactly same stacktrace today, from a script that used to work until last friday. The cause seems a recent update of numpy, from 1.19.5 to 1.20.0. I solved with forcing the previous version in the requirements.txt

numpy==1.19.5

This works ! Thanks for the help ! For anyone else installing the package new, pip3 install cellphonedb numpy==1.19.5 should fix the problem.

joshuacwnewton commented 3 years ago

Hello! I also encountered this problem on a separate project, and traced the issue to https://github.com/pandas-dev/pandas/issues/39520#issuecomment-770876494

I'm sharing this comment here just in case this is helpful for your own development. :slightly_smiling_face: