trials_raw is a trials tibble containing nested tibbles for movement_df_col and action_col. It should also contain columns specified by each string in marker_names. The trials tibble can have groups as per dplyr::group_by and heatmaps will be generated for each group.

plot_action_heatmaps(
  trials,
  movement_df_col,
  action_col = NULL,
  inner_col = NULL,
  action_label = NULL,
  marker_names = character(0),
  marker_indices = NULL,
  origin_landmark = NULL,
  axis_landmark = NULL,
  alignment_axis = "+Z",
  x_axis_lims = NULL,
  z_axis_lims = NULL,
  color_bar = TRUE,
  points_of_interest = TRUE,
  binning_count = 40
)

Arguments

movement_df_col

The nested tibbles of movement data from which to form a heatmap (as string)

action_col

The nested tibbles of action data (with a time column in each nested tibble) (as string)

inner_col

The column within an action data df containing action labels (as string)

action_label

The action label with which to filter movement data before forming a heatmap (as string)

marker_names

Columns containing position data to place markers on the heatmap (as a vector of strings)

marker_indices

Indices that specify which rows of markers to be plotted as numeric vector (ex: 1:5). (Default NULL - all rows)

origin_landmark

Column containing positional lists that specify the origin of the plot. (as string)

axis_landmark

Column containing positional lists marker to align onto an axis.

alignment_axis

Specify which axis data will be aligned to, options ("+Z" default, "-Z", "+X", "-X").

x_axis_lims

Specify x axis limits on plot as c(lower_lim, upper_lim) (numeric). (Default NULL - autodetect lims)

z_axis_lims

Specify y axis limits on plot as c(lower_lim, upper_lim)(numeric). (Default NULL - autodetect lims)

color_bar

Enable occupancy color bar (Default TRUE)

points_of_interest

Enable points of interest legend (Default TRUE)

binning_count

divides the smaller range on pos_x or pos_z axis into binning_count many bins. (Default 40)

trials_raw

A trials tibble

Details

action_col contains tibbles each with a time column and a column specified by inner_col containing label data. This is used to compute a mask to filter for time points where the inner_col == action_label. In case any of inner_col, action_label or action_col are missing, no mask is computed and filtering is skipped.

Within a group all movement tibbles will be concatenated and filtered by the mask computed. Then a spatial heatmap is produced for each group. marker_names names columns where the datum in a row would be a positional list containing pos_x and pos_z. These are used to mark points of interest in the heatmap (ex: fruit_position, safe_position). Positional lists from all rows will be plotted as points. User can specify particular rows instead via the marker_indices parameter.

You can specify the origin of each movement tibble by positional lists stored in a reference column in the trials tibble. The name of the reference column is passed as string via origin_landmark.

You can align the plot on the X-Z plane by aligning positional lists stored in a reference column to a preferred axis. The name of the reference column is passed as string via axis_landmark. The preferred axis is specified in alignment_axis Marker and movement data is rotated on the X-Z plane so that the axis landmark falls on the relevant axis ray (ex: "+X")

Both x_axis_lims and z_axis_lims are on the scale of the data.

You can tweak the binning of the heatmap with binning_count

Examples

heatmaps <- plot_action_heatmaps(example_data, movement_df_col = "head_movement_data_0", binning_count = 7)
#> Error in dplyr::mutate(., plots = list(extract_spatial_plot(movement_df,     !!!rlang::syms(marker_names)))): ℹ In argument: `plots = list(extract_spatial_plot(movement_df))`.
#> ℹ In row 1.
#> Caused by error in `loadNamespace()`:
#> ! there is no package called ‘ggnewscale’
heatmaps$plots[[1]]
#> Error: object 'heatmaps' not found