Mass Spectral Library Report

Share:

Description

Generate a report for a mass spectral library.

Usage

1
2
3
4
5
6
7
LibraryReport(spectra = example.spec,
                          metadata = example.meta,
                          structures = paste(system.file(package = "SpecLibExample"), "/extdata/struct/", sep = ""),
                          pdf = TRUE,
                          pdf.file = "SpecLibExample.pdf",
                          pdf.title = "SpecLibExample",
                          x.min = 40)

Arguments

spectra

data frame containing the mass spectra. See below for required column names.

metadata

data frame containing the metadata. See below for required column names.

structures

character string of directory containing the structure image files.

pdf

logical indicating if a PDF report should be generated.

pdf.file

character string. The file name of the PDF report. See pdf.

pdf.title

character string. Title string to embed in the PDF file. See pdf.

x.min

numeric value. The minimum m/z in the plot.

Details

See the OrgMassSpecR - Mass Spectral Libraries vignette for an overview and examples.

m/z values printed within the spectrum generally refer to the most intense peak within the cluster. m/z values printed in the table generally refer to the monoisotopic ion. Marks printed above the spectrum indicate the identified ions. If the identity includes the word “interference”, the color of the mark is grey.

The x-axis range is set using the argument x.min and (if present) the molecular weight calculated from the formula listed in the metadata plus 3%.

LibraryReport checks for the column names listed below. These columns must be present, but in most cases their contents may be NA. The contents are printed, so the types (character, numeric, ...) can be user defined. The exception within metadata is the column filename, which must contain character strings or NA (factors are coerced to characters). NAs in metadata$filename will be skipped when generating the report. Additional columns in metadata and spectra are ignored by LibraryReport.

An error will be generated if (1) metadata does not contain the column names listed below, (2) spectra does not contain the column names listed below, or (3) if metadata$filename %in% unique(spectra$filename) is not all TRUE (excluding NAs in metadata$filename).

The directory containing the structure images must contain either .pgm or .ppm files. Filenames must correspond to metadata$filenames. Absent structure images will be skipped (spectrum and metatdata is plotted, structure is not).

Required columns in spectra:

  • filename: character string matching the corresponding row in metadata and element name instructures.

  • mz: centroid m/z value

  • intensity: peak intensity

  • display: logical indicating if the m/z value should be displayed over the peak.

  • identity: identity of the fragment ion.

Required columns in metadata:

  • compound: compound name.

  • filename: character string matching the corresponding spectrum in spectra and element name in structures.

  • sample: sample name.

  • instrument: type of instrument and operating conditions.

  • category.1: user defined category.

  • category.2: user defined category.

  • category.3: user defined category.

  • rt.1D: retention time, in seconds, in the first dimension.

  • rt.2D: retention time, in seconds, in the second dimension.

  • formula: elemental formula. Must be readable by link{ListFormula}.

  • comment: user comment.

Value

A PDF report of the mass spectra. If PDF = FALSE, the report is generated using the graphics device.

Author(s)

Nathan G. Dodder

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run

## Example code to make filenames consistent, where
## x is a data frame with old and new filenames.

## To change structure filenames
## Not run: 
file.rename(paste(x$old.filename, ".pgm", sep = ""),
            paste(x$new.filename, ".pgm", sep = ""))

## End(Not run)

## To rename filenames in lib.dolphin2011.spec
## Not run: 
spec <- lib.dolphin2011.spec
for(i in 1:nrow(x)) {
  spec$filename[spec$filename == x$old.filename[i]] <- x$new.filename[i]
}

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.