getMS1Mat: Extract dected masses from a subset of MS1 scans in xcmsRaw...

Description Usage Arguments Value Author(s) Examples

View source: R/functions.r

Description

Identify masses using kernel density of centroided data.

Usage

1
getMS1Mat(xraw, rtrange = NULL, ppm = 25, minSignal = 400)

Arguments

xraw

an xcms raw object

rtrange

range of retention times of scans

ppm

mass deviation between scans for obtaining EIC for each mass

minSignal

lowest signal intensity that could be considered a mass

Value

ms1_mat

matrix where the rows are scans (ordered by retention time) and columns are masses

Author(s)

Igor Nikolskiy

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (xraw, rtrange = NULL, ppm = 25, minSignal = 400)
{
    if (is.null(rtrange)) {
        scans = 1:length(xraw@scantime)
    }
    else {
        scans = which(xraw@scantime >= rtrange[1] & xraw@scantime <=
            rtrange[2])
    }
    combinedScans = do.call(rbind, sapply(scans, getScan, object = xraw))
    cons_masses = getConsensusMasses(combinedScans, ppm = ppm)
    ms1_mat = c()
    for (s in scans) {
        scan = getScan(xraw, s)
        intensities = sapply(cons_masses, function(m) {
            matches = ppm_diff(m, scan[, "mz"]) < ppm
            if (any(matches))
                return(max(scan[matches, "intensity"]))
            else return(0)
        })
        ms1_mat = rbind(ms1_mat, intensities)
    }
    colnames(ms1_mat) = cons_masses
    rownames(ms1_mat) = round(xraw@scantime[scans], 2)
    ms1_mat
  }

yufree/decoMS2 documentation built on May 27, 2019, 9:56 a.m.