Title: | Importing Data from Loligo Systems Software, Calculating Metabolic Rates and Critical Tensions |
---|---|
Description: | Analysis of oxygen consumption data generated by Loligo (R) Systems respirometry equipment. The package includes a function for loading data output by Loligo's 'AutoResp' software (get.witrox.data()), functions for calculating metabolic rates over user-specified time intervals, extracting critical points from data using broken stick regressions based on Yeager and Ultsch (<DOI:10.1086/physzool.62.4.30157935>), and easy functions for converting between different units of barometric pressure. |
Authors: | Tyler L. Moulton |
Maintainer: | Tyler L. Moulton <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-12-03 06:37:12 UTC |
Source: | CRAN |
Analysis of oxygen consumption data generated by Loligo (R) Systems respirometry equipment. The package includes a function for loading data output by Loligo's 'AutoResp' software (get.witrox.data()), functions for calculating metabolic rates over user-specified time intervals, extracting critical points from data using broken stick regressions based on Yeager and Ultsch (1989), and easy functions for converting between different units of barometric pressure.
Package: | rMR |
Type: | Package |
Version: | 1.0.5 |
Date: | 2017-09-07 |
License: | 3 |
Tyler L. Moulton
Maintainer: Tyler L. Moulton <[email protected]>
Benson, B.B., and Daniel Krause, Jr (1980). The concentration and isotopic fractionation of gases dissolved in freshwater in equilibrium with the atmosphere. 1. Oxygen: Limnology and Oceanography, vol. 25, no. 4, p. 662-671. doi:10.4319/lo.1980.25.4.0662.
Gnaiger, Erich, and Hellmuth Forstner, eds. (2012). Polarographic oxygen sensors: Aquatic and physiological applications. Springer Science & Business Media. doi:10.1007/978-3-642-81863-9.
Lumley, Thomas (2013). "biglm: bounded memory linear and generalized linear models". 0.9-1. https://CRAN.R-project.org/package=biglm.
McDonnell, Laura H., and Lauren J. Chapman (2016). "Effects of thermal increase on aerobic capacity and swim performance in a tropical inland fish." Comparative Biochemistry and Physiology Part A: Molecular & Integrative Physiology 199: 62-70. doi:10.1016/j.cbpa.2016.05.018.
Mechtly, E. A. (1973). The International System of Units, Physical Constants and Conversion Factors. NASA SP-7012, Second Revision, National Aeronautics and Space Administration, Washington, D.C. https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19730018242.pdf.
Roche, Dominique G., et al. (2013). "Finding the best estimates of metabolic rates in a coral reef fish." Journal of Experimental Biology 216.11: 2103-2110. doi:10.1242/jeb.082925.
U.S. Geological Survey (2011). Change to solubility equations for oxygen in water: Office of Water Quality Technical Memorandum 2011.03, accessed July 15, 2011, at http://water.usgs.gov/admin/memo/QW/qw11.03.pdf.
Yeager, D. P. and Ultsch, G. R. (1989). Physiological regulation and conformation: a BASIC program for the determination of critical points. Physiological Zoology, 888-907. doi:10.1086/physzool.62.4.30157935.
http://www.loligosystems.com/
Takes user-defined start and end times to calculate the backround respiration rate in a respirometer.
background.resp(data, DO.var.name, time.var.name = "std.time", start.time, end.time, col.vec = c("black","red"),...)
background.resp(data, DO.var.name, time.var.name = "std.time", start.time, end.time, col.vec = c("black","red"),...)
data |
|
DO.var.name |
Column name of DO variable, formatted as a character string. |
time.var.name |
Column name of time variable as character string. Time column must be formatted as default class for datetime: |
start.time |
Input start time as character string of |
end.time |
Input endtime as character string of |
col.vec |
Specifies colors on plot in the following order: 1) scatterplot points, 2) regression color. |
... |
Passes on arguments to internal functions. |
Returns an object of method biglm
. The slope of this funtion is the metabolic rate in input units/(default time).
Tyler L. Moulton
Thomas Lumley (2013). biglm: bounded memory linear and generalized linear models. R package version 0.9-1. https://CRAN.R-project.org/package=biglm.
##load data## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") bgd.resp <- background.resp(fishMR, "DO.mgL", start.time = "2015-07-02 16:05:00", end.time = "2015-07-02 16:35:00")
##load data## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") bgd.resp <- background.resp(fishMR, "DO.mgL", start.time = "2015-07-02 16:05:00", end.time = "2015-07-02 16:35:00")
Function to estimate barometric pressure based on altitude.
Barom.Press(elevation.m, units = "atm")
Barom.Press(elevation.m, units = "atm")
elevation.m |
Elevation in meters above sea level. |
units |
Output units for barometric pressure must be one of: |
This is just a simple conversion function. Plug and chug, as they say...
Returns numeric object of barometric pressure in specified units.
Tyler L. Moulton
Mechtly, E. A., 1973: The International System of Units, Physical Constants and Conversion Factors. NASA SP-7012, Second Revision, National Aeronautics and Space Administration, Washington, D.C. https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19730018242.pdf.
U.S. Geological Survey (2011). Change to solubility equations for oxygen in water: Office of Water Quality Technical Memorandum 2011.03, accessed July 15, 2011, at http://water.usgs.gov/admin/memo/QW/qw11.03.pdf.
bar.pressure1 <- Barom.Press(elevation.m = 1000) # returns "atm" bar.pressure2 <- Barom.Press(elevation.m = 1000, "kpa") bar.pressure3 <- Barom.Press(elevation.m = 1000, "mmHg")
bar.pressure1 <- Barom.Press(elevation.m = 1000) # returns "atm" bar.pressure2 <- Barom.Press(elevation.m = 1000, "kpa") bar.pressure3 <- Barom.Press(elevation.m = 1000, "mmHg")
Calculate the percent saturation of oxygen in water given external temperature, barometric pressure, and recorded DO concentration in mg/L.
DO.saturation(DO.mgl, temp.C, elevation.m = NULL, bar.press = NULL, bar.units = NULL, salinity, salinity.units)
DO.saturation(DO.mgl, temp.C, elevation.m = NULL, bar.press = NULL, bar.units = NULL, salinity, salinity.units)
DO.mgl |
Recorded DO concentration in mg/L. |
temp.C |
Temperature in degrees C. |
elevation.m |
Elevation in meters above sea level. EITHER |
bar.press |
Barometric pressure in user defined units (bar.units)–defaults to |
bar.units |
Units of barometric pressure, defaults to |
salinity |
Salinity, either reported in parts per thousand ( |
salinity.units |
Salinity units, must be |
Returns numeric value of dissolved oxygen saturation.
Tyler L. Moulton
Mechtly, E. A., 1973: The International System of Units, Physical Constants and Conversion Factors. NASA SP-7012, Second Revision, National Aeronautics and Space Administration, Washington, D.C. https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19730018242.pdf.
U.S. Geological Survey (2011). Change to solubility equations for oxygen in water: Office of Water Quality Technical Memorandum 2011.03, accessed July 15, 2011, at http://water.usgs.gov/admin/memo/QW/qw11.03.pdf.
DO.sat1 <- DO.saturation(DO.mgl = 5.5, temp.C = 20, elevation.m = 1000) DO.sat2 <- DO.saturation(DO.mgl = 5.5, temp.C = 20, bar.press = 674.1, bar.units = "mmHg") DO.sat1 DO.sat2 # Will ya look at that...
DO.sat1 <- DO.saturation(DO.mgl = 5.5, temp.C = 20, elevation.m = 1000) DO.sat2 <- DO.saturation(DO.mgl = 5.5, temp.C = 20, bar.press = 674.1, bar.units = "mmHg") DO.sat1 DO.sat2 # Will ya look at that...
Converts between different different units of DO concentration. Takes into account ambient temperature, pressure and salinity.
DO.unit.convert(x, DO.units.in, DO.units.out, bar.units.in, bar.press, temp.C, bar.units.out = "mmHg", salinity = 0, salinity.units = "pp.thou")
DO.unit.convert(x, DO.units.in, DO.units.out, bar.units.in, bar.press, temp.C, bar.units.out = "mmHg", salinity = 0, salinity.units = "pp.thou")
x |
Value or object of class numeric to be converted. |
DO.units.in |
Units of dissolved oxygen concentration measured, i.e. to be converted from. Must be |
DO.units.out |
Units of dissolved oxygen concentration desired, i.e. to be converted to. Must be |
bar.units.in |
Units of barometric pressure of user specified barometric pressure measurement. Must take value of |
bar.press |
Ambient barometric pressure measurement |
temp.C |
Water temperature measured in degrees C |
bar.units.out |
Used in internal calculation, only visible if output DO.units.out = |
salinity |
Salinity, either reported in parts per thousand ( |
salinity.units |
Salinity units, must be |
Numeric object representing dissolved oxygen concentration in the units specified by DO.units.out
.
Use this function on entire data columns to convert them to desired units before analysing with functions like MR.loops
and get.pcrit
.
Tyler L. Moulton
Mechtly, E. A., 1973: The International System of Units, Physical Constants and Conversion Factors. NASA SP-7012, Second Revision, National Aeronautics and Space Administration, Washington, D.C. https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19730018242.pdf.
U.S. Geological Survey (2011). Change to solubility equations for oxygen in water: Office of Water Quality Technical Memorandum 2011.03, accessed July 15, 2011, at http://water.usgs.gov/admin/memo/QW/qw11.03.pdf.
plot
,
plotRaw
,
cbind
,
Eq.Ox.conc
,
DO.saturation
,
## on a single value ## DO.pct<- DO.unit.convert(x= 125.6863, DO.units.in = "PP", DO.units.out = "pct", bar.units.in = "mmHg", bar.press = 750, temp.C =15) ## Apply to a column in a 'data.frame' class object ## ## load data ## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") head(fishMR) #note that DO data are in mg/L (DO.mgL) and #that there is an instantaneous temperature column #(temp.C) and a pressure column (Bar.Pressure.hpa) DO.pct.col.a <- DO.unit.convert(fishMR$DO.mgL, DO.units.in = "mg/L", DO.units.out = "pct", bar.units.in = "kpa", bar.press = 101.3, temp.C = fishMR$temp.C, bar.units.out = "kpa") DO.pct.col.b<- DO.unit.convert(fishMR$DO.mgL, DO.units.in = "mg/L", DO.units.out = "pct", bar.units.in = "kpa", bar.press = 101.3, temp.C = fishMR$temp.C) head(DO.pct.col.a) head(DO.pct.col.b) # Now with df # fishMR2 <- as.data.frame(cbind(fishMR, DO.pct.col.a)) par(mfrow = c(1,2)) plotRaw(data = fishMR, DO.var.name = "DO.mgL", start.time = "2015-07-03 06:15:00", end.time = "2015-07-03 08:05:00", main = "DO (mg/L) vs time", xlab = "time", ylab = "DO (mg/L)") plotRaw(data = fishMR2, DO.var.name = "DO.pct.col.a", start.time = "2015-07-03 06:15:00", end.time = "2015-07-03 08:05:00", main = "DO (percent saturation) vs time", xlab = "time", ylab = "DO (percent saturation)")
## on a single value ## DO.pct<- DO.unit.convert(x= 125.6863, DO.units.in = "PP", DO.units.out = "pct", bar.units.in = "mmHg", bar.press = 750, temp.C =15) ## Apply to a column in a 'data.frame' class object ## ## load data ## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") head(fishMR) #note that DO data are in mg/L (DO.mgL) and #that there is an instantaneous temperature column #(temp.C) and a pressure column (Bar.Pressure.hpa) DO.pct.col.a <- DO.unit.convert(fishMR$DO.mgL, DO.units.in = "mg/L", DO.units.out = "pct", bar.units.in = "kpa", bar.press = 101.3, temp.C = fishMR$temp.C, bar.units.out = "kpa") DO.pct.col.b<- DO.unit.convert(fishMR$DO.mgL, DO.units.in = "mg/L", DO.units.out = "pct", bar.units.in = "kpa", bar.press = 101.3, temp.C = fishMR$temp.C) head(DO.pct.col.a) head(DO.pct.col.b) # Now with df # fishMR2 <- as.data.frame(cbind(fishMR, DO.pct.col.a)) par(mfrow = c(1,2)) plotRaw(data = fishMR, DO.var.name = "DO.mgL", start.time = "2015-07-03 06:15:00", end.time = "2015-07-03 08:05:00", main = "DO (mg/L) vs time", xlab = "time", ylab = "DO (mg/L)") plotRaw(data = fishMR2, DO.var.name = "DO.pct.col.a", start.time = "2015-07-03 06:15:00", end.time = "2015-07-03 08:05:00", main = "DO (percent saturation) vs time", xlab = "time", ylab = "DO (percent saturation)")
Determines equilibrium dissolved oxygen concentration in water based on pressure and temperature. An estimate for barometric pressure can be generated by supplying the temperature and elevation (calculation by Barom.Press()
)
Eq.Ox.conc(temp.C, elevation.m = NULL, bar.press = NULL, bar.units = "mmHg", out.DO.meas = "mg/L", salinity = 0, salinity.units = "pp.thou")
Eq.Ox.conc(temp.C, elevation.m = NULL, bar.press = NULL, bar.units = "mmHg", out.DO.meas = "mg/L", salinity = 0, salinity.units = "pp.thou")
temp.C |
Water temperature in degrees C |
elevation.m |
Elevation in meters. Default = |
bar.press |
Barometric pressure. Default = |
bar.units |
Units of barometric pressure for value supplied in bar.press. Must be |
out.DO.meas |
Units of dissolved oxygen concentration |
salinity |
Salinity, either reported in parts per thousand ( |
salinity.units |
Salinity units, must be |
Returns object of class numberic of full equilibrium dissolved oxygen concentration.
Tyler L. Moulton
Benson, B.B., and Daniel Krause, Jr (1980). The concentration and isotopic fractionation of gases dissolved in freshwater in equilibrium with the atmosphere. 1. Oxygen: Limnology and Oceanography, vol. 25, no. 4, p. 662-671. doi:10.4319/lo.1980.25.4.0662.
Gnaiger, Erich, and Hellmuth Forstner, eds. Polarographic oxygen sensors: Aquatic and physiological applications. Springer Science & Business Media, 2012. doi:10.1007/978-3-642-81863-9.
Mechtly, E. A., 1973: The International System of Units, Physical Constants and Conversion Factors. NASA SP-7012, Second Revision, National Aeronautics and Space Administration, Washington, D.C. https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19730018242.pdf.
U.S. Geological Survey (2011). Change to solubility equations for oxygen in water: Office of Water Quality Technical Memorandum 2011.03, accessed July 15, 2011, at http://water.usgs.gov/admin/memo/QW/qw11.03.pdf.
DO.saturation
DO.unit.convert
Barom.Press
eqO2.1 <- Eq.Ox.conc(temp.C = 20, elevation.m = 1000, bar.units = NULL) eqO2.2 <- Eq.Ox.conc(temp.C = 20, bar.press = 674.1, bar.units = "mmHg") eqO2.1 eqO2.2
eqO2.1 <- Eq.Ox.conc(temp.C = 20, elevation.m = 1000, bar.units = NULL) eqO2.2 <- Eq.Ox.conc(temp.C = 20, bar.press = 674.1, bar.units = "mmHg") eqO2.1 eqO2.2
This is a dataset acquired duirng a respirometry trial on a mormyrid of the species Gnathonemus victoriae. It went great. There are several "loops" (open/close the respirometer) to establish routine metabolic rate, as well as an extended "closed" period to capture the "P.crit", the point at which the linear relationship between metabolic rate and ambient dissolved oxygen changed.
data(fishMR)
data(fishMR)
A data frame with 64239 observations on the following 7 variables.
Date.time
a character vector
times
a numeric vector
Bar.Pressure.hpa
a numeric vector
Phase
a numeric vector
temp.C
a numeric vector
DO.mgL
a numeric vector
Moulton Tyler L., Chapman Lauren J., Krahe Rudiger. Manuscript in Prep.
data(fishMR) str(fishMR) head(fishMR)
data(fishMR) str(fishMR) head(fishMR)
Determines the critical point of a rate process based on the broken stick model featured in Yeager and Ultsch (1989). The two regressions are selected based on the break point which minimizes the total residual sum of squares. The rate process that this package is designed for is metabolic rate (MR.var.name
), and it is regressed on ambient dissolved oxygen concentration (DO.var.name
). However, the same function can be used for other processes.
If metabolic rate has not already been calculated and the user wishes to calculate metabolic rates directly from oxygen concentration measurements, let MR.var.name= NULL
. Then indicate the name of the time variable AND the time interval (i.e. the width of the time window over which you will estimate instantaneous metabolic rates).
get.pcrit(data, DO.var.name, MR.var.name = NULL, Pcrit.below, time.interval, time.var = NULL, start.time, stop.time, time.units = "sec", Pcrit.type = "both", syst.vol = NULL, col.vec = c("black", "gray60", "red", "blue"),...)
get.pcrit(data, DO.var.name, MR.var.name = NULL, Pcrit.below, time.interval, time.var = NULL, start.time, stop.time, time.units = "sec", Pcrit.type = "both", syst.vol = NULL, col.vec = c("black", "gray60", "red", "blue"),...)
data |
Data to be used. |
DO.var.name |
Variable name of oxygen concentration variable, formatted as character string. To be used for determination of critical point. If using pre-calculated instantaneous metabolic rates (MR) to conduct Pcrit, this should be specified by |
MR.var.name |
Metabolic rate variable name, formatted as character. Default = |
Pcrit.below |
DO concentration below which you are confident that Pcrit occurs. Accelerates process by reducing the number of iterations required to find Pcrit. Data points featuring DO conc > |
time.interval |
If |
time.var |
Column name for indexing (time) variable used to calculate instantaneous Metabolic Rate (MR) from oxygen concentration data (specified by |
start.time |
Beginning of time interval over which to evaluate data for Pcrit. Required if |
stop.time |
End of time interval over which to evaluate data for Pcrit. Required if |
time.units |
Units of time in MR calculation. Defaults to |
Pcrit.type |
Either |
syst.vol |
Enter the system volume in Liters. If |
... |
Arguments passed on to internal functions. |
col.vec |
Specifies colors on plot in the following order: 1) scatterplot points representing instantaneous MR, 2) regression lines color, 3) vertical line representing Pcrit using the intersect method ( |
This calculates the critical oxygen tension for a change in metabolic rate. It is a simple broken stick model which evaluates the data at dissolved oxygen values recorded within the specified time frame. The data of MR and DO are ordered by decreasing DO value. Then, the function iteratively calculates the total residual sum of squares (using tot.rss
) of two linear models, one spanning from Pcrit.below
to Pcrit.below
- i, the other with a range from the minimum DO value to Pcrit.below
- (i + 1). The broken stick model resulting in the lowest total residual sum of squares is selected.
A scatterplot of MR ~ DO is generated with the two regression lines (in gray). Also returns a list of 6. $Pcrit.lm
is the Pcrit given by the intersection of the two best fit lines (vertical red dashed line). $Pcrit.mp
is the Pcrit using the midpoint method (vertical blue dotted vertical line). $P$Adj.r2.above
gives the adjusted R2 value of the relationship between MR~DO above the critical point, and likewise, $Adj.r2.below
gives the R2 below the critical point. The other two elements are lm
class objects calculated from the regression slopes above and below the break point in the broken stick model (which is not necessarily the same point as where the regression lines intersect!).
Tyler L. Moulton
Yeager, D. P. and Ultsch, G. R. (1989). Physiological regulation and conformation: a BASIC program for the determination of critical points. Physiological Zoology, 888-907. doi:10.1086/physzool.62.4.30157935.
tot.rss
,
strptime
,
as.POSIXct
,
## set data ## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") Pcrit1 <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 120, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00") ## MR units in mgO2 / sec ## Change time interval ## Pcrit2 <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 60, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00", time.units = "min") ## MR units in mgO2 / min Pcrit3 <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 60, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00", time.units = "hr", ylab = "Met Rate (mg O2 L-1 hr-1)") ## MR units in mgO2 / hr ## syst vol specified at 0.75 L ## Pcrit3a <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 60, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00", time.units = "hr", syst.vol = 0.75, ylab = "Met Rate (mg O2 / hr)") ## MR units in mgO2 / hr ## No vertical lines on plot Pcrit4 <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 60, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00", time.units = "hr", ylab = "Met Rate (mg O2 L-1 hr-1)", Pcrit.type = "")
## set data ## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") Pcrit1 <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 120, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00") ## MR units in mgO2 / sec ## Change time interval ## Pcrit2 <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 60, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00", time.units = "min") ## MR units in mgO2 / min Pcrit3 <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 60, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00", time.units = "hr", ylab = "Met Rate (mg O2 L-1 hr-1)") ## MR units in mgO2 / hr ## syst vol specified at 0.75 L ## Pcrit3a <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 60, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00", time.units = "hr", syst.vol = 0.75, ylab = "Met Rate (mg O2 / hr)") ## MR units in mgO2 / hr ## No vertical lines on plot Pcrit4 <-get.pcrit(data = fishMR, DO.var.name = "DO.mgL", Pcrit.below = 2, time.var = "std.time", time.interval = 60, start.time = "2015-07-03 06:15:00", stop.time = "2015-07-03 08:05:00", time.units = "hr", ylab = "Met Rate (mg O2 L-1 hr-1)", Pcrit.type = "")
Allows user to import data from Loligo (R) Systems' 'Autoresp' software-generated text files into a R data.frame (class data.frame
)
get.witrox.data(data.name, lines.skip, delimit = "tab", choose.names = F, chosen.names = NULL, format)
get.witrox.data(data.name, lines.skip, delimit = "tab", choose.names = F, chosen.names = NULL, format)
data.name |
Full data file name as character string. |
lines.skip |
The lines in the header to be skipped. If |
delimit |
Choose the delimiter. Defaults to tab delimited. Can take values of |
choose.names |
logical: if |
chosen.names |
If |
format |
This is the format that the date-time column is formatted in by auto resp–This must be the FIRST COLUMN. The default format is |
Returns an object of class data.frame, with std.time
as the last column, which is in the default standard POSIXct
date-time format.
Tyler L. Moulton
# Requires a text file. Download fish_MR.txt from github repository and # accompanying readme file at: # https://github.com/tyler-l-moulton/rMR
# Requires a text file. Download fish_MR.txt from github repository and # accompanying readme file at: # https://github.com/tyler-l-moulton/rMR
This function calculates the metabolic rates from multiple closed respirometry loops simultaneously. Requires lots of user input, but is easy to manipulate. Returns list of metabolic rates, as well as the average metabolic rate and the standard deviation of the sample of metabolic rates, as well as biglm objects for each section of data used to calculate MRs.
MR.loops(data, DO.var.name, time.var.name = "std.time", in.DO.meas = "mg/L", out.DO.meas = "mg/L", start.idx, stop.idx, syst.vol = 1, background.consumption = 0, background.indices = NULL, temp.C, elevation.m = NULL, bar.press = NULL, bar.units = "atm", PP.units, time.units = "sec", col.vec = c("black","red"),...)
MR.loops(data, DO.var.name, time.var.name = "std.time", in.DO.meas = "mg/L", out.DO.meas = "mg/L", start.idx, stop.idx, syst.vol = 1, background.consumption = 0, background.indices = NULL, temp.C, elevation.m = NULL, bar.press = NULL, bar.units = "atm", PP.units, time.units = "sec", col.vec = c("black","red"),...)
data |
Must include a time variable in standard |
DO.var.name |
Column name of DO variable, must be entered as character string. |
time.var.name |
Column name of time variable (which is in |
in.DO.meas |
Units of DO measurement entered in the DO variable column: must be one of |
out.DO.meas |
Units of DO measurement returned for metabolic rate: must be one of |
start.idx |
Character class value or vector matching |
stop.idx |
Character class value or vector matching |
syst.vol |
System volume in Liters (defaults to 1 L). |
background.consumption |
Default = 0. If using a one point calibration for background, simply set |
background.indices |
If using a multi-point calibration to set the background respiration rate, enter a vector of times for when the respiration rates were calculated. There should be one time point per corresponding value in |
temp.C |
Water temperature in degrees C. |
elevation.m |
Elevation in m. Only required if |
bar.press |
barometric pressure in units defined by bar.units argument. Only required if |
bar.units |
Units of barometric pressure used as input and in output if |
PP.units |
Units of barometric pressure used for "PP". |
time.units |
Denominator for metabolic rate, also displayed as units on X-axis. Acceptable arguments: "hr", "min", "sec". |
col.vec |
Specifies colors on plot in the following order: 1) scatterplot points, 2) regression lines color. |
... |
Arguments passed on to internal functions |
Returns a list of 2. $MR.summary
is of class data.frame with 3 columns: $MR
(metabolic rate in user specified units, this is the same as the slope in each linear model), $sd.slope
(standard deviation of slopes calculation), $r.square
(adjusted r square value from each model). This second object is a list of biglm
objects, each one representing a metabolic loop (see McDonnell and Chapman 2016).
Tyler L. Moulton
McDonnell, Laura H., and Lauren J. Chapman (2016). "Effects of thermal increase on aerobic capacity and swim performance in a tropical inland fish." Comparative Biochemistry and Physiology Part A: Molecular & Integrative Physiology 199: 62-70. doi:10.1016/j.cbpa.2016.05.018.
Roche, Dominique G., et al. (2013). "Finding the best estimates of metabolic rates in a coral reef fish." Journal of Experimental Biology 216.11: 2103-2110. doi:10.1242/jeb.082925.
as.POSIXct
,
strptime
,
background.resp
,
Barom.Press
,
Eq.Ox.conc
,
biglm
,
## load data ## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") ## calc background resp rate bgd.resp <- background.resp(fishMR, "DO.mgL", start.time = "2015-07-02 16:05:00", end.time = "2015-07-02 16:35:00", ylab = "DO (mg/L)", xlab = "time (min)") bg.slope.a <- bgd.resp$mat[2] starts <- c("2015-07-03 01:15:00", "2015-07-03 02:13:00", "2015-07-03 03:02:00", "2015-07-03 03:50:00", "2015-07-03 04:50:00") stops <- c("2015-07-03 01:44:00", "2015-07-03 02:35:30", "2015-07-03 03:25:00", "2015-07-03 04:16:00", "2015-07-03 05:12:00") metR <- MR.loops(data = fishMR, DO.var.name ="DO.mgL", start.idx = starts, time.units = "hr", stop.idx = stops, time.var.name = "std.time", temp.C = "temp.C", elevation.m = 1180, bar.press = NULL, in.DO.meas = "mg/L", background.consumption = bg.slope.a, ylim=c(6, 8)) metR$MR.summary ## now lets assume we ran a control loop for background rate ## before and after we ran the MR loops ## let: bg.slope.b <-bg.slope.a -0.0001 metRa <- MR.loops(data = fishMR, DO.var.name ="DO.mgL", start.idx = starts, time.units = "hr", stop.idx = stops, time.var.name = "std.time", temp.C = "temp.C", elevation.m = 1180, bar.press = NULL, in.DO.meas = "mg/L", background.consumption = c(bg.slope.a, bg.slope.b), background.indices = c("2015-07-02 16:20:00", "2015-07-03 06:00:00"), ylim=c(6, 8)) metRa$MR.summary # note that the calculated slopes # diverge as time increases. This is # because the background respiration # rate is increasing. metR$MR.summary-metRa$MR.summary ## This looks great, but you need to check your start and ## stop vectors, otherwise, you could end up with some ## atrocious loops, e.g.: starts <- c("2015-07-03 01:15:00", "2015-07-03 02:13:00", "2015-07-03 03:02:00", "2015-07-03 03:50:00", "2015-07-03 04:50:00") stops <- c("2015-07-03 01:50:00", "2015-07-03 02:35:30", "2015-07-03 03:25:00", "2015-07-03 04:16:00", "2015-07-03 05:12:00") metRb <- MR.loops(data = fishMR, DO.var.name ="DO.mgL", start.idx = starts, stop.idx = stops, time.var.name = "std.time", temp.C = "temp.C", elevation.m = 1180, bar.press = NULL, in.DO.meas = "mg/L", background.consumption = bg.slope.a, ylim=c(6,8))
## load data ## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") ## calc background resp rate bgd.resp <- background.resp(fishMR, "DO.mgL", start.time = "2015-07-02 16:05:00", end.time = "2015-07-02 16:35:00", ylab = "DO (mg/L)", xlab = "time (min)") bg.slope.a <- bgd.resp$mat[2] starts <- c("2015-07-03 01:15:00", "2015-07-03 02:13:00", "2015-07-03 03:02:00", "2015-07-03 03:50:00", "2015-07-03 04:50:00") stops <- c("2015-07-03 01:44:00", "2015-07-03 02:35:30", "2015-07-03 03:25:00", "2015-07-03 04:16:00", "2015-07-03 05:12:00") metR <- MR.loops(data = fishMR, DO.var.name ="DO.mgL", start.idx = starts, time.units = "hr", stop.idx = stops, time.var.name = "std.time", temp.C = "temp.C", elevation.m = 1180, bar.press = NULL, in.DO.meas = "mg/L", background.consumption = bg.slope.a, ylim=c(6, 8)) metR$MR.summary ## now lets assume we ran a control loop for background rate ## before and after we ran the MR loops ## let: bg.slope.b <-bg.slope.a -0.0001 metRa <- MR.loops(data = fishMR, DO.var.name ="DO.mgL", start.idx = starts, time.units = "hr", stop.idx = stops, time.var.name = "std.time", temp.C = "temp.C", elevation.m = 1180, bar.press = NULL, in.DO.meas = "mg/L", background.consumption = c(bg.slope.a, bg.slope.b), background.indices = c("2015-07-02 16:20:00", "2015-07-03 06:00:00"), ylim=c(6, 8)) metRa$MR.summary # note that the calculated slopes # diverge as time increases. This is # because the background respiration # rate is increasing. metR$MR.summary-metRa$MR.summary ## This looks great, but you need to check your start and ## stop vectors, otherwise, you could end up with some ## atrocious loops, e.g.: starts <- c("2015-07-03 01:15:00", "2015-07-03 02:13:00", "2015-07-03 03:02:00", "2015-07-03 03:50:00", "2015-07-03 04:50:00") stops <- c("2015-07-03 01:50:00", "2015-07-03 02:35:30", "2015-07-03 03:25:00", "2015-07-03 04:16:00", "2015-07-03 05:12:00") metRb <- MR.loops(data = fishMR, DO.var.name ="DO.mgL", start.idx = starts, stop.idx = stops, time.var.name = "std.time", temp.C = "temp.C", elevation.m = 1180, bar.press = NULL, in.DO.meas = "mg/L", background.consumption = bg.slope.a, ylim=c(6,8))
A good way to visualize your respiro data to get an idea of where to set up the time intervals in functions like MR.loops()
or get.pcrit()
.
plotRaw(data, DO.var.name, time.var.name = "std.time", start.time = data$x[1], end.time = data$x[length(data$x)],...)
plotRaw(data, DO.var.name, time.var.name = "std.time", start.time = data$x[1], end.time = data$x[length(data$x)],...)
data |
data object for plotting |
DO.var.name |
A character string matching the column header for the DO variable column. |
time.var.name |
Column name of time (or x) axis in character class. |
start.time |
Character string specifying left bound x limit in |
end.time |
Character string specifying right bound x limit in |
... |
Arguments passed on to internal functions. |
start.time
and end.time
arguments must match the time.var.name
column's format for date time.
Plot showing the overall metabolic data
Tyler L. Moulton
plot
,
strptime
,
get.pcrit
,
MR.loops
,
## load data ## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") plotRaw(data = fishMR, DO.var.name = "DO.mgL", start.time = "2015-07-03 06:15:00", end.time = "2015-07-03 08:05:00") plotRaw(fishMR, DO.var.name = "DO.mgL", start.time = "2015-07-03 01:00:00", end.time = "2015-07-03 05:12:00")
## load data ## data(fishMR) ## create time variable in POSIXct format ## fishMR$std.time <- as.POSIXct(fishMR$Date.time, format = "%d/%m/%Y %I:%M:%S %p") plotRaw(data = fishMR, DO.var.name = "DO.mgL", start.time = "2015-07-03 06:15:00", end.time = "2015-07-03 08:05:00") plotRaw(fishMR, DO.var.name = "DO.mgL", start.time = "2015-07-03 01:00:00", end.time = "2015-07-03 05:12:00")
Internal Function for Use in Package for Calculating Sum of Squares of a Vector
sumsq(x)
sumsq(x)
x |
Numeric vector to be evaluated |
Internal function for package
The sum of squares of the vector
Tyler L. Moulton
vec <- sample(c(100:120), 50, replace = TRUE) sumsq(vec)
vec <- sample(c(100:120), 50, replace = TRUE) sumsq(vec)
Calculates the total residual sum of squares for broken stick model (2 part)
tot.rss(data, break.pt, xvar, yvar)
tot.rss(data, break.pt, xvar, yvar)
data |
data frame for calculating total residual sum of squares. |
break.pt |
This is the data point at which the data are split for a broken stick model. |
xvar |
The x-variable in the data frame for broken stick model. |
yvar |
The y-variable in the data frame for broken stick model. |
The residual sum of squares of a broken stick model with a specified break point.
Tyler L. Moulton
## load data ## data(fishMR) ## subset data to appropriate region ## data<-fishMR[fishMR$DO.mgL < 4,] data$times <- data$times-min(data$times) data<-data[data$times< 6800,] ## calculate total RSS for different breakpoints ## a1 <- tot.rss(data, break.pt = 4000, xvar = "times", yvar = "DO.mgL") a2 <- tot.rss(data, break.pt = 4250, xvar = "times", yvar = "DO.mgL") a3 <- tot.rss(data, break.pt = 4500, xvar = "times", yvar = "DO.mgL") a4 <- tot.rss(data, break.pt = 4750, xvar = "times", yvar = "DO.mgL") a5 <- tot.rss(data, break.pt = 5000, xvar = "times", yvar = "DO.mgL") a6 <- tot.rss(data, break.pt = 5250, xvar = "times", yvar = "DO.mgL") # a5 represents the break point for the # best broken stick linear model of the # above 6 options.
## load data ## data(fishMR) ## subset data to appropriate region ## data<-fishMR[fishMR$DO.mgL < 4,] data$times <- data$times-min(data$times) data<-data[data$times< 6800,] ## calculate total RSS for different breakpoints ## a1 <- tot.rss(data, break.pt = 4000, xvar = "times", yvar = "DO.mgL") a2 <- tot.rss(data, break.pt = 4250, xvar = "times", yvar = "DO.mgL") a3 <- tot.rss(data, break.pt = 4500, xvar = "times", yvar = "DO.mgL") a4 <- tot.rss(data, break.pt = 4750, xvar = "times", yvar = "DO.mgL") a5 <- tot.rss(data, break.pt = 5000, xvar = "times", yvar = "DO.mgL") a6 <- tot.rss(data, break.pt = 5250, xvar = "times", yvar = "DO.mgL") # a5 represents the break point for the # best broken stick linear model of the # above 6 options.