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 arSat.conc_uMol.kg n2Sat.conc_uMol.kg o2Sat.conc_uMol.kg Ar_uMolL N2Ar O2Ar N2_uMolL O2_uMolL N2_mgL O2_mgL Ar_mgL
25.1 Sample1 12.09965 470.8931 256.0983 12.00882 39.04704 25.01304 472.4557 302.6491 13.22876 9.684772 0.4803527
25.1 Sample2 12.09965 470.8931 256.0983 11.97778 39.05838 25.08267 472.5929 303.4915 13.23260 9.711729 0.4791111
25.1 Sample3 12.09965 470.8931 256.0983 11.94339 39.05136 25.11142 472.5079 303.8394 13.23022 9.722862 0.4777357
26.1 Sample4 11.88145 463.3433 253.0292 11.59060 38.37769 25.09848 455.9827 298.2064 12.76751 9.542604 0.4636239
26.1 Sample5 11.88145 463.3433 253.0292 11.59887 38.45231 25.27225 456.8693 300.2711 12.79234 9.608674 0.4639547
26.1 Sample6 11.88145 463.3433 253.0292 11.77280 38.89491 25.18581 462.1280 299.2440 12.93958 9.575807 0.4709121
25.3 Sample7 12.05545 469.3628 255.4663 11.75798 38.99877 24.76680 470.1476 298.5748 13.16413 9.554393 0.4703192
25.3 Sample8 12.05545 469.3628 255.4663 11.84647 38.96478 25.09616 469.7378 302.5454 13.15266 9.681451 0.4738588
25.3 Sample9 12.05545 469.3628 255.4663 11.81299 38.83963 25.41305 468.2291 306.3657 13.11041 9.803702 0.4725195
24.9 Sample10 12.14415 472.4339 256.7397 11.85492 39.39490 21.07834 478.4175 255.9785 13.39569 8.191311 0.4741968
24.9 Sample11 12.14415 472.4339 256.7397 11.90533 39.42348 20.99730 478.7645 254.9943 13.40541 8.159818 0.4762130
24.9 Sample12 12.14415 472.4339 256.7397 11.95593 39.39640 20.96711 478.4356 254.6277 13.39620 8.148087 0.4782373
26.3 Sample13 11.83865 461.8634 252.4423 11.77680 39.32482 20.95014 465.5527 248.0213 13.03548 7.936681 0.4710718
26.3 Sample14 11.83865 461.8634 252.4423 11.88897 39.35255 21.19046 465.8809 250.8664 13.04467 8.027724 0.4755589
26.3 Sample15 11.83865 461.8634 252.4423 11.89373 39.32164 21.22807 465.5150 251.3116 13.03442 8.041970 0.4757490
25.7 Sample16 11.96789 466.3329 254.2297 11.86847 39.36071 20.79488 471.0646 248.8709 13.18981 7.963867 0.4747390
25.7 Sample17 11.96789 466.3329 254.2297 11.87436 39.31090 21.02942 470.4685 251.6778 13.17312 8.053691 0.4749745
25.7 Sample18 11.96789 466.3329 254.2297 11.88057 39.30274 21.09600 470.3709 252.4746 13.17039 8.079187 0.4752228
25.9 Sample19 11.92453 464.8331 253.6250 11.83255 38.78803 27.83127 462.5291 331.8749 12.95082 10.619997 0.4733021
25.9 Sample20 11.92453 464.8331 253.6250 11.83667 38.73328 27.99674 461.8763 333.8481 12.93254 10.683138 0.4734668
25.9 Sample21 11.92453 464.8331 253.6250 11.84976 38.83837 27.92871 463.1294 333.0369 12.96762 10.657180 0.4739903
25.2 Sample22 12.07751 470.1267 255.7812 11.75605 38.50567 29.14297 465.0527 351.9746 13.02148 11.263187 0.4702422
25.2 Sample23 12.07751 470.1267 255.7812 11.80474 38.61164 29.27172 466.3326 353.5296 13.05731 11.312947 0.4721895
25.2 Sample24 12.07751 470.1267 255.7812 11.64738 38.24725 29.46728 461.9316 355.8915 12.93409 11.388528 0.4658953
# Check out the solubility concentrations
results$solubility.Concentrations
O2.conc_uMol.kg N2.conc_uMol.kg Ar.conc_uMol.kg
24.9 deg C 256.7397 472.4339 12.14415
26.3 deg C 252.4423 461.8634 11.83865

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