# \donttest{
# Irregular replicate structure ------------------------------------------
# Prepare the data to use in examples
# Note in this dataset each replicate is a different length!
data <- intermittent.rd
# Convert time to minutes (to show different options below)
data[[1]] <- round(data[[1]]/60, 2)
# Inspect
urch_insp <- inspect(data)
# Calculate the most linear rate within each replicate
auto_rate.int(urch_insp,
starts = c(1, 2101, 3901),
by = "row",
method = "linear",
width = 400) %>%
summary()
# Calculate the lowest rate within each replicate across
# 5 minutes (300 rows). For this we need to specify a 'measure' phase
# so that the flush is excluded.
auto_rate.int(urch_insp,
starts = c(1, 2101, 3901),
measure = 1000,
by = "row",
method = "lowest",
width = 300) %>%
summary()
# You can even specify different 'measure' phases in each rep
auto_rate.int(urch_insp,
starts = c(1, 2101, 3901),
measure = c(1000, 800, 600),
by = "row",
method = "lowest",
width = 300) %>%
summary()
# We usually don't want to use the start of a replicate just after the flush,
# so we can specify a 'wait' phase. We can also specify 'starts', 'wait',
# 'measure', and 'width' in units of time instead of rows.
#
# By time
# (this time we save the result)
urch_res <- auto_rate.int(urch_insp,
starts = c(0, 35, 65), # start locations in minutes
wait = 2, # wait for 2 mins
measure = 10, # measure phase of 10 mins
by = "time", # apply inputs by time values
method = "lowest", # get the 'lowest' rate...
width = 5) %>% # ... of 5 minutes width
summary()
# Regular replicate structure --------------------------------------------
# If replicates cycle at regular intervals, 'starts' can be used to specify
# the spacing in rows or time, starting at row 1. Therefore data must be
# subset first so that the first replicate starts at row 1.
#
# Subset and inspect data
zeb_insp <- zeb_intermittent.rd %>%
subset_data(from = 5840,
to = 75139,
by = "row",
quiet = TRUE) %>%
inspect()
# Calculate the most linear rate from the same 6-minute region in every
# replicate. Replicates cycle at every 660 rows.
zeb_res <- auto_rate.int(zeb_insp,
starts = 660,
wait = 120, # exclude first 2 mins
measure = 360, # measure period of 6 mins after 'wait'
method = "linear",
width = 200, # starting value for linear analysis
plot = TRUE) %>%
summary()
# S3 functions ------------------------------------------------------------
# Outputs can be used in print(), summary(), and mean().
# 'pos' can be used to select replicate ranges
summary(zeb_res)
mean(zeb_res, pos = 1:5)
# There are three ways by which the results can be plotted.
# 'pos' can be used to select replicates to be plotted.
#
# type = "rep" - the default. Each replicate plotted on a grid with rate
# region highlighted (up to a maximum of 20).
plot(urch_res)
# type = "full" - each replicate rate region plotted on entire data series.
plot(urch_res, pos = 1:2, type = "full")
# Of limited utility when datset is large
plot(zeb_res, pos = 10, type = "full")
# type = "ar" - the 'auto_rate' object for selected replicates in 'pos' is plotted
# Note this shows the 'measure' phase only
plot(urch_res, pos = 2, type = "ar")
# See vignettes on website for how to adjust and convert rates from auto_rate.int
# }
Run the code above in your browser using DataLab