Skip to content

Commit 84ba3b0

Browse files
Upload FishResp version 1.0.3 [stable]
This is a stable version of the R package "FishResp" used in the academic publication: Morozov, et al., 2019, Conservation Physiology, https://doi.org/10.1093/conphys/coz003.
1 parent 800f3b8 commit 84ba3b0

88 files changed

Lines changed: 19990 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DESCRIPTION

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Package: FishResp
2+
Version: 1.0.3
3+
Title: Analytical Tool for Aquatic Respirometry
4+
Description: Calculates metabolic rate of fish and other aquatic organisms measured using
5+
an intermittent-flow respirometry approach. The tool is used to run a set of graphical
6+
QC tests of raw respirometry data, correct it for background respiration and chamber
7+
effect, filter and extract target values of absolute and mass-specific metabolic rate.
8+
Experimental design should include background respiration tests and measuring of one
9+
or more metabolic rate traits. The package allows a user to import raw respirometry
10+
data obtained from 'AquaResp' (free software), 'AutoResp' ('LoligoSystems'), 'OxyView'
11+
('PreSens'), 'Pyro Oxygen Logger' ('PyroScience') and 'Q-box Aqua' ('QubitSystems').
12+
URL: https://fishresp.org
13+
Authors@R: c(
14+
person("Sergey", "Morozov", role = c("aut", "cre"), email = "sergey.morozov@helsinki.fi") ,
15+
person("R.J. Scott", "McCairns", role = c("aut", "ths"), email = "scott.mccairns@inra.fr"),
16+
person("Federico", "Calboli", role = "ctb"),
17+
person("Juha", "Merila", role = "ths"),
18+
person("Stephen", "White", role = "dtc"),
19+
person("Daniel", "Montgomery", role = "dtc"),
20+
person("Laura", "Almodovar-Acevedo", role = "dtc"),
21+
person("Niclas", "Kolm", role = "dtc"),
22+
person("Alexander", "Kotrschal", role = "dtc"))
23+
Maintainer: Sergey Morozov <sergey.morozov@helsinki.fi>
24+
License: GPL-3
25+
SystemRequirements: Display resolution >= 1280x800; RAM >= 4GB
26+
Depends: R (>= 3.0.0)
27+
Imports: chron, lattice, mclust, rMR, respirometry
28+
LazyData: FALSE
29+
RoxygenNote: 6.1.1
30+
Encoding: UTF-8
31+
NeedsCompilation: no
32+
Packaged: 2019-03-05 05:11:32 UTC; greatsage

NAMESPACE

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(QC.activity)
4+
export(QC.meas)
5+
export(QC.slope)
6+
export(calculate.MR)
7+
export(convert.rMR)
8+
export(convert.respirometry)
9+
export(correct.meas)
10+
export(export.MR)
11+
export(extract.slope)
12+
export(import.meas)
13+
export(import.test)
14+
export(input.info)
15+
export(presens.aquaresp)
16+
export(pyroscience.aquaresp)
17+
export(rm.data)
18+
importFrom(chron,chron)
19+
importFrom(chron,dates)
20+
importFrom(chron,times)
21+
importFrom(grDevices,dev.new)
22+
importFrom(graphics,abline)
23+
importFrom(graphics,axis)
24+
importFrom(graphics,box)
25+
importFrom(graphics,layout)
26+
importFrom(graphics,legend)
27+
importFrom(graphics,lines)
28+
importFrom(graphics,mtext)
29+
importFrom(graphics,panel.smooth)
30+
importFrom(graphics,par)
31+
importFrom(graphics,plot)
32+
importFrom(graphics,points)
33+
importFrom(lattice,bwplot)
34+
importFrom(lattice,strip.custom)
35+
importFrom(lattice,xyplot)
36+
importFrom(mclust,Mclust)
37+
importFrom(mclust,mclustBIC)
38+
importFrom(rMR,DO.unit.convert)
39+
importFrom(respirometry,conv_o2)
40+
importFrom(stats,coef)
41+
importFrom(stats,lm)
42+
importFrom(stats,predict.lm)
43+
importFrom(stats,qqline)
44+
importFrom(stats,quantile)
45+
importFrom(stats,rstandard)
46+
importFrom(stats,time)
47+
importFrom(utils,head)
48+
importFrom(utils,packageDescription)
49+
importFrom(utils,read.table)
50+
importFrom(utils,tail)
51+
importFrom(utils,write.csv)
52+
importFrom(utils,write.table)

R/AMR.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#' @name AMR
2+
#' @aliases AMR
3+
#' @docType data
4+
#' @title Active Metabolic Rate: Final Data
5+
#' @description A dataset contains background respiration, absolute and mass-specific active metabolic rate data obtained by using the function \code{\link{calculate.MR}}
6+
#' @usage AMR
7+
#' @format A data frame with 12 rows and 16 variables:
8+
#' \describe{
9+
#' \item{Chamber.No}{the number of a chamber}
10+
#' \item{Ind}{ID of an animal}
11+
#' \item{Mass}{wet mass of an animal (g)}
12+
#' \item{Volume}{the volume of a chamber (mL)}
13+
#' \item{Date.Time}{date and time of a measurement phase (yyyy/mm/dd hh:mm:ss)}
14+
#' \item{Phase}{the type of phase and an ordinal number of measurements (e.g. M1)}
15+
#' \item{Temp}{average temperature over the period of a measurement phase (\eqn{C^{o}})}
16+
#' \item{Slope.with.BR}{slope of animal oxygen consumption with slope of background respiration (\eqn{mg O_{2}\;L^{-1} s^{-1}})}
17+
#' \item{Slope}{slope of animal oxygen consumption without background respiration (\eqn{mg O_{2}\;L^{-1} s^{-1}})}
18+
#' \item{SE}{standard error of a slope of animal oxygen consumption without background respiration (\eqn{mg O_{2}\;L^{-1} s^{-1}})}
19+
#' \item{R2}{\eqn{r^{2}} of a slope of animal oxygen consumption without background respiration}
20+
#' \item{MR.abs.with.BR}{absolute AMR with background respiration (\eqn{mg O_{2}\;h^{-1}})}
21+
#' \item{BR}{percentage rate of background respiration}
22+
#' \item{MR.abs}{absolute AMR (\eqn{mg O_{2}\;h^{-1}})}
23+
#' \item{MR.mass}{mass-specific AMR (\eqn{mg O_{2}\;kg^{-1} h^{-1}})}
24+
#' \item{DO.unit}{the measure unit of DO concentration}
25+
#' }
26+
"AMR"

R/AMR.clean.R

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#' @name AMR.clean
2+
#' @aliases AMR.clean
3+
#' @docType data
4+
#' @title Active Metabolic Rate: Corrected Raw Data
5+
#' @description A dataset contains raw data of active metabolic rate measurements corrected for background respiration using the function \code{\link{correct.meas}}
6+
#' @usage AMR.clean
7+
#' @format A data frame with 7200 rows and 17 variables:
8+
#' \describe{
9+
#' \item{Date.Time}{date and time (yyyy/mm/dd hh:mm:ss)}
10+
#' \item{Date}{date (yyyy/mm/dd)}
11+
#' \item{Real.Time}{time (hh:mm:ss)}
12+
#' \item{Time}{ordinal number of seconds in each measurement phase (1-600)}
13+
#' \item{Phase}{the type of phase and an ordinal number of measurements (e.g. M1, F3)}
14+
#' \item{Start.Meas}{the first second of a measurement phase (hh:mm:ss)}
15+
#' \item{End.Meas}{the last second of a measurement phase (hh:mm:ss)}
16+
#' \item{Chamber.No}{the number of a chamber}
17+
#' \item{Ind}{ID of an animal}
18+
#' \item{Mass}{wet mass of an animal (g)}
19+
#' \item{Volume}{the volume of a chamber (mL)}
20+
#' \item{Init.O2}{initial level of dissolved oxygen (mgO2/L)}
21+
#' \item{Temp}{temperature at each second (\eqn{C^{o}})}
22+
#' \item{O2}{actual level of dissolved oxygen at each second (mgO2/L)}
23+
#' \item{BR}{slope of background respiration (\eqn{mg O_{2}\;L^{-1} s^{-1}})}
24+
#' \item{O2.correct}{actual level of dissolved oxygen at each second corrected by slope of background respiration (mgO2/L)}
25+
#' \item{DO.unit}{the measure unit of DO concentration}
26+
#' }
27+
"AMR.clean"

R/AMR.raw.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#' @name AMR.raw
2+
#' @aliases AMR.raw
3+
#' @docType data
4+
#' @title Active Metabolic Rate: Raw Data
5+
#' @description The dataset contains raw data of active metabolic rate measurements obtained by using the function \code{\link{import.meas}})
6+
#' @usage AMR.raw
7+
#' @format A data frame with 1800 rows and 16 variables:
8+
#' \describe{
9+
#' \item{Date.Time}{date and time (yyyy/mm/dd hh:mm:ss)}
10+
#' \item{Phase}{the type of phase and an ordinal number of measurements (e.g. M1, F3)}
11+
#' \item{Temp.1}{temperature at each second (\eqn{C^{o}})}
12+
#' \item{Ox.1}{actual level of dissolved oxygen at each second (mgO2/L)}
13+
#' \item{Real.Time}{time (hh:mm:ss)}
14+
#' \item{Date}{date (yyyy/mm/dd)}
15+
#' \item{Time}{ordinal number of seconds in each measurement phase (1-600)}
16+
#' \item{Start.Meas}{the first second of a measurement phase (hh:mm:ss)}
17+
#' \item{End.Meas}{the last second of a measurement phase (hh:mm:ss)}
18+
#' \item{Total.Phases}{the total number of measurement phases (constant value)}
19+
#' \item{Ox.2}{see Ox.1}
20+
#' \item{Ox.3}{see Ox.1}
21+
#' \item{Ox.4}{see Ox.1}
22+
#' \item{Temp.2}{see Temp.1}
23+
#' \item{Temp.3}{see Temp.1}
24+
#' \item{Temp.4}{see Temp.1}
25+
#' }
26+
"AMR.raw"

R/AMR.slope.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#' @name AMR.slope
2+
#' @aliases AMR.slope
3+
#' @docType data
4+
#' @title Active Metabolic Rate: Extracted Slope(s)
5+
#' @description A dataset contains extracted slopes for further AMR calculations and other attributes of active metabolic rate measurements obtained by using the function \code{\link{extract.slope}}
6+
#' @usage AMR.slope
7+
#' @format A data frame with 12 rows and 12 variables:
8+
#' \describe{
9+
#' \item{Chamber.No}{the number of a chamber}
10+
#' \item{Ind}{ID of an animal}
11+
#' \item{Mass}{wet mass of an animal (g)}
12+
#' \item{Volume}{the volume of a chamber (mL)}
13+
#' \item{Date.Time}{date and time of a measurement phase (yyyy/mm/dd hh:mm:ss)}
14+
#' \item{Phase}{the type of phase and an ordinal number of measurements (e.g. M1)}
15+
#' \item{Temp}{average temperature over the period of a measurement phase (\eqn{C^{o}})}
16+
#' \item{Slope.with.BR}{slope of animal oxygen consumption with slope of background respiration (\eqn{mg O_{2}\;L^{-1} s^{-1}})}
17+
#' \item{Slope}{slope of animal oxygen consumption without background respiration (\eqn{mg O_{2}\;L^{-1} s^{-1}})}
18+
#' \item{SE}{standard error of a slope of animal oxygen consumption without background respiration (\eqn{mg O_{2}\;L^{-1} s^{-1}})}
19+
#' \item{R2}{\eqn{r^{2}} of a slope of animal oxygen consumption without background respiration}
20+
#' \item{DO.unit}{the measure unit of DO concentration}
21+
#' }
22+
"AMR.slope"

R/FishResp.R

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#' FishResp: Analytical Tool for Aquatic Respirometry
2+
#'
3+
#' Calculates metabolic rate of fish and other aquatic organisms measured using an intermittent-flow respirometry approach. The tool is used to run a set of graphical QC tests of raw respirometry data, correct it for background respiration and chamber effect, filter and extract target values of absolute and mass-specific metabolic rate. Experimental design should include background respiration tests and measuring of one or more metabolic rate traits. The package allows a user to import raw respirometry data obtained from 'AquaResp' (free software), 'AutoResp' ('LoligoSystems'), 'OxyView' ('PreSens'), 'Pyro Oxygen Logger' ('PyroScience') and 'Q-box Aqua' ('QubitSystems').
4+
#'
5+
#' @docType package
6+
#' @name FishResp
7+
#' @author Sergey Morozov \email{sergey.morozov@@helsinki.fi} Scott McCairns \email{scott.mccairns@@inra.fr}
8+
#'
9+
#' @references {
10+
#' Before using the R package 'FishResp', we recommend reading the publication describing this software and two keystone reviews devoted to metabolic rate measurements of fish using an intermittent-flow approach:
11+
#' \enumerate{
12+
#' \item Morozov, S., McCairns, R. J. S., Merila, J. (2019). FishResp: R package and GUI application for analysis of aquatic respirometry data. Conservation Physiology, 7(1), coz003.
13+
#' \item Clark, T. D., Sandblom, E., Jutfelt, F. (2013). Aerobic scope measurements of fishes in an era of climate change: respirometry, relevance and recommendations. Journal of Experimental Biology, 216(15), 2771-2782.
14+
#' \item Svendsen, M. B. S., Bushnell, P. G., Steffensen, J. F. (2016). Design and setup of intermittent-flow respirometry system for aquatic organisms. Journal of Fish Biology, 88(1), 26-50.
15+
#' }
16+
#' }
17+
#'
18+
NULL

R/QC.activity.R

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#' Quality Control of Animal Activity
2+
#'
3+
#' Graphical quality control tests for animal activity in chambers over the period of measurements defined in the function \code{\link{correct.meas}}. The function is used for determination of time period for calculation of standard or resting metabolic rate. Note, that mass-specific metabolic rate is calculated for each period of measurements (not raw data).
4+
#'
5+
#' @param clean.data a data frame obtained by using the function \code{\link{correct.meas}}
6+
#' @param compare logical: if TRUE then two graphs are plotted to compare mass-specific metabolic rate before and after correction for background respiration
7+
#' @param output logical: if TRUE then the functions return output or print it
8+
#' @usage
9+
#' QC.activity(clean.data, compare = TRUE, output = FALSE)
10+
#'
11+
#' @details QC.activity uses functions \code{\link{extract.slope}} and \code{\link{calculate.MR}} with default parameters (excluding \eqn{r^{2} = 0}) to plot a graph of animal activity
12+
#'
13+
#' @importFrom lattice xyplot strip.custom
14+
#' @importFrom grDevices dev.new
15+
#' @importFrom graphics abline legend par plot
16+
#' @importFrom stats coef lm predict.lm
17+
#' @importFrom utils head read.table tail write.table
18+
#'
19+
#' @examples
20+
#' # if the data have been already loaded to R,
21+
#' # skip the first line of the code:
22+
#' data(SMR.clean)
23+
#'
24+
#' QC.activity(SMR.clean, compare = TRUE)
25+
#'
26+
#' @export
27+
28+
QC.activity <- function(clean.data, compare = TRUE, output = FALSE){
29+
Chamber.No<-NULL
30+
clean.data[is.na(clean.data)] <- 0
31+
slope.data.all<-extract.slope(clean.data, r2=0, method = "all")
32+
MR.data.all<-calculate.MR(slope.data.all, density = 1000,
33+
plot.BR = FALSE, plot.MR.abs = FALSE, plot.MR.mass = FALSE)
34+
a <- nlevels(MR.data.all$Chamber.No)
35+
36+
if(compare == TRUE){
37+
BW = MR.data.all$Mass/1000
38+
MR.mass.with.BR <- MR.data.all$MR.abs.with.BR/BW
39+
a <- xyplot(MR.mass + MR.mass.with.BR ~ Date.Time, groups=Chamber.No, grid = TRUE,
40+
data=MR.data.all, main="Activity during the whole period of measurements",
41+
type=c("a", "p"), allow.multiple=T, layout=(c(1,2)),
42+
xlab="Time", ylab = bquote("Mass-specific metabolic rate (" ~ .(clean.data$DO.unit[1]) ~ kg^-1 ~ h^-1 ~ ")"),
43+
strip = strip.custom(factor.levels = c("MO2 after correction for background respiration",
44+
"MO2 before correction for background respiration")),
45+
auto.key=list(space="top", columns=4,
46+
title="Chambers", cex.title=1, between.columns = 0.5,
47+
lines=TRUE, points = FALSE, cex = 0.8),
48+
par.settings = list(superpose.line = list(col = c("#0080ff", "#ff00ff", "darkgreen", "#ff0000", "orange", "#00ff00", "brown" , "#03c4a1"))))
49+
plot(a)
50+
}
51+
else{
52+
b <- xyplot(MR.mass ~ Date.Time, groups=Chamber.No, grid = TRUE,
53+
data=MR.data.all, main="Activity during the whole period of measurements",
54+
type=c("a", "p", lwd = 2),
55+
xlab="Time", ylab = bquote("Mass-specific metabolic rate (" ~ .(clean.data$DO.unit[1]) ~ kg^-1 ~ h^-1 ~ ")"),
56+
auto.key=list(space="top", columns=4, par.strip.text=list(cex=2),
57+
title="Chambers", cex.title=1, between.columns = 0.5,
58+
lines=TRUE, points = FALSE, cex = 0.8),
59+
par.settings = list(superpose.line = list(col = c("#0080ff", "#ff00ff", "darkgreen", "#ff0000", "orange", "#00ff00", "brown" , "#03c4a1"))))
60+
plot(b)
61+
}
62+
if(output == TRUE){
63+
return(MR.data.all)
64+
}
65+
}

R/QC.meas.R

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#' Quality Control of Raw Data
2+
#'
3+
#' Graphical quality control tests of temperature and oxygen raw data before and after correction for background respiration
4+
#'
5+
#' @usage
6+
#' QC.meas(clean.data,
7+
#' QC = c("Temperature",
8+
#' "Total.O2.phases",
9+
#' "Corrected.O2.phases",
10+
#' "Total.O2.chambers",
11+
#' "Corrected.O2.chambers"))
12+
#'
13+
#' @param clean.data a data frame obtained by using the function \code{\link{correct.meas}}
14+
#' @param QC string: the name of a visual QC test. Five options are available:
15+
#' \itemize{
16+
#' \item "Temperature": a graph of temperature vs. time ordered by chambers
17+
#' \item "Total.O2.chambers": a graph of dissolved oxygen vs. time ordered by chambers
18+
#' \item "Total.O2.phases": a graph of dissolved oxygen vs. time ordered by chambers and phases
19+
#' \item "Corrected.O2.chambers": a graph of dissolved oxygen corrected for background respiration vs. time ordered by chambers
20+
#' \item "Corrected.O2.phases": a graph of dissolved oxygen corrected for background respiration vs. time ordered by chambers and phases
21+
#' }
22+
#'
23+
#' @importFrom lattice xyplot
24+
#' @importFrom grDevices dev.new
25+
#' @importFrom graphics abline legend par plot
26+
#' @importFrom stats coef lm predict.lm
27+
#' @importFrom utils head read.table tail write.table
28+
#'
29+
#' @examples
30+
#' \dontrun{
31+
#' # if the data have been already loaded to R,
32+
#' # skip the first line of the code:
33+
#' data(SMR.clean)
34+
#'
35+
#' QC.meas(SMR.clean, "Temperature")
36+
#' QC.meas(SMR.clean, "Total.O2.phases")
37+
#' QC.meas(SMR.clean, "Corrected.O2.phases")
38+
#' QC.meas(SMR.clean, "Total.O2.chambers")
39+
#' QC.meas(SMR.clean, "Corrected.O2.chambers")
40+
#' }
41+
#' @export
42+
43+
QC.meas <- function(clean.data,
44+
QC = c("Temperature", "Total.O2.phases", "Corrected.O2.phases",
45+
"Total.O2.chambers", "Corrected.O2.chambers")){
46+
47+
if (QC == "Temperature"){
48+
return(xyplot(Temp~Time|Phase*Chamber.No, data=clean.data,
49+
par.strip.text=list(cex=0.6), cex=0.5,
50+
xlab = "Time (s)", ylab = bquote("Temperature (" ~ C^o ~ ")"), as.table = T,
51+
scales=list(tck=c(1,0), x=list(cex=0.7), y=list(cex=0.7))))
52+
}
53+
else if (QC == "Total.O2.phases"){
54+
return(xyplot(O2~Time|Phase*Chamber.No, data=clean.data,
55+
par.strip.text=list(cex=0.6), cex=0.5,
56+
xlab = "Time (s)", ylab = paste("DO (", clean.data$DO.unit[1], "/L)", sep = ""), as.table = T,
57+
scales=list(tck=c(1,0), x=list(cex=0.7), y=list(cex=0.7))))
58+
}
59+
60+
else if (QC == "Corrected.O2.phases"){
61+
return(xyplot(O2.correct~Time|Phase*Chamber.No, data=clean.data,
62+
par.strip.text=list(cex=0.6), cex=0.5,
63+
xlab = "Time (s)", ylab = paste("DO (", clean.data$DO.unit[1], "/L)", sep = ""), as.table = T,
64+
scales=list(tck=c(1,0), x=list(cex=0.7), y=list(cex=0.7))))
65+
}
66+
67+
else if (QC == "Total.O2.chambers"){
68+
return(xyplot(O2~Date.Time|Chamber.No, data=clean.data, cex=0.5,
69+
xlab = "Time", ylab = paste("DO (", clean.data$DO.unit[1], "/L)", sep = ""), as.table = T))
70+
}
71+
72+
else if (QC == "Corrected.O2.chambers"){
73+
return(xyplot(O2.correct~Date.Time|Chamber.No, data=clean.data, cex=0.5,
74+
xlab = "Time", ylab = paste("DO (", clean.data$DO.unit[1], "/L)", sep = ""), as.table = T))
75+
}
76+
77+
else
78+
{
79+
print ("This quality test does not exist! Please, choose among avaliable variants: Temperature, Total.O2.chambers, Total.O2.phases, Corrected.O2.chambers or Corrected.O2.phases")
80+
}
81+
}

0 commit comments

Comments
 (0)