plotScores: Plot Scores from PCA, MIA or PARAFAC Analysis of a Spectra or...

Description Usage Arguments Value Author(s) Examples

View source: R/plotScores.R

Description

Plots the requested scores using the color scheme derived from the Spectra or Spectra2D object. Options are provided to add confidence ellipses for each group in the object. The ellipses may be robust or classical. Option to label the extreme points provided.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plotScores(
  spectra,
  so,
  pcs = c(1, 2),
  ellipse = "none",
  tol = "none",
  use.sym = FALSE,
  leg.loc = "topright",
  ...
)

Arguments

spectra

An object of S3 class Spectra or Spectra2D object.

so

"Score Object" One of the following:

  • An object of class prcomp, created by ChemoSpec functions c_pcaSpectra, r_pcaSpectra, irlba_pcaSpectra or s_pcaSpectra.

  • An object of class mia produced by function miaSpectra2D.

  • An object of class parafac produced by function pfacSpectra2D.

  • An object of class pop produced by function popSpectra2D.

Any of the above score objects will have been modified to include a list element called $method, a character string describing the pre-processing carried out and the type of PCA performed (used to annotate the plot).

pcs

A vector of two integers specifying the components (scores) to plot.

ellipse

A character vector specifying the type of ellipses to be plotted. One of c("both", "none", "cls", "rob"). cls specifies classical confidence ellipses, rob specifies robust confidence ellipses. An ellipse is drawn for each group unless there are three or fewer samples in the group.

tol

A number describing the fraction of points to be labeled. tol = 1.0 labels all the points; tol = 0.05 labels the most extreme 5 percent. Set to "none" to completely suppress labels.

use.sym

A logical; if TRUE, the color scheme is set to black and the points plotted with symbols. Applies only to Spectra objects.

leg.loc

Character; if "none" no legend will be drawn. Otherwise, any string acceptable to legend.

...

Additional parameters to be passed to the plotting functions.

Value

None. Side effect is a plot.

Author(s)

Bryan A. Hanson, DePauw University.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
if (checkForPackageWithVersion("ChemoSpec", "5.1")) {
  library("ChemoSpec")
  data(metMUD1)

  pca <- c_pcaSpectra(metMUD1)
  plotScores(metMUD1, pca,
    main = "metMUD1 NMR Data",
    pcs = c(1, 2), ellipse = "cls", tol = 0.05
  )
}

if (checkForPackageWithVersion("ChemoSpec2D", "0.3")) {
  library("ChemoSpec2D")
  data(MUD1)

  res <- miaSpectra2D(MUD1)
  plotScores(MUD1, res, main = "MIA Scores", tol = 0.1, ellipse = "cls")

  set.seed(123)
  res <- pfacSpectra2D(MUD1, parallel = FALSE, nfac = 2)
  plotScores(MUD1, res, tol = 0.1, leg.loc = "bottomright", main = "PARAFAC Score Plot")
}

Example output

PCASUP: eigenvalues mode C
        Eigenvalue Fit(%)
Comp.1    92964.50  79.89
Comp.2     6995.23  85.90
Comp.3     5744.79  90.84
Comp.4     4342.95  94.57
Comp.5     2282.62  96.53
Comp.6     1959.07  98.22
Comp.7     1132.67  99.19
Comp.8      528.56  99.65
Comp.9      263.81  99.87
Comp.10     148.99 100.00

  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |==========================================                            |  60%
  |                                                                            
  |=================================================                     |  70%
  |                                                                            
  |========================================================              |  80%
  |                                                                            
  |===============================================================       |  90%
  |                                                                            
  |======================================================================| 100%

ChemoSpecUtils documentation built on March 16, 2021, 1:08 a.m.