theislab / zellkonverter

Conversion between scRNA-seq objects
https://theislab.github.io/zellkonverter/
Other
144 stars 27 forks source link

altExps not being written to .h5ad file with writeH5AD #97

Open ScreachingFire opened 1 year ago

ScreachingFire commented 1 year ago

Hello!

I am having an issue where Alternative Experiments aren't being loaded when I try to read a .h5ad file after writing with writeH5AD(). For example:

> scdata
class: SingleCellExperiment
dim: 21703 22058
metadata(0): 
assays(1): counts
rownames(21703): RP11-34P13.7 FO538757.2 ... BPIFB4 KLF1 
rowData names(0): 
colnames(22058): hu_092618_AAACCTGAGGGAACGG hu_092618_AAACCTGAGGGCTTCC ... hu_080619_TTTGTTGTCCCATGGG hu_080619_TTTGTTGTCTCAATCT 
colData names(2): sample sex 
reducedDimNames(0): 
mainExpName: NULL 
altExpNames(1): test

I generated an SCE object with an alternative experiment test storing a 3000x22058 matrix. However, when writing it out and then reading it back in I get the following:

writeH5AD(scdata, "path_to_file", compression = 'lzf')
scdata <- readH5AD("path_to_file")

> scdata
class: SingleCellExperiment
dim: 21703 22058
metadata(0):
assays(1): counts
rownames(21703): RP11-34P13.7 FO538757.2 ... BPIFB4 KLF1
rowData names(0): 
colnames(22058): hu_092618_AAACCTGAGGGAACGG hu_092618_AAACCTGAGGGCTTCC ... hu_080619_TTTGTTGTCCCATGGG hu_080619_TTTGTTGTCTCAATCT
colData names(2): sample sex
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):

Is there anyway Alternative Experiments could be stored such that you can read/write them, as well as have them show up as a layer in anndata?

lazappi commented 1 year ago

Hi @ScreachingFire

Thanks for giving {zellkonverter} a go. Firstly, just for clarification, the .h5ad file format doesn't have a concept of alternative experiments so this is one of the things that can't be directly converted from a SingleCellExperiment. The closest thing is the raw slot which is similar but there can only be one in a file.

We are currently able to read the raw slot from a file but not write it to a new .h5ad. There may have been a technical reason for this but more likely it was just overlooked. If this is a feature you would like to have we can discuss adding it (or a PR would be even better).