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 toNULL
, thealign_*
will use thelayout
data. Additionally, thedata
argument can also accept a function (purrr-like lambda is also okay), which will be applied with thelayout
data,It is important to note that all
align_*
functions consider therows
as the observations. It means theNROW(data)
must return the same number with the parallellayout
axis.layout_heatmap
: for column annotation, thelayout
data will be transposed before using (If data is afunction
, 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
: thelayout
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()
orstack_active()
.