Skip to main content
Topic: using plotPeaks to plot selected peaks (Read 5867 times) previous topic - next topic

using plotPeaks to plot selected peaks

Hi all,

I used plotPeaks to plot my xraw but it is only showing for the first few m/z. How do I set it to plot a peak that I am interested in.

This is what I use: mypeaks = findPeaks.matchedFilter(xraw, snthresh=10, step=0.1, steps=2))
                            plotPeaks(xraw, mypeaks, figs=c(2, 2))

Thanks for your help in advance.

Sola

Re: using plotPeaks to plot selected peaks

Reply #1
Hi,

It's always good to post a self-contained code snippet in a question,
so that I can cut&paste to find a solution. I think the trick is to have
a loop around the plotPeaks() to plot the next page of peaks.
That way you can also sort prior to plotting, e.g. by descending intensity
or fitgauss or ...

Hope that helped,

Yours,
Steffen

Code: [Select]
library(xcms)

file <- system.file('cdf/KO/ko15.CDF', package = "faahKO")
xraw <- xcmsRaw(file)
p <- findPeaks.centWave(xraw, fitgauss=T, verbose=T, sleep=0.001)

plotPeaks(xraw, p, figs=c(8, 4))

for (i in seq(1,nrow(p), by=32)) {
  plotPeaks(xraw, p[seq(i,max(i+32, nrow(p))),], figs=c(10, 10))
}

--
IPB Halle                          Mass spectrometry & Bioinformatics
Dr. Steffen Neumann         http://www.IPB-Halle.DE
Weinberg 3 06120 Halle     Tel. +49 (0) 345 5582 - 1470
sneumann(at)IPB-Halle.DE

Re: using plotPeaks to plot selected peaks

Reply #2
Hi there,

Thanks for getting back to me. I have some difficulty understanding the loop

So this is what im working with below:

library(xcms)
list.files("/CDFs/20150414_Exp1d_3/new", recursive = TRUE)
xraw = xcmsRaw("5TD_1.CDF", profstep = 1, profmethod = "bin", profparam = list(), includeMSn=FALSE, mslevel=NULL, scanrange=NULL)
mypeaks = findPeaks.matchedFilter(xraw, fwhm=4, snthresh=10, step=0.1, steps=2)
plotPeaks(xraw, mypeaks, figs=c(2, 2))

here is your suggestion: plotPeaks(xraw, p[seq(i,max(i+32, nrow(p))),], figs=c(10, 10))

i dont understand what seq, i, max, i+32, and nrow means if you could please elucidate on this. Thanks.

BW,

Sola

Re: using plotPeaks to plot selected peaks

Reply #3
if possible could you include an actual example.

Cheers

 

Re: using plotPeaks to plot selected peaks

Reply #4
played about and got it working!

plotPeaks(xraw, mypeaks[seq(200,max(5, nrow(mypeaks))),], figs=c(2, 2))

Cheers again