Metabolomics Society Forum

Software => R => XCMS => Topic started by: lawalo on June 10, 2015, 06:51:14 AM

Title: using plotPeaks to plot selected peaks
Post by: lawalo on June 10, 2015, 06:51:14 AM
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
Title: Re: using plotPeaks to plot selected peaks
Post by: sneumann on June 10, 2015, 06:56:49 AM
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))
}

Title: Re: using plotPeaks to plot selected peaks
Post by: lawalo on June 10, 2015, 08:52:40 AM
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
Title: Re: using plotPeaks to plot selected peaks
Post by: lawalo on June 10, 2015, 09:01:04 AM
if possible could you include an actual example.

Cheers
Title: Re: using plotPeaks to plot selected peaks
Post by: lawalo on June 10, 2015, 09:10:26 AM
played about and got it working!

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

Cheers again