Learn R Programming

ropls (version 1.4.2)

plot.opls: Plot Method for (O)PLS(-DA)

Description

This function plots values based upon a model trained by opls.

Usage

"plot"(x, y, typeVc = c("correlation", "outlier", "overview", "permutation", "predict-train", "predict-test", "summary", "x-loading", "x-score", "x-variance", "xy-score", "xy-weight")[7], parAsColFcVn = NA, parCexN = 0.8, parCompVi = c(1, 2), parDevNewL = TRUE, parEllipsesL = NA, parLabVc = NA, parTitleL = TRUE, file.pdfC = NULL, .sinkC = NULL, ...)

Arguments

x
An S4 object of class opls, created by the opls function.
y
Currently not used.
typeVc
Character vector: the following plots are available: 'correlation': Variable correlations with the components, 'outlier': Observation diagnostics (score and orthogonal distances), 'overview': Model overview showing R2Ycum and Q2cum (or 'Variance explained' for PCA), 'permutation': Scatterplot of R2Y and Q2Y actual and simulated models after random permutation of response values; 'predict-train' and 'predict-test': Predicted vs Actual Y for reference and test sets (only if Y has a single column), 'summary' [default]: 4-plot summary showing permutation, overview, outlier, and x-score together, 'x-variance': Spread of raw variables corresp. with min, median, and max variances, 'x-loading': X-loadings (the 6 of variables most contributing to loadings are colored in red to facilitate interpretation), 'x-score': X-Scores, 'xy-score': XY-Scores, 'xy-weight': XY-Weights
parAsColFcVn
Optional factor character or numeric vector to be converted into colors for the score plot; default is NA [ie colors will be converted from 'y' in case of (O)PLS(-DA) or will be 'black' for PCA]
parCexN
Numeric: amount by which plotting text should be magnified relative to the default
parCompVi
Integer vector of length 2: indices of the two components to be displayed on the score plot (first two components by default)
parDevNewL
Should the graphics be displayed in a new window [default]; If FALSE, parLayL must be set to FALSE also
parEllipsesL
Should the Mahalanobis ellipses be drawn? If 'NA' [default], ellipses are drawn when either a character parAsColVcn is provided (PCA case), or when 'y' is a character factor ((O)PLS-DA cases).
parLabVc
Optional character vector for the labels of observations on the plot; default is NA [ie row names of 'x', if available, or indices of 'x', otherwise, will be used]
parTitleL
Should the titles of the plots be printed on the graphics (default = TRUE); It may be convenient to set this argument to FALSE when the user wishes to add specific titles a posteriori
file.pdfC
Figure filename (e.g. in case of batch mode) ending with '.pdf'; for multiple graphics, set parLayL to TRUE; default is NULL (no saving; displaying instead)
.sinkC
Character: Name of the file for R output diversion [default = NULL: no diversion]; Diversion of messages is required for the integration into Galaxy
...
Currently not used.

Examples

Run this code
data(sacurine)
attach(sacurine)

for(typeC in c("correlation", "outlier", "overview",
               "permutation", "predict-train","predict-test",
               "summary", "x-loading", "x-score", "x-variance",
               "xy-score", "xy-weight")) {

    print(typeC)

    if(grepl("predict", typeC))
        subset <- "odd"
    else
        subset <- NULL

    opLs <- opls(dataMatrix, sampleMetadata[, "gender"],
                 predI = ifelse(typeC != "xy-weight", 1, 2),
                 orthoI = ifelse(typeC != "xy-weight", 1, 0),
                 permI = ifelse(typeC == "permutation", 10, 0),
                 subset = subset,
                 printL = FALSE, plotL = FALSE)

    plot(opLs, typeVc = typeC)

}

detach(sacurine)

Run the code above in your browser using DataLab