keller-mark / anndataR

AnnData interoperability in R
https://anndatar.data-intuitive.com
Other
0 stars 0 forks source link

attributes return no element called `_index` within `read_zarr_data_frame_index` #4

Open Artur-man opened 4 hours ago

Artur-man commented 4 hours ago

Here, attritube doesnt have any elemend called _index. Hence, failes calling the ZarrAnnData.

https://github.com/keller-mark/anndataR/blob/87907159024d7c3152aedadb4a0196e373c6227a/R/read_zarr_helpers.R#L461-L468

adata <- AnnData(
  X = matrix(rnorm(100), nrow = 10),
  obs = data.frame(
    cell_type = factor(rep(c("A", "B"), each = 5))
  ),
  var = data.frame(
    gene_name = paste0("gene_", 1:10)
  )
)
write_zarr(adata, store = "data/example.zarr", compression = "gzip")
adata <- read_zarr(path = "data/example.zarr", to = "ZarrAnnData")

> adata
debugging in: read_zarr_data_frame_index(private$zarr_store, "obs")
debug at /Users/amanuky/Dropbox/Research/MDC/Projects/SpatialData/Packages/anndataR/R/read_zarr_helpers.R#461: {
    version <- match.arg(version)
    g <- pizzarr::zarr_open_group(store, path = name)
    attributes <- g$get_attrs()$to_list()
    index_name <- attributes$`_index`
    read_zarr_element(store, file.path(name, index_name))
}

...
Browse[2]> 
debug at /Users/amanuky/Dropbox/Research/MDC/Projects/SpatialData/Packages/anndataR/R/read_zarr_helpers.R#468: index_name <- attributes$`_index`
Browse[2]> attributes
$`encoding-type`
[1] "dataframe"

$`encoding-version`
[1] "dataframe"

Browse[2]> 
debug at /Users/amanuky/Dropbox/Research/MDC/Projects/SpatialData/Packages/anndataR/R/read_zarr_helpers.R#470: read_zarr_element(store, file.path(name, index_name))
Browse[2]> 
Error in if (!is.na(path)) { : argument is of length zero
Artur-man commented 3 hours ago

It seems AbstractAnnData and AnnData have been drastically updated, that now private variables such as obs_names and var_names are not used anymore. Hence, ZarrAnnData should do the same, and how would you keep up with all other changes ?

https://github.com/scverse/anndataR/blob/dbc6897492d129bc59bf8de51bdaafdf90bcd22a/R/HDF5AnnData.R#L1-L13

Fancy if I make some changes and push to your zarr branch ?

Artur-man commented 4 minutes ago

@keller-mark can you tell me what is the function of attributes _index and column-order. Are these lazy ordering attributes ?