scverse/anndataR

Previously written fields are not cleaned up

Opened this issue · 0 comments

library(anndataR)
library(Matrix)

a = AnnData(obs_names=as.character(1:10), var_names=as.character(1:10), layer=list(foo=matrix(1, 10, 10)))
write_h5ad(a, "test.h5ad")

b = AnnData(obs_names=as.character(1:100), var_names=as.character(1:10), X=matrix(0, 100, 10))
write_h5ad(b, "test.h5ad")
$ h5ls -r test.h5ad
/                        Group
/X                       Dataset {100, 10}
/layers                  Group
/layers/foo              Dataset {10, 10}
/obs                     Group
/obs/_index              Dataset {100}
/obsm                    Group
/obsp                    Group
/uns                     Group
/var                     Group
/var/_index              Dataset {10}
/varm                    Group
/varp                    Group

layers/foo is still in the file, though b did not have that entry. layers/foo is also not of the correct shape, making the file invalid.