Reorders layout observations based on specific statistics.
align_reorder(
stat,
...,
reverse = FALSE,
strict = TRUE,
data = NULL,
set_context = FALSE,
name = NULL
)
A new Align
object.
A summary function which accepts a data and returns the
statistic, which we'll call order2()
to extract the ordering information.
<dyn-dots> Additional arguments passed to
function provided in stat
argument.
A boolean value. Should the sort order be in reverse?
A boolean value indicates whether the order should be strict.
If previous groups has been established, and strict is FALSE
, this will
reorder the observations in each group.
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()
.
The align_reorder()
function differs from align_order()
in that the wts
argument in align_order()
must return atomic weights for each observation.
In contrast, the stat
argument in align_reorder()
can return more complex
structures, such as hclust or
dendrogram, among others.
Typically, you can achieve the functionality of align_reorder()
using
align_order()
by manually extracting the ordering information from
the statistic.
order2()
ggheatmap(matrix(rnorm(81), nrow = 9)) +
hmanno("l") +
align_reorder(hclust2)
Run the code above in your browser using DataLab