Converting MS formats to move data between tools can be done using the following steps:
- Load the library and import the source data file:
library(mzR)
mzxml_file <- file.path(getwd(), "datasets", "ch6", "threonine_i2_e35_pH_tree.mzXML")
mzdata <- openMSfile(mzxml_file)
- Extract the header and peak data:
header_info <- header(mzdata)
peak_data_list <- spectra(mzdata)
- Write the data into a new format file:
writeMSData(peak_data_list,
file.path(getwd(), "datasets", "ch6", "out.mz"),
header = header_info,
outformat = "mzml",
rtime_seconds = TRUE
)