Visualizes chromatographic traces and/or UV spectra for a selected peak,
retention time, or scan index from a peak_table or list of chromatograms.
Spectra can also be exported as a data.frame when export_spectrum = TRUE.
Usage
plot_spectrum(
loc = NULL,
peak_table,
chrom_list = NULL,
idx = "max",
lambda = "max",
plot_spectrum = TRUE,
plot_trace = TRUE,
spectrum_labels = TRUE,
scale_spectrum = FALSE,
export_spectrum = FALSE,
verbose = TRUE,
what = c("peak", "rt", "idx", "click"),
engine = c("base", "plotly", "ggplot2"),
...
)Arguments
- loc
The peak, retention time, or scan index from which to extract spectral data.
- peak_table
A
peak_tableobject created byget_peaktable.- 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.- idx
Index or name of the chromatogram to plot, or
"max"(the default) to select the chromatogram with the largest value forlocinpeak_table."max"is available only whenwhat = "peak".- lambda
The wavelength at which to plot the chromatographic trace, or
"max"(the default) for the wavelength of maximum absorbance in the extracted spectrum.- 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.- 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.- 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".- 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.
Value
If
export_spectrum = FALSE(default), returns aplotlyorggplotobject according to the specifiedengine. No value is returned whenengine = "base".If
export_spectrumisTRUE, invisibly returns the spectrum as adata.framewith wavelengths as rows and a single column encoding the absorbance (normalized, ifscale_spectrum = TRUE).
Details
Use it to confirm the identity of a peak, or to assess whether
a peak table column likely represents a single compound. Retention times may
also be selected interactively by clicking on a chromatographic trace when
what = "click".
When plot_trace is TRUE, the chromatographic trace for the
specified chromatogram (idx) is plotted at wavelength lambda, with a
dotted red line indicating the selected retention time (loc). The trace
corresponds to a single column of the chromatographic matrix.
When plot_spectrum is TRUE, the UV spectrum at the specified retention
time is plotted. The spectrum corresponds to a single row of the
chromatographic matrix.
See also
Other visualization functions:
boxplot.peak_table(),
mirror_plot(),
plot.chrom_list(),
plot.matched_peak_list(),
plot.peak_list(),
plot.peak_table(),
plot_all_spectra(),
plot_chrom_contour(),
plot_chroms(),
plot_chroms_heatmap(),
scan_chrom()

