knitr::opts_chunk$set(echo = FALSE, message = FALSE)
library(tidyverse)
library(here)
library(amstools)
library(HybridGIS)

options(digits = 4)
options(scipen = 3)

Data reduction and analysis for carbonate samples run on May 28, 2021. Includes C-1, C-2, and test shell carbonates from Simon Pendleton. This version compares the effect of including or discarding outliers.

#Raw AMS data results file path
file <- here("data/USAMS052621R.txt")

# Date samples run (needed to separate other experiments with this wheel/targets)
date <- as.Date("2021-05-28")

# Positions of normalizing standards
standards <- c(5, 8, 13, 17)

# Positions of blanks for blank correction
blanks <- c(6, 9, 11)

Data reduction proceeds as follows:

  1. Read raw file
  2. Apply 13C correction to each run of a target
  3. Flag outliers by interquartile distance
  4. Determine per-target means, internal and external errors
  5. Normalize targets using mean of standards and propagate errors
  6. Apply a large blank correction using the mean of blanks and propagate errors.

raw results

df <- get_hgis_data(file, date, standards)

Currents and ratios vs time.

df %>% 
  filter(!(Pos %in% 1:4)) %>% 
  plot_hgis_time(normFm, ce*normFm) +
  ggtitle("Sample ratio vs. time")
df %>% 
  filter(!(Pos %in% 1:4)) %>% 
  plot_hgis_time(he12C) +
  ggtitle("Sample current vs time")
# The data without outliers
df_sum <- sum_hgis_targets(df) %>% 
  norm_hgis() %>% 
  blank_cor_hgis(blanks = c(6, 9, 11)) %>% 
  mutate(outliers_dropped = TRUE)

# The data with outliers
df_sum_ol <- sum_hgis_targets(df, remove_outliers = FALSE) %>% 
  norm_hgis() %>% 
  blank_cor_hgis(blanks = c(6, 9, 11)) %>% 
  mutate(outliers_dropped = FALSE)

df_all <- rbind(df_sum, df_sum_ol)

Results

df_all %>% 
  filter(as.numeric(Pos) > 4) %>% 
  mutate(sig_normFm = max_err * normFm) %>% 
  select(Pos, Sample.Name, outliers_dropped, he12C, n_runs, fm_corr, sig_fm_corr) %>% 
  arrange(Sample.Name) %>% 
  knitr::kable()
  # gt::gt()
df_all %>% 
  filter(as.numeric(Pos) > 4) %>% 
  ggplot(aes(Sample.Name, fm_corr, color = outliers_dropped)) +
    geom_pointrange(aes(ymin = fm_corr - sig_fm_corr, ymax = fm_corr + sig_fm_corr),
                    size = 0.1) + 
    theme(axis.text.x = element_text(angle = 45, hjust=1)) +
      labs(x = NULL,
           y = "Fraction Modern")

Agreement of replicates

Compare results for samples with more than one replicate.

df_all %>% 
  filter(as.numeric(Pos) > 4) %>% 
   mutate(Name = str_remove(Sample.Name, "_.$")) %>% 
    group_by(Name, outliers_dropped) %>% 
    filter(n() > 1) %>% 
    summarize(across(c(he12C, fm_corr, sig_fm_corr),
                     list(mean = mean, sd = sd)),
              N = n()) %>% 
  knitr::kable()

Agreement with consensus

cons <- df_all %>% 
  filter(as.numeric(Pos) > 4,
         !is.na(fm_consensus)) %>% 
  select(Sample.Name, outliers_dropped, fm_consensus, fm_corr, sig_fm_corr) %>% 
  mutate(Fm_diff = fm_corr - fm_consensus,
         sigma = amstools::sigma(fm_corr, fm_consensus, sig_fm_corr)) %>% 
  arrange(Sample.Name)

knitr::kable(cons)

Mean error, difference from consensus, and sigma with and without outliers.

cons %>% 
  group_by(outliers_dropped) %>% 
  summarize(across(c(sig_fm_corr, Fm_diff, sigma), mean))


blongworth/HybridGIS documentation built on Dec. 19, 2021, 10:41 a.m.