Learn R Programming

ggbrain (version 0.9.0)

ggbrain_slices: R6 class for managing slice data for ggbrain plots

Description

R6 class for managing slice data for ggbrain plots

R6 class for managing slice data for ggbrain plots

Arguments

Author

Michael Hallquist

Active bindings

slice_index

read-only access to the slice_index containing the slice numbers

coord_input

the input string used to lookup the slices

coord_label

the calculated x, y, or z coordinate of the relevant slice

slice_number

the slice number along the relevant axis of the 3D image matrix

slice_data

a nested list of data.frames where each element contains all data relevant to that slice and the list elements within are each a given image

slice_matrix

the slice data in matrix form

slice_labels

a data.frame for each slice containing the coordinates of labels available to be drawn

layer_names

a character vector of layer names within each slice

Methods


Method new()

create a ggbrain_slices object based

Usage

ggbrain_slices$new(slice_df = NULL)

Arguments

slice_df

a data.frame generated by ggbrain_images$get_slices()

Details

If this becomes a user-facing/exported class, we may want a more friendly constructor


Method compute_contrasts()

computes contrasts of the sliced image data

Usage

ggbrain_slices$compute_contrasts(contrast_list = NULL)

Arguments

contrast_list

a named list or character vector containing contrasts to be computed. The names of the list form the contrast names, while the values should be character strings that use standard R syntax for logical tests, subsetting, and arithmetic


Method as_tibble()

convert the slices object into a data.frame with list-columns for slice data elements

Usage

ggbrain_slices$as_tibble()


Method get_ranges()

calculates the numeric ranges of each image/contrast in this object, across all constituent slices. This is useful for setting scale limits that are shared across panels

Usage

ggbrain_slices$get_ranges(slice_indices = NULL)

Arguments

slice_indices

an optional integer vector of slice indices to be used as a subset in the calculation

Returns

a tibble keyed by 'layer' with overall low and high values, as well as split by pos/neg


Method get_uvals()

returns a data.frame with the unique values for each label layer, across all constituent slices

Usage

ggbrain_slices$get_uvals(slice_indices = NULL, add_labels = NULL)

Arguments

slice_indices

an optional integer vector of slice indices to be used as a subset in the calculation

add_labels

an optional named list indicating the label columns to add to a given layer. The names of the list specify the layer to which labels are added and the values should be character vectors specifying the names of columns that serve as labels for the layer. These are always added to any existing label columns for the layer.

Details

add_labels is provided here for any categorical columns that were specified inline in the layer definition using factor or as.factor, such as aes(fill=factor(value)). Otherwise, it's best to input data with labels in the first place so that labels are described in the data structure itself.


Method clone()

The objects of this class are cloneable with this method.

Usage

ggbrain_slices$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.