Title: | An R toolbox for analysing respirometry data |
---|---|
Description: | An R toolbox for analysing respirometry data. |
Authors: | Mikkel Roald-Arbøl [aut, cre] |
Maintainer: | Mikkel Roald-Arbøl <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.2.1 |
Built: | 2025-03-08 05:33:19 UTC |
Source: | https://github.com/roaldarbol/respirometr |
Converts CO2 measurements from gas analyzer data into standardized units, with options for temperature correction. It can process both single measurements and vectors of measurements.
The function implements standard gas analysis conversions and can optionally apply temperature corrections using a Q10 = 2 approach (metabolic rate doubles for every 10°C increase).
convert_unit_co2( co2_value, flow_rate, unit_flowrate = "mL/min", unit_input_co2 = "umol/mol", unit_output_time = "h", unit_output_vol = "mL", from_temperature = NULL, to_temperature = NULL )
convert_unit_co2( co2_value, flow_rate, unit_flowrate = "mL/min", unit_input_co2 = "umol/mol", unit_output_time = "h", unit_output_vol = "mL", from_temperature = NULL, to_temperature = NULL )
co2_value |
Numeric vector. The differential CO2 value(s) from gas analyzer (default in μmol/mol or ppm) |
flow_rate |
Numeric. The flow rate of gas though the system. |
unit_flowrate |
Character. Flow rate unit, either "mL/min" or "mL/h". Default: "mL/min" |
unit_input_co2 |
Character. Input CO2 unit, either "uM/M" or "umol/mol" (both equivalent to ppm). Default: "umol/mol" |
unit_output_time |
Character. Desired time unit for the output rate, one of "s", "min", or "h". Default: "min" |
unit_output_vol |
Character. Desired volume unit for the output, either "mL" or "uL". Default: "mL" |
from_temperature |
Numeric. Source temperature in Celsius. Only required if metabolic temperature correction is desired (must be provided with to_temperature). |
to_temperature |
Numeric. Optional target temperature in Celsius. Must be provided together with from_temperature if temperature correction is desired. |
The function performs the following conversions:
Converts CO2 measurements from ppm (μmol/mol) to fractions
Optionally applies temperature correction using Q10 = 2
Converts to desired output units (μL conversion is direct volume conversion)
Temperature correction uses the formula: correction_factor = 10^((to_temperature - from_temperature) * (log10(2)/10))
Numeric vector of converted CO2 values in the specified output units
Temperature correction method based on standard Q10 = 2 approach, where metabolic rate doubles for every 10°C increase in temperature.
# Basic usage convert_unit_co2( co2_value = 100, flow_rate = 1300, unit_output_time = "h", unit_output_vol = "uL" ) # With temperature correction convert_unit_co2( co2_value = 100, flow_rate = 200, from_temperature = 17, # Experiment temperature to_temperature = 25, # Standard temperature unit_output_vol = "uL", unit_output_time = "min" ) # Processing a sequence of measurements co2_values <- c(95, 98, 100, 103, 99) convert_unit_co2( co2_value = co2_values, flow_rate = 200, unit_output_vol = "mL", unit_output_time = "min" )
# Basic usage convert_unit_co2( co2_value = 100, flow_rate = 1300, unit_output_time = "h", unit_output_vol = "uL" ) # With temperature correction convert_unit_co2( co2_value = 100, flow_rate = 200, from_temperature = 17, # Experiment temperature to_temperature = 25, # Standard temperature unit_output_vol = "uL", unit_output_time = "min" ) # Processing a sequence of measurements co2_values <- c(95, 98, 100, 103, 99) convert_unit_co2( co2_value = co2_values, flow_rate = 200, unit_output_vol = "mL", unit_output_time = "min" )
This function normalizes measurement data by subtracting baseline values predicted from a linear regression of pre and post data.
normalise_drift_lm( data, data_pre, data_post, colname_time = "time", colname_measure = "co2d_um_m" )
normalise_drift_lm( data, data_pre, data_post, colname_time = "time", colname_measure = "co2d_um_m" )
data |
A data frame containing the main dataset to be normalized |
data_pre |
A data frame containing pre-experiment data used for baseline calculation |
data_post |
A data frame containing post-experiment data used for baseline calculation |
colname_time |
Character string specifying the column name for time measurements. Default is "time". |
colname_measure |
Character string specifying the column name for the measurement. Default is "co2d_um_m". |
The function performs the following steps:
Combines pre and post data
Fits a linear regression model using time as the predictor
Predicts baseline values for the main dataset
Subtracts these baseline values from the original measurements
A modified version of the input data
with baseline-adjusted measurements
## Not run: # Assuming you have pre, post, and main datasets normalized_data <- normalise_drift_lm( data = main_data, data_pre = pre_experiment_data, data_post = post_experiment_data ) ## End(Not run)
## Not run: # Assuming you have pre, post, and main datasets normalized_data <- normalise_drift_lm( data = main_data, data_pre = pre_experiment_data, data_post = post_experiment_data ) ## End(Not run)
This function normalizes a data vector by subtracting a linear interpolation between the means of pre and post measurements. This is useful for correcting measurement drift in experimental data.
normalise_drift_means(data, pre, post)
normalise_drift_means(data, pre, post)
data |
Numeric vector containing the measurements to be normalized |
pre |
Numeric vector or single value representing pre-measurement(s) |
post |
Numeric vector or single value representing post-measurement(s) |
The function performs the following steps:
Calculates mean of pre-measurements if multiple values provided
Calculates mean of post-measurements if multiple values provided
Creates a linear interpolation between pre and post means
Subtracts interpolated values from the data to correct for drift
A numeric vector of the same length as data
containing the
normalized values
# Single pre/post values data <- c(15, 16, 17, 18, 19) normalise_drift_means(data, pre = 10, post = 20) # Multiple pre/post values normalise_drift_means( data = c(15, 16, 17, 18, 19), pre = c(10, 11, 12), post = c(19, 20, 21) )
# Single pre/post values data <- c(15, 16, 17, 18, 19) normalise_drift_means(data, pre = 10, post = 20) # Multiple pre/post values normalise_drift_means( data = c(15, 16, 17, 18, 19), pre = c(10, 11, 12), post = c(19, 20, 21) )
Creates a visualization of time series data. Useful for analyzing patterns in continuous measurements such as physiological data or other single-trace recordings.
plot_timeseries(data, value_col, time_col = "time", y_max = NULL)
plot_timeseries(data, value_col, time_col = "time", y_max = NULL)
data |
A data frame containing time series data with the following columns:
|
value_col |
Character string specifying which column to plot |
time_col |
Character string specifying the time column (default: "time") |
y_max |
Optional numeric value specifying the maximum value for the y-axis. If NULL (default), the y-axis limit is automatically determined from the data. |
A ggplot object wrapped in patchwork.
## Not run: # Plot heart rate data plot_timeseries(physio_data, value_col = "heart_rate") # Plot temperature with custom time column plot_timeseries(physio_data, value_col = "temperature", time_col = "timestamp") ## End(Not run)
## Not run: # Plot heart rate data plot_timeseries(physio_data, value_col = "heart_rate") # Plot temperature with custom time column plot_timeseries(physio_data, value_col = "temperature", time_col = "timestamp") ## End(Not run)
Read respirometry data from a variety of Licor devices.
read_licor(filepath, model)
read_licor(filepath, model)
filepath |
Path to file |
model |
LiCor model |
Tidy LiCor data
Reads data from a LI-7000 CO2/H2O analyzer file, cleans column names, and ensures proper time column handling. Handles cases where headers are repeated mid-file.
read_licor_li7000(filepath)
read_licor_li7000(filepath)
filepath |
Character string specifying the path to the LI-7000 data file. File should be tab-separated with two header rows. |
The function performs the following operations:
Reads the entire file as lines
Identifies and removes any mid-file headers
Cleans column names using janitor::make_clean_names()
Ensures proper time column naming
A tibble containing the processed LI-7000 data with:
All original columns with cleaned names (lowercase, no spaces)
Standardized time column
Data combined across any mid-file header breaks
## Not run: # Read a LI-7000 data file data <- read_licor_li7000("path/to/li7000_data.txt") ## End(Not run)
## Not run: # Read a LI-7000 data file data <- read_licor_li7000("path/to/li7000_data.txt") ## End(Not run)
Reads data from a LI-850 CO2/H2O analyzer file, cleans column names, removes columns with NA values, and adds an elapsed time column. Handles cases where headers are repeated mid-file.
read_licor_li850(filepath)
read_licor_li850(filepath)
filepath |
Character string specifying the path to the LI-850 data file. File should be tab-separated with a one-line header. |
The function performs the following operations:
Reads the entire file and handles any mid-file headers
Cleans column names using janitor::make_clean_names()
Removes any columns containing NA values
Converts system time to HMS format
Adds an elapsed time column in seconds
A tibble containing the processed LI-850 data with:
All original columns except those containing NA values
Cleaned column names (lowercase, no spaces)
system_time_h_m_s
converted to HMS format
New time
column with seconds elapsed from start
Data combined across any mid-file header breaks
## Not run: # Read a LI-850 data file data <- read_licor_li850("path/to/li850_data.txt") ## End(Not run)
## Not run: # Read a LI-850 data file data <- read_licor_li850("path/to/li850_data.txt") ## End(Not run)