plotPCA: plotPCA

View source: R/plotPCA.R

plotPCAR Documentation

plotPCA

Description

plot PCA [Deprecated]

plotPCA was renamed to plot_pca for more consistent function naming nomenclature in OCMSutility. Usage is still exactly the same

Usage

plotPCA(
  pc,
  metadata,
  colourby = "none",
  shapeby = "none",
  group = "none",
  continuous = FALSE,
  pcs = c("PC1", "PC2")
)

Arguments

pc

prcomp object

metadata

metadata dataframe

colourby

colour by. default "none"

shapeby

shape by. default "none"

group

group aes in ggplot. default "none"

continuous

is colourby a continuous variable? default FALSE

pcs

principal components to plot. default c("PC1", "PC2")

Value

list of ggplot pca plot and corresponding dataframe used to make the plot

Examples

pca_result <- prcomp(USArrests, scale = TRUE)
state_data <- data.frame(abb = state.abb, area = state.area,
                         center = state.center, region = state.region,
                         division = state.division)
rownames(state_data) <- state.name
plotPCA(pca_result, state_data, colourby='division', shapeby='region')
# ->
plot_pca(pca_result, state_data, colourby='division', shapeby='region')


OxfordCMS/OCMSutility documentation built on Feb. 27, 2025, 8:19 p.m.