-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reticulate 1.36 breaks anndata R #28
Comments
Thanks for reporting this! Here is a minimum reproducible example: library(anndata)
ad <- AnnData(
X = matrix(0:5, nrow = 2),
obs = data.frame(group = c("a", "b"), row.names = c("s1", "s2")),
var = data.frame(type = c(1L, 2L, 3L), row.names = c("var1", "var2", "var3")),
layers = list(
spliced = matrix(4:9, nrow = 2),
unspliced = matrix(8:13, nrow = 2)
)
)
adpy <- ad$.__enclos_env__$private$.anndata
adpy$obs
# group
# s1 a
# s2 b
reticulate::py_to_r(adpy$obs)
# Error: Expected a python object, received a character
class(adpy$obs)
# [1] "pandas.core.frame.DataFrame" "pandas.core.generic.NDFrame" "pandas.core.base.PandasObject" "pandas.core.accessor.DirNamesMixin"
# [5] "pandas.core.indexing.IndexingMixin" "pandas.core.arraylike.OpsMixin" "python.builtin.object" |
Here's an even smaller example: library(reticulate)
df <- data.frame(
row.names = c("s1", "s2"),
group = c("a", "b")
)
py_to_r(r_to_py(df)) # works
# group
# s1 a
# s2 b
library(anndata)
py_to_r(r_to_py(df))
# Error: Expected a python object, received a character |
This issue was fixed by rstudio/reticulate#1592 and will be included in the next release of reticulate. For the time being, users encountering this issue can switch to the latest version of reticulate by running |
Fixed in reticulate 1.36.1 |
Anndata throws an error when trying to access for example
.obs
:Error: Expected a python object, received a character
Might be related to rstudio/reticulate#1531
The text was updated successfully, but these errors were encountered: