Skip to content
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

attributes return no element called _index within read_zarr_data_frame_index #4

Closed
Artur-man opened this issue Nov 1, 2024 · 6 comments

Comments

@Artur-man
Copy link
Collaborator

Artur-man commented Nov 1, 2024

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

read_zarr_data_frame_index <- function(store, name, version = "0.2.0") {
version <- match.arg(version)
g <- pizzarr::zarr_open_group(store, path = name)
attributes <- g$get_attrs()$to_list()
index_name <- attributes$`_index`

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
Copy link
Collaborator Author

Artur-man commented Nov 1, 2024

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
Copy link
Collaborator Author

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

@keller-mark
Copy link
Owner

Hi @Artur-man those attributes are part of the AnnData on-disk format for dataframes https://anndata.readthedocs.io/en/latest/fileformat-prose.html#dataframe-specification-v0-2-0 You can check them by writing an anndata object with the python package like adata.write_zarr("my_adata.zarr") and then looking at the contents of my_adata.zarr/obs/.zattrs

@keller-mark
Copy link
Owner

Feel free to contribute to this repo, I just added you as a collaborator

@Artur-man
Copy link
Collaborator Author

Artur-man commented Nov 1, 2024

Started here #5 ... looks clean, and perhaps we can also later continue discussing the update on scverse#91 ?

@Artur-man
Copy link
Collaborator Author

ok so the indexing is sort of fixed here ... moving on!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants