R Session Info
sessionInfo()
## R version 3.4.4 (2018-03-15)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: macOS High Sierra 10.13.3
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## loaded via a namespace (and not attached):
## [1] compiler_3.4.4 backports_1.1.2 magrittr_1.5 rprojroot_1.3-2
## [5] tools_3.4.4 htmltools_0.3.6 yaml_2.1.18 Rcpp_0.12.16
## [9] stringi_1.1.7 rmarkdown_1.9 knitr_1.20 stringr_1.3.0
## [13] digest_0.6.15 evaluate_0.10.1
Purpose: The purpose of this document is to explore the feasability of modeling growth rates in three focus drainages as well as the mainstem of the Kenai River watershed. Data included: length and weight-at-age data collected throughout the summer seasons of 2015 and 2016. A variety of graphics are created for visualization and exploratory data analysis.
Hypothesis: Differential growth rates for juvenile Coho and Chinook salmon can be observed among Beaver Creek, Russian River, Ptarmigan Creek, and Mainstem Kenai River using size-at-age data.
If the data allows, the observed growth rates will be used to provide size inputs (weight) for bioenergetic simulations in upcoming analyses.
Fish sampling effort consisted of day-length monthly site visits in summer 2015 and 2016 to lower, middle, and upper reaches of each study drainage (with the exception of the Kenai River, which had only lower and middle sites) (Figure X, below).
# NOTE 1/22/18: this code also exists as a script at "/Users/bmeyer/Google Drive/Thesis/R Analysis/Thesis Analyses R Project/Overall_scripts_2015_2016/sampling_periods.R". Attempted to just source("\path") this script in to the markdown document but, 'source' function prevents knitting through markdown for some reason.
############
#
# 2015
#
###########
# Verify that sheet is present, create object of sheet with all tabs
SCTC2015 <- gs_title("2015 EPSCoR SCTC.xlsx")
#read in specific worksheet containing fishing data
effort2015 <- SCTC2015 %>%
gs_read(ws = "B Fishing Data",col_names=TRUE, skip=2) %>%
#rename needed columns
rename(site.id=Site_ID,
sample.event=Sample_Event) %>%
#select desired columns
select(site.id,River,sample.event,sample.event.num,deploy_dt,collect_dt) %>%
#filter our blanks
filter(!is.na(sample.event)) %>%
# transform columns to desired classes
transform(site.id=as.factor(site.id),
sample.event=as.factor(sample.event),
sample.event.num=as.factor(sample.event.num))
###################
#
# 2016
#
###################
# Verify that sheet is present, create object of sheet with all tabs
SCTC2016 <- gs_title("2016_EPSCoR_Aquatic_Ecology_Database")
#read in specific worksheet containing fishing data
effort2016 <- SCTC2016 %>%
gs_read(ws = "B Fishing Data",col_names=TRUE, skip=2) %>%
#rename needed columns
rename(site.id=Site_ID,
sample.event=Sample_Event) %>%
#select desired columns
select(site.id,River,sample.event,sample.event.num,deploy_dt,collect_dt) %>%
#filter our blanks
filter(!is.na(sample.event)) %>%
# transform columns to desired classes
transform(site.id=as.factor(site.id),
sample.event=as.factor(sample.event),
sample.event.num=as.factor(sample.event.num))
# bind 2015 & 2016 data; format datetimes
effort <- bind_rows(effort2015,effort2016) %>%
transform(collect_dt = anytime(collect_dt),
deploy_dt = anytime(deploy_dt)) %>%
mutate(year = year(collect_dt))
###########################
# Define Temporal Extents #
###########################
# "Sample Event" temporal extent
# find earliest deployment time and latest collection time for each sampling event.
# sampling events are typically fall within 24 hours (~99% of the time) with a few exceptions.
# calculate start and finish of each sampling event
sample_events <- effort %>%
group_by(sample.event,River, sample.event.num,year) %>%
summarise(event.start = min(deploy_dt),
event.end = max(collect_dt)) %>%
mutate(hours = as.numeric(difftime(event.end,event.start,unit="hours")),
doy =yday(event.start))
# "Season" temporal extent
# find earliest deployment date and latest collection date for each 'sample.event.num' by River and year
# to determine temporal extent for each season
seasons <- effort %>%
group_by(sample.event.num,River,year) %>%
summarize(season.start = min(deploy_dt),
season.end = max(collect_dt)) %>%
mutate(season = fct_recode(as.factor(sample.event.num),
"Early Summer"="1",
"Mid-Summer" = "2",
"Late Summer" ="3",
"Fall" = "4")) %>%
mutate(days = as.numeric(difftime(season.end,season.start,unit="days")))
# join "seasons" to "sample_events" to show which sampling events occurred in which seasons
effort_fnl <- left_join(sample_events,seasons,by = c("River","sample.event.num","year")) %>%
# convert season datetimes to day-of-year ("doy")
mutate(season.start.doy = yday(season.start),
season.end.doy = yday(season.end),
event.start.doy = yday(event.start)) %>%
transform(year = as.factor(year))
# set plottling theme (mostly)
theme_bm <- theme(axis.text.x = element_text(size=18),
axis.text.y = element_text(size=18), # x axis text
axis.title.x = element_text(size=18, face = "bold"), # x axis title
axis.title.y = element_text(size=18, face = "bold"),
strip.text.x = element_text(size = 16, face = "bold"),
legend.text = element_text(size = 16))
cbbPalette <- c("#D55E00", "#0072B2", "#F0E442", "#009E73", "#56B4E9", "#E69F00")
# test plot
s <- ggplot(effort_fnl, aes(x=season.start.doy, xend = season.end.doy,
y=year, yend=year), color = season) +
scale_x_continuous(breaks = c(152,182,213,244),
labels = c("June","July","August","Sept")) +
theme_bw() +
ggtitle("Fish Sampling Periods") +
geom_segment(aes(color = season), size = 24) +
facet_wrap(~River) +
geom_point(aes(event.start.doy, year), size = 3) +
xlab("Month") +
ylab("Year") +
theme(plot.title = element_text(size= 30, face = "bold", hjust = 0.5)) +
theme(legend.title=element_text(size=24, face = "bold")) +
guides(color = guide_legend(override.aes = list(size=8))) +
scale_color_manual(name="Season",
breaks = c("Early Summer",
"Mid-Summer",
"Late Summer",
"Fall"),
values=cbbPalette) +
theme_bm
# print plot
s
Figure X - Fish sampling periods. Each black dot indicates a day of a fish sampling event (numerical day of year). Each colored bar denotes the length of a ‘season,’ or period of time between the first and last of a drainage’s monthly site visits.
Table X - Table of fish sampling event data.
# 2015 & 2016 catch data
# Create bar graph(s) showing proportions (by spp, year, river, diet sample (y/n))
# 1.) By overall drainage and year
# a.) 2015
# b.) 2016
# c.) both years juxtaposed
# 2015
# Verify that sheet is present, create object of sheet with all tabs
SCTC2015 <- gs_title("2015 EPSCoR SCTC.xlsx")
# read in desired worksheet
catch15 <- SCTC2015 %>%
gs_read(ws = "C 2015 Diet & LW Data",col_names=TRUE) %>%
select(Year,river,spp,Count,sample.event.num,DS) %>%
mutate(season = fct_recode(as.factor(sample.event.num), #code sampling events as seasons
"Early Summer"="1",
"Mid-Summer" = "2",
"Late Summer" ="3")) %>%
rename(diet_sample = DS) %>%
filter(spp %in% c("Coho", "Chinook")) # filter out all species except Chinook and Coho
# create summary of catch by drainage, species, and lavaged vs non-lavaged
catch_summary15 <- catch15 %>%
group_by(Year,river,spp,diet_sample) %>%
summarise(ct = sum(Count)) %>%
mutate(count_label = paste("( n=", as.character(ct),")")) #create count labels
# specify order of drainages
catch_summary15$river <- factor(catch_summary15$river, levels = c("Beaver Creek",
"Russian River",
"Ptarmigan Creek",
"Kenai River"))
# create theme to plot 2015 catch data
c15 <- ggplot(catch_summary15, aes(x = spp, y = ct, fill = diet_sample)) +
geom_bar(stat = "identity", color = "white") +
facet_wrap(~river,nrow=1) +
theme_bw() +
scale_fill_discrete(name="Diet Sample\nCollected") +
theme(legend.key.size = unit(1.7, 'lines')) +
theme(plot.title = element_text(size = 26, face = "bold"),
axis.text.x = element_text(size=14, face="bold"),
axis.text.y = element_text(size=16, face="bold"),
axis.title.x = element_text(size=22, face="bold"),
axis.title.y = element_text(size = 22, face = "bold")) +
theme(strip.text.x = element_text(size=16, face="bold")) +
theme(legend.title = element_text(size=20, face="bold")) +
theme(legend.text = element_text(size = 16, face = "bold")) +
xlab("Species") +
ylab("Count")
# plot and title for 2015 data
# c15 + ggtitle("2015 Juvenile Chinook and Coho\n Catch Data") # can un-hashtag to show 2015 plot
# 2016
# import 2016 database, create object of sheet with all tabs
SCTC2016 <- gs_title("2016_EPSCoR_Aquatic_Ecology_Database")
# read in desired worksheet
catch16 <- SCTC2016 %>%
gs_read(ws = "C 2016 Diet & LW Data",col_names=TRUE) %>%
select(Year,river,spp,Count,sample.event.num,DS) %>%
mutate(season = fct_recode(as.factor(sample.event.num), #code sampling events as seasons
"Early Summer"="1",
"Mid-Summer" = "2",
"Late Summer" ="3",
"Fall" = "4")) %>%
rename(diet_sample = DS) %>%
filter(spp %in% c("Coho", "Chinook")) # filter out all species except Chinook and Coho
# create summary of catch by drainage, species, and lavaged vs non-lavaged
catch_summary16 <- catch16 %>%
group_by(Year,river,spp,diet_sample) %>%
summarise(ct = sum(Count)) %>%
mutate(count_label = paste("( n=", as.character(ct),")")) #create count labels
# specify order of drainages
catch_summary16$river <- factor(catch_summary16$river, levels = c("Beaver Creek",
"Russian River",
"Ptarmigan Creek",
"Kenai River"))
# create theme to plot catch data
c16 <- ggplot(catch_summary16, aes(x = spp, y = ct, fill = diet_sample)) +
geom_bar(stat = "identity", color = "white") +
facet_wrap(~river,nrow=1) +
theme_bw() +
scale_fill_discrete(name="Diet Sample\nCollected") +
theme(legend.key.size = unit(1.7, 'lines')) +
theme(plot.title = element_text(size = 26, face = "bold"),
axis.text.x = element_text(size=14, face="bold"),
axis.text.y = element_text(size=16, face="bold"),
axis.title.x = element_text(size=22, face="bold"),
axis.title.y = element_text(size = 22, face = "bold")) +
theme(strip.text.x = element_text(size=16, face="bold")) +
theme(legend.title = element_text(size=20, face="bold")) +
theme(legend.text = element_text(size = 16, face = "bold")) +
xlab("Species") +
ylab("Count")
# plot and title for 2016 data
# c16 + ggtitle("2016 Juvenile Chinook and Coho\n Catch Data") # can un-hashtag to show 2016 plot
# combined plot for 2015 and 2016 data
# create combined table
all <- bind_rows(catch_summary15,catch_summary16)
allplot <- ggplot(all, aes(x = spp, y = ct, fill = diet_sample, color = spp)) +
geom_bar(stat = "identity", color = "white") +
facet_wrap(Year~river,nrow=2) +
theme_bw() +
scale_fill_discrete(name="Diet Sample\nCollected") +
theme(legend.key.size = unit(1.7, 'lines')) +
theme(plot.title = element_text(size = 26, face = "bold"),
axis.text.x = element_text(size=14, face="bold"),
axis.text.y = element_text(size=16, face="bold"),
axis.title.x = element_text(size=22, face="bold"),
axis.title.y = element_text(size = 22, face = "bold")) +
theme(strip.text.x = element_text(size=14, face="bold")) +
theme(legend.title = element_text(size=20, face="bold")) +
theme(legend.text = element_text(size = 16, face = "bold")) +
xlab("Species") +
ylab("Count")
A total of 3166 juvenile Coho and 1262 juvenile Chinook were captured thoughout the 2015/2016 sampling periods, with 725 Coho and 252 Chinook sampled for scales and diet contents (using gastric lavage technique). Chinook were generally sparse everywhere relative to Coho, except in the main stem Kenai River.
# plot and title for 2016 data
allplot + ggtitle("Overall Capture 2015 and 2016\n Juvenile Chinook and Coho")
# 2015 & 2016 catch data
# 2015
# Verify that sheet is present, create object of sheet with all tabs
SCTC2015 <- gs_title("2015 EPSCoR SCTC.xlsx")
# read in desired worksheet
catch15 <- SCTC2015 %>%
gs_read(ws = "C 2015 Diet & LW Data",col_names=TRUE) %>%
select(Year,river,spp,Count,sample.event.num,DS) %>%
mutate(season = fct_recode(as.factor(sample.event.num), #code sampling events as seasons
"Early Summer"="1",
"Mid-Summer" = "2",
"Late Summer" ="3")) %>%
rename(diet_sample = DS) %>%
filter(spp %in% c("Coho", "Chinook")) # filter out all species except Chinook and Coho
# create summary of catch by drainage, species, and lavaged vs non-lavaged
catch_summary15 <- catch15 %>%
group_by(Year,river,spp,diet_sample) %>%
summarise(ct = sum(Count)) %>%
mutate(count_label = paste("( n=", as.character(ct),")")) #create count labels
# 2016
# import 2016 database, create object of sheet with all tabs
SCTC2016 <- gs_title("2016_EPSCoR_Aquatic_Ecology_Database")
# read in desired worksheet
catch16 <- SCTC2016 %>%
gs_read(ws = "C 2016 Diet & LW Data",col_names=TRUE) %>%
select(Year,river,spp,Count,sample.event.num,DS) %>%
mutate(season = fct_recode(as.factor(sample.event.num), #code sampling events as seasons
"Early Summer"="1",
"Mid-Summer" = "2",
"Late Summer" ="3",
"Fall" = "4")) %>%
rename(diet_sample = DS) %>%
filter(spp %in% c("Coho", "Chinook")) # filter out all species except Chinook and Coho
# create summary of catch by drainage, species, and lavaged vs non-lavaged
catch_summary16 <- catch16 %>%
group_by(Year,river,spp,diet_sample) %>%
summarise(ct = sum(Count)) %>%
mutate(count_label = paste("( n=", as.character(ct),")")) #create count labels
# create combined table
all <- bind_rows(catch_summary15,catch_summary16)
# print table
all
Table X - Table of catch summary data.
Length and weight data were acquired in the field from minnow-trapped fish using a measuring board and electronic balance. Age data was generated using scales collected from a subset of captured fish with >50 mm fork length at each sampling event. Scales were aged by two independent observers under 4.0x magnification, and age-length keys were applied using methods detailed in Chapter 5 of “Introductory Fisheries Analysis with R” (Ogle 2016). (Link to age-length key methods/results write-up here when available).
Age-length keys were generated at the scale of individual river and year (e.g. “Beaver Creek 2015”); data from lower, middle, and upper sites were pooled in order to acheive usable sample sizes.
# NOTE ON AGE STRUCTURE 3/28/18
# This script originally imported google sheet titled "all_fish_ages.csv", which contained results output from the "fish_ages_all.R" script. The "fish_ages_all.R" script uses methods described in Ch. 5 of Ogle 2016 ("Introductory fisheries analyses with R") to age all captured fish from a subset of fish scale samples. Resultant csv file was copied to the google sheet referenced here.
# Further consideration has determined that using age-length keys for this project may not best serve its interests. In the colum "Age_manual2" imported in this chunk, age thresholds were identified visually as described is "fish_age_structure.R". These data will later be compared to the use of bayesian methods to identify age thresholds.
# ID googlesheet with fish age data (3/28/18: no longer in use)
#fish_ages <- gs_title("all_fish_ages.csv")
#Sys.sleep(6)
# Verify that sheets are present, create object of sheet with all tabs
SCTC2015 <- gs_title("2015 EPSCoR SCTC.xlsx")
SCTC2016 <- gs_title("2016_EPSCoR_Aquatic_Ecology_Database")
# read in desired worksheet 2015
fish_ages15 <- SCTC2015 %>%
gs_read(ws = "C 2015 Diet & LW Data",col_names=TRUE) %>%
select(river,sample.id,sample.event,spp,Weight_g,Length_mm,Age_manual2,sample.event.num,Date,`Site ID`,reach_name) %>%
mutate(season = fct_recode(as.factor(sample.event.num), #code sampling events as seasons
"Early Summer"="1",
"Mid-Summer" = "2",
"Late Summer" ="3")) %>%
rename(wt_g = Weight_g,
len_mm = Length_mm,
age = Age_manual2,
Hydrologic.Segment = reach_name) %>%
transform(Date = anydate(Date)) %>%
filter(spp %in% c("Coho", "Chinook")) # filter out all species except Chinook and Coho
# read in desired worksheet 2016
fish_ages16 <- SCTC2016 %>%
gs_read(ws = "C 2016 Diet & LW Data",col_names=TRUE) %>%
select(river,sample.id,sample.event,spp,Weight_g,Length_mm,Age_manual2,sample.event.num,Date,`Site ID`,reach_name) %>%
mutate(season = fct_recode(as.factor(sample.event.num), #code sampling events as seasons
"Early Summer"="1",
"Mid-Summer" = "2",
"Late Summer" ="3",
"Fall" ="4")) %>%
rename(wt_g = Weight_g,
len_mm = Length_mm,
age = Age_manual2,
Hydrologic.Segment = reach_name) %>%
transform(Date = anydate(Date),
wt_g = as.numeric(wt_g)) %>%
filter(spp %in% c("Coho", "Chinook")) # filter out all species except Chinook and Coho
#join 2015 and 2016 data
fish_ages <- bind_rows(fish_ages15,fish_ages16)
#prep dataframe containing age data
dat <- fish_ages %>%
separate(sample.event, c("reach","year","sample.event.num"), sep = "-", remove = F) %>%
unite(river_spp, river, spp, remove = F, sep = " ") %>%
# manually order appearance of seasons and rivers for plots
transform(year = as.factor(year),
river = factor(river, levels=c("Beaver Creek",
'Russian River',
'Ptarmigan Creek',
'Kenai River')),
season = factor(season, levels = c("Early Summer",
"Mid-Summer",
"Late Summer",
"Fall")),
river_spp = as.factor(river_spp)) %>%
mutate(river_spp = paste(river,"\n",spp)) %>%
mutate(doy = yday(Date)) %>%
filter(!is.na(age))
# age 2 fish: this cohort is sparse and likely departing for the ocean.
#filter(age != 2)
# create data table for each species
all_coho <- dat %>%
filter(spp=="Coho")
all_chnk <- dat %>%
filter(spp=="Chinook")
Tests for annual difference in size distribution
Question: Do significant differences exist in size-at-age between 2015 and 2016 Coho and Chinook? If the size-at-age patterns are similar between the two years, it could be possible to pool data between the two years to increase sample size. If not, we will explore for growth trends in the annual datasets seperately for each year.
ANOVA tests are performed below to compare two models: 1.) age ~ size (length or weight); and 2.) age ~ size * year. Analyses performed at the grouping level of river and year for each species of fish.
# restructure data
all_sub <- bind_rows(all_coho, all_chnk) %>%
mutate(river_spp_yr = paste(river_spp,year)) %>%
transform(river_spp_yr = as.factor(river_spp_yr),
year = as.factor(year),
spp = as.factor(spp),
len_mm = as.numeric(len_mm)) %>%
select(river_spp_yr,river,year,spp,age,len_mm,wt_g)
# create table of p-values for each anova test
length_age_year <- all_sub %>%
group_by(river, spp) %>%
nest() %>%
mutate(
age_len = map(data, ~lm(age~len_mm, data=.)),
age_len_year = map(data, ~lm(age~len_mm*year, data=.))
) %>%
mutate(anova = map2(age_len, age_len_year, ~anova(.x,.y))) %>%
mutate(tidy_anova = map(anova, broom::tidy)) %>%
mutate(p_val = map_dbl(tidy_anova, ~.$p.value[2])) %>%
select(river, spp, p_val)
# print table
length_age_year
Table X - Results of ANOVA tests including the linear models a.) age ~ fork length, and b.) age ~ fork length*year for each iteration of species and river.
# create table of p-values for each anova test
weight_age_year <- all_sub %>%
group_by(river, spp) %>%
nest() %>%
mutate(
age_wt = map(data, ~lm(age~wt_g, data=.)),
age_wt_year = map(data, ~lm(age~wt_g*year, data=.))
) %>%
mutate(anova = map2(age_wt, age_wt_year, ~anova(.x,.y))) %>%
mutate(tidy_anova = map(anova, broom::tidy)) %>%
mutate(p_val = map_dbl(tidy_anova, ~.$p.value[2])) %>%
select(river, spp, p_val)
# print table
weight_age_year
Table X - Results of ANOVA tests including the linear models a.) age ~ weight, and b.) age ~ weight*year for each iteration of species and river.
Discussion, 2015 vs 2016 size distribution
Evidence generally supports that size distributions are different among years for each iteration of species and river (p-values generally < 0.05) for both fork length and weight. Evidence for equal size distribution equivalence among years is not as apparant in the Kenai mainstem, but it’s dataset is much smaller and more sporadic.
Size data will be examined for growth trends at the time scale of individual year rather than as pooled data.
Summary values (means, standard deviation, total count) are provided for each iteration of river, season, year, and age for juvenile Coho captured in 2015 and 2016.
# create summary table
t_coho <- all_coho %>%
group_by(river, season, age, spp, year) %>%
summarise(average_wt = mean(wt_g),
stdev_wt = sd(wt_g),
average_len = mean(len_mm),
stdev_len = sd(len_mm),
count = n()) %>%
select(river,season,year,spp,age,count,average_wt,stdev_wt,average_len,stdev_len) %>%
rename("_age_" = age)
# print table
t_coho
Table X - Table of Coho length and weight data summary values.
NOTE: Probably not useful to examine growth trends for Age 2 Coho because they are most likely all smolting out and departing for the marine environment. Included here for display interest.
# Coho lengths
p0 <- ggplot(all_coho, aes(season,len_mm, fill = as.factor(age))) +
geom_boxplot(outlier.size = 0) +
geom_point(pch = 21, position = position_jitterdodge()) +
facet_grid(year~river) +
xlab("Season") +
ylab("Length (mm)") +
ggtitle("Juvenile Coho Lengths") +
theme_bw() +
bm_theme +
# legend
scale_fill_discrete(name="Age") +
theme(legend.background = element_rect(fill="gray90", size=.5, linetype="dotted"))
p0
Figure X - Boxplots of juvenile Coho fork lengths by season, for each year and drainage.
p1 <- ggplot(all_coho, aes(season,wt_g, fill = as.factor(age))) +
geom_boxplot(outlier.size = 0) +
geom_point(pch = 21, position = position_jitterdodge()) +
facet_grid(year~river) +
xlab("Season") +
ylab("Weight (g)") +
ggtitle("Juvenile Coho Weights") +
theme_bw() +
bm_theme +
# legend
scale_fill_discrete(name="Age")
p1
Figure X - Boxplots of juvenile Coho weights by season, for each year and drainage.
# temporarily load plyr package
library(plyr)
# choose formula style for plotting
formula <- y ~ x
# Correct Facet Labels
age_facets <- c(
`0` = "Age 0",
`1` = "Age 1",
`2` = "Age 2"
)
river_facets <- c(
`Beaver Creek` = "Beaver Creek",
`Russian River` = "Russian River",
`Ptarmigan Creek` = "Ptarmigan Creek",
`Kenai River` = "Kenai River"
)
# specify format for formula and r2 labels in LENGTH plots
len_formula_labels <- stat_poly_eq(aes(label = paste("atop(",..eq.label.., ",", ..adj.rr.label.., ")", sep = "")),
formula = formula,
rr.digits = 2,
coef.digits = 2,
parse = TRUE,
label.y = 110,
size = 3,
geom = "label",
alpha = 0.8)
# calculate n values
coho.cor <- ddply(.data=all_coho,
.(age, river,year),
summarize,
n=paste("n =", length(sample.event)))
coho.cor.15 <- coho.cor %>%
filter(year =="2015")
coho.cor.16 <- coho.cor %>%
filter(year =="2016")
chnk.cor <- ddply(.data=all_chnk,
.(age, river, year),
summarize,
n=paste("n =", length(sample.event)))
chnk.cor.15 <- chnk.cor %>%
filter(year =="2015")
chnk.cor.16 <- chnk.cor %>%
filter(year =="2016")
# unload plyr package
detach(package:plyr)
# Coho LENGTH date vs. age facets
axl <- ggplot(data = all_coho, aes(x = doy, y = len_mm)) +
facet_grid(age ~ river, labeller = labeller(age = as_labeller(age_facets),
river = as_labeller(river_facets))) +
geom_jitter(width = 0.4, aes(color = Hydrologic.Segment)) +
geom_smooth(method = lm, color = "black", se = F) +
xlab("Day of Year") +
ylab("Fork Length (mm)") +
ylim(c(15, NA)) +
len_formula_labels +
theme_bw() +
bm_theme
# 2015 coho lengths
axl %+% subset(all_coho, year %in% c("2015")) +
# n labels
geom_text(data=coho.cor.15, aes(x=165, y=30, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2015 Coho Lengths")
Figure X - 2015 Coho length vs. day of year. Each iteration of fish age and drainage is fitted with a linear relationship, with formula and adjusted r^2 value reported.
# 2016 coho lengths
axl %+% subset(all_coho, year %in% c("2016")) +
# n labels
geom_text(data=coho.cor.16, aes(x=165, y=30, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2016 Coho Lengths")
Figure X - 2016 Coho length vs. day of year. Each iteration of fish age and drainage is fitted with a linear relationship, with formula and adjusted r^2 value reported.
# specify format for formula and r2 labels in WEIGHT plots
wt_formula_labels <- stat_poly_eq(aes(label = paste("atop(",..eq.label.., ",", ..adj.rr.label.., ")", sep = "")),
formula = formula,
rr.digits = 2,
coef.digits = 2,
parse = TRUE,
label.y = 20,
size = 3,
geom = "label",
alpha = 0.8)
# Coho WEIGHT date vs. age facets
axw <- ggplot(data = all_coho, aes(x = doy, y = wt_g)) +
facet_grid(age ~ river, labeller = labeller(age = as_labeller(age_facets),
river = as_labeller(river_facets))) +
geom_jitter(width = 0.4, aes(color = Hydrologic.Segment)) +
geom_smooth(method = lm, color = "black", se = F) +
xlab("Day of Year") +
ylab("Weight (g)") +
#ylim(c(15, NA)) +
wt_formula_labels +
theme_bw() +
bm_theme
# 2015 coho weights
axw %+% subset(all_coho, year %in% c("2015")) +
# n labels
geom_text(data=coho.cor.15, aes(x=165, y=30, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2015 Coho Weights")
Figure X - 2015 Coho weight vs. day of year. Each iteration of fish age and drainage is fitted with a linear relationship, with formula and adjusted r^2 value reported.
# 2016 coho weights
axw %+% subset(all_coho, year %in% c("2016")) +
# n labels
geom_text(data=coho.cor.16, aes(x=165, y=30, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2016 Coho Weights")
Figure X - 2016 Coho weight vs. day of year. Each iteration of fish age and drainage is fitted with a linear relationship, with formula and adjusted r^2 value reported.
season_facets <- c(
`1` = "Early Summer",
`2` = "Mid-Summer",
`3` = "Late Summer",
`4` = "Fall"
)
# plot age vs. fork length faceted by season and river
p <- ggplot(all_coho, aes(x = as.numeric(age), y = len_mm)) +
facet_grid(sample.event.num ~ river, labeller = labeller(sample.event.num = season_facets)) +
geom_jitter(data = all_coho, width = 0.2, aes(color = year)) +
geom_smooth(data = subset(all_coho, year %in% c("2015")), method = "lm", se = FALSE, col = "black") +
geom_smooth(data = subset(all_coho, year %in% c("2016")), method = "lm", se = FALSE) +
xlab("Age") +
ylab("Fork Length (mm)") +
scale_x_continuous(breaks=c(0,1,2)) +
theme_bw() +
bm_theme_1
# print plot
p + ggtitle("Coho Age vs. Fork Length")
Figure X - Coho age vs. fork length. Each iteration of year, river, and season is fitted with a linear relationship.
season_facets <- c(
`1` = "Early Summer",
`2` = "Mid-Summer",
`3` = "Late Summer",
`4` = "Fall"
)
# plot age vs. fork length faceted by season and river
######### 2/1/18 unable to change y-facet labels to season names #######
p <- ggplot(all_coho, aes(x = as.numeric(age), y = wt_g)) +
facet_grid(sample.event.num ~ river, labeller = labeller(sample.event.num = season_facets)) +
geom_jitter(data = all_coho, width = 0.2, aes(color = year)) +
geom_smooth(data = subset(all_coho, year %in% c("2015")), method = "lm", se = FALSE, col = "black") +
geom_smooth(data = subset(all_coho, year %in% c("2016")), method = "lm", se = FALSE) +
xlab("Age") +
ylab("Weight (g)") +
scale_x_continuous(breaks=c(0,1,2)) +
theme_bw() +
bm_theme_1
# print plot
p + ggtitle("Coho Age vs. Weight")
Figure X - Coho age vs. fork length. Each iteration of year, river, and season is fitted with a linear relationship.
p <- ggplot(all_coho, aes(x=len_mm, y=season)) +
geom_density_ridges() +
facet_grid(age ~ river, labeller = labeller(age = as_labeller(age_facets),
river = as_labeller(river_facets))) +
xlab("Fork Length (mm)") +
ylab("Season") +
theme_bw() +
bm_theme
p %+% subset(all_coho, year %in% c("2015")) +
# nlabels
geom_text(data=coho.cor.15, aes(x=118, y=0.8, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2015 Coho Fork Lengths")
2015 Coho fork length density plots, faceted for each iteration of river and age (total count n for each in bold).
p %+% subset(all_coho, year %in% c("2016")) +
# nlabels
geom_text(data=coho.cor.16, aes(x=118, y=0.8, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2016 Coho Fork Lengths")
2015 Coho fork length density plots, faceted for each iteration of river and age (total count n for each in bold).
p <- ggplot(all_coho, aes(x=wt_g, y=season)) +
geom_density_ridges() +
facet_grid(age ~ river, labeller = labeller(age = as_labeller(age_facets),
river = as_labeller(river_facets))) +
xlab("Weight (g)") +
xlim(0,18) +
ylab("Season") +
theme_bw() +
bm_theme
p %+% subset(all_coho, year %in% c("2015")) +
# nlabels
geom_text(data=coho.cor.15, aes(x=15, y=0.8, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2015 Coho weights")
2015 Coho weight density plots, faceted for each iteration of river and age (total count n for each in bold).
p %+% subset(all_coho, year %in% c("2016")) +
# nlabels
geom_text(data=coho.cor.16, aes(x=15, y=0.8, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2016 Coho weights")
2015 Coho weight density plots, faceted for each iteration of river and age (total count n for each in bold).
Comments on Coho size distriution analysis: Blah blah
# test, in devpt -- VBF relationships?
# mod_age1 <- multinom(season~lcat5*age,data=all_coho,maxit=500)
Summary values (means, standard deviation, total count) are provided for each iteration of river, season, year, and age for juvenile Chinook captured in 2015 and 2016.
# create summary table
t_chnk <- all_chnk %>%
group_by(river, season, age, spp,year) %>%
summarise(average_wt = mean(wt_g),
stdev_wt = sd(wt_g),
average_len = mean(len_mm),
stdev_len = sd(len_mm),
count = n()) %>%
select(river,year,season,spp,age,count,average_wt,stdev_wt,average_len,stdev_len) %>%
rename("_age_" = age)
# print table
t_chnk
NOTE: Probably not useful to examine growth trends for Age 1 Chinook because they are most likely all smolting out and departing for the marine environment. Included here for display interest.
# Chinook lengths
p2 <- ggplot(all_chnk, aes(season,len_mm, fill = as.factor(age))) +
geom_boxplot(outlier.size = 0) +
geom_point(pch = 21, position = position_jitterdodge()) +
facet_grid(year~river) +
xlab("Season") +
ylab("Length (mm)") +
ggtitle("Juvenile Chinook Lengths") +
theme_bw() +
bm_theme +
# legend
scale_fill_discrete(name="Age") +
theme(legend.background = element_rect(fill="gray90", size=.5, linetype="dotted"))
p2
# Chinook weights
p3 <- ggplot(all_chnk, aes(season,wt_g, fill = as.factor(age))) +
geom_boxplot(outlier.size = 0) +
geom_point(pch = 21, position = position_jitterdodge()) +
facet_grid(year~river) +
xlab("Season") +
ylab("Weight (g)") +
ggtitle("Juvenile Chinook Weights") +
theme_bw() +
bm_theme +
# legend
scale_fill_discrete(name="Age") +
theme(legend.background = element_rect(fill="gray90", size=.5, linetype="dotted"))
p3
# prep formula labeller for Chinook data range
# specify format for formula and r2 labels in LENGTH plots
len_formula_labels <- stat_poly_eq(aes(label = paste("atop(",..eq.label.., ",", ..adj.rr.label.., ")", sep = "")),
formula = formula,
rr.digits = 2,
coef.digits = 2,
parse = TRUE,
label.y = 79,
size = 3,
geom = "label",
alpha = 0.8)
# Chinook LENGTH date vs. age facets
axl <- ggplot(data = all_chnk, aes(x = doy, y = len_mm)) +
facet_grid(age ~ river, labeller = labeller(age = as_labeller(age_facets),
river = as_labeller(river_facets))) +
geom_jitter(width = 0.4, aes(color = Hydrologic.Segment)) +
geom_smooth(method = lm, color = "black", se = F) +
xlab("Day of Year") +
ylab("Fork Length (mm)") +
ylim(c(15, NA)) +
len_formula_labels +
theme_bw() +
bm_theme
# 2015 Chinook lengths
axl %+% subset(all_chnk, year %in% c("2015")) +
# n labels
geom_text(data=chnk.cor.15, aes(x=165, y=30, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2015 Chinook Lengths")
Figure X - 2015 Chinook length vs. day of year. Each iteration of fish age and drainage is fitted with a linear relationship, with formula and adjusted r^2 value reported.
# 2016 Chinook lengths
axl %+% subset(all_chnk, year %in% c("2016")) +
# n labels
geom_text(data=chnk.cor.16, aes(x=165, y=30, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2016 Chinook Lengths")
Figure X - 2016 Chinook length vs. day of year. Each iteration of fish age and drainage is fitted with a linear relationship, with formula and adjusted r^2 value reported.
# specify format for formula and r2 labels in WEIGHT plots
wt_formula_labels <- stat_poly_eq(aes(label = paste("atop(",..eq.label.., ",", ..adj.rr.label.., ")", sep = "")),
formula = formula,
rr.digits = 2,
coef.digits = 2,
parse = TRUE,
label.y = 6.5,
size = 3,
geom = "label",
alpha = 0.8)
# Chinook WEIGHT date vs. age facets
axw <- ggplot(data = all_chnk, aes(x = doy, y = wt_g)) +
facet_grid(age ~ river, labeller = labeller(age = as_labeller(age_facets),
river = as_labeller(river_facets))) +
geom_jitter(width = 0.4, aes(color = Hydrologic.Segment)) +
geom_smooth(method = lm, color = "black", se = F) +
xlab("Day of Year") +
ylab("Weight (g)") +
#ylim(c(15, NA)) +
wt_formula_labels +
theme_bw() +
bm_theme
# 2015 Chinook weights
axw %+% subset(all_chnk, year %in% c("2015")) +
# n labels
geom_text(data=chnk.cor.15, aes(x=165, y=2, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2015 Chinook Weights")
Figure X - 2015 Chinook weight vs. day of year. Each iteration of fish age and drainage is fitted with a linear relationship, with formula and adjusted r^2 value reported.
# 2016 Chinook weights
axw %+% subset(all_chnk, year %in% c("2016")) +
# n labels
geom_text(data=chnk.cor.16, aes(x=165, y=2, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2016 Chinook Weights")
Figure X - 2016 Chinook weight vs. day of year. Each iteration of fish age and drainage is fitted with a linear relationship, with formula and adjusted r^2 value reported.
season_facets <- c(
`1` = "Early Summer",
`2` = "Mid-Summer",
`3` = "Late Summer",
`4` = "Fall"
)
# plot age vs. fork length faceted by season and river
######### 2/1/18 unable to chnage y-facet labels to season names #######
p <- ggplot(all_chnk, aes(x = as.numeric(age), y = len_mm)) +
facet_grid(sample.event.num ~ river, labeller = labeller(sample.event.num = season_facets)) +
geom_jitter(data = all_chnk, width = 0.2, aes(color = year)) +
geom_smooth(data = subset(all_chnk, year %in% c("2015")), method = "lm", se = FALSE, col = "black") +
geom_smooth(data = subset(all_chnk, year %in% c("2016")), method = "lm", se = FALSE) +
xlab("Age") +
ylab("Fork Length (mm)") +
scale_x_continuous(breaks=c(0,1,2)) +
theme_bw() +
bm_theme_1
# print plot
p + ggtitle("Chinook Age vs. Fork Length")
Figure X - Chinook age vs. fork length. Each iteration of year, river, and season is fitted with a linear relationship.
season_facets <- c(
`1` = "Early Summer",
`2` = "Mid-Summer",
`3` = "Late Summer",
`4` = "Fall"
)
# plot age vs. fork length faceted by season and river
p <- ggplot(all_chnk, aes(x = as.numeric(age), y = wt_g)) +
facet_grid(sample.event.num ~ river, labeller = labeller(sample.event.num = season_facets)) +
geom_jitter(data = all_chnk, width = 0.2, aes(color = year)) +
geom_smooth(data = subset(all_chnk, year %in% c("2015")), method = "lm", se = FALSE, col = "black") +
geom_smooth(data = subset(all_chnk, year %in% c("2016")), method = "lm", se = FALSE) +
xlab("Age") +
ylab("Weight (g)") +
scale_x_continuous(breaks=c(0,1,2)) +
theme_bw() +
bm_theme_1
# print plot
p + ggtitle("Chinook Age vs. Weight")
Figure X - Chinook age vs. fork length. Each iteration of year, river, and season is fitted with a linear relationship.
p <- ggplot(all_chnk, aes(x=len_mm, y=season)) +
geom_density_ridges() +
facet_grid(age ~ river, labeller = labeller(age = as_labeller(age_facets),
river = as_labeller(river_facets))) +
xlab("Fork Length (mm)") +
ylab("Season") +
theme_bw() +
bm_theme
p %+% subset(all_chnk, year %in% c("2015")) +
# nlabels
geom_text(data=chnk.cor.15, aes(x=50, y=0.8, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2015 Chinook Fork Lengths")
2015 Chinook fork length density plots, faceted for each iteration of river and age (total count n for each in bold).
p %+% subset(all_chnk, year %in% c("2016")) +
# nlabels
geom_text(data=chnk.cor.16, aes(x=50, y=0.8, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2016 Chinook Fork Lengths")
2015 Chinook fork length density plots, faceted for each iteration of river and age (total count n for each in bold).
p <- ggplot(all_chnk, aes(x=wt_g, y=season)) +
geom_density_ridges() +
facet_grid(age ~ river, labeller = labeller(age = as_labeller(age_facets),
river = as_labeller(river_facets))) +
xlab("Weight (g)") +
xlim(0,12) +
ylab("Season") +
theme_bw() +
bm_theme
p %+% subset(all_chnk, year %in% c("2015")) +
# nlabels
geom_text(data=chnk.cor.15, aes(x=5, y=0.8, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2015 Chinook weights")
2015 Chinook weight density plots, faceted for each iteration of river and age (total count n for each in bold).
p %+% subset(all_chnk, year %in% c("2016")) +
# nlabels
geom_text(data=chnk.cor.16, aes(x=5, y=0.8, label=n),
colour="black", inherit.aes=FALSE, parse=FALSE, fontface = "bold") +
ggtitle("2016 Chinook weights")
2015 Chinook weight density plots, faceted for each iteration of river and age (total count n for each in bold).
Comments on Chinook size distriution analysis: Blah blah