Skip to contents

Reorders layout observations based on weights or summary statistics.

Usage

align_reorder(
  fun = rowMeans,
  ...,
  strict = TRUE,
  decreasing = FALSE,
  data = NULL,
  set_context = FALSE,
  name = NULL
)

Arguments

fun

A summary function. It should take a data and return the weights for the layout observations.

...

Additional arguments passed to fun.

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.

decreasing

A boolean value. Should the sort order be increasing or decreasing?

data

A matrix, a data frame, or even a simple vector that will be converted into a one-column matrix. If the data argument is set to NULL, the align_* will use the layout data. Additionally, the data argument can also accept a function (purrr-like lambda is also okay), which will be applied with the layout data,

It is important to note that all align_* functions consider the rows as the observations. It means the NROW(data) must return the same number with the parallel layout axis.

  • layout_heatmap: 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.

  • layout_stack: 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_reorder()