FishResp: R package and GUI application for analysis of aquatic respirometry data

FishResp is a user-friendly tool for calculating oxygen uptake of aquatic organisms. The aim of the software is to improve the quality of metabolic rate estimates based on a straightforward pipeline: background respiration correction, detection of mechanical problems, conduction of QC tests, and filtration based on user-defined criteria.


Introduction
Whole-body intermittent-flow respirometry (i.e. measuring the oxygen uptake of an organism) represents the most reliable and widespread technique to estimate aerobic metabolic rate of aquatic animals (Steffensen, 1989;Clark et al., 2013;Svendsen et al., 2016b). As the availability and precision of oxygen sensors has grown (Nelson, 2016), respirometry has become increasingly common in the field of evolutionary and conservation physiology (Metcalfe et al., 2016;Chabot et al., 2016a). Among other fundamental questions, it has been applied to the identification of ecological and environmental factors that cause metabolic rate variation (Ohlberger et al., 2007;Auer et al., 2015;Christensen et al., 2017) and for studying physiological plasticity and adaptation to novel 1 environmental conditions, including adaptive potential to global ocean warming, ocean acidification, hypoxia and chemical contaminants (Kreiss et al., 2015;McDonnell and Chapman, 2015;Hancock and Place, 2016;Kunz et al., 2016;Jayasundara et al., 2017;. In addition, intermittent-flow respirometry has been recently used in studies devoted to both applied and fundamental problems in aquaculture and fisheries (Hessenauer et al., 2015;Siikavuopio and James, 2015;Gerile and Pirhonen, 2017;Svendsen et al., 2018).
Despite the growing use of respirometry, quality-control of raw data and extraction of key parameters from it, remains the responsibility of individual researchers (Rodgers et al., 2016). The lack of standard quality-control software with the ability to detect and correct for technical problems in the raw data may compromise the comparability of results from different studies. Indeed, the literature contains many contradictory reports of intraspecific metabolic differences that are difficult to ascribe to only biological causes. For example, whilst inter-population comparisons of mean standard metabolic rate (SMR) estimates of Trinidadian guppy (Poecilia reticulata) have reported difference up to 1.7fold between populations (Handelsman et al., 2013;Auer et al., 2018), comparisons between independent studies conducted under similar temperature conditions show 5-fold differences (from 100 to 550 mg O 2 /kg/h; Svendsen et al., 2013;Ejbye-Ernst et al., 2016;Killen et al., 2016). Such a wide range of SMR estimates within a species are unlikely to be explained by biological factors, but more likely, reflect unstandardized measurement conditions and data post-processing procedures.
Two critical factors that influence the quality and reliability of respirometry data are (i) mechanical problems with the system itself and (ii) background respiration. As to the former, both the absence of or damage to a mixing device leading to poor water circulation in a system, and a large ratio of respirometer to fish volume, can reduce the resolution of raw data (Rodgers et al., 2016;Svendsen et al., 2016a). Similarly, study animals blocking the water supply to an oxygen sensor can cause dramatic drops in dissolved oxygen measurements, whereas leaking of a measurement chamber, which can be particularly pronounced under high water flow velocity in Blazka-type swimming tunnels (Blazka et al., 1960), has potential to lead to underestimation of metabolic rates (Svendsen et al., 2016b). Mechanical problems are relatively easy to detect via linear analysis of raw data, and may indicate the need to repair faulty equipment. However, detecting and correcting for background respiration (i.e. oxygen consumption of microorganisms in the water or on inner surfaces of equipment) can be more challenging (Dalla Via, 1983;Clark et al., 2013;Rodgers et al., 2016). Although several approaches exist, many studies fail to mention how background respiration was dealt with, or whether background respiration was totally ignored in data processing (see Svendsen et al., 2016b). The potential problem with background respiration is especially relevant when metabolic rate is measured at high temperatures-a condition that favours microbial growth-and in small chambers, where the relative contribution of microbes to total rate of oxygen consumption is high and not constant over time (Rodgers et al., 2016). Both are prevalent when working with small tropical fish, as in the aforementioned guppy example, and can lead to substantial overestimates of oxygen consumption. In addition, background respiration may represent an increasingly large proportion of the total oxygen consumption under hypoxic conditions.
Here, we introduce 'FishResp', software for running quality control tests, filtering raw data and calculating metabolic estimates of high accuracy. We demonstrate the utility of FishResp for detecting mechanical problems and correcting for background microbial oxygen consumption using raw data obtained from the three-spined stickleback (Gasterosteus aculeatus) and the Trinidadian guppy (Poecilia reticulata). These examples demonstrate how FishResp significantly improves the quality of final estimates, setting what we hope will become standard practice for processing raw respirometry data.

Software description
FishResp is an R package (R Development Core Team, 2018) for analysing raw data from intermittent-flow respirometry systems. Its current version 1.0.2 consists of 15 functions (listed in Table 1) and utilizes six dependencies (existing R packages) which will be automatically installed once FishResp is executed (listed in Table 2). The order of application of each function in a typical analysis is described in Fig. 1, encompassing all steps from data input to parameter estimation. Alternatively, a graphical user interface (GUI) of FishResp is also available, written in JavaFX. To integrate Java with R, the 'rJava' package (Urbanek, 2018) and its extension 'JRI' are used. The graphical interface consists of five tabs with functional blocks on the left side (functions with parameters), and information, graphical or extensions modules on the right side of the application (Fig. 2). The 'Extensions Module' has been created to integrate FishResp with other respirometry tools written in the R language, such as modified functions for unit conversion from the R packages 'respirometry' and 'rMR' (Birk, 2018;Moulton, 2018). Different colours of tabs and buttons are used as indicators of progress: unavailable (grey); plotting optional (blue); action required (yellow); successful execution (green). The log of complete actions can be saved using an icon in the upper-right corner of the graphical interface. imported into the R package/GUI application directly from 'AutoResp' (Loligo Systems, Denmark) and 'Q-box Aqua' (Qubit Systems, Canada); and via 'AquaResp' (University of Copenhagen, Denmark) with 'OxyView' (PreSens GmbH, Germany) and 'Pyro Oxygen Logger' (Pyro Science GmbH, Germany) output. The output from other logger software and DIY setups can be manually adjusted to 'FishResp' import format (see 'Details' in the documentation of the R function 'import.test' or 'import.meas'). The software accepts several units of O 2 concentration, while partial pressure units (e.g. % sat, mmHg or kPa) can be converted to O 2 concentration using the R functions 'convert.respirometry' and 'convert.rMR' or in the 'Extensions Module' of the GUI application (for details see the documentation of those functions). Quality-control tests and data filtering are performed with the aid of graphical visualizations, and parameters from simple linear models: the slope of the linear regression of O 2 concentration over time, and the coefficient of determination (r 2 ). Slopes are used to calculate metabolic rate, and to correct for background respiration.

Experimental design for correction of background respiration
The number of traits calculated per one session is not limited in the R package, while GUI implementation of FishResp can be used only for measuring one or two metabolic traits per session, as shown in Fig. 3. In order to subtract background respiration from total oxygen consumption, additional tests must be conducted without an animal in the chambers  before, after or during metabolic rate measurements (pretest, post-tests and parallel blank test, respectively). A full experiment processed with the GUI application can consist of four different steps (Fig. 3A), but this can be reduced to one metabolic measurement with either one or two background respiration tests (Fig. 3B). Both full and reduced designs are described to illustrate the use of the R package and its GUI version.
Six options are available for the correction of background respiration, each based on subtracting the slope of background respiration over time from the slope of animal oxygen consumption over time. Methods 'pre.test' and 'post.test' are used to remove background respiration before or after metabolic rate measurements, respectively. When a single metabolic trait has been measured with both pre-and posttests (Fig. 3B), 'average', 'linear' and 'exponential' methods can be used to subtract the averaged slope of the tests, or the progressively changing slope over time between those tests. Alternatively, an empty chamber running in parallel with actual metabolic rate measurements can be used for the correction. Note that the 'parallel' method does not require running pre-and/or post-tests. To choose an optimal method of correction, monitoring of background respiration over a long measurement period is recommended (Rodgers et al., 2016;Svendsen et al., 2016b).

Metabolic rate calculation
Several methods of slope extraction are available to estimate metabolic rate: all slopes, slopes with minimal or maximal values, or those of a given quantile within the frequency distribution of observed slopes. In addition, four methods for determination of SMR have been integrated into FishResp: mean of the lowest normal distribution (MLND), quantiles, low10, and low10% (see Chabot et al., 2016b). Likewise, users can define a threshold r 2 value (default value of 0.95), the parameter used to detect mechanical problems in a respirometry system (e.g. chamber leaking and poor water flow) or spontaneous animal activity during SMR measurements (but see Clark et al., 2013;Norin and Clark, 2017;Zhang and Gilbert, 2017).

Fish and respirometry systems used for case studies
Use of FishResp is demonstrated in two case studies. Case Study 1 shows how the full scheme can be run using the R package, and provides an example of how mechanical problems can be detected. Raw respirometry data come from four three-spined sticklebacks (average mass = 1.96, SD = 0.19 g), measured in a 4-channel respirometry system of 250 mL Blazka-type swim tunnels (DAQ-PAC-F4 package, AutoResp user's manual; Loligo Systems, Denmark), together with pre-and post-tests. Standard metabolic rate (SMR) was measured overnight (22:00-06:00) after 4 h of acclimation in the absence of light and other external stimuli; active metabolic rate (AMR) was measured during the day at 80% of individual critical swimming speed, which represents a proxy of maximum aerobic activity during prolonged swimming performance, but not absolute maxMO 2 (for definitions, see Brett, 1964;Fry, 1971). We used an intermittentflow procedure consisting of flush, wait and measurement phases (420/180/1200 s for SMR and pre-test, and 420/180/ 600 s for AMR and post-test). The experiment was

5
conducted in fresh water at 16.5°C with constant velocity (5 cm/s) generated by a propeller inside a swim tunnel. The level of dissolved oxygen during an open phase was 8.8 mg/L (90% air saturation), and it never dropped below 5.95 mg/L (61% air saturation) during the measurement phase.
Case Study 2, using data from four male and four female guppies (average mass male = 0.084, SD = 0.014 g and average mass female = 0.271, SD = 0.109 g), provides an example of excessively high background respiration, and is presented to demonstrate both the GUI and the importance of background respiration correction. Measures of SMR were taken overnight after 4 h of acclimation using eight 21.8 mL static chambers connected to an 8-channel respirometry system (DAQ-PAC-WF8 package, AutoResp user's manual; Loligo Systems, Denmark) with 300 s flush, 180 s wait and 720 s measurement periods. Fresh water was constantly mixed by a pump during the measurement phase (T = 24.8°C; mean cO 2 = 7.1, SD = 0.5 mg/L). Background respiration in the chambers was measured before and after the experiment (Fig. 3B). The calibration of the oxygen sensors for case studies was performed following the 2-point calibration procedure described in the AutoResp user's manual (Loligo Systems, Denmark). Raw data for both Case Study 1 and Case Study 2 can be found in the package folders 'FishResp/extdata/stickleback' and 'FishResp/extdata/guppy,' respectively.
Experiments were carried out in accordance with the recommendations and approval of the National Animal Experiment Board of Finland (permit no: ESAVI/6097/ 04.10.07/2013) and the Stockholm Ethical Board (permit no: N173/13, 223/15 and N8/17).

Results and discussion
Case Study 1: Calculation of SMR, AMR and MS of Sticklebacks Import and correction of raw data Following the general outline of a typical 'FishResp' analysis ( Fig. 1), the command library(FishResp) is used to load the package. The function input.info() must be applied first to specify dissolved oxygen measurement units, and to provide information about individual ID, fish mass (g), and chamber volumes (mL) used in subsequent analyses (see Table 1): info <input.info(DO.unit = "mg/L", ID = c("Stickleback_1", "Stickleback_2", "Stickleback_3", "Stickleback_4"), Mass = c(1.86, 1.92, 2.23, 1.80), Volume = c(250, 250, 250, 250)) To load files containing raw data of background respiration measurements into R ('pre-test.txt' and 'post-test.txt'), the function import.test() should be used-note that if data files are not located in the same directory as the R session, file names should be specified with their full paths (see code in File S1). The path to the file, the type of oxygen logger software, and the number of chambers used should also be included as arguments. Graphs of oxygen and temperature over time are plotted automatically to check temperature fluctuations and water supply to the sensor during background respiration tests: pre <import.test(pre.path, info.data=info, logger="AutoResp", n.chamber=4) post <import.test(post.path, info.data=info, logger="AutoResp", n.chamber=4) The next step is to import raw data of SMR and AMR measurements into R using the import.meas() function. If the date format is not 'DMY', specify it in this function. Two additional parameters (start.measure and stop.measure, respectively) corresponding to the time interval of measurements not exceeding 24 h can help remove non-target data (e.g. acclimation period after handling stress): SMR.raw <import.meas(SMR.path, info.data=info, logger="AutoResp", n.chamber=4, start.measure="22:00:00", stop.measure="06:00:00") AMR.raw <import.meas(AMR.path, info.data=info, logger="AutoResp", n.chamber=4) As a full design was chosen for this experiment (Fig. 3A), 'pre' and 'post' methods are used to correct SMR and AMR for background respiration, respectively, where slopes of linear models (level of dissolved oxygen over time) for background respiration tests are automatically subtracted from slopes of linear models for actual measurements using the function correct.meas(): SMR.clean <correct.meas(info.data=info, pre.data=pre, meas.data=SMR.raw, method="pre.test") AMR.clean <correct.meas(info.data=info, post.data=post, meas.data=AMR.raw, method="post.test") Oxygen data before and after background respiration correction can be visualized using the function QC.meas(): QC.meas(SMR.clean, "Total.O2.phases") QC.meas(SMR.clean, "Corrected.O2.phases") QC.meas(SMR.clean, "Total.O2.chambers") QC.meas(SMR.clean, "Corrected.O2.chambers") Plotting raw data plays an important role in assessing its quality, providing preliminary information about the rate of background respiration; corrected O 2 plots allow the user to evaluate their choice of correction strategy. In this example, levels of dissolved oxygen and temperature were stable over the duration of the experiment, indicating that both pre-and post-tests can be used to remove background respiration.

Extraction and visualization of results: identifying and removing artefacts due to animal disturbance or swimming inactivity
The next step is to select slopes of dissolved oxygen concentration over time to calculate metabolic rate. This is particularly relevant when several consecutive measurement cycles are taken. In this example, SMR measurements were collected every 30 min over an 8 h period, but only three slopes have been extracted to determine SMR. In contrast, as only three AMR measurements are available for each individual, all three slopes are used for calculation of AMR. For both traits, only slopes with r 2 > 0.95 are extracted.
SMR.slope <extract.slope(SMR.clean, method="min", n.slope=3, r2=0.95) AMR.slope <extract.slope(AMR.clean, method="all", r2=0.95) It can be helpful to plot each slope separately: the function QC.slope() visualizes how a linear model fits data corrected for background respiration. However, if one of the 'calcSMR' methods is selected to determine SMR (Chabot et al., 2016b), a user should first extract all slopes to be able to plot linear models, and then apply a 'calcSMR' method (see Case Study 2 and File S2). Note that an exponential decrease of oxygen content over long measurement periods might be caused by chamber leaking or poor water circulation in a respirometry system even with high r 2 value (Svendsen et al., 2016b;Norin and Clark, 2017). Would this be the case, those data should be omitted from further analyses.
QC.slope(SMR.slope, SMR.clean, chamber="CH1", current=1200, alter=600) QC.slope(AMR.slope, AMR.clean, chamber="CH4", current=600, alter=300) In this example, linear models perfectly capture the trend in SMR and most AMR data (Fig. 4, M1). However, data from the two final AMR measurement phases in 'Chamber 4' show decreases in oxygen uptake rate with time (Fig. 4,  M2 & M3). During experiments (including Morozov et al., 2018), we noticed that some individuals could not constantly maintain 80% of U crit in swimming tunnels during the final minutes of AMR measurements, but leaned against the honeycomb stopper housing the oxygen sensor. Occasionally, fish were able to block the oxygen supply to the sensor, leading to dramatic decrease of oxygen level in raw data (Fig. 4, M2). The slopes for M2 look similar because blocking of the sensor was short and in the middle stage of measurement phase. The other common problem, when an experimental organism stopped swimming and rate of oxygen uptake dropped, is illustrated in panel M3 (Fig. 4,  M3): the fish was not able to swim after the first five minutes of the measurement phase, reflected in the upward inflection of the QC plot. In fact, here we detected both these mechanical problems based on graphical QC tests, but not based on r 2 < 0.95. Thus, it is important to combine computational methods with visualization of intermittent results of the analysis. To avoid under-and over-estimating AMR, and to follow a uniform approach for extracting slopes for this trait, we decreased the time interval used for slope calculation with the function extract.slope(). The other important feature of the function QC.slope(), which can represent a useful tool for detecting deviations from linearity and in determination of measurement window length, is regression diagnostic plots for current and alternative length of a measurement window (Fig. 5). In this example, reducing the  ........................................................................................................................................................... 7 measurement window to 5 min (300 s) helps improve linear fit and allow us to avoid artefacts due to swimming inactivity ( Fig. 4; red lines, Fig. 5; red graphs): QC.slope(AMR.slope, AMR.clean, chamber="CH4", current=600, alter=300, residuals=TRUE) AMR.slope <extract.slope(AMR.clean, method="all", r2=0.95, length=300) It should be noted that a call to extract.slope() uses r 2 = 0.95 as a default linearity filter. Svendsen et al. (2016b) have suggested that this should be viewed as the minimum criterion when estimating O 2 consumption from the slope of a linear model. This value can be manually changed if users wish to use a more robust value. Under some circumstances users may wish to relax this parameter; however, we would urge careful reflection before doing so, and that all parameters used be reported.
The final step is to calculate and plot metabolic rate estimates, together with the percentage rate of background respiration using the function calculate.MR().

Toolbox
AMR <calculate.MR(AMR.slope, density=1000) Results can be exported as .txt or .csv files. Optionally, when two traits are measured, they can be merged into one dataset containing absolute, mass-specific and factorial metabolic scopes.
results <export.MR (SMR, AMR, "results.csv", simplify=TRUE, MS=TRUE) Note that the rate of background respiration for both SMR and AMR is not more than 13.8% and 28.7% respectively. However, the situation can change dramatically when the experiment is conducted at high water temperature and/ or in small chambers, as demonstrated by Case Study 2.
Case Study 2: The effect of background respiration on SMR of Guppies

Running the analysis using GUI application
The GUI version is created for users who prefer to interact with graphical elements in a user-friendly interface instead of working with a command line. Here, we demonstrate the use of the application for estimating background respiration, and calculating SMR (see File S2 to run this example in R). After launching the program, a user should set parameters in the 'Global settings' module: we choose 'preand post-tests' as background respiration tests, 'AutoResp' for the type of logger software, and eight chambers in the respirometry system. As we measured only one trait (SMR), the field for 'Trait 2' should be empty. Click the 'Save global settings' button, and fill in the table with information about animals and chambers (Fig. 2). Next, move to the 'Background respiration' tab and import data for pre-and post-tests. Note that conducting visual QC tests of raw data is critical: if the temperature is unstable, or oxygen data show loss of linearity, further calculations might be meaningless. Navigation buttons of the graphical module can be used for zooming and switching plots for different chambers. Finally, open the 'Standard Metabolic Rate' tab, import raw data for SMR (time interval: 22:00:00-06:00:00), and correct them for background respiration. As both pre-and post-tests were used, all methods excluding 'parallel' are available (Fig. 3B). In this example, the method 'exponential' is used because

9
background respiration was on average 17% lower during the pre-test than during the post-test in all chambers (Wilcoxon signed-rank test, P = 0.014), wherein exponential microbial growth is expected (Dalla Via, 1983, but see Rodgers et al., 2016).

Comparison of SMR before and after correction
In the module 'Visual QC tests', a user can compare non-corrected versus corrected data, and check for indications of animal activity over the measurement period (GUI implementation of the package functions, QC.meas and QC.activity). 'Activity' and 'Comparison' options calculate mass-specific metabolic rate automatically, disabling any filters for slope estimation (but see Wilson, 2018). The 'Activity' option can be helpful for defining the time of corrected SMR, while 'Comparison' is used for graphical comparison of results with and without correction for background respiration (Fig. 6). Fig. 6 shows that mass-specific SMR after the subtraction of microbial oxygen consumption is markedly lower than before correction.
To calculate SMR, together with the percentage of background respiration, open the 'Results' tab. The method 'calcSMR: quant' (Chabot et al., 2016b) is chosen to determine SMR based on calculation of the lower quantile (P = 0.25) of all slopes with r 2 > 0.9 (the threshold level is reduced because of the high rate of background respiration, coupled with a low ratio between mass of male guppies and the volume of chambers, both of which seriously reduced the linearity of corrected data). Note, if any of 'calcSMR' methods are applied, then slopes cannot be plotted individually in the module 'QC of slopes'. Thus, before using 'calcSMR: quant', we extract all slopes and conduct graphical QC tests of slopes for each chamber. Finally, we insert information about the body density of fish and click the button 'Calculate and plot'. Three graphs are plotted automatically in the graphical module: percentage rate of background respiration, absolute and mass-specific SMR. The last step is to save results as a .csv or .txt file (a log file with all commands applied during the analysis is also logged automatically in the same folder).
Results of the analysis show that background respiration represents 57.1-89% of the total oxygen consumption (Fig. 7A), despite daily cleaning of chambers and sensors, weekly changing 50% of water volume in the respirometry system and constant usage of the UV filter. Absolute SMR varies depending on mass of fish, while the mean mass-specific SMR is 185.5 mgO 2 /kg/h. Thus, mean SMR is overestimated by~2.8 times for females and 6.7 times for males (Fig. 7B), when not corrected for background respiration.

Conclusions
Our case studies demonstrate that neglecting mechanical problems and microbial growth in a respirometry system can

10
lead to underestimation and/or overestimation of metabolic rate. FishResp software, used together with a proper experimental design (Clark et al., 2013;Svendsen et al., 2016b), represents a simple and efficient approach to account for the effects of chamber issues and background respiration in the processing of raw respirometry data. To make FishResp a universally available tool, we have developed both the R package (available on CRAN), and its cross-platform and user-friendly graphical implementation under open source licenses. Both can import raw data from the majority of respirometry systems available on the market. FishResp can be adjusted for different experimental designs: the software allows users to choose among various options for detection of mechanical problems, correction of background respiration, and calculation of metabolic rate. Therefore, FishResp provides a universal and straightforward tool that can improve the quality of metabolic rate estimation in fishes and other aquatic animals. Last but not least, the 'Extensions module' in the GUI version of FishResp represents a platform for graphical implementation of other R packages, scripts and functions available in open-access/published. Thus, FishResp has potential to become a community-driven software in the field of aquatic respirometry.

Data availability
The R package and data are available on the CRAN repository (http://cran.r-project.org/package=FishResp). R scripts for running both case studies are provided in Supplementary files S1 & S2. Application of functions which have not been reviewed in the case studies are shown in Supplementary file S3. The official website (https://fishresp.org) will host all information related to FishResp, including user manuals, tutorial videos, FAQ, a forum and a blog with the latest updates of the software.

Supplementary material
Supplementary material is available at Conservation Physiology online.