--- title: "Cort lab Anth 253 S22: Assay results" output: html_document: theme: lumen toc: true toc_depth: 3 --- ```{r setup load data, include=FALSE} knitr::opts_chunk$set(message = FALSE, warning = FALSE) library(tidyverse) library(googlesheets4) library(kableExtra) library(ggrepel) library(magrittr) urine <- read_sheet("https://docs.google.com/spreadsheets/d/1A2ARxMgr0WwaTr3QXXuJn8CaPPe0kDFj5zU3NRYcU8E/edit?usp=sharing", sheet = 1) %>% select(-time_of_day) saliva <- read_sheet("https://docs.google.com/spreadsheets/d/1A2ARxMgr0WwaTr3QXXuJn8CaPPe0kDFj5zU3NRYcU8E/edit?usp=sharing", sheet = 2) results <- read_sheet("https://docs.google.com/spreadsheets/d/1A2ARxMgr0WwaTr3QXXuJn8CaPPe0kDFj5zU3NRYcU8E/edit?usp=sharing", sheet = 3) sample_info <- full_join(urine, saliva) cort_df <- left_join(sample_info, results, by = "sample_ID") ``` ### Q1. Interpret adjustments to cortisol concentrations Notice (below) how I adjusted raw cortisol concentrations according to the media they were measured in. - Cortisol in *urine* samples is corrected for sample water content, such that cort concentration is multiplied by a factor of sample specific gravity relative to the population average specific gravity. - Cortisol in *saliva* samples is corrected for saliva production, by multiplying cort concentration by flow rate and creating a measure of analyte "output" in pg/min. ```{r} cort_df %<>% # create correction factors: mutate(flow_rate = vol_ml/duration_collection) %>% # flow_rate = saliva ml/min mutate(pop_SG = mean(SG, na.rm = T)) %>% # adjusting cortisol concentrations: mutate(cort_adj = case_when( # if urine sample... grepl("U$", sample_ID) ~ cort_pgml*(SG/pop_SG), # if saliva sample (cort_adj = cort pg/min) grepl("S", sample_ID) ~ cort_pgml*flow_rate)) %>% # # anticipating viz mutate(ID = as.factor(ID)) %>% mutate(am_pm = case_when( grepl("AM", sample_ID) ~ "AM", grepl("PM", sample_ID) ~ "PM", TRUE ~ NA_character_ )) ``` - **Explain** how the SG correction factor changes urinary concentrations of analyte. (e.g. how does raw cort_pgml change when sample SG is much lower than population SG?) You can look at the data themselves to intuit this. ```{r urinary cort example, echo=FALSE} cort_df %>% filter(grepl("U$", sample_ID)) %>% select(sample_ID, SG, pop_SG, cort_pgml, cort_adj) %>% mutate(across(where(is.numeric), round, 3)) %>% kbl() %>% kable_classic_2() ``` - **Explain** how flow rate (ml/min) changes salivary cort values (pg/ml). (e.g. how does slow saliva production change raw cort_pgml?) Again, below are the data to help understand. ```{r salivary cort example, echo = FALSE} cort_df %>% filter(grepl("S", sample_ID) & !is.na(cort_pgml)) %>% select(sample_ID, flow_rate, cort_pgml, cort_adj) %>% mutate(across(where(is.numeric), round, 3)) %>% kbl() %>% kable_classic_2() ``` $~$ $~$ $~$ ### Q2. Interpret results from urinary samples Briefly characterize the results of our diurnal cortisol analysis. In a study that aimed to measure individual baseline cortisol, how would you control for cortisol's circadian rhythm? ```{r urine plot, echo = FALSE, fig.cap= "Diurnal changes in urinary cortisol"} u_df <- cort_df %>% filter(grepl("U$", sample_ID)) u_label <- u_df %>% filter(am_pm != "PM") u_df %>% ggplot(aes(x = am_pm, y = cort_adj, group = ID, color = ID)) + geom_point() + geom_line() + geom_label_repel(data = u_label, aes(label = ID), hjust = 0) + labs(x = "Sample Time", y = "Urinary Cortisol pg/ml") + theme_minimal() + theme(legend.position = "none") ``` $~$ $~$ $~$ ### Q3. Interpret results from salivary samples We barely got any results from our saliva samples, primarily because the second AM samples had OD's (optical density values) that were below the range of the standard curve. Making lemonade from lemons, what do our results still allow us to infer about morning changes in cort? ```{r saliva plot, echo = FALSE, fig.cap= "Cortisol after rising in saliva"} s_df <- cort_df %>% filter(grepl("S", sample_ID)) %>% mutate(ID = as.factor(ID)) %>% mutate(am_lab = case_when( grepl("S.1", sample_ID) ~ "1", grepl("S.2", sample_ID) ~ "2" )) s_label <- s_df %>% filter(am_lab == "1") s_df %>% ggplot(aes(x = am_lab, y = cort_adj, group = ID, color = ID)) + geom_point() + geom_line() + geom_label_repel(data = s_label, aes(label = ID), hjust = 0) + labs(x = "AM sample", y = "Salivary Cortisol pg/min") + theme_minimal() + theme(legend.position = "none") ```