Reorders layout observations based on specific statistics.
align_reorder(
stat,
...,
reverse = FALSE,
strict = TRUE,
data = NULL,
active = NULL,
set_context = deprecated(),
name = deprecated()
)
A "AlignReorder"
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 atomic vector used as the input for
the stat
function. Alternatively, you can specify a function
(including
purrr-like lambda syntax) that will be applied to the layout matrix,
transforming it as necessary for statistic calculations. By default, it will
inherit from the layout matrix.
A active()
object that defines the context settings when
added to a layout.
It is important to note that we consider rows as observations, meaning
vec_size(data)
/NROW(data)
must match the number of observations along the
axis used for alignment (x-axis for a vertical stack layout, y-axis for a
horizontal stack layout).
quad_layout()
/ggheatmap()
: For column annotation, the layout
matrix
will be transposed before use (if data
is a function, it is
applied to the transposed matrix), as column annotation uses columns as
observations but alignment requires rows.
stack_layout()
: The layout matrix is used as is, aligning all plots
along a single axis.
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)) +
anno_left() +
align_reorder(hclust2)
Run the code above in your browser using DataLab