plotPCA: Create a scatterplot from a PCA object

View source: R/analysis_dimReduction_pca.R

plotPCAR Documentation

Create a scatterplot from a PCA object

Description

Create a scatterplot from a PCA object

Usage

plotPCA(
  pca,
  pcX = 1,
  pcY = 2,
  groups = NULL,
  individuals = TRUE,
  loadings = FALSE,
  nLoadings = NULL
)

Arguments

pca

prcomp object

pcX

Character: name of the X axis of interest from the PCA

pcY

Character: name of the Y axis of interest from the PCA

groups

Matrix: groups to plot indicating the index of interest of the samples (use clinical or sample groups)

individuals

Boolean: plot PCA individuals

loadings

Boolean: plot PCA loadings/rotations

nLoadings

Integer: Number of variables to plot, ordered by those that most contribute to selected principal components (this allows for faster performance as only the most contributing variables are rendered); if NULL, all variables are plotted

Value

Scatterplot as an highchart object

See Also

Other functions to analyse principal components: calculateLoadingsContribution(), performPCA(), plotPCAvariance()

Examples

pca <- prcomp(USArrests, scale=TRUE)
plotPCA(pca)
plotPCA(pca, pcX=2, pcY=3)

# Plot both individuals and loadings
plotPCA(pca, pcX=2, pcY=3, loadings=TRUE)

# Only plot loadings
plotPCA(pca, pcX=2, pcY=3, loadings=TRUE, individuals=FALSE)

nuno-agostinho/psichomics documentation built on Feb. 11, 2024, 11:16 p.m.