theislab / zellkonverter

Conversion between scRNA-seq objects
https://theislab.github.io/zellkonverter/
Other
144 stars 27 forks source link

Error when converting `obs_names` #74

Closed simonmfr closed 1 year ago

simonmfr commented 1 year ago

Hi, I keep getting an error about adata$obs_names$to_list: $ operator is invalid for atomic vectors:

image

Any help/suggestions? Would be much appreciated.

adata$obs_names is a character vector (using the anndata R package):

image

Using zellkonverter 1.7.7:

R version 4.2.1 (2022-06-23 ucrt) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 14393)

Matrix products: default

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

other attached packages: [1] zellkonverter_1.7.7 anndata_0.7.5.5 EnhancedVolcano_1.14.0 [4] ggrepel_0.9.1 SeuratDisk_0.0.0.9020 sp_1.5-0
[7] SeuratObject_4.1.2 Seurat_4.2.0 data.table_1.14.2
[10] forcats_0.5.2 stringr_1.4.1 dplyr_1.0.10
[13] purrr_0.3.4 readr_2.1.2 tidyr_1.2.0
[16] tibble_3.1.7 ggplot2_3.3.6 tidyverse_1.3.1

lazappi commented 1 year ago

Hi @simonmfr

Thanks for giving {zellkonverter} a go! That's weird, I'm not really sure what has happened there. Are you able to share the .h5ad file (or a small subset that reproduces the issue)? Can you also try reading the file without loading the R {anndata} package first? I have never really tested that and I'm wondering if somehow there is an interaction there.

P.S. For future reference please include code examples directly in backticks (```your code```) rather than an image, it's much easier to read that way.

simonmfr commented 1 year ago

The anndata package was indeed the culprit, does not seem to be compatible with zellkonverter currently. Thanks!

lazappi commented 1 year ago

Thanks for checking! I am going to open a new issue about the {anndata} incompatibility, feel free to follow allow if you are interested.

rcannood commented 1 year ago

Thanks for noticing this! I'm checking with @lazappi as to what the best solution could be regarding making sure that both packags can be loaded at the same time.

The main issue is that anndata (the R package) creates a few reticulate converters which zellkonverter automatically picks up when anndata is loaded.

For now, if you want to use zellkonverter and anndata in the same environment, you can always not load anndata. For example:

library(zellkonverter)
file <- system.file("extdata", "krumsiek11.h5ad", package = "zellkonverter")

# this works
ad <- anndata::read_h5ad(file)

# this also works
sce <- readH5AD(file)