Skip to content

Commit

Permalink
updated calibrations
Browse files Browse the repository at this point in the history
  • Loading branch information
kaitlin-rempfert committed Feb 27, 2023
1 parent be0a7aa commit 99b9e4d
Show file tree
Hide file tree
Showing 36 changed files with 2,334 additions and 53 deletions.
27 changes: 20 additions & 7 deletions 160512_run1_calibration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,13 @@ plot_nmoles <- df_w_conc %>%
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
guides(color = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check for if calibration is ok
plot_nmoles_ggplot <- plot_nmoles +
geom_point(aes(shape = df_w_conc$area_in_calib, fill = category, color = category)) +
geom_point(aes(shape = df_w_conc$area_calib_ok, fill = category, color = category)) +
scale_shape_manual(values = c(21, 22)) +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL))
plot_nmoles_ggplot
#interactive plot to see individual sample names from plot above
Expand Down Expand Up @@ -484,12 +484,12 @@ N_plot <- df_final %>%
xlab("Run Number") +
guides(color = guide_legend(title = NULL), shape = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check if calibration is ok
plot_Nisotopes_ggplot <- N_plot +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
ylab(latex2exp::TeX("$\\delta^{15}N$")) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
plot_Nisotopes_ggplot
```
Expand All @@ -510,12 +510,12 @@ O_plot <- df_final %>%
guides(color = guide_legend(title = NULL), shape = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check if calibration is OK
plot_Oisotopes_ggplot <- O_plot +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
ylab(latex2exp::TeX("$\\delta^{18}O$")) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
plot_Oisotopes_ggplot
```
Expand All @@ -538,6 +538,7 @@ df_final %>% group_by(category, name) %>%
iso_summarize_data_table(cutoff = 1, d15N, d15N_err, d18O, d18O_err, conc, conc_err)
```

## Export samples
```{r, include=FALSE}
df_final %>%
filter(category %in% c("OM15", "OM16")) %>%
Expand All @@ -550,3 +551,15 @@ df_final %>%
# saveRDS
```

## Export standards data
```{r, include=FALSE}
df_final %>%
filter(category %in% c("USGS-34", "IAEA-NO3")) %>%
select(analysis, run_number, volume, area, name, category, conc, conc_err, d15N, d15N_err, d18O, d18O_err, compound) %>%
write.csv(file = file.path("data", "calibrated", "run1_stds_calib_data_export.csv"))
df_final %>%
filter(category %in% c("USGS-34", "IAEA-NO3")) %>%
saveRDS(file = file.path("data", "calibrated", "df_stds_run1"))
# saveRDS
```
34 changes: 24 additions & 10 deletions 160519_run2_calibration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ $\delta^{45}N_{2}O$ and $\delta^{46}N_{2}O$ in $‰$ are represented as d45 and
```{r "raw data summary"}
#table of average and standard deviations of peak areas, d45, and d46 for standards and controls
df.raw %>% group_by(category, name) %>%
iso_summarize_data_table(area, d45, d46, cutoff = 3) %>%
knitr::kable(digits=1)
iso_summarize_data_table(area, d45, d46, cutoff = 3)
```


Expand Down Expand Up @@ -150,7 +149,7 @@ df.drift <- df.raw %>% evaluate_drift(d45, d46, correct = TRUE, method = "lm", c
#linear calibration applied; new columns d45.drift, d46.drift, p.drift created
```

## $^{17}$O correction
### $^{17}$O correction
Correction for $^{17}$O isobaric interference in the mass 45 peak according to Kaiser et al. (2008) to derive raw $\delta^{15}N$ and $\delta^{18}O$ values.
```{r}
df.O17 <- df.drift %>%
Expand Down Expand Up @@ -255,13 +254,13 @@ plot_nmoles <- df_w_conc %>%
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
guides(color = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check or if calibration was ok
plot_nmoles_ggplot <- plot_nmoles +
geom_point(aes(shape = df_w_conc$area_in_calib, fill = df_w_conc$category, color = df_w_conc$category)) +
geom_point(aes(shape = df_w_conc$area_calib_ok, fill = df_w_conc$category, color = df_w_conc$category)) +
scale_shape_manual(values = c(21, 22)) +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL))
plot_nmoles_ggplot
#interactive plot to see individual sample names from plot above
Expand Down Expand Up @@ -437,12 +436,12 @@ N_plot <- df_final %>%
xlab("Run Number") +
guides(color = guide_legend(title = NULL), shape = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check for if calibration was ok
plot_Nisotopes_ggplot <- N_plot +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
ylab(latex2exp::TeX("$\\delta^{15}N$")) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
plot_Nisotopes_ggplot
```
Expand All @@ -463,12 +462,12 @@ O_plot <- df_final %>%
guides(color = guide_legend(title = NULL), shape = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check for if the calibration was ok
plot_Oisotopes_ggplot <- O_plot +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
ylab(latex2exp::TeX("$\\delta^{18}O$")) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
plot_Oisotopes_ggplot
```
Expand All @@ -495,6 +494,8 @@ df_final %>% group_by(category, name) %>%
iso_summarize_data_table(cutoff = 1, d15N, d15N_err, d18O, d18O_err, conc, conc_err)
```


## Export Samples Data
```{r, include=FALSE}
df_final %>%
filter(category %in% c("OM15")) %>%
Expand All @@ -506,3 +507,16 @@ df_final %>%
saveRDS(file = file.path("data", "calibrated", "df_final_run2"))
# saveRDS
```

## Export standards data
```{r, include=FALSE}
df_final %>%
filter(category %in% c("USGS-34", "IAEA-NO3")) %>%
select(analysis, run_number, volume, area, name, category, conc, conc_err, d15N, d15N_err, d18O, d18O_err, compound) %>%
write.csv(file = file.path("data", "calibrated", "run2_stds_calib_data_export.csv"))
df_final %>%
filter(category %in% c("USGS-34", "IAEA-NO3")) %>%
saveRDS(file = file.path("data", "calibrated", "df_stds_run2"))
# saveRDS
```
23 changes: 18 additions & 5 deletions 160602_run3_calibration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ plot_nmoles <- df_w_conc %>%
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
guides(color = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check for if calibration ok
plot_nmoles_ggplot <- plot_nmoles +
geom_point(aes(shape = df_w_conc$area_in_calib, fill = df_w_conc$category, color = df_w_conc$category)) +
geom_point(aes(shape = df_w_conc$area_calib_ok, fill = df_w_conc$category, color = df_w_conc$category)) +
scale_shape_manual(values = c(21, 22)) +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL))
plot_nmoles_ggplot
#interactive plot to see individual sample names from plot above
Expand Down Expand Up @@ -379,12 +379,12 @@ N_plot <- df_final %>%
xlab("Run Number") +
guides(color = guide_legend(title = NULL), shape = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check for if calibration ok
plot_Nisotopes_ggplot <- N_plot +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
ylab(latex2exp::TeX("$\\delta^{15}N$")) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
plot_Nisotopes_ggplot
Expand Down Expand Up @@ -422,3 +422,16 @@ df_final %>%
saveRDS(file = file.path("data", "calibrated", "df_final_run3"))
# saveRDS
```

## Export standards data
```{r, include=FALSE}
df_final %>%
filter(category %in% c("USGS-34", "IAEA-NO3")) %>%
select(analysis, run_number, volume, area, name, category, conc, conc_err, d15N, d15N_err, compound) %>%
write.csv(file = file.path("data", "calibrated", "run3_stds_calib_data_export.csv"))
df_final %>%
filter(category %in% c("USGS-34", "IAEA-NO3")) %>%
saveRDS(file = file.path("data", "calibrated", "df_stds_run3"))
# saveRDS
```
43 changes: 29 additions & 14 deletions 20170321_run4_calibration.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ df.raw <- raw_data %>%
category = ifelse(grepl("ICDSTD", category), "IS", category)) %>%
#label conditioners
change_category(run_number < 9, "Conditioner") %>%
change_category(grepl("HPW", name), "Background") %>%
change_category(grepl("HPW", name), "Degassed") %>%
change_category(grepl("ICDSTD", name), "control") %>% #select only relevant categories from metadata for downstream processing
filter(category %in% c("Background", "Degassed", "control", "N2O", "Conditioner", "OM17", "USGS-34", "IAEA-NO3"))
Expand Down Expand Up @@ -276,13 +276,13 @@ plot_nmoles <- df_w_conc %>%
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
guides(color = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check for if calibration is ok
plot_nmoles_ggplot <- plot_nmoles +
geom_point(aes(shape = df_w_conc$area_in_calib, fill = df_w_conc$category, color = df_w_conc$category)) +
geom_point(aes(shape = df_w_conc$area_calib_ok, fill = df_w_conc$category, color = df_w_conc$category)) +
scale_shape_manual(values = c(21, 22)) +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL))
plot_nmoles_ggplot
#interactive plot to see individual sample names from plot above
Expand Down Expand Up @@ -347,7 +347,7 @@ N_residuals <- df_calibN %>%
ggplotly(N_residuals)
#multiple regressions using concentration or volume are not better than the simple linear calibration model
#multiple regressions using concentration is better than the simple linear calibration model
```

### Generate calibration for O
Expand Down Expand Up @@ -391,11 +391,11 @@ ggplotly(O_residuals)
```

### Apply calibration
Applying a multiple regression calibration with volume for N and O
Applying a multiple regression calibration with concentration for N and O
```{r warning = FALSE}
# apply linear calibration for N for subrun 1
# apply multiple regression calibration with concentration for N for subrun 1
df_finalN1 <- df_calibN %>%
filter(d15N_calib == "Nlinear")%>%
filter(d15N_calib == "Nwith_conc")%>%
filter (subrun == "subrun 1") %>%
iso_apply_calibration(
predict = true_d15N,
Expand All @@ -404,9 +404,9 @@ filter(d15N_calib == "Nlinear")%>%
) %>%
iso_get_calibration_data() %>% iso_remove_list_columns()
# apply linear calibration for N for subrun 2
# apply multiple regression calibration with concentration for N for subrun 2
df_finalN2 <- df_calibN %>%
filter(d15N_calib == "Nwith_volume")%>%
filter(d15N_calib == "Nwith_conc")%>%
filter (subrun == "subrun 2") %>%
iso_apply_calibration(
predict = true_d15N,
Expand Down Expand Up @@ -478,12 +478,12 @@ N_plot <- df_final %>%
xlab("Run Number") +
guides(color = guide_legend(title = NULL), shape = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check for if calibration is ok
plot_Nisotopes_ggplot <- N_plot +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
ylab(latex2exp::TeX("$\\delta^{15}N$")) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
plot_Nisotopes_ggplot
Expand All @@ -510,12 +510,12 @@ O_plot <- df_final %>%
guides(color = guide_legend(title = NULL), shape = guide_legend(title = NULL))
#ggplot version with calibration range
#ggplot version with check if calibration ok
plot_Oisotopes_ggplot <- O_plot +
scale_fill_manual(values = cbPalette) +
theme_figure(grid = TRUE, legend = TRUE, text_size = 20) +
ylab(latex2exp::TeX("$\\delta^{18}O$")) +
guides(shape = guide_legend(title = "In calibration range"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
guides(shape = guide_legend(title = "Calibration OK"), fill = guide_legend(title = NULL), color = guide_legend(title = NULL))
plot_Oisotopes_ggplot
Expand Down Expand Up @@ -545,6 +545,8 @@ df_final %>% group_by(category, name) %>%
iso_summarize_data_table(cutoff = 1, d15N, d15N_err, d18O, d18O_err, conc, conc_err)
```


## Export Sample Data
```{r, include=FALSE}
df_final %>%
filter(category == "OM17") %>%
Expand All @@ -556,3 +558,16 @@ df_final %>%
saveRDS(file = file.path("data", "calibrated", "df_final_run4"))
# saveRDS
```

## Export standards data
```{r, include=FALSE}
df_final %>%
filter(category %in% c("USGS-34", "IAEA-NO3")) %>%
select(analysis, run_number, volume, area, name, category, conc, conc_err, d15N, d15N_err, d18O, d18O_err, compound) %>%
write.csv(file = file.path("data", "calibrated", "run4_stds_calib_data_export.csv"))
df_final %>%
filter(category %in% c("USGS-34", "IAEA-NO3")) %>%
saveRDS(file = file.path("data", "calibrated", "df_stds_run4"))
# saveRDS
```
Loading

0 comments on commit 99b9e4d

Please sign in to comment.