Skip to contents

Order layout observations based on weights

Usage

align_order(
  wts = rowMeans,
  ...,
  reverse = FALSE,
  strict = TRUE,
  data = NULL,
  set_context = FALSE,
  name = NULL
)

Arguments

wts

A summary function which accepts a data and returns the weights for each observations. Alternatively, you can provide an ordering index as either an integer or a character. Since characters have been designated as character indices, if you wish to specify a function name as a string, you must enclose it with I().

...

<dyn-dots> Additional arguments passed to function provided in wts argument.

reverse

A boolean value. Should the sort order be in reverse?

strict

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.

data

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.

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("l") +
    align_order(I("rowMeans"))
#> → heatmap built with `geom_tile()`