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

Cannot handle obsm data with >2 dimensions #204

Open
human9 opened this issue Nov 27, 2024 · 0 comments
Open

Cannot handle obsm data with >2 dimensions #204

human9 opened this issue Nov 27, 2024 · 0 comments

Comments

@human9
Copy link

human9 commented Nov 27, 2024

Issue summary

AnnData only requires entries in obsm have "a first dimension of size n_obs", but AnndataR seems to additionally require that the number of dimensions is no larger than 2.

Example: reading h5ad

For example, I have an h5ad containing the following 3D obsm entry which I can load up in Python:

> import anndata
> adata = anndata.read_h5ad("spatial_data.h5ad")
> adata.obsm['cell_border'].shape

(130597, 32, 2)

I try to load it in anndataR:

> library(anndataR)
> adata <- read_h5ad("spatial_data.h5ad")

Error in private$.validate_aligned_array(collection[[mtx_name]], collection_name,  : 
  dim(obsm[['cell_border']])[1] should have shape: 130597, found: 2.

Example: saving h5ad

Also, I can create an object with some n-dimensional obsm in AnndataR manually, but I can't save it back to a file because it requires the entry to be a matrix:

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)
  ),
  obsm = list(borders = array(rep(0, 10*2*10), c(10, 2, 10))),
)
adata$to_HDF5AnnData("myanndata.h5ad")
Warning message:
  In value[[3L]](cond) :
  Could not write element 'obsm/borders' of type 'array':
  argument is not a matrix
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

1 participant