Skip to contents

ggalign is just an alias of align_gg.

Usage

align_gg(
  data = NULL,
  mapping = aes(),
  size = NULL,
  free_labs = waiver(),
  free_spaces = waiver(),
  plot_data = waiver(),
  limits = TRUE,
  facet = TRUE,
  set_context = TRUE,
  order = NULL,
  name = NULL
)

ggalign(
  data = NULL,
  mapping = aes(),
  size = NULL,
  free_labs = waiver(),
  free_spaces = waiver(),
  plot_data = waiver(),
  limits = TRUE,
  facet = TRUE,
  set_context = TRUE,
  order = NULL,
  name = NULL
)

Arguments

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.

mapping

Additional default list of aesthetic mappings to use for plot.

size

Plot size, can be an unit object.

free_labs

A boolean value or a string containing one or more of "t", "l", "b", and "r" indicates which axis title should be free from alignment. If NULL, all axis title will be aligned. Default: "tlbr".

free_spaces

A boolean value or a string containing one or more of "t", "l", "b", and "r" indicates which border spaces should be removed. If NULL (default), no space will be removed.

plot_data

A function used to transform the plot data before rendering. By default, it'll inherit from the parent layout. If no parent layout, the default is NULL, which means we won't want to modify anything.

Used to modify the data after layout has been created, but before the data is handled of to the ggplot2 for rendering. Use this hook if the you needs change the default data for all geoms.

limits

A boolean value indicates whether to set the layout limtis for the plot.

facet

A boolean value indicates whether to set the layout facet for the plot. If this is FALSE, limits will always be FALSE too.

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.

order

An single integer for the layout order.

name

A string of the plot name. Used to switch the active context in hmanno() or stack_active().

Value

A AlignGG object.

ggplot2 specification

align_gg initializes a ggplot data and mapping.

The internal will always use a default mapping of aes(y = .data$.y) or aes(x = .data$.x).

For ggplot usage, matrix (including a simple vector) data is converted into a long-format data frame. The data in the underlying ggplot object will contain following columns:

  • .panel: the panel for current layout axis.

  • .x or .y: the x or y coordinates

  • .row_names and .row_index: A factor of the row names and an integer of row index of the original matrix or data frame.

  • .column_names and .column_index: the column names and column index of the original matrix (only applicable if data is a matrix).

  • value: the actual matrix value (only applicable if data is a matrix).

In the case where the input data is already a data frame, three additional columns (.row_names, .row_index, and .panel) are added to the data frame.

if data is inherit from the heatmap layout, an additional column will be added.

  • .extra_panel: the panel information for column (left or right annotation) or row (top or bottom annotation).

Examples

ggheatmap(matrix(rnorm(81), nrow = 9)) +
    hmanno("top") +
    ggalign() +
    geom_point(aes(y = value))