Learn R Programming

specmine (version 4.0.0)

ica_kmeans_plot2D: ICA 2D k-means plot

Description

Creates a two-dimensional ICA plot coloured by k-means clusters.

Usage

ica_kmeans_plot2D(
  dataset,
  ica.result,
  num.clusters = 3,
  dims = c(1, 2),
  kmeans.result = NULL,
  use.embedding = TRUE,
  labels = FALSE,
  bw = FALSE,
  ellipses = FALSE,
  leg.pos = "right",
  xlim = NULL,
  ylim = NULL
)

Value

A ggplot object.

Arguments

dataset

Dataset to cluster.

ica.result

Result returned by ica_analysis_dataset().

num.clusters

Number of k-means clusters.

dims

Two independent components to plot.

kmeans.result

Optional k-means result containing a cluster vector.

use.embedding

Logical indicating whether k-means should be applied to the ICA embedding when kmeans.result is not supplied.

labels

Logical indicating whether sample labels should be displayed.

bw

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

ellipses

Logical indicating whether group ellipses should be displayed.

leg.pos

Legend position.

xlim

Optional x-axis limits.

ylim

Optional y-axis limits.

Examples

Run this code
if (requireNamespace("fastICA", quietly = TRUE)) {
  datamat <- matrix(rnorm(240), nrow = 8)
  dataset <- list(
    data = datamat,
    metadata = data.frame(
      class = factor(rep(c("A", "B"), each = 15))
    )
  )

  ica.result <- ica_analysis_dataset(
    dataset,
    n_components = 2,
    maxit = 100,
    seed = 42
  )

  kmeans.result <- list(
    cluster = rep(1:2, each = 15)
  )

  ica_kmeans_plot2D(
    dataset,
    ica.result,
    num.clusters = 2,
    kmeans.result = kmeans.result
  )
}

Run the code above in your browser using DataLab