BIOL321MR Preliminary Graphs and Analyses

Author

Willow Gumpel-Jones, Annalise Kulhmann, Micah Lohr, Kathleen Strachota

Setup (packages and data cleaning)

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.0     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.1     ✔ tibble    3.1.8
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(ggplot2)
library(lubridate)
library(ggsci)
library(readxl)
library(packrat)

#Load 7C temp data
mussel_cold <- read.csv("/Users/madelinelohr/BIOSTATS/mussel_cold.csv")
cold <- mussel_cold

#Load control tank temp data 
mussel_ctrl <- read.csv("/Users/madelinelohr/BIOSTATS/mussel_ctrl.csv")
ctrl <- mussel_ctrl

# Load big mussel data sheet
MKAW_mussel <- read.csv("/Users/madelinelohr/BIOSTATS/MKAW_mussel.csv")
MKAW <- MKAW_mussel

#Fix dates 
cold2 <- cold %>% 
   select(entry,Date_time,Temp) 

cold2$Date_time <- mdy_hms(cold2$Date_time)

cold2 <- cold2 %>% 
  mutate(date=as_date(Date_time))

ctrl$Date_time <- mdy_hms(ctrl$Date_time)
ctrl2 <- ctrl %>% 
  mutate(date=as_date(Date_time)) 

#Make a growth variable for later 
growth = (MKAW$Start_Length_mm - MKAW$End_Length_mm)
MKAW2 <- cbind(MKAW, growth) 

MKAW3 <- MKAW2 %>% 
  drop_na(growth)

Graphs and Analyses

Temperature

cold_means <- cold2 %>% 
  group_by(date) %>% 
  summarize(mean=mean(Temp), sd=sd(Temp), n=n(), se=sd/sqrt(n))

ctrl_means <- ctrl2 %>% 
  group_by(date) %>% 
  summarize(mean=mean(Temp), sd=sd(Temp), n=n(), se=sd/sqrt(n))

temp_plot <- ggplot()+
  geom_line(data=cold_means, aes(x=date, y=mean, color="Treatment (7 \u00B0C)"))+
  geom_line(data=ctrl_means, aes(x=date, y=mean,color="Control (15 \u00B0C)"))+
  ylim(0,18)+
  labs(x="Date", y="Average Temperature (\u00B0C)", color="Legend")+
  theme_classic()+
  scale_color_aaas()
temp_plot

We feel that we do not need statistical analysis for this data. The purpose of the graph was to visualize that the temperature in each respective tank remained consistent, and that the control and treatment tanks were held at different temperatures.

Body Size

bodysize_means <- MKAW3 %>% 
  group_by(Population,Treatment) %>% 
  summarize(mean=mean(Start_Length_mm), sd=sd(Start_Length_mm), n=n(), se=sd/sqrt(n))
`summarise()` has grouped output by 'Population'. You can override using the
`.groups` argument.
body_size_plot <- ggplot(data=bodysize_means, aes(x=Population, y=mean, color=Treatment))+
  geom_point()+
  geom_errorbar(data=bodysize_means, aes(ymin=mean-se, ymax=mean+se), width=0.5)+
  geom_jitter(data=MKAW3, aes(x=Population,y=Start_Length_mm, color=Treatment),alpha=0.5, width=0.5)+
  theme_classic()+
  scale_color_aaas()+
  labs(x="Population", y="Mean Length (mm)")
body_size_plot

aov_start_poptreat <- aov(data=MKAW3, Start_Length_mm~Treatment*Population)
summary(aov_start_poptreat)
                     Df Sum Sq Mean Sq F value Pr(>F)  
Treatment             1   75.0   75.04   1.606 0.2148  
Population            1  191.5  191.46   4.098 0.0519 .
Treatment:Population  1    0.0    0.00   0.000 0.9950  
Residuals            30 1401.4   46.71                 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
aov_end_poptreat <- aov(data=MKAW3, End_Length_mm~Treatment*Population)
summary(aov_end_poptreat)
                     Df Sum Sq Mean Sq F value Pr(>F)  
Treatment             1   68.9   68.89   1.472 0.2345  
Population            1  186.9  186.86   3.993 0.0548 .
Treatment:Population  1    0.1    0.14   0.003 0.9564  
Residuals            30 1403.8   46.79                 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Growth

avg_growth <- MKAW3 %>% 
  group_by(Treatment) %>% 
  summarize(mean=mean(growth), sd=sd(growth), n=n(), se=sd/sqrt(n), Population)
Warning: Returning more (or less) than 1 row per `summarise()` group was deprecated in
dplyr 1.1.0.
ℹ Please use `reframe()` instead.
ℹ When switching from `summarise()` to `reframe()`, remember that `reframe()`
  always returns an ungrouped data frame and adjust accordingly.
`summarise()` has grouped output by 'Treatment'. You can override using the
`.groups` argument.
growth_plot <- ggplot(data=avg_growth, aes(x=Treatment, y=mean))+
  geom_point()+
  geom_errorbar(data=avg_growth, aes(ymin=mean-se, ymax=mean+se),width=0.2)+
  labs(y="Average Growth", x="Treatment")+
  theme_classic()
growth_plot

aov_poptreat <- aov(growth~Treatment*Population, data=MKAW3)

summary(aov_poptreat)
                     Df Sum Sq Mean Sq F value Pr(>F)  
Treatment             1 0.1313 0.13134   3.004 0.0933 .
Population            1 0.0279 0.02788   0.638 0.4308  
Treatment:Population  1 0.1771 0.17713   4.052 0.0532 .
Residuals            30 1.3114 0.04371                 
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1