# load isorun library
library(isorunN2O)

Processing step #1

Load data, assign categories, evaluate drift, correct for O17.

# processing step1
data.raw <- 
  %s 
  # select which columns to keep:
  select_columns(folder, date, analysis, run_number, category, name, volume, area, d45, d46, quiet = TRUE) %%>%%
  # identify excluded analyses
  change_category(run_number %%in%% c(%s), "excluded") %%>%%
  # drift correction 
  evaluate_drift(
    d45, d46, correct = %s, plot = TRUE, method = "%s", span = %s,
    correct_with = category %%in%% c(%s)) %%>%%
  # O17 correction
  correct_N2O_for_17O(d45.drift, d46.drift) %%>%%
  # introduce groupings for the lab reference, standard 1 & 2
  left_join(
    bind_rows(
      data_frame(category = c(%s), group = "Lab ref"),
      data_frame(category = c(%s), group = "Standard 1"),
      data_frame(category = c(%s), group = "Standard 2")
    ),
    by = "category"
  ) %%>%% 
  # introduce color and paneling for easier plotting
  mutate(
    panels = factor(group, levels = c("Lab ref", "Standard 1", "Standard 2")),
    colors = ifelse(group %%in%% c("Standard 1", "Standard 2"), name, category))

Overview plot

Here for d15.raw but could use others.

# static plot
data.raw %%>%% plot_overview(d15.raw, color = colors, panel = panels)
# make into interactive version
make_interactive() 

Standards

Here for d15.raw and d18.raw but could use different ones or more than these two.

# standards
data.raw %%>%% 
  # filter raw data to only look at the standards
  filter(group %%in%% c("Standard 1", "Standard 2")) %%>%% 
  # multie variable plot overview for d15.raw and d18.raw
  plot_overview(d15.raw, d18.raw, color = colors) + 
  # make use of ggplot's facet_wrap for panelling
  facet_wrap(panel ~ group, scales = "free", ncol = 2)

Processing step #2

Calculate concentrations and calibrate against isotopic standards. This is not implmented in the UI, implement this manually if interested in using.

# data.cal <- data.raw %%>%%
#   # calculate the background area based on analyses named 'background'
#   calculate_background(area, criteria = name %%in%% c("background")) %%>%%
#   # set the background area manually (use this as alternative to calculate_background)
#   set_background(0.251) %%>%%
#   # calculate the concentrations based on the standards (here with naming patter XuM)
#   calculate_concentrations(area, volume, conc_pattern = "(\\d+)uM",
#                            standards = category %%in%% c("USGS-34", "IAEA-NO3")) %%>%%
#   # calibrate d15 based on the two provided standards
#   calibrate_d15(d15.raw, standards = c(`USGS-34` = -1.8, `IAEA-NO3` = 4.7)) %%>%%
#   # calibrate d18 based on the two provided standards
#   calibrate_d18(d18.raw, cell_volume = 1.5, standards = c(`USGS-34` = -27.93, `IAEA-NO3` = 25.61))

Data overview / summary

Here for the raw data but could use for calibrated data as well.

# data overview
data.raw %%>%%
  # use grouping to calculate averages / stdevs for each group
  group_by(category) %%>%%
  # include d15.raw and d18raw as well as the area and include all samples
  generate_data_table(d15.raw, d18.raw, area, cutoff = 3) %%>%%
  # sort data
  ungroup() %%>%% arrange(desc(n), category) %%>%%
  # output in table format
  knitr::kable(digits = 2)

Export final data to Excel

Example of exporting specific parts of the data

# export data
data.raw %%>%% 
  # example: only select columns not starting with p. (parameter columns)
  select(-starts_with("p.")) %%>%%
  # sorting
  arrange(category, name) %%>%%
  # export to excel
  openxlsx::write.xlsx(file = "export.xlsx") 


sebkopf/isorunN2O documentation built on April 18, 2021, 6:57 p.m.