KrishnaswamyLab / phateR

PHATE dimensionality reduction method implemented in R
GNU General Public License v2.0
77 stars 9 forks source link

Error: $ operator is invalid for atomic vectors #49

Closed AndrewSkelton closed 4 years ago

AndrewSkelton commented 4 years ago

Describe the bug

Error: $ operator is invalid for atomic vectors

To Reproduce

library(phateR)
X <- phateR::tree.data.small$data
X_phate <- phate(X)

Expected behavior Phate to Run without error

Actual behavior The phate function produces the above error, and unfortunately I can't figure out where the root issue is.

System information:

Output of phate.__version__:

Please run phate.__version__ and paste the results here.

You can do this with `python -c 'import phate; print(phate.__version__)'`

Output of pd.show_versions():

``` Please run pd.show_versions() and paste the results here. You can do this with `python -c 'import pandas as pd; pd.show_versions()'` ```

Output of sessionInfo():

``` R version 4.0.2 (2020-06-22) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Catalina 10.15.5 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] reticulate_1.16 phateR_1.0.4 Matrix_1.2-18 loaded via a namespace (and not attached): [1] Rcpp_1.0.4.6 rstudioapi_0.11 knitr_1.29 magrittr_1.5 rappdirs_0.3.1 tidyselect_1.1.0 munsell_0.5.0 colorspace_1.4-1 lattice_0.20-41 R6_2.4.1 [11] rlang_0.4.6 dplyr_1.0.0 tools_4.0.2 grid_4.0.2 gtable_0.3.0 xfun_0.15 htmltools_0.5.0 ellipsis_0.3.1 yaml_2.2.1 digest_0.6.25 [21] tibble_3.0.1 lifecycle_0.2.0 crayon_1.3.4 purrr_0.3.4 ggplot2_3.3.2 vctrs_0.3.1 memoise_1.1.0 glue_1.4.1.9000 evaluate_0.14 rmarkdown_2.3 [31] pillar_1.4.4 compiler_4.0.2 generics_0.0.2 scales_1.1.1 jsonlite_1.7.0 pkgconfig_2.0.3 ```

Output of reticulate::py_discover_config(required_module = "phate"):

``` python: /Users/andrewskelton/Library/r-miniconda/envs/r-reticulate/bin/python libpython: /Users/andrewskelton/Library/r-miniconda/envs/r-reticulate/lib/libpython3.6m.dylib pythonhome: /Users/andrewskelton/Library/r-miniconda/envs/r-reticulate:/Users/andrewskelton/Library/r-miniconda/envs/r-reticulate version: 3.6.10 | packaged by conda-forge | (default, Apr 24 2020, 16:27:41) [GCC Clang 9.0.1 ] numpy: /Users/andrewskelton/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/numpy numpy_version: 1.18.5 ```

Output of phateR::check_pyphate_version():

``` Error: object of type 'closure' is not subsettable ```

Additional context Add any other context about the problem here.

scottgigante commented 4 years ago

You'll want to load the data with the builtin data function.

> library(phateR)
> data("tree.data.small")
> X <- tree.data.small$data
scottgigante commented 4 years ago

Though looking in more detail this may not be the issue. There should be more error text than just what you pasted -- can you paste the full log from the commands you ran?

scottgigante commented 4 years ago

Also, you haven't run the diagnostics for the PHATE python package. Can you paste the output of phate.__version__ and pd.show_versions()?

AndrewSkelton commented 4 years ago

Sure, Thanks for the response.

Full Command Log:

> library(phateR)
> data("tree.data.small")
> X <- tree.data.small$data
> X_phate <- phate(X)
Error: $ operator is invalid for atomic vectors
> 

Noteworthy that the data imports correctly:

> X[1:5,1:5]
          [,1]      [,2]       [,3]       [,4]       [,5]
[1,]  8.132258  3.488540 -0.4705138  2.3645012 -0.2709322
[2,]  1.195481 -2.998776 -5.0235553  0.7382647 -1.2045404
[3,]  9.982471  7.553401 -5.4184183  3.7043284  9.5906120
[4,] -1.682318 -6.412553 -0.4101279  5.2041908 -1.0131886
[5,]  1.283608 -3.722553  3.3639010 -5.5879818  7.6889156

Python Stuff:

 % python
Python 3.7.4 (default, Aug 13 2019, 15:17:50) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import phate
>>> import pandas as pd
>>> phate.__version__
'1.0.4'
>>> pd.show_versions()

INSTALLED VERSIONS
------------------
commit           : None
python           : 3.7.4.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 19.5.0
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : en_GB.UTF-8
LOCALE           : en_GB.UTF-8

pandas           : 0.25.1
numpy            : 1.17.2
pytz             : 2019.3
dateutil         : 2.8.0
pip              : 19.2.3
setuptools       : 41.4.0
Cython           : 0.29.13
pytest           : 5.2.1
hypothesis       : None
sphinx           : 2.2.0
blosc            : None
feather          : None
xlsxwriter       : 1.2.1
lxml.etree       : 4.4.1
html5lib         : 1.0.1
pymysql          : None
psycopg2         : None
jinja2           : 2.10.3
IPython          : 7.8.0
pandas_datareader: None
bs4              : 4.8.0
bottleneck       : 1.2.1
fastparquet      : None
gcsfs            : None
lxml.etree       : 4.4.1
matplotlib       : 3.1.1
numexpr          : 2.7.0
odfpy            : None
openpyxl         : 3.0.0
pandas_gbq       : None
pyarrow          : None
pytables         : None
s3fs             : None
scipy            : 1.3.1
sqlalchemy       : 1.3.9
tables           : 3.5.2
xarray           : None
xlrd             : 1.2.0
xlwt             : 1.3.0
xlsxwriter       : 1.2.1
>>> 

Hope that helps narrow the issue. Happy to provide more information

scottgigante commented 4 years ago

Note that in the reticulate config you are running python 3.6.10 but the version you showed PHATE installed in is 3.7.4. You can either remove the r-reticulate env altogether (/Users/andrewskelton/Library/r-miniconda/envs/r-reticulate/) and tell reticulate to use your default python (which python in bash will tell you where) or you can install PHATE in the reticulate env with

/Users/andrewskelton/Library/r-miniconda/envs/r-reticulate/bin/python -m pip install phate
scottgigante commented 4 years ago

I'll look into why the error message is uninformative.

AndrewSkelton commented 4 years ago

Sorry in advance that my Python knowledge is pretty weak in terms of package management. Thanks for the pointer in versions... As far as I was aware, apart from system python, the conda python version was all that was on my system. I'd already pip installed phate without issue, however I kept getting non-specific conda conflict errors when installing, even in a new conda environment. Running pip3 install phate, "fixed" it and Phate runs in R now. I'd guess that something is messed up in my Python setup.

scottgigante commented 4 years ago

No problem, you're not the only one! https://xkcd.com/1987/

Closing this now as it seems to be resolved. Feel free to reopen if you run into further issues.

matthpich commented 3 years ago

Hi, If it helps, I get the same error, having installed phate through reticulate:

> reticulate::py_discover_config("phate")
python:         /Users/xxx/Library/r-miniconda/envs/r-reticulate/bin/python
libpython:      /Users/xxx/Library/r-miniconda/envs/r-reticulate/lib/libpython3.6m.dylib
pythonhome:     /Users/xxx/Library/r-miniconda/envs/r-reticulate:/Users/xxx/Library/r-miniconda/envs/r-reticulate
version:        3.6.11 | packaged by conda-forge | (default, Nov 27 2020, 18:51:43)  [GCC Clang 11.0.0]
numpy:          /Users/xxx/Library/r-miniconda/envs/r-reticulate/lib/python3.6/site-packages/numpy
numpy_version:  1.19.4
> data("tree.data.small")
> X <- tree.data.small$data
> X_phate <- phate(X)
Error: $ operator is invalid for atomic vectors
> is.atomic(X)
[1] TRUE
> is.recursive(X)
[1] FALSE
scottgigante commented 3 years ago

@matthpich can you please make sure your phateR version is up to date?

matthpich commented 3 years ago

It works like a charm. Sorry for the false alarm and thanks a lot for your prompt help.

paolabc commented 1 year ago

Hi There!

I have the same error, and I installed it by using pip3 did not work to correct the issue. By the way, the phate version installed is 1.0.11.

phate <- phateR::phate(t(GetAssayData(seurat_integratedObj,assay = "RNA",slot = "data"))) Error: $ operator is invalid for atomic vectors

I also teste in the example above, and it generated the same error data("tree.data.small") X <- tree.data.small$data X_phate <- phate(X) Error: $ operator is invalid for atomic vectors

Can someone help to figure out what it is going on?

Thanks, Paola

scottgigante commented 1 year ago

Your version of phateR is out of date. Please run update.packages("phateR"). If you are still having issues, please open a new issue and fill in the issue template.

paolabc commented 1 year ago

Hi There

Thank you for your quickly answer. It works now.

Thank you, Paola