Skip to contents

Split layout by k-means clustering groups.

Usage

align_kmeans(
  centers,
  iter.max = 10,
  nstart = 1,
  algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen"),
  trace = FALSE,
  data = NULL,
  set_context = FALSE,
  name = NULL
)

Arguments

centers

either the number of clusters, say \(k\), or a set of initial (distinct) cluster centres. If a number, a random set of (distinct) rows in x is chosen as the initial centres.

iter.max

the maximum number of iterations allowed.

nstart

if centers is a number, how many random sets should be chosen?

algorithm

character: may be abbreviated. Note that "Lloyd" and "Forgy" are alternative names for one algorithm.

trace

logical or integer number, currently only used in the default method ("Hartigan-Wong"): if positive (or true), tracing information on the progress of the algorithm is produced. Higher values may produce more tracing information.

data

A matrix, a data frame, or even a simple vector that will be converted into a one-column matrix. If the data argument is set to NULL, the align_* will use the layout data. Additionally, the data argument can also accept a function (purrr-like lambda is also okay), which will be applied with the layout data,

It is important to note that all align_* functions consider the rows as the observations. It means the NROW(data) must return the same number with the parallel layout axis.

  • layout_heatmap: for column annotation, the layout data will be transposed before using (If data is a function, it will be applied with the transposed matrix). This is necessary because column annotation uses heatmap columns as observations, but we need rows.

  • layout_stack: the layout data will be used as it is since we place all plots along a single axis.

set_context

A single boolean value indicates whether to set the active context to current plot. If TRUE, all subsequent ggplot elements will be added into this plot.

name

A string of the plot name. Used to switch the active context in hmanno() or stack_active().

Value

A new Align object.

Examples

ggheatmap(matrix(rnorm(81), nrow = 9)) +
    hmanno("t") +
    align_kmeans(3L)