sneumann / xcms

This is the git repository matching the Bioconductor package xcms: LC/MS and GC/MS Data Analysis
Other
177 stars 81 forks source link

LC-MS/MS single XCMSnExp objects containing the data of each isolation window #630

Closed hansenju closed 1 year ago

hansenju commented 1 year ago

Dear developers, thank your for the great xcms package. I am trying to use the MS2 data for a fingerprint analysis. My data (vDIA thermoscientific) is very similar to the SWATH data in the LC-MS/MS data analysis with xcms vignette. Since we don't want to identify specific compounds, I ran findChromPeaks() and findChromPeaksIsolationWindow() but skipped the reconstructChromPeakSpectra() step.

library(xcms)
library(magrittr)
library(data.table)

swath_file <- system.file("TripleTOF-SWATH",
                          "PestMix1_SWATH.mzML",
                          package = "msdata")

swath_data <- readMSData(swath_file, mode = "onDisk")

cwp <- CentWaveParam(snthresh = 5, noise = 100, ppm = 10,
                     peakwidth = c(3, 30))
swath_data <- findChromPeaks(swath_data, param = cwp)

cwp <- CentWaveParam(snthresh = 3, noise = 10, ppm = 10,
                     peakwidth = c(3, 30))
swath_data <- findChromPeaksIsolationWindow(swath_data, param = cwp)

swath_data is a XCMSnExp object with the correct isolation windows. For my approach, single XCMSnExp objects containing the data of each isolation window would be very helpful because I would like to use the chromatogram() function in the next step. Is it possible to extract this information directly from the XCMSnExp object? My current approach is to use chromPeaks() and chromPeaksData() to access the information.

Thanks in advance. Jule

jorainer commented 1 year ago

Hi Jule,

there would be two options to split an XCMSnExp by isolation window. The first would be to use split(swath_data, f = isolationWindow) which should give you the data subsetted by isolation window - you would obviously need the variable isolationWindow that defines the isolation windows (could be you have that already in fData(swath_data)$isolationWindow.

The second option would be to use the filterIsolationWindow function to subset swath_data to the specified isolation window. The function would expect a single m/z value mz and would return a subsetted object with all spectra with their isolationWindowLowerMz <= mz and isolationWindowUpperMz >= mz.

Hope that helps. Let me know if something is not working as expected.

hansenju commented 1 year ago

Thank you very much, it's working as expected.

jorainer commented 1 year ago

Closing this issue now. Feel free to re-open if needed.