Plots the trace and/or spectrum for a given peak in peak table.
Usage
# S3 method for class 'peak_table'
plot(
x,
loc,
chrom_list = NULL,
what = "peak",
idx = "max",
lambda = "max",
plot_spectrum = TRUE,
plot_trace = TRUE,
box_plot = FALSE,
vars = NULL,
spectrum_labels = TRUE,
scale_spectrum = FALSE,
export_spectrum = FALSE,
verbose = TRUE,
engine = c("base", "plotly", "ggplot"),
...
)Arguments
- x
The peak table (output from
get_peaktable).- loc
A vector specifying the peak(s) or retention time(s) to plot. If missing when
what = "peak", you are prompted for a peak name. When a value is returned (see below), only the first element oflocis used, with a warning.- chrom_list
A list of chromatograms in matrix format (timepoints × wavelengths). If no argument is provided here, the function will try to find the
chrom_listobject using the pointer in thepeak_table.- what
What to look for. Either
peakto extract spectral information for a certain peak,rtto scan by retention time,idxto scan by numeric index, orclickto manually select retention time by clicking on the chromatogram. Defaults to"peak"mode."click"requiresengine = "base".- idx
Numerical index of chromatogram you wish to plot;
"max"(default) to plot the chromatogram with the largest value for the peak in the peak table; or"all"to plot spectra for all chromatograms.- lambda
The wavelength at which to plot the trace.
"max"(default) selects the wavelength at which the spectrum atlocis highest.- plot_spectrum
Logical. If
TRUE, plots the spectrum of the chosen peak. Defaults toTRUE.- plot_trace
Logical. If
TRUE, plots the trace of the chosen peak at lambda. Defaults toTRUE.- box_plot
Logical. If
TRUE, plots box plot using categories defined byvars.- vars
Character vector of column names in the sample metadata, used as the right-hand side of the boxplot formula.
- spectrum_labels
Logical. If
TRUE, plots labels on maxima in spectral plot. Defaults toTRUE.- scale_spectrum
Logical. If
TRUE, scales spectrum to unit height. Defaults toFALSE.- export_spectrum
Logical. If
TRUE, invisibly returns the spectrum as adata.frame. Defaults toFALSE.- verbose
Logical. If
TRUE(default), prints the index and name of each chromatogram plotted, with its retention time, wavelength and absorbance.- engine
Plotting backend to use. One of
"base","ggplot", or"plotly"."ggplot2"is also accepted here, for backward compatibility, but"ggplot"is the spelling the other plotting functions take.- ...
Additional arguments to boxplot.
Value
If
export_spectrum = FALSE(default), aplotlyorggplotobject, or nothing ifengine == "base".If
export_spectrum = TRUE, the spectrum as adata.framewith wavelengths as rows and one column per sample giving absorbance at each wavelength (normalized ifscale_spectrum = TRUE).
Details
Use it to confirm the identity of a peak, or to check that a particular column in the peak table represents a single compound. It also draws simple box plots of the distribution of a peak against variables defined in sample metadata.
When plot_trace is TRUE, plots the trace of chromatogram idx at
wavelength lambda, with a dotted red line at the retention time given by
loc. When plot_spectrum is TRUE, plots the spectrum of the same
chromatogram at that retention time. When box_plot is TRUE, draws a
boxplot of the peak with groups defined by vars.
See also
Other visualization functions:
boxplot.peak_table(),
mirror_plot(),
plot.chrom_list(),
plot.matched_peak_list(),
plot.peak_list(),
plot_all_spectra(),
plot_chrom_contour(),
plot_chroms(),
plot_chroms_heatmap(),
plot_spectrum(),
scan_chrom()
