Skip to contents

[Stable]

Ordering observations based on summary weights or a specified ordering character or integer index.

Usage

align_order(
  weights = rowMeans,
  ...,
  reverse = FALSE,
  strict = TRUE,
  data = NULL,
  active = NULL,
  set_context = deprecated(),
  name = deprecated()
)

Arguments

weights

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 weights 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 atomic vector used as the input for the weights 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 weight calculations. By default, it will inherit from the layout matrix.

active

A active() object that defines the context settings when added to a layout.

set_context

[Deprecated] Please use active argument instead.

name

[Deprecated] Please use active argument instead.

Value

A "AlignOrder" object.

Axis Alignment for Observations

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.

Examples

ggheatmap(matrix(rnorm(81), nrow = 9)) +
    anno_left() +
    align_order(I("rowMeans"))
#> → heatmap built with `geom_tile()`