pca_scoresplot2D: PCA 2D scores plot

View source: R/pca.R

pca_scoresplot2DR Documentation

PCA 2D scores plot

Description

Creates a 2D PCA scores plot.

Usage

pca_scoresplot2D(
  dataset,
  pca.result,
  column.class = NULL,
  pcas = c(1, 2),
  labels = FALSE,
  ellipses = FALSE,
  bw = FALSE,
  pallette = 2,
  leg.pos = "right",
  xlim = NULL,
  ylim = NULL
)

Arguments

dataset

Dataset used in the PCA.

pca.result

PCA result object.

column.class

Optional metadata column used for colouring groups.

pcas

Principal components to plot.

labels

Logical indicating whether sample labels should be shown.

ellipses

Logical indicating whether group ellipses should be drawn.

bw

Logical indicating whether a black-and-white style should be used.

pallette

Brewer palette identifier.

leg.pos

Legend position.

xlim

Optional x-axis limits.

ylim

Optional y-axis limits.

Value

A ggplot object.

Examples


datamat <- matrix(
  rnorm(20),
  nrow = 4,
  dimnames = list(paste0("x", 1:4), paste0("s", 1:5))
)
metadata <- data.frame(class = factor(c("A", "A", "B", "B", "A")))
dataset <- list(data = datamat, metadata = metadata)
pca_res <- pca_analysis_dataset(dataset)
pca_scoresplot2D(dataset, pca_res, column.class = "class")



specmine documentation built on Aug. 5, 2026, 5:06 p.m.