library(isorunN2O)

Processing step #1

Load data (from excel by default, from raw .dxf files is also presented but commented out, can delete if not used), assign categories, evaluate drift, correct for O17.

data.raw <- 

  ### approach #1: reading from original dxf files ###
  # # TODO: change to local folder
  # load_run_folder("%s", quiet = T) %%>%%
  # # pull out the data summary from the raw isodat file:
  # get_isodat_data_tables() %%>%% 
  # # derive file categories:
  # parse_file_names() %%>%% 
  # # discard the reference peaks:
  # select_N2O_peak( c(%d, %d) ) %%>%% 
  # # focus on the columns we care about:
  # rename(d45 = `d 45N2O/44N2O`, d46 = `d 46N2O/44N2O`, area = `Intensity All`) %%>%%

  ### approach #2: reading from N2O data viewer excel export ### 
  # TODO: change to local folder 
  readxl::read_excel("%s", sheet = "data") %%>%%

  ### regular processing for both approaches ###
  # 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.

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

Export data

Example of exporting specific parts of the data (not run here)

data.raw %%>%% 
  # only select columns not starting with p., ending in .raw or .drift and 
  # rename some columns while we're at it
  select(-starts_with("p."), -ends_with(".raw"), -ends_with(".drift"), d15 = d15.raw, d18 = d18.raw) %%>%%
  # sorting
  arrange(category, name) %%>%%
#  # export (not run, uncomment to run)
#  openxlsx::write.xlsx(file = "export.xlsx") %%>%%
  invisible() # invisible instead


KopfLab/dpos documentation built on May 8, 2019, 5:38 p.m.