lgatto / MSnbase

Base Classes and Functions for Mass Spectrometry and Proteomics
http://lgatto.github.io/MSnbase/
123 stars 50 forks source link

ERROR in reading GC×GC netCDF files #588

Closed SONGKai-PKU closed 6 months ago

SONGKai-PKU commented 1 year ago

Dear @lgatto

I converted GC×GC chromatograms into netCDF form, which could be potentially read by the MSnbase. However, when trying to read this file, several errors occurred. Could you please help me?

cooking_raw_data <- readMSData(files = list.files(), pdata = new("NAnnotatedDataFrame", cooking_meta), mode = "onDisk") Polarity can not be extracted from netCDF files, please set manually the polarity with the 'polarity' method. [1] "vobjtovarid4: error #F: I could not find the requsted var (or dimvar) in the file!" [1] "var (or dimvar) name: instrument_name" [1] "file name: F:\TDGCMS\Mobile_source\data_processing\comprehensive_pixel\Image_CDF_XCMS\cooking\CDF\cooking_gas_01_Run01_Img01.cdf" Error in vobjtovarid4(nc, varid, verbose = verbose, allowdimvar = TRUE) : Variable not found

Best regards, Kai

lgatto commented 1 year ago

MSnbase relies on mzR to parse raw data. Could you try they following and open an issue there:

library(mzR)
x <- openMSfile(list.files()[1]) ## assuming that list.files returns the correct file(s)

Have you tried converting to mzML?

SONGKai-PKU commented 1 year ago

Thanks for your reply. It did work in mzR. However, when converted into mzML, certain errors still occurs.

setwd("F:/TDGCMS/Mobile_source/data_processing/comprehensive_pixel/Image_CDF_XCMS/cooking/CDF/")

convert CDF into mzXL files

CDF_name <- list.files()[1] CDF_temp <- openMSfile(CDF_name)

Get the spectra

pks <- spectra(CDF_temp)

Get the header

hdr <- header(CDF_temp)

out_file_name <- CDF_name %>% stringr::word(sep = fixed(".cdf"))

setwd("F:/TDGCMS/Mobile_source/data_processing/comprehensive_pixel/Image_CDF_XCMS/cooking/mzXL/") writeMSData(object = pks, file = out_file_name, header = hdr)

reading mzML files after conversion

setwd("F:/TDGCMS/Mobile_source/data_processing/comprehensive_pixel/Image_CDF_XCMS/cooking/mzXL/") cooking_raw_data <- readMSData(files = list.files())

ERRORS:

Error in readInMemMSData(files, pdata = pdata, msLevel. = msLevel., verbose = verbose, : No MS(n>1) spectra in fileF:\TDGCMS\Mobile_source\data_processing\comprehensive_pixel\Image_CDF_XCMS\cooking\mzXL\cooking_gas_01_Run01_Img01

Please refer to the CDF files as follows, https://drive.google.com/drive/folders/1fKWLnNJHbnQipQmPY6c7-OmaOEju69hy?usp=sharing

BESIDES: the netCDF files could be read by MZmine software, yet the converted mzML files could not ::>_<::

Kai~

jorainer commented 1 year ago

Indeed, the error comes from the mzR::instrumentInfo function that is called by readMSData, seems the "instrument_name" field is missing in the CDF file. This would need to be fixed in mzR - but maybe it would even work with mzML.

Can you try to read the mzML file using the same settings (i.e. with mode = "onDisk")?

yguitton commented 2 months ago

Hi @lgatto

Just an info this cdf to mzML conversion trick worked for my GCMS Leco files where intrument_name variable is missing in the cdf but the size of the mzML file is 1.7 time bigger !

would be cool for GCMS users to have an option in MSnbase that allows cdffiles without these variables (the branch you made for me some years ago may help https://github.com/lgatto/MSnbase/tree/yguitton). I wasn't able to adapt it to the new R and xcms

Best Yann