combineSpectra of a feature
ricoderks opened this issue · comments
Hi,
I'am analysing 3 data files with MSMS data. I used centwave for the peak picking and obiwarp for the alignment. I use the function featureSpectra
(method closest_rt) to extract the MSMS of a feature. This means for each feature I have 3 MSMS spectra. Below the code I used and an example of 3 MSMS spectra of a feature.
spectra_closest <- xcms::featureSpectra(x = xdata,
msLevel = 2L,
return.type = "Spectra",
expandMz = 0.01,
ppm = 100,
method = "closest_rt")
Spectra::plotSpectra(spectra_closest[which(spectra_closest$feature_id == "FT469")])
If I then use the function combineSpectra
(from Spectra). I still get the same 3 MSMS spectra.
spectra_closest_combine <- Spectra::combineSpectra(x = spectra_closest,
FUN = Spectra::combinePeaks,
tolerance = 0.025,
ppm = 100,
peaks = "union",
intensityFun = base::mean,
mzFun = base::mean,
f = spectra_closest$feature_id)
Spectra::plotSpectra(spectra_closest_combine[which(spectra_closest_combine$feature_id == "FT469")])
I'am doing something wrong here?
If I use combineSpectra
a second time I get one MSMS spectrum per feature, but it doesn't really that nice.
spectra_closest_combine2 <- Spectra::combineSpectra(x = spectra_closest_combine,
FUN = Spectra::combinePeaks,
tolerance = 0.025,
ppm = 100,
peaks = "union",
intensityFun = base::mean,
mzFun = base::mean,
f = spectra_closest_combine$feature_id)
Spectra::plotSpectra(spectra_closest_combine2[which(spectra_closest_combine2$feature_id == "FT469")])
Can you help me with this? Why do I need to use the combineSpectra
function twice? The intensities are quite off in the last MSMS spectrum compared to the MSMS spectra above?
Cheers, Rico
I just noticed an extra parameter p
in combineSpectra
. This will give me one spectrum per feature.
spectra_closest_combine <- Spectra::combineSpectra(x = spectra_closest,
FUN = Spectra::combinePeaks,
tolerance = 0.025,
ppm = 100,
peaks = "union",
intensityFun = base::mean,
mzFun = base::mean,
f = spectra_closest$feature_id,
p = spectra_closest$feature_id)
Spectra::plotSpectra(spectra_closest_combine[which(spectra_closest_combine$feature_id == "FT469")])
Remains only the problem with the intensities.
Cheers, Rico
Ok, it depends a lot on the settings of ppm and tolerance. I'll close this issue.
Thanks for posting also your solution and closing the issue!