Learn R Programming

ggalign (version 0.0.4)

align: Create a new Align object

Description

Align object will act with the layout object, reorder or split the observations, some of them can also add plot components into the layout object.

Usage

align(
  align_class,
  params,
  data,
  size = NULL,
  free_guides = waiver(),
  free_spaces = waiver(),
  plot_data = waiver(),
  theme = waiver(),
  free_labs = waiver(),
  limits = TRUE,
  facet = TRUE,
  set_context = TRUE,
  order = NULL,
  name = NULL,
  check.param = TRUE,
  call = caller_call()
)

Value

A new Align object.

Arguments

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.

size

Plot size, can be an unit object.

free_guides

Override the guides argument specified in the layout for a plot. Options include:

  • waiver(): inherits behavior from the layout.

  • NULL: no guide legends will be collected for the plot.

  • A string containing one or more of "t", "l", "b", and "r" indicates which side of guide legends should be collected for the plot..

free_spaces

A string with one or more of "t", "l", "b", and "r" indicating which border spaces should be removed. Defaults to waiver(), which inherits from the parent layout. If no parent, the default is NULL, meaning no spaces are removed.

plot_data

A function to transform plot data before rendering. Defaults to waiver(), which inherits from the parent layout. If no parent layout, the default is NULL, meaning the data won't be modified.

Used to modify the data after layout has been created, which should be a data frame, 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.

theme

Default plot theme: One of:

  • waiver(): will inherit from the parent layout.

  • NULL: Use the default theme.

  • theme(): will be added with the parent layout theme.

Note: The axis title and labels parallel to the layout axis will always be removed by default. For vertical stack layouts, this refers to the x-axis, and for horizontal stack layouts, this refers to the y-axis. If you want to display the axis title or labels, you should manually add theme() elements for the parallel axis title or labels.

free_labs

A string with one or more of "t", "l", "b", and "r" indicating which axis titles should be free from alignment. Defaults to waiver(), which inherits from the parent layout. If no parent layout, no axis titles will be aligned. If NULL, all axis titles will be aligned.

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 plot area order.

name

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

check.param

A single boolean value indicates whether to check the supplied parameters and warn.

call

The call used to construct the Align for reporting messages.

Align

Each of the Align* objects is just a ggproto() object, descended from the top-level Align, and each implements various methods and fields.

To create a new type of Align* object, you typically will want to override one or more of the following:

  • setup_params: Prepare parameter or check parameters used by this annotation.

  • setup_data: Prepare data used by this annotation.

  • compute: A method used to compute statistics.

  • layout: A method used to group heamap rows/columns into panel or reorder heamtap rows/columns.

  • draw: A method used to draw the plot. Must return a ggplot object.

Examples

Run this code
align_gg()
align_dendro()

Run the code above in your browser using DataLab