ri_data_extract: Extract peak data from a RI file

ri_data_extractR Documentation

Extract peak data from a RI file

Description

A convenient function to extract peak data from a RI file. This function is mostly intended for debugging purposes, for example, when a given peak is not found within a expected time range (which could be because a faulty retention time correction). The arguments of this function are similar as those of the ncdf4_data_extract function.

Usage

ri_data_extract(RIfile, massValues, timeRange, useRT = FALSE, ...)

Arguments

RIfile

A path to a RI file format (binary or text).

massValues

A numeric vector representing m/z values. The values will be converted to integers internally.

timeRange

A numeric vector of even length, or, a two-column matrix. This parameter represents the lower and upper time limits. See details below.

useRT

Logical. If TRUE, the time range is in seconds, otherwise if FALSE (default), the time range is in retention time index units (TRUE).

...

Extra parameters passed to internal functions. Currently, only the columns parameter is used for text-format RI files. This, however, should not be necessary. See also text2bin.

Details

The function takes a RI file generated by TargetSearch (binary or text works) and extracts all the peaks detected of given m/z ion traces in a given time range. The time range can be in seconds or arbitrary retention time index units.

The parameter timeRange can be either a numeric vector of even length or a two-column matrix. If it is a matrix, the first column represent the lower bounds while the second the upper ones. If it is a vector, it must have at least two elements, which in this case represent the lower and upper limits, or if longer, it will be coerced to matrix internally (Important: the values are filled by columns). In any case, the number of rows of the (coerced) matrix must divide the length of the massValues parameter, such that each row corresponds to a time range for each m/z value. This is done so the ranges can be recycled.

The output is simply a four column matrix in which a row is a peak of a given ion trace at a retention time (index). The output is always a matrix even if no peaks are found, in which case the number of rows is zero.

Value

A four column matrix with column names described below. Each row represents a peak in the specified time range. Potentially, there could be zero rows if no peaks are found.

  • RI retention time index of the peak.

  • RT retention time.

  • Intensity peak height intensity

  • mz the m/z of the peak

Note

This function is intended to be used internally or by advances users. It can be used for debugging when TargetSearch fails to find a peak.

See also the function FindAllPeaks which offers a similar functionality but with different input parameters.

Author(s)

Alvaro Cuadros-Inostroza

See Also

text2bin, ncdf4_data_extract, FindAllPeaks, FindPeaks

Examples

require(TargetSearchData)
path <- tsd_data_path()
rifile <- tsd_rifiles()[1]

# extract peak data for m/z 116 and 117 in time range 180 - 220 seconds
data <- ri_data_extract(rifile, c(116, 117), c(180, 220), useRT=TRUE)

# same but using Retention Time Index
data <- ri_data_extract(rifile, c(116, 117), c(205000, 228000), useRT=FALSE)

# different time ranges for each m/z
trange <- c(180, 240, 280, 190, 250, 290)
data <- ri_data_extract(rifile, c(116, 144, 147), trange, useRT=TRUE)

# Note: the range definition above is equivalent to
trange <- cbind(c(180,240,280), c(190, 250, 290))


acinostroza/TargetSearch documentation built on Nov. 22, 2024, 3:31 p.m.