Adds text labels to peaks on a chromatogram plot produced by
plot_chroms(). Peak retention times and intensities are looked up
automatically from the peak table.
Usage
annotate_peaks(
p,
loc,
peak_table,
chrom_list = NULL,
label = NULL,
lambda = NULL,
idx = NULL,
vjust = -0.5,
...
)Arguments
- p
A
ggplotobject produced byplot_chroms().- loc
A character vector of peak names (e.g.
c("V8", "V15")). If named, the names are used as labels (e.g.c(Sinigrin = "V8",1ME= "V15")).- 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.- label
Labels to display at each peak. Can be a character vector of labels (one per peak),
"rt"to use retention times from the peak table. If labels are not specified here, the names oflocwill be applied, or if thelocvector is not named, the peak names will be used directly.- lambda
Wavelength(s) to use for locating the peak apex. Inherited from
pifNULL(default). If multiple wavelengths are provided, the one with the highest absorbance is used.- idx
Index of chromatogram(s) to use for locating the peak apex. Inherited from
pifNULL(default).- vjust
Vertical justification of the label relative to the peak apex. Defaults to
-0.5.- ...
Additional arguments passed to
ggplot2::annotate().
Examples
if (requireNamespace("ggplot2", quietly = TRUE)) {
data(Sa_warp)
data(pk_tab)
plot_chroms(Sa_warp, lambdas = 210, engine = "ggplot") |>
annotate_peaks(c(C1="V9", C2="V11", C3="V17"), peak_table = pk_tab)
}
