sneumann / xcms

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

Extract MS2 data by "featureSpectra" or "spectra" #600

Open MuyaoXi9271 opened 2 years ago

MuyaoXi9271 commented 2 years ago

Dear Experts

Comparison "featureSpectra" with "spectra" on extraction of MS2 spectra.

The background is that I tried to extract MS2 spectra from XCMSnExp object (after doing gap-filling) by using "featureSpectra" featureSpectra(xcms_p_POS_g_r_g_fill, return.type = "MSpectra") and it succeeded. However, I noticed that a few MS2 spectra were indeed present in the XCMSnExp object, but they were not extracted by "featureSpectra". Instead, I found them from the results extracted by "spectra".

So my question is that is it possible to combine spectra obtained from "spectra", or what parameters could I add in "featureSpectra" to extract more ms2 spectra?

Bests, Muyao

jorainer commented 2 years ago

The spectra returns you all MS1 and/or MS2 spectra from your object. If you're interested in getting all MS2 spectra on an object xdata you can use spectra(filterMsLevel(xdata)).

featureSpectra is designed to just return MS2 spectra which are associated with a feature. This means, all MS2 spectra with a precursor m/z which is withing the min and max m/z and a retenten time which is within the rt range of any of the chromatographic peakse (EICs) of a feature is returned. The function has also additional parameters that allow to expand the rt range and the m/z range to look for MS2 spectra (have a look at ?featureSpectra for more information).

I hope this explains the difference.

MuyaoXi9271 commented 2 years ago

Hi Johannes,

If I use "spectra" to extract MS2 spectra, how can I combine spectra for each feature? As far as I learn, "combineSpectra" is now allowed the first input as a large list.

Bests, Muyao

jorainer commented 2 years ago

There are two different combineSpectra functions, one is in MSnbase, that works on MSpectra objects, the other is in Spectra that works on Spectra objects. Thus, it depends on the return.type parameter of featureSpectra which one you can use. With return.type = "MSpectra" you can only use MSnbase::combineSpectra, with return.type = "Spectra" you need to use Spectra::combineSpectra instead. Really sorry for this confusion.

Note that there is now a better description for Spectra::combineSpectra available here.