Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mclust3dSpectra

mclust Analysis of a Spectra Object in 3D


Description

This function conducts an mclust analysis of the PCA results of a Spectra object and displays the results in 3D. Classical or robust confidence ellipses can be added if desired. Improperly classified data points can be marked. rgl graphics are employed.

Usage

mclust3dSpectra(
  spectra,
  pca,
  pcs = c(1:3),
  ellipse = TRUE,
  rob = FALSE,
  cl = 0.95,
  frac.pts.used = 0.8,
  truth = NULL,
  title = "no title provided",
  t.pos = NULL,
  lab.opts = FALSE,
  use.sym = FALSE,
  ...
)

Arguments

spectra

An object of S3 class Spectra.

pca

An object of class prcomp.

pcs

An integer vector describing which PCs to use.

ellipse

Logical indicating if confidence ellipses should be drawn.

rob

Logical; if ellipse = TRUE, indicates that robust confidence ellipses should be drawn. If FALSE, classical confidence ellipses are drawn.

cl

A number indicating the confidence interval for the ellipse.

frac.pts.used

If ellipse = TRUE and rob = TRUE, a number indicating the fraction of the data points to be considered "good" and thus used to compute the robust confidence ellipse.

truth

A character vector indicating the known group membership for reach row of the PC scores. Generally this would be spectra$groups. #' @param title A character string for the plot title.

title

A character string giving the title.

t.pos

A character selection from LETTERS[1:8] ( = A through H) indicating the desired location for the title.

lab.opts

A logical indicating whether or not to display the locations where the title and legend can be placed. These locations are the corners of a cube surrounding the data.

use.sym

Logical; if true, the color scheme is changed to black and symbols are used for plotting.

...

Other parameters to be passed downstream.

Details

If you intend to make a hard copy of your plot, use lab.opts = TRUE until you have found a good view of your data. Then note corners of the cube where the title won't interfere with viewing the data, and use this for t.pos, and add title. Adjust as necessary, then turn off label display using lab.opts = FALSE. Back at the console, use > rgl.snapshot("file_name.png") to create the hardcopy.

Note that the confidence ellipses computed here are generated independently of the Mclust results - they do not correspond to the ellipses seen in 2D plots from Mclust.

Value

The mclust model is returned invisibly, and a plot is produced.

Author(s)

Bryan A. Hanson, DePauw University.

See Also

Mclust for background on the method. Additional documentation at https://bryanhanson.github.io/ChemoSpec/

Examples

## Not run: 
require(mclust)
data(metMUD1)
class <- c_pcaSpectra(metMUD1)
mclust3dSpectra(metMUD1, class,
  title = "mclust3dSpectra demo",
  lab.opts = FALSE, t.pos = "A"
)

## End(Not run)

ChemoSpec

Exploratory Chemometrics for Spectroscopy

v5.3.11
GPL-3
Authors
Bryan A. Hanson [aut, cre] (<https://orcid.org/0000-0003-3536-8246>), Mike Bostock [cph, ctb] (author of the d3.js library used by plotSpectraJS, http://d3js.org), Matt Keinsley [ctb] (author of initial AOV-PCA code)
Initial release
2021-03-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.