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

Getting MS1 spectrum for xcms features #611

Open jorainer opened 2 years ago

jorainer commented 2 years ago

The featureSpectra allows to extract MS1 spectra for each features from an XCMSnExp. To extract the MS1 spectra closest to the apex position of the chromatographic peaks associated with the features:

ms1 <- featureSpectra(xdata, msLevel = 1L, method = "closest_rt", return.type = "Spectra")

This will return a Spectra object with all MS1 spectra for all chromatographic peaks for all features in xdata. The method = "closest_rt" defines that, for each chromatographic peak, the MS1 spectrum closest to the apex position is selected. The feature and peak IDs are available with ms1$peak_id and ms1$feature_id. Alternatively, with return.type = "List" a List of Spectra objects is returned - one Spectra for each feature. Also, it would be possible to extract MS1 for specific features only by providing their IDs with the features parameter.

Let me know if you would need some alternative/different way to extract data @RogerGinBer

jorainer commented 2 years ago

The resulting Spectra could then eventually be filtered restricting to peaks of interest (based on their expected m/z) using the Spectra::filterMzValues function.

RogerGinBer commented 2 years ago

That looks very cool, @jorainer ! :+1: I'll give it a try and let you know if I need anything else