-
-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
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
Labels
No labels