scyan icon indicating copy to clipboard operation
scyan copied to clipboard

Issue when running with reticulate

Open hrj21 opened this issue 10 months ago • 1 comments

Hello! Thank you for a very powerful tool for the cytometry community.

This perhaps isn't a bug per se, but I am having trouble running scyan through reticulate in R. I appreciate this is a python package and it isn't your responsibility to ensure it functions through the reticulate interface, but I wanted to post this in case the resolution was something obvious to you.

I start by setting up a conda environment as follows:

library(reticulate)
conda_create('r-scyan', python_version = '3.9')
use_condaenv(condaenv = 'r-scyan')
py_install("scyan", pip = TRUE)

I then recapitulate the basic usage demo from the Readme:

scyan <- import("scyan")
aml <- scyan$data$load("aml")

adata <- aml[[1]]
table <- aml[[2]]

model = scyan$Scyan(adata, table)

Everything seems to work fine until the last call to scyan$Scyan(), which gives me the following error:

Error in py_call_impl(callable, call_args$unnamed, call_args$named) : 
  AttributeError: 'AttributeDict' object has no attribute 'batch_key'
Run `reticulate::py_last_error()` for details.

Do you have any thoughts on what causes this? I have tried with my own dataset but get the exact same result. I've pasted my R session information below.

Best wishes Hefin

R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 22631)

Matrix products: default


locale:
[1] LC_COLLATE=English_United Kingdom.utf8  LC_CTYPE=English_United Kingdom.utf8   
[3] LC_MONETARY=English_United Kingdom.utf8 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.utf8    

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] reticulate_1.40.0

loaded via a namespace (and not attached):
 [1] utf8_1.2.4        Matrix_1.7-1      lattice_0.22-6    rappdirs_0.3.3    glue_1.8.0       
 [6] png_0.1-8         lifecycle_1.0.4   cli_3.6.3         fansi_1.0.6       vctrs_0.6.5      
[11] grid_4.4.1        withr_3.0.2       compiler_4.4.1    rprojroot_2.0.4   here_1.0.1       
[16] rstudioapi_0.17.1 tools_4.4.1       pillar_1.9.0      Rcpp_1.0.13-1     rlang_1.1.4      
[21] jsonlite_1.8.9   


python:         C:/Users/u061745/AppData/Local/miniconda3/envs/r-scyan/python.exe
libpython:      C:/Users/u061745/AppData/Local/miniconda3/envs/r-scyan/python39.dll
pythonhome:     C:/Users/u061745/AppData/Local/miniconda3/envs/r-scyan
version:        3.9.21 | packaged by conda-forge | (main, Dec  5 2024, 13:41:22) [MSC v.1929 64 bit (AMD64)]
Architecture:   64bit
numpy:          C:/Users/u061745/AppData/Local/miniconda3/envs/r-scyan/Lib/site-packages/numpy
numpy_version:  1.26.4
scyan:          C:\Users\u061745\AppData\Local\MINICO~1\envs\r-scyan\lib\site-packages\scyan\__init__.p

NOTE: Python version was forced by import("scyan")

hrj21 avatar Jan 20 '25 10:01 hrj21

Hi @hrj21, thanks for reporting. Unfortunately, I don't have any experience in reticulate so it's difficult for me to debug. Does everything work as expected using the python package directly? Please let me know if you find a solution or a potential way to fix it!

quentinblampey avatar Jan 21 '25 09:01 quentinblampey