plotRefSpectra: Plot reference spectrum of a compound

plotRefSpectraR Documentation

Plot reference spectrum of a compound

Description

A simple function to plot the reference spectrum of a compound in the style of common visualization tools. This is useful when comparing the spectrum of a metabolite with such software tools.

Usage

plotRefSpectra(lib, libID, col='darkblue', main=NULL, xlab='m/z', ylab='Intensity',
               label=TRUE, cex=0.8, label_col=NULL, sel_font=4, type='h', ...)

Arguments

lib

A tsLib object created by ImportLibrary function.

libID

An index (integer or character) value representing the respective metabolite in the reference library lib. If missing, the first metabolite in the library is taken.

col

The color(s) of the vertical lines. This option is passed to plot.

main

The title for the plot. If NULL, then the metabolite name is displayed.

xlab

The x axis label. Passed to plot.

ylab

The y axis label. Passed to plot.

label

Logical. It controls whether the m/z labels are displayed.

cex

The cex values (numerical vector) used to scale the m/z labels of the plot.

label_col

The color vector for the m/z labels.

sel_font

The font for the m/z labels of the selective masses. This should be an integer like the parameter font documented in par.

type

A character that specifies the plot type. Defaults to 'h' (for vertical bars) and cannot be changed by the user (it has no effect).

...

Extra graphical parameters passed to plot.

Details

This is a simple function to plot the spectrum of a reference metabolite. It is expected that the spectrum for that metabolite is not empty, in which case nothing is plotted and a warning is thrown.

The m/z label positions are determined automatically such that they do not intersect with each other and do not touch the vertical lines of the plot.

Value

Returns invisible().

Author(s)

Alvaro Cuadros-Inostroza

See Also

See the function ImportLibrary for importing a metabolite library. See plot and par for graphical parameters.

Examples

def.par <- par(no.readonly = TRUE) # save parameters for resetting

# load pre-calculated example data files and objects
data(TSExample)

# plot the reference spectrum of the compound ID 'GC.3'
plotRefSpectra(refLibrary, 'GC.3')

# that is equivalent to
plotRefSpectra(refLibrary['GC.3'])

# change some graphical parameter and add a grid via 'panel.first'
plotRefSpectra(refLibrary, 'GC.3', col='darkred', main='Valine', xlab='mz',
               ylab='intensity', cex=0.7, label_col='blue', sel_font=2,
               panel.first=grid())

par(def.par) # reset to default

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