Load packages

library(tidyverse) # general data wrangling and plotting
library(isoreader) # reading the raw data files
library(isoprocessor) # processing the data

This analysis was run using isoreader version 1.0.7 and isoprocessor version 0.4.0.

For use as a data processing template, please follow the Source link above, download the raw file and adapt as needed. Knitting for stand-alone data analysis works best to HTML rather than the in-package default html_vignette.

All code chunks that contain a critical step towards the final data (i.e. do more than visualization or a data summary) are marked with (*) in the header to make it easier to follow all key steps during interactive use.

Load data

Process file information (*)

# process file information
iso_files <- iso_files_raw %>% 
  # rename key file info columns
  iso_rename_file_info(id1 = `Identifier 1`, id2 = `Identifier 2`) %>% 
  # parse text info into numbers
  iso_parse_file_info(number = Analysis) %>% 
  # process other file information that is specific to the naming conventions
  # of this particular sequence
  iso_mutate_file_info(
    # what is the type of each analysis?
    type = case_when(
      str_detect(id1, "[Zz]ero")      ~ "on_off",
      str_detect(id1, "[Ll]inearity") ~ "lin",
      str_detect(id1, "A5")           ~ "std",
      TRUE                            ~ "sample"
    ),
    # was there seed oxidation?
    seed_oxidation = ifelse(`Seed Oxidation` == "1", "yes", "no"),
    # what was the injection volume based on the AS method name?
    injection_volume.uL = str_extract(`AS Method`, "AS PTV [0-9.]+") %>% 
      parse_number(),
    # what was the concentration? (assuming Preparation = concentration or volume)
    conc.ng_uL = str_extract(Preparation, "[0-9.]+ ?ng( per |/)uL") %>% parse_number(),
    # or the volume?
    volume.uL = str_extract(Preparation, "[0-9.]+ ?uL") %>% parse_number(),
    # what folder are the data files in? (assuming folder = sequence)
    folder = basename(dirname(file_path))
  ) %>% 
  # add in additional sample metadata (could be any info)
  # note: this would typically be stored in / read from a csv or excel file
  iso_add_file_info(
    tibble::tribble(
      # column names
      ~id1,                           ~sample,          ~fraction,
      # metadata (row-by-row)
      "OG268_CZO-SJER_F1",            "SJER",           "F1",
      "OG271_CZO-CTNA_F1",            "CTNA",           "F1",
      "OG281_CZO-Niwot_Tundra2_F1",   "Niwot_Tundra2",  "F1",
      "OG282_CZO-Niwot_Tundra1_F1",   "Niwot_Tundra1",  "F1"
    ),
    join_by = "id1"
  ) %>% 
  # focus only on the relevant file info, discarding the rest
  iso_select_file_info(
    folder, Analysis, file_datetime, id1, id2, type, sample, 
    seed_oxidation, injection_volume.uL, conc.ng_uL, volume.uL
  )
#> Info: renaming 2 file info column(s) wherever they exist across 45 isofile(s):
#>  - 'Identifier 1' to 'id1' in 45 files
#>  - 'Identifier 2' to 'id2' in 44 files
#> Info: parsing 1 file info columns for 45 data file(s):
#>  - to number: 'Analysis'
#> Info: mutating file info for 45 data file(s)
#> Info: adding new file information ('sample', 'fraction') to 45 data file(s), joining by 'id1'...
#>  - 'id1' join: 4/4 new info rows matched 4/45 data files
#> Info: keeping 12 file info column(s) wherever they exist across 45 isofile(s):
#>  - 'Analysis' in 45 files
#>  - 'conc.ng_uL' in 45 files
#>  - 'file_datetime' in 45 files
#>  - 'file_id' in 45 files
#>  - 'folder' in 45 files
#>  - 'id1' in 45 files
#>  - 'id2' in 45 files
#>  - 'injection_volume.uL' in 45 files
#>  - 'sample' in 45 files
#>  - 'seed_oxidation' in 45 files
#>  - 'type' in 45 files
#>  - 'volume.uL' in 45 files

Show file information

Analysis file_datetime id1 id2 type sample seed_oxidation injection_volume.uL conc.ng_uL volume.uL
2026 2017-10-25 20:22:23 CO2 zero 6V on_off NA no NA NA NA
2030 2017-10-25 20:55:44 Linearity CO2 NA lin NA no NA NA NA
2034 2017-10-26 03:15:48 A5 0.5ul std NA yes 0.5 14 NA
2041 2017-10-26 14:50:38 A5 3ul std NA no 3.0 14 NA
2047 2017-10-26 23:50:04 A5 3ul std NA yes 3.0 14 NA
2061 2017-10-27 19:29:27 OG271_CZO-CTNA_F1 1.5uL sample CTNA yes 1.5 NA 25
2093 2017-10-29 18:32:04 A5 0.5ul std NA yes 0.5 14 NA
2099 2017-10-30 04:33:19 A5 0.5ul std NA yes 0.5 14 NA
2106 2017-10-30 16:25:45 OG281_CZO-Niwot_Tundra2_F1 1.5uL sample Niwot_Tundra2 yes 1.5 NA 150
2114 2017-10-31 04:08:42 A5 1.5ul std NA yes 1.5 14 NA
2132 2017-11-01 12:33:25 A5 conc 1ul std NA yes 1.0 140 NA
2138 2017-11-02 01:48:12 A5 conc 1.5ul std NA yes 1.5 140 NA
2027 2017-10-25 20:30:42 CO2 zero 3V on_off NA no NA NA NA
2031 2017-10-25 22:30:54 A5 0.5ul std NA yes 0.5 14 NA
2035 2017-10-26 04:50:43 A5 1.5ul std NA yes 1.5 14 NA
2044 2017-10-26 18:23:25 A5 4.5ul std NA no 4.5 14 NA
2053 2017-10-27 08:49:22 OG268_CZO-SJER_F1 1.5uL sample SJER yes 1.5 NA 50
2069 2017-10-28 06:37:31 A5 1.5ul std NA yes 1.5 14 NA
2096 2017-10-29 23:48:23 A5 1.5ul std NA yes 1.5 14 NA
2100 2017-10-30 06:08:16 A5 1.5ul std NA yes 1.5 14 NA
2107 2017-10-30 18:00:40 OG282_CZO-Niwot_Tundra1_F1 1.5uL sample Niwot_Tundra1 yes 1.5 NA 150
2115 2017-10-31 05:43:46 A5 3ul std NA yes 3.0 14 NA
2139 2017-11-02 09:13:36 A5 conc 1ul std NA yes 1.0 140 NA
2028 2017-10-25 20:39:02 CO2 zero 1.2V on_off NA no NA NA NA
2032 2017-10-26 00:05:49 A5 1.5ul std NA yes 1.5 14 NA
2036 2017-10-26 06:25:48 A5 3ul std NA yes 3.0 14 NA
2045 2017-10-26 20:40:08 A5 0.5ul std NA yes 0.5 14 NA
2056 2017-10-27 13:34:08 A5 1.5ul std NA yes 1.5 14 NA
2075 2017-10-28 14:27:22 A5 1.5ul std NA yes 1.5 14 NA
2097 2017-10-30 01:23:28 A5 3ul std NA yes 3.0 14 NA
2101 2017-10-30 07:43:23 A5 3ul std NA yes 3.0 14 NA
2116 2017-10-31 07:18:39 A5 conc 1ul std NA yes 1.0 140 NA
2136 2017-11-01 22:38:25 A5 conc 0.5ul std NA yes 0.5 140 NA
2140 2017-11-02 10:48:30 A5 conc 2ul std NA yes 2.0 140 NA
2029 2017-10-25 20:47:22 CO2 zero 0.7V on_off NA no NA NA NA
2033 2017-10-26 01:40:55 A5 3ul std NA yes 3.0 14 NA
2040 2017-10-26 13:07:47 A5 1.5ul std NA yes 1.5 14 NA
2046 2017-10-26 22:15:02 A5 1.5ul std NA yes 1.5 14 NA
2060 2017-10-27 17:54:33 A5 conc 1ul std NA no 1.0 140 NA
2086 2017-10-29 07:58:06 A5 1.5ul std NA yes 1.5 14 NA
2098 2017-10-30 02:58:24 A5 conc 1ul std NA yes 1.0 140 NA
2102 2017-10-30 09:18:16 A5 conc 1ul std NA yes 1.0 140 NA
2113 2017-10-31 02:33:47 A5 0.5ul std NA yes 0.5 14 NA
2117 2017-10-31 08:53:43 A5 conc 3ul std NA yes 3.0 140 NA
2137 2017-11-02 00:13:18 A5 conc 1ul std NA yes 1.0 140 NA

Peak Identification

Analyte peaks

Calibration

Single analysis calibration (for QA)

Coefficients

# look at coefficients and summary
stds_w_calibs %>% 
  # unnest calibration parameters
  iso_unnest_calibration_parameters(
    select_from_coefs = 
      c(term, estimate, SE = std.error, signif),
    select_from_summary = 
      c(fit_R2 = adj.r.squared, fit_RMSD = deviance, residual_df = df.residual)) %>%
  iso_remove_list_columns() %>% 
  arrange(term) %>% 
  knitr::kable(digits = 4)
Analysis calib file_datetime seed_oxidation injection_volume.uL mean_area_identified.Vs term estimate SE signif fit_R2 fit_RMSD residual_df
2032 lm(d13C ~ true_d13C) 2017-10-26 00:05:49 yes 1.5 7.2615 (Intercept) 11.2381 0.3698 *** 0.9981 0.1368 13
2033 lm(d13C ~ true_d13C) 2017-10-26 01:40:55 yes 3.0 13.8194 (Intercept) 11.0859 0.4703 *** 0.9969 0.2212 13
2034 lm(d13C ~ true_d13C) 2017-10-26 03:15:48 yes 0.5 1.8254 (Intercept) 11.2671 0.9756 *** 0.9870 0.9521 13
2035 lm(d13C ~ true_d13C) 2017-10-26 04:50:43 yes 1.5 7.4256 (Intercept) 10.8131 0.4285 *** 0.9974 0.1837 13
2036 lm(d13C ~ true_d13C) 2017-10-26 06:25:48 yes 3.0 14.2196 (Intercept) 10.8792 0.3646 *** 0.9981 0.1330 13
2041 lm(d13C ~ true_d13C) 2017-10-26 14:50:38 no 3.0 14.8699 (Intercept) 10.3123 3.0026 ** 0.8869 9.0195 13
2045 lm(d13C ~ true_d13C) 2017-10-26 20:40:08 yes 0.5 2.4771 (Intercept) 10.8889 0.6412 *** 0.9943 0.4113 13
2046 lm(d13C ~ true_d13C) 2017-10-26 22:15:02 yes 1.5 9.9667 (Intercept) 11.1801 0.4632 *** 0.9970 0.2147 13
2047 lm(d13C ~ true_d13C) 2017-10-26 23:50:04 yes 3.0 19.1787 (Intercept) 11.2081 0.3546 *** 0.9983 0.1258 13
2056 lm(d13C ~ true_d13C) 2017-10-27 13:34:08 yes 1.5 20.4067 (Intercept) 11.0069 0.3724 *** 0.9981 0.1387 13
2060 lm(d13C ~ true_d13C) 2017-10-27 17:54:33 no 1.0 47.1479 (Intercept) 11.4129 0.8419 *** 0.9904 0.7091 13
2075 lm(d13C ~ true_d13C) 2017-10-28 14:27:22 yes 1.5 8.3326 (Intercept) 11.2325 0.3605 *** 0.9982 0.1300 13
2086 lm(d13C ~ true_d13C) 2017-10-29 07:58:06 yes 1.5 9.7230 (Intercept) 11.1096 0.1856 *** 0.9995 0.0345 13
2093 lm(d13C ~ true_d13C) 2017-10-29 18:32:04 yes 0.5 2.8175 (Intercept) 12.0237 0.6659 *** 0.9941 0.4436 13
2096 lm(d13C ~ true_d13C) 2017-10-29 23:48:23 yes 1.5 12.2762 (Intercept) 11.2949 0.2081 *** 0.9994 0.0433 13
2097 lm(d13C ~ true_d13C) 2017-10-30 01:23:28 yes 3.0 23.1567 (Intercept) 11.3383 0.2171 *** 0.9993 0.0472 13
2099 lm(d13C ~ true_d13C) 2017-10-30 04:33:19 yes 0.5 3.4620 (Intercept) 10.3700 0.5911 *** 0.9949 0.3495 13
2100 lm(d13C ~ true_d13C) 2017-10-30 06:08:16 yes 1.5 13.6752 (Intercept) 11.1531 0.1618 *** 0.9996 0.0262 13
2101 lm(d13C ~ true_d13C) 2017-10-30 07:43:23 yes 3.0 26.5336 (Intercept) 11.0189 0.1998 *** 0.9994 0.0399 13
2102 lm(d13C ~ true_d13C) 2017-10-30 09:18:16 yes 1.0 62.7400 (Intercept) 10.7432 0.4240 *** 0.9974 0.1798 13
2113 lm(d13C ~ true_d13C) 2017-10-31 02:33:47 yes 0.5 1.9775 (Intercept) 11.5001 1.0634 *** 0.9846 1.1312 13
2114 lm(d13C ~ true_d13C) 2017-10-31 04:08:42 yes 1.5 7.8675 (Intercept) 11.3763 0.3359 *** 0.9984 0.1129 13
2115 lm(d13C ~ true_d13C) 2017-10-31 05:43:46 yes 3.0 15.0260 (Intercept) 11.2240 0.1824 *** 0.9995 0.0333 13
2117 lm(d13C ~ true_d13C) 2017-10-31 08:53:43 yes 3.0 120.6737 (Intercept) 9.7739 1.1193 *** 0.9815 1.2534 13
2136 lm(d13C ~ true_d13C) 2017-11-01 22:38:25 yes 0.5 13.4564 (Intercept) 10.9667 0.1148 *** 0.9998 0.0132 13
2137 lm(d13C ~ true_d13C) 2017-11-02 00:13:18 yes 1.0 33.9905 (Intercept) 11.3123 0.1869 *** 0.9995 0.0350 13
2139 lm(d13C ~ true_d13C) 2017-11-02 09:13:36 yes 1.0 40.8236 (Intercept) 11.2577 0.2570 *** 0.9991 0.0661 13
2140 lm(d13C ~ true_d13C) 2017-11-02 10:48:30 yes 2.0 81.1947 (Intercept) 10.7605 0.1660 *** 0.9996 0.0276 13
2032 lm(d13C ~ true_d13C) 2017-10-26 00:05:49 yes 1.5 7.2615 true_d13C 1.0118 0.0118 *** 0.9981 0.1368 13
2033 lm(d13C ~ true_d13C) 2017-10-26 01:40:55 yes 3.0 13.8194 true_d13C 1.0076 0.0150 *** 0.9969 0.2212 13
2034 lm(d13C ~ true_d13C) 2017-10-26 03:15:48 yes 0.5 1.8254 true_d13C 1.0145 0.0311 *** 0.9870 0.9521 13
2035 lm(d13C ~ true_d13C) 2017-10-26 04:50:43 yes 1.5 7.4256 true_d13C 0.9995 0.0137 *** 0.9974 0.1837 13
2036 lm(d13C ~ true_d13C) 2017-10-26 06:25:48 yes 3.0 14.2196 true_d13C 1.0001 0.0116 *** 0.9981 0.1330 13
2041 lm(d13C ~ true_d13C) 2017-10-26 14:50:38 no 3.0 14.8699 true_d13C 1.0085 0.0958 *** 0.8869 9.0195 13
2045 lm(d13C ~ true_d13C) 2017-10-26 20:40:08 yes 0.5 2.4771 true_d13C 1.0076 0.0205 *** 0.9943 0.4113 13
2046 lm(d13C ~ true_d13C) 2017-10-26 22:15:02 yes 1.5 9.9667 true_d13C 1.0137 0.0148 *** 0.9970 0.2147 13
2047 lm(d13C ~ true_d13C) 2017-10-26 23:50:04 yes 3.0 19.1787 true_d13C 1.0137 0.0113 *** 0.9983 0.1258 13
2056 lm(d13C ~ true_d13C) 2017-10-27 13:34:08 yes 1.5 20.4067 true_d13C 1.0071 0.0119 *** 0.9981 0.1387 13
2060 lm(d13C ~ true_d13C) 2017-10-27 17:54:33 no 1.0 47.1479 true_d13C 1.0217 0.0269 *** 0.9904 0.7091 13
2075 lm(d13C ~ true_d13C) 2017-10-28 14:27:22 yes 1.5 8.3326 true_d13C 1.0133 0.0115 *** 0.9982 0.1300 13
2086 lm(d13C ~ true_d13C) 2017-10-29 07:58:06 yes 1.5 9.7230 true_d13C 1.0049 0.0059 *** 0.9995 0.0345 13
2093 lm(d13C ~ true_d13C) 2017-10-29 18:32:04 yes 0.5 2.8175 true_d13C 1.0366 0.0213 *** 0.9941 0.4436 13
2096 lm(d13C ~ true_d13C) 2017-10-29 23:48:23 yes 1.5 12.2762 true_d13C 1.0110 0.0066 *** 0.9994 0.0433 13
2097 lm(d13C ~ true_d13C) 2017-10-30 01:23:28 yes 3.0 23.1567 true_d13C 1.0123 0.0069 *** 0.9993 0.0472 13
2099 lm(d13C ~ true_d13C) 2017-10-30 04:33:19 yes 0.5 3.4620 true_d13C 0.9830 0.0189 *** 0.9949 0.3495 13
2100 lm(d13C ~ true_d13C) 2017-10-30 06:08:16 yes 1.5 13.6752 true_d13C 1.0066 0.0052 *** 0.9996 0.0262 13
2101 lm(d13C ~ true_d13C) 2017-10-30 07:43:23 yes 3.0 26.5336 true_d13C 1.0020 0.0064 *** 0.9994 0.0399 13
2102 lm(d13C ~ true_d13C) 2017-10-30 09:18:16 yes 1.0 62.7400 true_d13C 0.9978 0.0135 *** 0.9974 0.1798 13
2113 lm(d13C ~ true_d13C) 2017-10-31 02:33:47 yes 0.5 1.9775 true_d13C 1.0174 0.0339 *** 0.9846 1.1312 13
2114 lm(d13C ~ true_d13C) 2017-10-31 04:08:42 yes 1.5 7.8675 true_d13C 1.0121 0.0107 *** 0.9984 0.1129 13
2115 lm(d13C ~ true_d13C) 2017-10-31 05:43:46 yes 3.0 15.0260 true_d13C 1.0082 0.0058 *** 0.9995 0.0333 13
2117 lm(d13C ~ true_d13C) 2017-10-31 08:53:43 yes 3.0 120.6737 true_d13C 0.9734 0.0357 *** 0.9815 1.2534 13
2136 lm(d13C ~ true_d13C) 2017-11-01 22:38:25 yes 0.5 13.4564 true_d13C 1.0030 0.0037 *** 0.9998 0.0132 13
2137 lm(d13C ~ true_d13C) 2017-11-02 00:13:18 yes 1.0 33.9905 true_d13C 1.0120 0.0060 *** 0.9995 0.0350 13
2139 lm(d13C ~ true_d13C) 2017-11-02 09:13:36 yes 1.0 40.8236 true_d13C 1.0149 0.0082 *** 0.9991 0.0661 13
2140 lm(d13C ~ true_d13C) 2017-11-02 10:48:30 yes 2.0 81.1947 true_d13C 0.9974 0.0053 *** 0.9996 0.0276 13

Global Calibration with all standards

Generate calibrations (*)

Coefficients

# look at coefficients and summary
global_calibs %>% 
  # unnest calibration parameters
  iso_unnest_calibration_parameters(
    select_from_coefs = 
      c(term, estimate, SE = std.error, signif),
    select_from_summary = 
      c(fit_R2 = adj.r.squared, fit_RMSD = deviance, residual_df = df.residual)) %>%
  iso_remove_list_columns() %>% 
  arrange(term) %>% 
  knitr::kable(digits = 4)
calib calib_ok term estimate SE signif fit_R2 fit_RMSD residual_df
linear TRUE (Intercept) 11.1100 0.0889 *** 0.9976 3.6232 298
with_area TRUE (Intercept) 11.1271 0.0882 *** 0.9977 3.5360 297
with_area_cross TRUE (Intercept) 11.2339 0.1346 *** 0.9977 3.5229 296
with_area TRUE area.Vs -0.0009 0.0003 ** 0.9977 3.5360 297
with_area_cross TRUE area.Vs -0.0058 0.0047 - 0.9977 3.5229 296
linear TRUE true_d13C 1.0075 0.0028 *** 0.9976 3.6232 298
with_area TRUE true_d13C 1.0074 0.0028 *** 0.9977 3.5360 297
with_area_cross TRUE true_d13C 1.0108 0.0043 *** 0.9977 3.5229 296
with_area_cross TRUE true_d13C:area.Vs -0.0002 0.0002 - 0.9977 3.5229 296

Evaluation

Data

Summary

sample compound n area.Vs mean area.Vs sd true_d13C_pred mean true_d13C_pred sd
CTNA nC22 1 14.60 NA -28.48 NA
CTNA nC24 1 20.30 NA -28.23 NA
CTNA nC25 1 32.69 NA -27.11 NA
CTNA nC27 1 64.38 NA -27.80 NA
CTNA nC28 1 31.02 NA -29.06 NA
CTNA nC29 1 47.43 NA -29.44 NA
CTNA nC30 1 25.78 NA -30.81 NA
CTNA nC31 1 14.99 NA -33.14 NA
Niwot_Tundra1 nC27 1 8.37 NA -31.84 NA
Niwot_Tundra1 nC29 1 26.45 NA -31.66 NA
Niwot_Tundra1 nC31 1 16.12 NA -31.79 NA
Niwot_Tundra2 nC27 1 10.31 NA -31.75 NA
Niwot_Tundra2 nC29 1 34.20 NA -31.59 NA
Niwot_Tundra2 nC31 1 16.15 NA -31.85 NA
SJER nC27 1 10.26 NA -36.49 NA
SJER nC29 1 24.28 NA -36.49 NA
SJER nC31 1 48.44 NA -38.30 NA

Final

Final data processing and visualization usually depends on the type of data and the metadata available for contextualization (e.g. core depth, source organism, age, etc.). The relevant metadata can be added easily with iso_add_file_info() during the initial data load / file info procesing. Alternatively, just call iso_add_file_info() again at this later point or use dplyr’s left_join directly.