##Growth and condition factor library(plyr) library(lubridate) library(ggplot2) library(gridExtra) rm(list = ls()) setwd("ENTER DIRECTORY HERE") #######Read in data###### fish <- read.csv("fish_summer_recaptures.csv") fish$year <- as.factor(as.character(fish$year)) fish$date<- mdy(fish$date) fish$growth_g <- fish$wt-fish$wt_early_summer fish$growth_g_day <- fish$growth_g/fish$days_since_last_capture colors <- c("orangered2","steelblue2","dark blue") ###Figure 3### p1 <- ggplot(data=fish, aes(x=year,y=growth_mm_day,fill=year))+geom_boxplot()+ scale_fill_manual(values=colors)+theme_classic(12)+theme(legend.position = "none")+ labs(x="",y="Growth (mm/day)") p1 ggsave("ENTER DIRECTORY HERE/Figure 3.jpg", plot = last_plot(), device = NULL, path = NULL, scale = 1, width = 3, height =3, units = "in", dpi = 300) ##Figure S1#### p2 <- ggplot(data=fish, aes(x=year,y=growth_g_day,fill=year))+geom_boxplot()+ scale_fill_manual(values=colors)+theme_classic(12)+theme(legend.position = "none")+ labs(x="",y="Growth (g/day)") p2 ggsave("ENTER DIRECTORY HERE/Figure S1.jpg", plot = last_plot(), device = NULL, path = NULL, scale = 1, width = 3, height =3, units = "in", dpi = 300) ##plot of initial Fl an wt for supplemental early_summer <- ggplot(data=fish, aes(x = FL_early_summer))+geom_histogram(bins=20,color="black")+ facet_wrap(~year)+theme_classic(12)+theme(strip.background = element_blank())+ labs(x = "FL (mm) in July", y = "Count") early_summer late_summer <- ggplot(data=fish, aes(x = FL))+geom_histogram(bins=20,color="black")+ facet_wrap(~year)+theme_classic(12)+theme(strip.background = element_blank())+ labs(x = "FL (mm) in September", y = "Count") late_summer g <- grid.arrange(early_summer, late_summer, ncol=1) ggsave("ENTER DIRECTORY HERE/Figure S4.jpg", g, device = NULL, path = NULL, scale = 1, width = 6, height =4, units = "in", dpi = 300) early_summer_wt <- ggplot(data=fish, aes(x = wt_early_summer))+geom_histogram(bins=15,color="black")+ facet_wrap(~year)+theme_classic(12)+theme(strip.background = element_blank())+ labs(x = "Mass (g) in July", y = "Count") early_summer_wt late_summer_wt <- ggplot(data=fish, aes(x = wt))+geom_histogram(bins=15,color="black")+ facet_wrap(~year)+theme_classic(12)+theme(strip.background = element_blank())+ labs(x = "Mass (g) in September", y = "Count") late_summer_wt g<-grid.arrange(early_summer_wt, late_summer_wt, ncol=1) ggsave("ENTER DIRECTORY HERE/Figure S5.jpg", g, device = NULL, path = NULL, scale = 1, width = 6, height =4, units = "in", dpi = 300) ###ANOVAs fit <- lm(growth_mm_day ~ year, data = fish) anova(fit) summary(fit) fit <- lm(growth_g_day ~ year, data = fish) anova(fit) summary(fit) fit <- lm(growth_mm_day ~ FL, data = fish) summary(fit) fit <- lm(FL ~ FL_early_summer, data = fish) summary(fit) confint(fit, 'FL_early_summer', level=0.95) df_predict <- data.frame(FL_early = seq(from=50,to=200,by=1), FL_late = predict(fit, list(FL_early_summer = seq(from=50,to=200,by=1)))) ##Looking at dataframe, at FL = 120, FL early summer == FL late summer #### ##plot of initial FL by final FL - Figure S2 ### #### p <- ggplot(data=fish, aes(x = FL_early_summer, y = FL))+ geom_point(color="gray 50",size=1.2, alpha=0.8)+ geom_line(aes(x=FL_early_summer,y=FL_early_summer), color = "black",linetype=1,size=1)+ labs(x = "July Fork Length (mm)", y = "September Fork Length (mm)")+ geom_smooth(method = "lm", color ="red",size=.75,se=F)+ theme_classic(12) p ggsave("ENTER DIRECTORY HERE/Figure S2.jpg", plot = last_plot(), device = NULL, path = NULL, scale = 1, width = 3, height =3, units = "in", dpi = 300) ###################### ###Condition Factor### ###################### allfish <- read.csv("efish_2015_2016_2017_Elder_Fox.csv") allfish$date <- mdy(allfish$date) allfish$month <- month(allfish$date) ###End of summer condition factor sept <- subset(allfish, month %in% c(9,10)) sept$year<- as.factor(as.character(sept$year)) ##ancova fit_sept <- lm(log(wt)~log(FL)*year, data = sept) summary(fit_sept) anova(fit_sept) exp(4.954545) ##at what length do the lines intersect test <- subset(sept, FL < 142) 982/1022 ##how many fish are under 142 mm FL intercept = fit_sept$coefficients[1] log_FL_p= fit_sept$coefficients[2] year2016 = fit_sept$coefficients[3] year2017 = fit_sept$coefficients[4] log_FL_16 =fit_sept$coefficients[5] log_FL_17 = fit_sept$coefficients[6] log_FL = seq(3.5, 5.5, length.out=100) wt_2015 = intercept+log_FL*log_FL_p wt_2016 = intercept+log_FL*log_FL_p+log_FL*log_FL_16+year2016 wt_2017 = intercept+log_FL*log_FL_p+log_FL*log_FL_17+year2017 preddata_horiz <- data.frame(logFL =log_FL,wt_2015 = wt_2015, wt_2016 =wt_2016, wt_2017 = wt_2017) preddata_horiz$wt16_more_wt15<- 0 preddata_horiz$wt16_more_wt15[preddata_horiz$wt_2016>preddata_horiz$wt_2015]<-1 preddata_horiz$wt16_more_wt17<- 0 preddata_horiz$wt16_more_wt17[preddata_horiz$wt_2016>preddata_horiz$wt_2017]<-1 preddata_horiz$wt15_more_wt17<- 0 preddata_horiz$wt15_more_wt17[preddata_horiz$wt_2015>preddata_horiz$wt_2017]<-1 preddata <- data.frame(logFL = rep(log_FL,3),year= c(rep("2015",100),rep("2016",100),rep("2017",100)),logwt = c(wt_2015,wt_2016, wt_2017)) preddata$year<- as.factor(preddata$year) ####Figure 5 p <- ggplot()+geom_point(data=sept, aes(x = log(FL), y = log(wt),color = year),size=1.2,alpha=0.5)+ geom_line(data=preddata,aes(y=logwt, x= logFL, color=year))+scale_color_manual(values = colors)+ theme_classic(12)+theme(legend.position = c(0.2,0.8),legend.title = element_blank())+ labs(x ="Fork Length (log-mm)",y = "Weight (log-g)") p ggsave("ENTER DIRECTORY HERE/Figure 5.jpg", plot = last_plot(), device = NULL, path = NULL, scale = 1, width = 3, height =3, units = "in", dpi = 300) ######################################## ####Do pools hang onto their biomass?### ######################################### #comparing biomass in pools in Sept with pools in July catch_by_pool_sept <- ddply(sept, .(year, location, pool), summarize, num_fish_sept = sum(FL>0), num_yoy_sept = sum(FL<85),num_oneplus_sept = sum(FL>85), biomass_sept=sum(wt,na.rm=T)) catch_by_pool_july <- ddply(subset(allfish,month %in% c(7,8)), .(year, location, pool),summarize, num_fish_july = sum(FL>0), num_yoy_july = sum(FL<85),num_oneplus_july = sum(FL>85), biomass_july=sum(wt,na.rm=T)) ##combine into one data frame for pools that were sampled in July and September density_compare <- merge(catch_by_pool_sept, catch_by_pool_july, by = c("location","pool","year")) density_compare$year <- as.factor(as.character(density_compare$year)) colors <- c("orangered2","steelblue2","dark blue") fit <- lm(biomass_sept ~ biomass_july*year, data = density_compare) summary(fit) anova(fit)