plot_spectra {waves} | R Documentation |
Plot spectral data, highlighting outliers as identified using Mahalanobis distance
Description
Generates a ggplot
object of given
spectra, with wavelength on the x axis and given spectral values on the y.
Mahalanobis distance is used to calculate outliers, which are both
identified on the plot. Rows from the original dataframe are printed to the
console for each outlier that is identified.
Usage
plot_spectra(
df,
num.col.before.spectra = 1,
window.size = 10,
detect.outliers = TRUE,
color = NULL,
alternate.title = NULL,
verbose = TRUE,
wavelengths = deprecated()
)
Arguments
df |
|
num.col.before.spectra |
Number of columns to the left of the spectral matrix (including unique ID). Default is 1. |
window.size |
number defining the size of window to use when calculating the covariance of the spectra (required to calculate Mahalanobis distance). Default is 10. |
detect.outliers |
Boolean indicating whether spectra should be filtered
before plotting. If |
color |
String or vector of strings indicating colors to be passed to
|
alternate.title |
String to be used as plot title. If
|
verbose |
If |
wavelengths |
DEPRECATED |
Value
If verbose, prints unique ID and metadata for rows identified as outliers. Returns plot of spectral data with non-outliers in blue and outliers in red. X-axis is wavelengths and y-axis is spectral values.
Author(s)
Jenna Hershberger jmh579@cornell.edu
Examples
library(magrittr)
ikeogu.2017 %>%
dplyr::rename(unique.id = sample.id) %>%
dplyr::select(unique.id, dplyr::everything(), -TCC) %>%
na.omit() %>%
plot_spectra(
df = .,
num.col.before.spectra = 5,
window.size = 15,
detect.outliers = TRUE,
color = NULL,
alternate.title = NULL,
verbose = TRUE
)