plotSpectraDist {ChemoSpec} | R Documentation |
Plot the Distance Between Spectra and a Reference Spectrum in a Spectra Object
Description
This function plots the distance between a reference spectrum and all other
spectra in a Spectra
object. Distance can be defined in a number of
ways (see Arguments).
Usage
plotSpectraDist(spectra, method = "pearson", ref = 1, labels = TRUE, ...)
Arguments
spectra |
An object of S3 class |
method |
Character. Any method acceptable to |
ref |
Integer. The spectrum to be used as a reference. |
labels |
Logical. Shall the points be labeled? |
... |
Parameters to be passed to the plotting routines. Applies to base graphics only. |
Value
The returned value depends on the graphics option selected (see ChemoSpecUtils::GraphicsOptions()
).
-
base A data frame or list containing the data plotted. Assign the value and run
str()
ornames()
on it to see what it contains. Side effect is a plot. -
ggplot2 The plot is displayed, and a
ggplot2
plot object is returned if the value is assigned. The plot can be modified in the usualggplot2
manner. If you want the plotted values, you can access them via the base graphics mode.
Author(s)
Bryan A. Hanson (DePauw University), Tejasvi Gupta.
See Also
To compare all spectra simultaneously in a heatmap, see
sampleDist
. Additional documentation
at https://bryanhanson.github.io/ChemoSpec/
Examples
# You need to install package "amap" to use this function
if (requireNamespace("amap", quietly = TRUE)) {
# This example assumes the graphics output is set to ggplot2 (see ?GraphicsOptions).
library("ggplot2")
data(SrE.NMR)
txt1 <- paste("Distance from", SrE.NMR$names[1])
txt2 <- paste("Rank Distance from", SrE.NMR$names[1])
p <- plotSpectraDist(SrE.NMR)
p <- p + labs(title = txt1, xlab = txt2, ylab = txt2) +
coord_cartesian(ylim = c(0, 1.1), xlim = c(0, 16))
p
}