Metabolomics Society Forum

Software => R => XCMS => Topic started by: Ricca on April 12, 2012, 02:52:02 AM

Title: matchedFilter parameters
Post by: Ricca on April 12, 2012, 02:52:02 AM
Hi to everybody,
I'm setting up an xcms object using the matchedFilter algorithm. So, reading the Smith's paper (XCMS: Processing Mass Spectrometry....) I'm adjusting s/n and fwhm parameters to obtain the best result.

Code: [Select]
xsetSUP <- xcmsSet(files, method="matchedFilter", snthresh=8, fwhm=10, sleep=1)

My question is about the red horizontal line: I think is regulated by the s/n so, the higher is the s/n the higher is the red line. Is it right?? Is the red line used as baseline to integrate the signal?? How it is calculated the s/n ratio?? RMS or Peak to peak??

Best

Riccardo
Title: Re: matchedFilter parameters
Post by: hpbenton on April 13, 2012, 01:29:13 PM
Riccardo,

Yep the red line indicates the calculated signal to noise level. A peak above this line should get picked and integrated. I would like to give the formula for this but latex doesn't work on the forum :( . Second best option is the actual code for it.

Code: [Select]
specNoise <- function(spec, gap = quantile(diff(spec[,"mz"]), .9)) {

    # In a spectrum with just one raw peak we can't calculate noise
    if (nrow(spec) < 2) {
      return(0)
    }

    intmean <- mean(spec[,"intensity"])

    mzlen <- diff(range(spec[,"mz"]))
    mzdiff <- diff(spec[,"mz"])
    gaplen <- sum(mzdiff[mzdiff > gap])

    weighted.mean(c(intmean, min(spec[,"intensity"])/2), c(1 - gaplen/mzlen,
                                                          gaplen/mzlen))
}

where spec is a single scan. It comes to this function as a matrix of columns mz and intensity.

Let me know if this is clear. Otherwise I can try and explain the way it works.

Paul
Title: Re: matchedFilter parameters
Post by: Ricca on April 18, 2012, 01:17:28 AM
Hi Paul,
reading the code you wrote I think I understand what you mean but I haven' t understand the way to use the function you wrote, because is not clear in my mind how to extract a scan from an xcmsSet object  :oops: .

Can you explain it to me??

Regards