From 146e3523cd5467401f7a0d1847c0e28a5dfb5498 Mon Sep 17 00:00:00 2001 From: SamGurr Date: Wed, 2 Oct 2024 21:50:02 -0400 Subject: [PATCH] size script small edit --- RAnalysis/Scripts/.Rhistory | 68 ++++++++++++++++++------------------- RAnalysis/Scripts/Size.Rmd | 13 +++---- 2 files changed, 41 insertions(+), 40 deletions(-) diff --git a/RAnalysis/Scripts/.Rhistory b/RAnalysis/Scripts/.Rhistory index 40f622c..f4979dd 100644 --- a/RAnalysis/Scripts/.Rhistory +++ b/RAnalysis/Scripts/.Rhistory @@ -1,37 +1,3 @@ -# str(df) -# number of runs -unique(df$Generation) # 1, 2, and 3 -Rep_Summary_all <- df %>% dplyr::select(c(Generation, Age, Parent_pCO2, Larvae_pCO2)) %>% -dplyr::group_by_all() %>% -dplyr::summarise(n=n()) -# print the runs -# summary: -Rep_Summary_G1 <- Rep_Summary_all %>% dplyr::filter(Generation %in% 1) # -Rep_Summary_G1 %>% kbl() %>% kable_classic(full_width = F, html_font = "Cambria") -Rep_Summary_G2 <- Rep_Summary_all %>% dplyr::filter(Generation %in% 2) # -Rep_Summary_G2 %>% kbl() %>% kable_classic(full_width = F, html_font = "Cambria") -Rep_Summary_G3 <- Rep_Summary_all %>% dplyr::filter(Generation %in% 3) # -Rep_Summary_G3 %>% kbl() %>% kable_classic(full_width = F, html_font = "Cambria") -df_Exp2 <- df%>% -filter(Generation=="1") %>% dplyr::mutate(Experiment = 2) -df_Exp4 <- df%>% -filter(Generation=="2") %>% dplyr::mutate(Experiment = 4) -df_Exp6 <- df%>% -filter(Generation=="3") %>% dplyr::mutate(Experiment = 6) -# create new columns for live and dead based on the count and proportion (of alive) to back calculate dead - these are integers! -df_Exp6 <- df_Exp6 %>% -dplyr::mutate(Count = -as.numeric(gsub(",","",Count))) %>% # remove the commas from these numbers- id as character if not removed! -dplyr::rename(Count_alive = Count) %>% # rename to avoid confusion -dplyr::mutate(proportion = Percent_Survival/100, -Count_total = case_when(proportion == 0 ~ 0, -proportion >0 ~ -(1/as.numeric(proportion))* -as.numeric(Count_alive)),# proportion is that of alive -Count_dead = Count_total - Count_alive) -# create new columns for live and dead based on the count and proportion (of alive) to back calculate dead - these are integers! -df_Exp6 <- df_Exp6 %>% -dplyr::mutate(Count = as.numeric(gsub(",","",Count))) %>% # remove the commas from these numbers- id as character if not removed! dplyr::rename(Count_alive = Count) %>% # rename to avoid confusion dplyr::mutate(proportion = Percent_Survival/100, @@ -510,3 +476,37 @@ tbl_regression(exp = TRUE) Exp6_coxph_test_table_3 Exp6_hazardratio_plot_3 <- ggforest(Exp6_coxph_test_3, data = binary_Exp6_larvae) Exp6_hazardratio_plot_3 +knitr::opts_chunk$set(echo = TRUE) +# SET WORKING DIRECTORY +#knitr::opts_knit$set(root.dir = "C:/Users/samjg/Documents/Github_repositories/EAD-ASEB-Airradians_Larvae_crossgen_OA/RAnalysis") # Sam's +# knitr::opts_knit$set(root.dir = +# "C:/Users/samjg/Documents/Github_repositories/EAD-ASEB-Airradians_Larvae_crossgen_OA/RAnalysis/") # Sam's work +knitr::opts_knit$set(root.dir = +"C:/Users/samuel.gurr/Documents/Github_repositories/EAD-ASEB-Airradians_Larvae_crossgen_OA/RAnalysis/") # Sam's work +# install.packages('gcookbook') +# LOAD PACKAGES ::::::::::::::::::::::::::::::::::::::::::::::::::::::: +library(dplyr) +library(ggplot2) +# install.packages('gcookbook') +# LOAD PACKAGES ::::::::::::::::::::::::::::::::::::::::::::::::::::::: +library(dplyr) +library(ggplot2) +library(reshape2) +# install.packages('gcookbook') +# LOAD PACKAGES ::::::::::::::::::::::::::::::::::::::::::::::::::::::: +library(dplyr) +library(ggplot2) +library(reshape2) +library(knitr) +library(car) +library(gcookbook) +library(ggpubr) +# LOAD DATA ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +# 8.16/2025 shannon assembled a means and SD dataset for the DIC+TA to calculate +CarbChem_Meseck_means <- read.csv(file="Data/Seawater_chemistry/raw/Seawater_Chemsitry_means_Meseck_20240816.csv", +header=TRUE) # load the chem data +# This is all the data, we can back calculate to get to what Shannon assembled or just use the one above.. +# if we come toa conclusion that TA+pH or pH+DIC is desired than we can do that +CarbChem_all <- read.csv(file="Data/Seawater_chemistry/raw/Seawater_Chemsitry_raw.csv", +header=TRUE) # load the chem data +CarbChem_Meseck_means diff --git a/RAnalysis/Scripts/Size.Rmd b/RAnalysis/Scripts/Size.Rmd index 9999689..c43ad23 100644 --- a/RAnalysis/Scripts/Size.Rmd +++ b/RAnalysis/Scripts/Size.Rmd @@ -12,8 +12,8 @@ output: html_document knitr::opts_chunk$set(echo = TRUE) # SET WORKING DIRECTORY #knitr::opts_knit$set(root.dir = "C:/Users/katherine.mcfarland/Documents/GitHub/EAD-ASEB-Airradians_Larvae_crossgen_OA/RAnalysis") # Katie's -knitr::opts_knit$set(root.dir = "C:/Users/samjg/Documents/Github_repositories/EAD-ASEB-Airradians_Larvae_crossgen_OA/RAnalysis") # Sam's -#knitr::opts_knit$set(root.dir = "C:/Users/samuel.gurr/Documents/Github_repositories/EAD-ASEB-Airradians_Larvae_crossgen_OA/RAnalysis") # Sam's work +#knitr::opts_knit$set(root.dir = "C:/Users/samjg/Documents/Github_repositories/EAD-ASEB-Airradians_Larvae_crossgen_OA/RAnalysis") # Sam's +knitr::opts_knit$set(root.dir = "C:/Users/samuel.gurr/Documents/Github_repositories/EAD-ASEB-Airradians_Larvae_crossgen_OA/RAnalysis") # Sam's work ``` @@ -34,7 +34,7 @@ library(nlme) library(lme4) library(multcomp) library(Matrix) - +?Matrix ``` @@ -805,6 +805,9 @@ lme_Exp4.emmeans.Age.letters <- multcomp::cld(object = lme_Exp4.emmeans.Age$emme library(DHARMa) # (2) GLMMs +library(lmerTest) # otherwise lme4 does not report table + +hist(Exp2_GLMMs$Length) # (2.1) All treatment Low, moderate, and high Exp2_GLMMs <- Exp2 %>% @@ -818,9 +821,7 @@ str(Exp2_GLMMs) # RUN STATISTICAL MODEL :::::::::::::::::::::::::::::::::: library(nlme) library(lme4) -library(lmerTest) # otherwise lme4 does not report table - -hist(Exp2_GLMMs$Length) +library(Matrix) # adjust a difference in two proportions for confounders: # to do so, you would run a logistic GLM with identity link.