Plots the trace and/or spectrum for a given peak or retention time in a
peak_table object or a list of chromatograms.
Usage
plot_spectrum(
loc = NULL,
peak_table,
chrom_list,
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"),
chr = NULL,
...
)Arguments
- loc
The name of the peak or retention time for which you wish to extract spectral data.
- peak_table
The peak table (output from
get_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 used to create the providedpeak_table.- idx
Numerical index of chromatogram you wish to plot, or "max" to automatically plot the chromatogram with the largest signal at the given peak or retention time.
- lambda
The wavelength you wish to plot the trace at if plot_trace == TRUE and/or the wavelength to be used for the determination of signal abundance.
- 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, exports spectrum to console. Defaults toFALSE.- verbose
Logical. If
TRUE, prints verbose output to console. Defaults toTRUE.- 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.- chr
Deprecated. Please use
idxinstead.- ...
Additional arguments.
Value
If export_spectrum is TRUE, returns the spectrum as a
data.frame with wavelengths as rows and a single column encoding the
absorbance (or normalized absorbance, if scale_spectrum is TRUE)
at each wavelength. If export_spectrum is FALSE, the output depends on
the plotting engine. If engine == "plotly", returns a plotly
object containing the specified plots. Otherwise, if engine == "base",
there is no return value.
Details
Can be used to confirm the identity of a peak or check that a particular
column in the peak table represents a single compound. Retention times can
also be selected by clicking on the plotted trace if what == 'click'.
Plots can be produced using either base R graphics,
ggplot2, or plotly, according to the
value of the engine argument.
Side effects
If
plot_traceisTRUE, plots the chromatographic trace of the specified chromatogram (idx), at the specified wavelength (lambda) with a dotted red line to indicate the retention time given byloc. The trace is a single column from the chromatographic matrix.If
plot_spectrumisTRUE, plots the spectrum for the specified chromatogram at the specified retention time. The spectrum is a single row from 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()
