Jacob Anderson 12/12/2021
peak.gas is an R package developed as a useful tool in extrapolating gas concentration data from text file output generated from benchtop infrared gas analyzers(IRGA).
there are 2 processing functions that are included in peak.gas, each processing function is accompanied by a plotting function
extract.peaks(cut.off = 2, method = “linear”, standard.sum = F, check.stand = F, check.alpha = .05, ci.meth = “avg”, verbose = F)
timeseries.peaks()
The text file output should be formatted into 3 columns.
the first column should contain the time between samples starting at time zero as well as the sample names distinguished between dash marks (typically labeled as Etime),
the second column should be the datetime the sample was collected (typically labeled as Time),
and the third column should be the readings outpurt from the machine (in the case below labeled as CO2 (μmol/mol)). the sample name annotation should be included in the Etime column and distinguished by a series of dash marks. (see example below)
Should your data look differently the code should be modified to account for the change, or the data itself should be modified to match the structure of the example below
Example of proper .txt file output generated using a LI-COR LI-8100A IRGA
This function can be installed from the github repository
andersonjake1988/peak.gas by using the package devtools
and the
following approach
library(devtools)
install_github('andersonjake1988/peak.gas')
library(peak.gas)
extract.peaks() function will loop through a folder of text files sharing identical formatting to combine and output a single dataframe containing the columns:
# run extract.peaks() function and store as object
output <- extract.peaks(directory = path.package("peak.gas"))
## Working directory set to:
## C:/Users/ander/Documents/R/win-library/4.1/peak.gas
## [1] "Looping through Folder:"
## | | | 0% | |================== | 25% | |=================================== | 50% | |==================================================== | 75% | |======================================================================| 100%[1] "done"
# look at output
head(output)
## # A tibble: 6 x 10
## File_Name Sample Replicate Order_Run AUC Peak Time_Peak_Start
## <chr> <chr> <chr> <dbl> <dbl> <dbl> <dttm>
## 1 vn_clear_071621.txt 300cu~ 1 1 30.5 10.5 2021-07-16 11:32:07
## 2 vn_clear_071621.txt 300cu~ 2 1 24.4 9.02 2021-07-16 11:32:51
## 3 vn_clear_071621.txt 300cu~ 3 1 23.2 8.69 2021-07-16 11:33:19
## 4 vn_clear_071621.txt 500cu~ 1 2 44.8 14.4 2021-07-16 11:34:25
## 5 vn_clear_071621.txt 500cu~ 2 2 46.8 14.9 2021-07-16 11:35:18
## 6 vn_clear_071621.txt 500cu~ 3 2 47.7 15.4 2021-07-16 11:36:03
## # ... with 3 more variables: Time_Peak_End <dttm>, Timespan_(s) <dbl>,
## # AUC_ppm <dbl>
peak.gas provides a plotting framework for exploring the data output from the extract.peaks() function
# Pulls up a random plot from extract.peaks() output
plot(output)
# plots all samples called "NN_DARKVEG"
plot(output, sample = "NN_DARKVEG")
# plots all samples called "NN_DARKVEG" from file "vn_darkveg_071621.txt"
plot(output, file = "vn_darkveg_071621.txt", sample = "NC_DARKVEG")
# Plots the total linear standard curve using all files
plot(output, std.curve = T)
# Plots the total log transformed standard curve using all files
plot(output, std.curve = T, method = 'log')
# Plots the standard curve for the file "vn_clear_07292021.txt"
plot(output, file = "vn_clear_07292021.txt", std.curve = T)
This is a simplified version of extract.peaks()
this function will
transfer over the sample name and combine all the text files into a
single timeseries dataframe. There are no arguments needed for this
function.
test <- timeseries.peaks(directory = path.package("peak.gas"))
## Working directory set to:
## C:/Users/ander/Documents/R/win-library/4.1/peak.gas
## [1] "Looping through Folder:"
## | | | 0% | |================== | 25% | |=================================== | 50% | |==================================================== | 75% | |======================================================================| 100%
head(test)
## File Sample Time CO2
## 46 vn_clear_071621.txt 300curve 2021-07-16 11:31:44 -1.16
## 47 vn_clear_071621.txt 300curve 2021-07-16 11:31:45 -1.02
## 48 vn_clear_071621.txt 300curve 2021-07-16 11:31:46 -1.14
## 49 vn_clear_071621.txt 300curve 2021-07-16 11:31:47 -1.03
## 50 vn_clear_071621.txt 300curve 2021-07-16 11:31:48 -0.88
## 52 vn_clear_071621.txt 300curve 2021-07-16 11:31:49 -0.87
peak.gas provides a plotting framework for exploring the data output from the timeseries.peaks() function
# plot timeseries by file
plot(test, file = "vn_veg_07292021.txt")
# Plot timeseris by file and sample name
plot(test, file = "vn_veg_07292021.txt", sample = "500curve")
# plot timeseries by file starting after "2021-08-02 13:30:00"
plot(test, file = "vn_veg_07292021.txt", time.start = "2021-08-02 13:30:00")
# plot timeseries by file starting before "2021-08-02 12:40:00"
plot(test, file = "vn_veg_07292021.txt", time.stop = "2021-08-02 12:40:00")
# plot timeseries by file between the times "2021-08-02 12:45:00" and "2021-08-02 13:00:00"
plot(test, file = "vn_veg_07292021.txt", time.start = "2021-08-02 12:45:00", time.stop = "2021-08-02 13:00:00")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.