Skip to contents

This function attempts to automate the extraction of relevant values from tables in the format of the Oroboros-O2K output csv. 'Stable' regions within each stage of the SUIT protocols are identified, with the mean values across these regions returned for downstream analysis. If multiple stable regions are present, the earliest (in terms of run time) will be used. The requirements for "Stability" can be edited using the window_size and change_threshold arguments. Negative values will not be considered.

Usage

o2k_oxy_list_to_tbl(
  chamber_list,
  unique_events,
  open_timings,
  treat_opening = "after",
  window_sizes = 15,
  change_thresholds = 1
)

Arguments

chamber_list

A list of tibbles or dataframes containing the raw oxygen flux measurements. Each element in the list must have at three columns containing information on the time, the event name, and the calibrated oxygen flux readings for a single chamber (in this order). Any additional columns will be ignored. Each chamber should be a separate element in the list. This can be generated using o2k_oxy_to_list().

unique_events

A vector of unique events that occur for which a window/mean value is to be calculated. This should not include 'open', 'close', nor 'WARNING'. If two events occur simultaneously, only the second event should be included. e.g.: If "11Tm" is added immediately after "11As", only "11Tm" should be included in this vector. If both events are included, an error will occur and the output will not be returned.

open_timings

A tibble with at least one column named 'time'. Each row should contain the time at which a chamber was opened.

treat_opening

In instances where a chamber is opened during a state, should the reading be taken from "before" or "after" the event? Must be one of these two values.

window_sizes

A numeric value specifying the size of the "window" that must be reached before mean values are calculated. If this window size is not met before the next event the final window of this size will be used and a warning will be returned. Example.: A window size of 15 (the default) means that the oxygen flux value must be stable for 30 seconds (15 x 2 second intervals) for a mean value to be calculated and returned. If the signal is never stable for 30 seconds (in this example) then the final 30 seconds before the next event will be used.

change_thresholds

A numeric value specifying the tolerance for change between consecutive O2K measurements. Changes less than this value will be considered 'stable'.

Value

A tibble with three columns: state, oxygen flux in left chamber, oxygen flux in right chamber.

See also

Other read o2k files: o2k_oxy_to_list(), read_o2k_oxy_csv(), read_o2k_oxy_xlsx()

Examples

 example_data <- o2k_oxy_list_to_tbl(
   chamber_list = test_data[[1]],
   unique_events = unique_events,
   open_timings = test_data[[2]],
   treat_opening = "after",
   window_sizes = 15,
   change_thresholds = 1
   )
#> Error: object 'unique_events' not found

 # using output from `o2k_oxy_to_list()`:

 # get unique events
   unique_events <- unique(output_from_o2k_oxy_to_list[[1]][[1]]$event_left)[!is.na(unique(output_from_o2k_oxy_to_list[[1]][[1]]$event_left))]
#> Error: object 'output_from_o2k_oxy_to_list' not found
   unique_events <- unique_events[!unique_events %in% c("your_event")]
#> Error: object 'unique_events' not found

 example_data <- o2k_oxy_list_to_tbl(
   chamber_list = output_from_o2k_oxy_to_list[[1]],
   unique_events = unique_events,
   open_timings = output_from_o2k_oxy_to_list[[2]],
   treat_opening = "after",
   window_sizes = 15,
   change_thresholds = 1
   )
#> Error: object 'unique_events' not found