calc_rate.int
uses the starts
input to subset each replicate. The wait
and measure
inputs control which parts of each replicate data are excluded
and included from the rate calculation. It extracts a rate from each
replicate using these, and saves it and other data to a summary table.
The x
input should be aninspect
object. Alternatively, it can be a
two-column data frame containing paired values of time and oxygen from an
intermittent-flow experiment in columns 1 and 2 respectively (though we
always recommend processing such data in inspect()
first). If a multiple
column dataset is entered as x
the first two columns are selected by
default. If these are not the intended data use inspect
to select the
correct time and oxygen columns.
Specifying replicate structure
The starts
input specifies the locations of the start of each replicate in
the data in x
. This can be in one of two ways:
A single numeric value specifying how replicates are spaced starting from
the data in the first row. This option should only be used when replicates
cycle at regular intervals. This can be a regular row or time interval, as
specified via the by
input. If the first replicate does not start at row 1,
the data should be subset so that it does (see subset_data()
) and example
here.
A numeric vector of row locations or times, as specified via the by
input, of the start of each individual replicate. The first replicate does
not have to start at the first row of the data, and all data after the last
entry is assumed to be part of the final replicate. Regular R
syntax such
as seq()
, 1:10
, etc. is also accepted, so can be used to specify both
regular and irregular replicate spacing.
For both methods it is assumed each replicate ends at the row preceding the
start of the next replicate, or in the case of the last replicate the final
row of the dataset.
Specifying rate region
The wait
and measure
inputs are used to specify the region from which to
extract a rate and exclude flush periods. They can be entered as row
intervals or time values in the units of the input data. The wait
phase
controls the amount of data at the start of each replicate to be ignored,
that is not used in rate calculations. The measure
phase determines the
region after this over which a rate is calculated. There is no flush
phase
input since this is assumed to be from the end of the measure
phase to the
end of the replicate.
Both wait
and measure
can be entered in one of two ways:
Single numeric values specifying a row width or a time period, as specified
via the by
input. Use this if you want to use the same wait
and
measure
phases in every replicate, that is extract a rate from the same
region of each.
If starts
is a vector of locations of the start of each replicate, these
inputs can also be vectors of equal length of row lengths or time periods as
specified via the by
input. This is only useful if you want to use
different wait
and/or measure
phases in different replicates.
If wait = NULL
no wait phase is applied. If measure = NULL
the rate is
extracted from the start of the replicate or end of the wait
phase to the
last row of the replicate. This will typically include the flush period, so
is rarely what you would want. Similarly if any measure
input is beyond the
available values in the replicate the closest value (row or time) is used
instead, which again would typically be the last row of the replicate.
Example
See examples below for actual code, but here is a simple example. An
experiment comprises replicates which cycle at ten minute intervals with data
recorded every second. Therefore each replicate will be 600 rows long.
Flushes of the respirometer take 3 minutes at the end of each replicate. We
want to exclude the first 2 minutes (120 rows) of data in each, and measure
an oxygen uptake rate for five minutes (300 rows), leaving the three minutes
of flushing (180 rows) excluded. The inputs for this would be:
starts = 600, wait = 120, measure = 300, by = "row"
More details
Only a single rate can be extracted from each replicate. If for some reason
you need to extract multiple rates from single replicates use subset_data()
and calc_rate()
which accepts multiple from
and to
inputs. Similarly,
the calc_rate
method of by = "oxygen"
is not supported in
calc_rate.int
. See vignettes on the website for examples of alternative
ways of iterating calc_rate
across multiple replicates if you need to get
around these constraints.
Plot
If plot = TRUE
(the default), the result for each replicate is plotted on a
grid up to a maximum of 20. Which replicates are plotted can be selected
using the pos
input (default is 1:20), either in the main function call or
when calling plot()
on output objects.
There are three ways of plotting the results, which can be selected using the
type
input:
type = "rep"
: The default. Each individual replicate is plotted with the
rate region (i.e. measure
phase) highlighted in yellow. The wait
and
measure
phases are also highlighted with red and green backgrounds
respectively. These are also labelled if legend = TRUE
.
type = "full"
: Each replicate rate (i.e. measure
phase) is highlighted
in the context of the whole dataset. May be quite difficult to interpret if
dataset is large.
type = "cr"
: Plots individual replicate results as calc_rate
objects.
For all types pos
can be used to select which replicate(s) to plot.
S3 Generic Functions
Saved output objects can be used in the generic S3 functions plot()
,
print()
, summary()
, and mean()
.
plot()
: plots the result. See Plot section above.
print()
: prints the result of a single replicate, by default the first.
Others can be printed by passing the pos
input. e.g. print(x, pos = 2)
summary()
: prints summary table of all results and metadata, or the rows
specified by the pos
input. e.g. summary(x, pos = 1:5)
. The $rep
column
indicates the replicate number. The summary table can be exported as a
separate data frame by passing export = TRUE
.
mean()
: calculates the mean of the rates from every replicate, or the
rows specified by the pos
input. e.g. mean(x, pos = 1:5)
The mean can be
exported as a numeric value by passing export = TRUE
.
More
For additional help, documentation, vignettes, and more visit the respR
website at https://januarharianto.github.io/respR/