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 x wavelengths). If no argument is provided here, the function will try to find the
chrom_listobject using the pointer in thepeak_table.- idx
Numerical index of chromatogram you wish to plot, or "max" to automatically select the chromatogram with the highest signal intensity at the specified peak or retention time.
- lambda
The wavelength used for plotting chromatographic traces and determining signal intensity.
- 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 verbose output to console.- 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.- engine
Which plotting engine to use:
base,ggplot2, orplotly.- ...
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
This function can be used to confirm the identity of a peak or 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.peak_list(),
plot.peak_table(),
plot_all_spectra(),
plot_chroms(),
plot_chroms_heatmap(),
scan_chrom()
