Split layout by k-means clustering groups.
align_kmeans(centers, ..., data = NULL, set_context = FALSE, name = NULL)
A new Align
object.
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.
Arguments passed on to stats::kmeans
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.
A matrix, data frame, or a simple vector. If an atomic vector is
provided, it will be converted into a one-column matrix. When data = NULL
,
the internal layout
data will be used by default. Additionally, data
can
be a function (including purrr-like lambdas), which will be applied to the
layout
data.
It is important to note that we consider the rows
as the observations. It
means the NROW(data)
must return the same number with the specific layout
axis (meaning the x-axis for vertical stack layout, or y-axis for horizontal
stack layout).
heatmap_layout()
: 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.
stack_layout()
: the layout
data will be used as it is since we place
all plots along a single axis.
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.
A string of the plot name. Used to switch the active context in
hmanno()
or stack_active()
.
ggheatmap(matrix(rnorm(81), nrow = 9)) +
hmanno("t") +
align_kmeans(3L)
Run the code above in your browser using DataLab