pca_kmeans_plot3D: PCA 3D k-means plot

View source: R/pca.R

pca_kmeans_plot3DR Documentation

PCA 3D k-means plot

Description

Plots PCA scores in 3D coloured by k-means cluster assignment.

Usage

pca_kmeans_plot3D(
  dataset,
  pca.result,
  num.clusters = 3,
  pcas = c(1, 2, 3),
  kmeans.result = NULL,
  labels = FALSE,
  size = 1,
  ...
)

Arguments

dataset

Dataset used in the PCA.

pca.result

PCA result object.

num.clusters

Number of clusters.

pcas

Principal components to plot.

kmeans.result

Optional precomputed k-means result.

labels

Logical indicating whether sample labels should be shown.

size

Point size.

...

Additional arguments passed to rgl::plot3d().

Value

No return value, called for its side effect of plotting.

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_kmeans_plot3D(dataset, pca_res, num.clusters = 2)



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