Skip to content

Warn that matrix dimnames are not stored in uns #331

@LouiseDck

Description

@LouiseDck
h5ad_file <- system.file("extdata", "example.h5ad", package = "anndataR")
adata <- read_h5ad(h5ad_file)

# generate random matrix with dimnames
named_matrix <- matrix(rnorm(20), nrow = 5, ncol = 4)
rownames(named_matrix) <- paste0("Row", 1:5)
colnames(named_matrix) <- paste0("Col", 1:4)

adata$uns[["named_matrix"]] <- named_matrix
#             Col1       Col2       Col3        Col4
# Row1  0.44347140 -0.3506371  1.0323446 -0.03400620
# Row2 -0.99902193  0.1735424 -0.2974675  0.39795719
# Row3  1.15786673  0.5032449 -0.1217729 -0.05625188
# Row4  0.08085226  1.8353912 -1.4228116 -0.38971408
# Row5  0.14804978  1.4974531 -0.3820515 -0.16296954

adata$write_h5ad("output.h5ad")

adata2 <- read_h5ad("output.h5ad")
adata2$uns[["named_matrix"]]
#             [,1]       [,2]       [,3]        [,4]
# [1,]  0.44347140 -0.3506371  1.0323446 -0.03400620
# [2,] -0.99902193  0.1735424 -0.2974675  0.39795719
# [3,]  1.15786673  0.5032449 -0.1217729 -0.05625188
# [4,]  0.08085226  1.8353912 -1.4228116 -0.38971408
# [5,]  0.14804978  1.4974531 -0.3820515 -0.16296954

We should at least issue a warning when writing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions