Learn R Programming

ggbrain (version 0.9.0)

ggb: Generic R6 base class that is used to support + semantics

Description

Generic R6 base class that is used to support + semantics

Generic R6 base class that is used to support + semantics

Arguments

Public fields

ggb_images

ggbrain_images object for this plot

ggb_image_labels

a named list of data.frames that label corresponding images

ggb_slices

list slices to extract for this plot

ggb_contrasts

a character vector of contrasts to be computed as part of this plot

ggb_layers

a list of ggbrain_layer objects containing the bottom-to-top layers to be plotted

ggb_plot

a ggbrain_plot object containing the specification of the plot

ggb_annotations

a list of annotation objects

ggb_region_labels

a list of ggbrain_label objects to be added as text to label regions

action

what should this ggb object contribute to another when added with it?

Methods


Method new()

create a new ggb object. Note that inputs are always cloned to avoid unintended modify-in-place behaviors of R6 classes.

Usage

ggb$new(
  images = NULL,
  slices = NULL,
  contrasts = NULL,
  layers = NULL,
  labels = NULL,
  annotations = NULL,
  region_labels = NULL,
  title = NULL,
  bg_color = NULL,
  text_color = NULL,
  base_size = NULL,
  action = NULL
)

Arguments

images

a ggbrain_images object containing relevant images

slices

a character vector of slices to extract

contrasts

a character vector of contrasts to define and compute

layers

a list of ggbrain_layer objects

labels

a list of data.frames with labels that align with one or more images

annotations

a list of data.frames with annotations that will be added to specific slices

region_labels

a list of ggbrain_label objects with text-based labels to be drawn on the plot

title

overall title of the plot

bg_color

the background color of the overall plot

text_color

the text color of the overall plot

base_size

the base size of text on the plot

action

the action to be taken when adding this object to an existing ggb


Method add_layers()

add layers from another ggb object to this one

Usage

ggb$add_layers(ilist)

Arguments

ilist

a list of ggbrain_layer objects. If a ggb object is passed, we will get this list from obj$ggb_layers


Method add_slices()

add slices to the existing vector of slices

Usage

ggb$add_slices(slices = NULL)

Arguments

slices

a character vector of slices to be appended to the existing slices


Method add_contrasts()

add contrast definitions to the plot object

Usage

ggb$add_contrasts(contrasts)

Arguments

contrasts

a character vector of contrasts to compute as part of the plot generation


Method add_annotations()

add annotations to panels

Usage

ggb$add_annotations(annotations = NULL)

Arguments

annotations

a list or data.frame containing the annotations to add to each panel. Minimally, the list or data.frame must contain position and label columns that define the position and text to be added. Other arguments that pass through to ggplot2::annotate() can be provided as columns/elements in annotations and these will be passed through to annotate


Method add_image_labels()

add labels to a given image

Usage

ggb$add_image_labels(...)

Arguments

...

a named list of arguments where each is a data.frame with labels denoting corresponding images


Method add_region_labels()

add a list of ggbrain_label objects to the overall ggb for compiling a plot

Usage

ggb$add_region_labels(labels = NULL)

Arguments

labels

a list of data.frames with region labels that should be plotted on each slice. This is generated internally by ggbrain_images$get_slices() in the $slice_labels field.


Method render()

this method converts the ggb object into a compiled ggplot2 object that can then be passed to other functions from cowplot, ggplot2, and patchwork. Once the object is rendered, it no longer retains the underlying ggb fields that contain the elemental data.

Usage

ggb$render(guides = "collect")

Arguments

guides

Passes through to patchwork::plot_layout to control how legends are combined across plots. The default is "collect", which collects legends within a given nesting level (removes duplicates).


Method plot()

plot this ggb object -- just an alias for render

Usage

ggb$plot(guides = "collect")

Arguments

guides

Passes through to patchwork::plot_layout to control how legends are combined across plots. The default is "collect", which collects legends within a given nesting level (removes duplicates).

Details

requires that required elements are in place already.


Method clone()

The objects of this class are cloneable with this method.

Usage

ggb$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

this object becomes a simple storage class that contains all relevant objects (e.g., ggbrain_images) required to generate a brain plot