Plot PLS-DA classification performance using different components
Source:R/metabolomics_plots.R
met.plot_PLS.Crossvalidation.Rd
met.plot_PLS.Crossvalidation
performs cross-validation (CV) on the generated PLS-DA model, where a fraction of data is held back, and the model trained on the rest. In each CV, the predicted data are compared with the original data, and the sum of squared errors is calculated. The prediction error is then summed over all samples (Predicted Residual Sum of Squares or PRESS). For convenience, the PRESS is divided by the initial sum of squares and subtracted from 1 to resemble the scale of the R2. Good predictions will have low PRESS or high Q2. Generally speaking, a model with an R2 (and Q2) value above 0.7 can be considered predictive. It is possible to have negative Q2, which means that your model is not at all predictive or is overfitted.
Usage
met.plot_PLS.Crossvalidation(
mSetObj = NA,
imgName = "PLSDA-CrossValidation",
format = "pdf",
dpi = NULL,
width = NA,
plot = TRUE,
export = TRUE,
title = FALSE
)
Arguments
- mSetObj
Input name of the created mSet object. Data container after partial least squares-discriminant analysis (
met.PLSR.Anal
andmet.PLSDA.CV
).- imgName
(Character) Enter a name for the image file (if
export = TRUE
).- format
(Character,
"png"
or"pdf"
) image file format (ifexport = TRUE
).- dpi
(Numeric) resolution of the image file (if
export = TRUE
). IfNULL
, the resolution will be chosen automatically based on the chosen file format (300 dpi for PNG, 72 dpi for PDF)- width
(Numeric) width of the the image file in inches (if
export = TRUE
).- plot
(Logical,
TRUE
orFALSE
) Shall the plot be returned in the RStudio 'Plots' pane?- export
(Logical,
TRUE
orFALSE
) Shall the plot be exported as PDF or PNG file?- title
(Logical)
TRUE
to add a title with the used normalization, transformation, and scaling method, orFALSE
to not add any title.
Value
The input mSet object with added cross validation test plot. The plot can be retrieved from within R via print(mSetObj$imgSet$pls.crossvalidation.plot)
.
References
adapted from PlotPLS.Classification
(https://github.com/xia-lab/MetaboAnalystR).
Author
Nicolas T. Wirth mail.nicowirth@gmail.com Technical University of Denmark License: GNU GPL (>= 2)