mimsy is a package designed to calculate dissolved gas concentrations of oxygen, nitrogen, and argon from Membrane Inlet Mass Spectrometer (MIMS) signal data. For more information on the gas solubility equations used in this package, please see the References section. No R expertise is required to use mimsy, and this guide is designed for novice R users.
If you find bugs in this software, or you would like to suggest new features, please let us know on the mimsy GitHub page.
mimsy is not yet released on CRAN, the official repository for R packages. To download mimsy from GitHub, use the devtools package:
# Install the devtools package
install.packages("devtools")
# Load devtools
library(devtools)
# Download mimsy from github using devtools
install_github("michelleckelly/mimsy", dependencies = "Depends")
Afterwards, you can load mimsy like any other package:
# Load mimsy
library(mimsy)
The general structure for running mimsy is:
read.csv()
mimsy()
functionmimsy.save()
or an RData file using save()
You’ll need to add some special columns to your data file before loading it into R. The easiest way to do this is to use a spreadsheet editor like Excel. We recommend saving a seperate copy of your raw data file for mimsy (add “_mimsy" to the file name) to prevent any accidents.
Figure 1. An example of a correctly formatted raw data file.
CSV file format:
Columns:
read.csv()
# Load data into R
data <- read.csv(file = "data.csv", header = TRUE, stringsAsFactors = FALSE)
# Check out the structure
str(data, vec.len = 2)
#> 'data.frame': 42 obs. of 14 variables:
#> $ Type : chr "Standard" "Standard" ...
#> $ Group : int 1 1 1 1 1 ...
#> $ CollectionTemp: num 24.9 24.9 24.9 26.3 26.3 ...
#> $ RunDate : chr "2/1/2018" "2/1/2018" ...
#> $ Label : chr NA NA ...
#> $ Index : int 3029 3079 3128 3212 3261 ...
#> $ Time : chr "10:32:53 AM" "10:34:07 AM" ...
#> $ X28 : num 1.20e-08 1.20e-08 1.20e-08 1.19e-08 1.18e-08 ...
#> $ X32 : num 5.75e-09 5.75e-09 5.75e-09 5.66e-09 5.66e-09 ...
#> $ X40 : num 2.98e-10 2.98e-10 2.98e-10 2.93e-10 2.93e-10 ...
#> $ X99 : num 5.51e-07 5.49e-07 5.49e-07 5.41e-07 5.41e-07 ...
#> $ N2.Ar : num 40.3 40.3 ...
#> $ O2.Ar : num 19.3 19.3 ...
#> $ Notes : chr "Barometric pressure = 977.2 hPa" "" ...
mimsy()
functionYou must specify the barometric pressure (as baromet.press
) and its units in the function argument. Units must be one of "atm"
, "hPa"
, "psi"
, "bar"
, or "Torr"
. All other inputs, such as background corrections or standard salinity, are optional. Check out ?mimsy
for more information.
# Run the function
results <- mimsy(data, baromet.press = 977.2, units = "hPa")
#> Calculated dissolved concentrations based on a two-point temperature standard.
#> Standard 1: 24.9 C, Standard 2: 26.3 C
You’ll see that mimsy()
returns a list containing five seperate dataframes (results
, solubility.Concentrations
, calibration.Factors
, calibration.DriftCorrection
, and results.full
). Check out ?mimsy() for more specific information on those outputs and how they were calculated.
# Check out the structure of the output
summary(results)
#> Length Class Mode
#> results 11 grouped_df list
#> solubility.Concentrations 3 data.frame list
#> calibration.Factors 3 data.frame list
#> calibration.DriftCorrection 12 data.frame list
#> results.full 30 grouped_df list
# See the summarized results dataframe
str(results$results, give.attr = FALSE)
#> Classes 'grouped_df', 'tbl_df', 'tbl' and 'data.frame': 24 obs. of 11 variables:
#> $ CollectionTemp: num 25.1 25.1 25.1 26.1 26.1 26.1 25.3 25.3 25.3 24.9 ...
#> $ Label : chr "Sample1" "Sample2" "Sample3" "Sample4" ...
#> $ Notes : chr "" "" "" "" ...
#> $ data$Type : chr "Sample" "Sample" "Sample" "Sample" ...
#> $ data$Group : int 1 1 1 1 1 1 1 1 1 1 ...
#> $ N2_uMol : num 469 469 465 443 447 ...
#> $ O2_uMol : num 301 301 300 290 293 ...
#> $ Ar_uMol : num 12 12 11.9 11.6 11.6 ...
#> $ N2_mg : num 13.1 13.1 13 12.4 12.5 ...
#> $ O2_mg : num 9.63 9.62 9.61 9.29 9.37 ...
#> $ Ar_mg : num 0.48 0.479 0.478 0.464 0.464 ...
# Save output to an Excel workbook
mimsy.save(results, file = "results.xlsx")
# Save output to an RData file
save(results, file = "results.RData")
We don’t reccomend saving results dataframes to CSV files (although you can), as you’ll need multiple CSV’s to preserve all of the outputs, and that gets kind of messy. A good alternative is to save both an Excel workbook copy and an RData copy, that way all of your output is preserved every time.
You can load RData files back into R using load("results.RData")
. Check out ?load()
for more info.
# Install the devtools package
install.packages("devtools")
# Load devtools
library(devtools)
# Download mimsy from Github using devtools
install_github("michelleckelly/mimsy", dependencies = "Depends")
# Load mimsy
library(mimsy)
# Load data into R
data <- read.csv(file = "data.csv", header = TRUE, stringsAsFactors = FALSE)
# Run the mimsy function
results <- mimsy(data, baromet.press = 977.2, units = "hPa")
# Save the results
mimsy.save(results, file = "results.xlsx") # To Excel file
save(results, file = "results.RData") # To RData file
# Done! :)