plotSpectra {TargetSearch} | R Documentation

## Plot a Spectra Comparison

### Description

`plotSpectra` plots a contrast between the reference spectra and the median spectra of a given metabolite in the library. `plotAllRIdev` saves the plots of the median-reference spectra comparisons of all the metabolites in the reference library into a PDF file.

### Usage

    plotSpectra(Lib, peaks, libId = 1, type = "ht")

    plotAllSpectra(Lib, peaks, type = "ht", pdfFile, width = 8, height = 8, ...)

### Arguments

`Lib` | A `tsLib` object created by `ImportLibrary` function.
`peaks` | A `tsMSdata` object. See `peakFind`.
`libId` | A numeric vector providing the indices of the metabolites to plot.
`type` | The type of the plot. Options are `"ht"`, head-tail plot, `"ss"`, side by side plot, and `"diff"`, spectrum difference plot.
`pdfFile` | A file name where the plot will be saved. Only `plotAllRIdev`.
`width, height` | The width and height of the plots in inches. Only `plotAllRIdev`.
`...` | Further options passed to `pdf`.

### Details

The median spectra is obtained by computing the median intensity of every ion across the samples. The median and the reference spectra values are scaled to vary between 0 and 999 in order to make them comparable.

### Author(s)

Alvaro Cuadros-Inostroza, Matthew Hannah, Henning Redestig

### See Also

`tsLib`, `tsMSdata`,`pdf`

### Examples

    require(TargetSearchData)
    data(TSExample)

    # get RI file path
    RI.path <- file.path(find.package("TargetSearchData"), "gc-ms-data")
    # update RI file path
    RIpath(sampleDescription) <- RI.path

    peakData <- peakFind(sampleDescription, refLibrary, corRI)

    # Plot a comparison RI deviation of metabolite "Valine"
    grep("Valine", libName(refLibrary)) # answer: 3
    plotSpectra(refLibrary, peakData, libId = 3, type = "ht")

    # Plot the spectra "side by side"
    plotSpectra(refLibrary, peakData, libId = 3, type = "ss")

    # Plot the spectra difference
    plotSpectra(refLibrary, peakData, libId = 3, type = "diff")

[Package TargetSearch version 1.43.3 Index]