rformassspectrometry / Spectra

Low level infrastructure to handle MS spectra
https://rformassspectrometry.github.io/Spectra/
37 stars 25 forks source link

Question/Documentation: Hdf5 backends #150

Closed ococrook closed 3 years ago

ococrook commented 3 years ago

I think I'm missing something in the documentation. I've already generated generated a dataset with an Hdf5 backend using:

fl <- c("data/N64184_1_HOIP_b.mzML")
HOIP_raw2 <- Spectra(fl, source = MsBackendMzR(), backend =  MsBackendHdf5Peaks())

unsupringly, when I come back to this analysis later I get the very reasonable result

Error in .local(object, ...) : 
  File(s) C:\Users\OllyC\Desktop\2020-HDXraw\data/N64184_1_HOIP_b.h5 does/do already exist

The question is how to start working again with this dataset at another time. My guess was the following after trying a few things, but this leads to an empty object:

HOIP_raw2 <- Spectra("N64184_1_HOIP_b.h5", source = MsBackendHdf5Peaks())
HOIP_raw2

MSn data (Spectra) with 0 spectra in a MsBackendHdf5Peaks backend:

double check for insanity

 "N64184_1_HOIP_b.h5" %in% dir()
[1] TRUE

I'm probably simply missing something very straightforward

jorainer commented 3 years ago

Ah, yes, sure. That will unfortunately not work that way. What should work is if you save/serialize your HOIP_raw2 with save (e.g. save(HOIP_raw2, file = "HOIP_raw2.RData") and then load it again later with load. The point is that the MsBackendHdf5Peaks does only store the peaks matrices in the hdf5 file(s), but not all the other required info such as msLevel etc. So you can't restore such a backend only from the hdf5 file itself.

ococrook commented 3 years ago

perfect, this works for me