Get started

1. Introduction

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.

2. Installation

Install mimsy from the CRAN repository and load into your R environment:

# Install the package
install.packages("mimsy")

# Load the package
library(mimsy)

Alternatively, the latest in-development version of mimsy can be pulled from Github via:

# Install and load devtools
install.packages("devtools")
library(devtools)

# Download mimsy from Github
install_github("michelleckelly/mimsy")

# Load the package
library(mimsy)

3. Running mimsy

The general structure for running mimsy is:

  1. Format your CSV file
  2. Load CSV file into R using read.csv()
  3. Run the mimsy() function
  4. Explore the results
  5. Save the results to an Excel file using mimsy.save() or an RData file using save()

3.1. Format your CSV file

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.

Click to download an example CSV file for single water bath MIMS setups (“one temperature setups”): Download data_oneTemp.csv

Click to download an example CSV file for dual water bath MIMS setups (“two temperature setups”): Download data_twoTemp.csv

Figure 1. An example of a correctly formatted raw data file for a MIMS setup with two water baths.
Figure 1. An example of a correctly formatted raw data file for a MIMS setup with two water baths.

CSV file format:

  • You can save as CSV within Excel from the File > Save as menu, choosing the CSV (Comma delimited) (.csv) option.

Columns:

  • Type
    • If the row contains data for a standard, enter “Standard”. If the row contains data for a sample, enter “Sample”.
    • The name of this column must be “Type” (check for correct capitalization)
  • Group
    • Each block of standards and the samples run directly afterwards belong to a group. You’ll enter “1” for the first block of standards and the first block of samples. You’ll enter “2” for the second block of standards and the second block of samples, etc.
    • The name of this column must be “Group” (check for correct capitalization)
  • CollectionTemp
    • The temperature of samples or standards at the time of field collection, in degrees C
    • The name of this column must be “CollectionTemp” (check for correct capitalization)
  • RunDate
    • The date (M/D/YYYY) that samples were run on the MIMS.
    • The name of this column must be “RunDate” (check for correct capitalization)
  • Label or other sample identifier columns
    • mimsy will preserve all labelling columns in the final output, so you should add whatever labels or notes columns you like
  • Index, Time, 28, 32, 40, N2/Ar, O2/Ar columns
    • This is the default output from the MIMS. If you have a newer setup, this may also include a “99” column indicating the MIMS’ internal pressure. Including, or not including, this column won’t affect your results.

3.2. Load your CSV file into R using read.csv()

# Load data into R
data <- read.csv(file = "data_twoTemp.csv", header = TRUE, stringsAsFactors = FALSE)

# Check it out
data
Type Group CollectionTemp RunDate Label Index Time X28 X32 X40 N2.Ar O2.Ar Notes
Standard 1 24.9 2/1/18 NA 3029 10:32:53 AM 0 0 0 40.27659 19.29615 Barometric pressure = 977.2 hPa
Standard 1 24.9 2/1/18 NA 3079 10:34:07 AM 0 0 0 40.28539 19.29992
Standard 1 24.9 2/1/18 NA 3128 10:35:19 AM 0 0 0 40.29580 19.30377
Standard 1 26.3 2/1/18 NA 3212 10:37:22 AM 0 0 0 40.42873 19.31060
Standard 1 26.3 2/1/18 NA 3261 10:38:35 AM 0 0 0 40.41858 19.30813
Standard 1 26.3 2/1/18 NA 3315 10:39:54 AM 0 0 0 40.43270 19.30843
Sample 1 25.1 2/1/18 Sample1 3455 10:43:20 AM 0 0 0 40.46266 22.82152
Sample 1 25.1 2/1/18 Sample2 3554 10:45:46 AM 0 0 0 40.47978 22.88816
Sample 1 25.1 2/1/18 Sample3 3620 10:47:23 AM 0 0 0 40.47607 22.91647
Sample 1 26.1 2/1/18 Sample4 3701 10:49:22 AM 0 0 0 39.79033 22.77329
Sample 1 26.1 2/1/18 Sample5 3792 10:51:36 AM 0 0 0 39.87121 22.93365
Sample 1 26.1 2/1/18 Sample6 3913 10:54:34 AM 0 0 0 40.33485 22.85876
Sample 1 25.3 2/1/18 Sample7 3975 10:56:05 AM 0 0 0 40.44159 22.58631
Sample 1 25.3 2/1/18 Sample8 4043 10:57:45 AM 0 0 0 40.40981 22.88878
Sample 1 25.3 2/1/18 Sample9 4121 10:59:40 AM 0 0 0 40.28400 23.18026
Sample 1 24.9 2/1/18 Sample10 4233 11:02:25 AM 0 0 0 40.86557 19.27496
Sample 1 24.9 2/1/18 Sample11 4327 11:04:43 AM 0 0 0 40.90063 19.20336
Sample 1 24.9 2/1/18 Sample12 4422 11:07:03 AM 0 0 0 40.87803 19.17829
Standard 2 24.9 2/1/18 NA 4654 11:12:45 AM 0 0 0 40.38071 19.34272
Standard 2 24.9 2/1/18 NA 4742 11:14:54 AM 0 0 0 40.37351 19.34234
Standard 2 24.9 2/1/18 NA 4779 11:15:48 AM 0 0 0 40.38127 19.34579
Standard 2 26.3 2/1/18 NA 4866 11:17:57 AM 0 0 0 40.48250 19.34875
Standard 2 26.3 2/1/18 NA 4962 11:20:18 AM 0 0 0 40.48784 19.34937
Standard 2 26.3 2/1/18 NA 5007 11:21:24 AM 0 0 0 40.48557 19.34862
Sample 2 26.3 2/1/18 Sample13 4516 11:09:21 AM 0 0 0 40.80347 19.00344
Sample 2 26.3 2/1/18 Sample14 5089 11:23:25 AM 0 0 0 40.85389 19.24914
Sample 2 26.3 2/1/18 Sample15 5179 11:25:37 AM 0 0 0 40.82519 19.28765
Sample 2 25.7 2/1/18 Sample16 5270 11:27:51 AM 0 0 0 40.87712 18.98291
Sample 2 25.7 2/1/18 Sample17 5370 11:30:18 AM 0 0 0 40.82986 19.20466
Sample 2 25.7 2/1/18 Sample18 5475 11:32:53 AM 0 0 0 40.82610 19.27355
Sample 2 25.9 2/1/18 Sample19 5668 11:37:37 AM 0 0 0 40.29644 25.40370
Sample 2 25.9 2/1/18 Sample20 5741 11:39:24 AM 0 0 0 40.24260 25.56124
Sample 2 25.9 2/1/18 Sample21 5972 11:45:04 AM 0 0 0 40.36147 25.51976
Sample 2 25.2 2/1/18 Sample22 6079 11:47:42 AM 0 0 0 40.03570 26.81639
Sample 2 25.2 2/1/18 Sample23 6192 11:50:28 AM 0 0 0 40.15149 26.95080
Sample 2 25.2 2/1/18 Sample24 6335 11:53:58 AM 0 0 0 39.77960 27.15118
Standard 3 24.9 2/1/18 NA 6475 11:57:24 AM 0 0 0 40.46484 19.63069
Standard 3 24.9 2/1/18 NA 6542 11:59:03 AM 0 0 0 40.46932 19.53179
Standard 3 24.9 2/1/18 NA 6599 12:00:27 PM 0 0 0 40.49352 19.50314
Standard 3 26.3 2/1/18 NA 6723 12:03:29 PM 0 0 0 40.55150 19.45527
Standard 3 26.3 2/1/18 NA 6825 12:05:59 PM 0 0 0 40.54939 19.42995
Standard 3 26.3 2/1/18 NA 6870 12:07:06 PM 0 0 0 40.55973 19.42807

Don’t be worried that your “28”, “32”, and “40” columns are now “X28”, “X32”, and “X40”. As R doesn’t accept column names that start with a number, it added an “X” to these column names when the data was imported. Similarly, “N2/Ar” and “O2/Ar” have been automatically adjusted to “N2.Ar” and “O2.Ar”.

3.3. Run the mimsy() function

You 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

3.4. Explore the results

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 summarized results
results$results

The summarized results includes the calculated gas concentrations for all samples:

CollectionTemp Label Notes CollectionSalinity Ar_uMolL N2Ar_molarRatio O2Ar_molarRatio
25.1 Sample1 0 11.97304 39.04704 25.01304
25.1 Sample2 0 11.94209 39.05838 25.08267
25.1 Sample3 0 11.90781 39.05136 25.11142
26.1 Sample4 0 11.55302 38.37769 25.09848
26.1 Sample5 0 11.56127 38.45231 25.27225
26.1 Sample6 0 11.73464 38.89491 25.18581
25.3 Sample7 0 11.72233 38.99877 24.76680
25.3 Sample8 0 11.81056 38.96478 25.09616
25.3 Sample9 0 11.77718 38.83963 25.41305
24.9 Sample10 0 11.82021 39.39490 21.07834
24.9 Sample11 0 11.87047 39.42348 20.99730
24.9 Sample12 0 11.92093 39.39640 20.96711
26.3 Sample13 0 11.73800 39.32482 20.95014
26.3 Sample14 0 11.84980 39.35255 21.19046
26.3 Sample15 0 11.85454 39.32164 21.22807
25.7 Sample16 0 11.83125 39.36071 20.79488
25.7 Sample17 0 11.83712 39.31090 21.02942
25.7 Sample18 0 11.84331 39.30274 21.09600
25.9 Sample19 0 11.79482 38.78803 27.83127
25.9 Sample20 0 11.79893 38.73328 27.99674
25.9 Sample21 0 11.81197 38.83837 27.92871
25.2 Sample22 0 11.72072 38.50567 29.14297
25.2 Sample23 0 11.76926 38.61164 29.27172
25.2 Sample24 0 11.61238 38.24725 29.46728
# Check out the solubility concentrations
results$solubility.Concentrations
O2.conc_umolL N2.conc_umolL Ar.conc_umolL
temp_24.9degCsalinity_0 255.9881 471.0509 12.10860
temp_26.3degCsalinity_0 251.6107 460.3418 11.79965

Check out ?mimsy() for more specific information on the results, solubility.Concentrations, calibration.Factors, calibration.DriftCorrection, and results.full dataframes, including details on how they were calculated.

3.5. Save the results

# 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 it is possible), 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.

4. Putting it all together

# Install mimsy
install.packages("mimsy")

# 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! :)