Function for plotting PCA, PLS or OPLS model scores.

plotscores(obj, pc, an, title = "", qc, legend = "in", cv = TRUE, ...)

Arguments

obj

PCA, PLS or OPLS model of the package metabom8 or MetaboMate.

pc

num vector (n=2), indicating which omponents to be plotted on abscissa and ordinate. If not specified: PCA components 1 vs 2, OPLS: predictive vs 1st orth component.

an

list of 3 elements: 1st: scatter colour, 2nd: shape and 3rd: label specification (see Details).

title

cher, plot title.

qc

int vector, row indices of QC samples (can be left NA). If specified, QC samples will be highlighted in the plot.

legend

str, position of the plot legend, set to NA if legend should be outside of the plotting area.

cv

logical, indicating if cross-validated (cv) scores should be plotted (only for PLS and O-PLS).

...

Additional values passed on to scale_colour_gradientn.

Value

This function returns a ggplot2 object.

Details

Scores colouring is specified with the argument an, which is a list of three elements. The first list element specifies the colour (class factor required for categorical variables), the second list element specifies a point labeling (class character or factor) and the third list element specifies point shape. The Hotelling's T2 ellipse is automatically included and calculated for the dimensions selected by the pc argument.

NA

References

Trygg J. and Wold, S. (2002) Orthogonal projections to latent structures (O-PLS). Journal of Chemometrics, 16.3, 119-128.

Hotelling, H. (1931) The generalization of Student’s ratio. Ann. Math. Stat., 2, 360-378.

See also

Other NMR ++: .hotellingsT2(), cvanova(), es_cdelta(), minmax(), opls_perm(), pca(), pqn(), predict_opls(), scRange()

Author

torben.kimhofer@murdoch.edu.au

torben.kimhofer@murdoch.edu.au

Examples

data(covid) model=pca(X)
#> Too many number of components, setting pc to 2
plotscores(model, an=list(Class=an$type, Clinic=an$hospital, id=1:nrow(an)), pc=c(1,2))
#> Error in names(x) <- value: 'names' attribute [3] must be the same length as the vector [0]