Read in growth and release datasets.

Carlin_full_growth<-readRDS(paste(shared.path, "Salmon/Data/Growth/Data/Carlin_growth_fulldata.rds", sep = ""))

releasedata<- readRDS(paste(shared.path, "Salmon/Data/Mark-recap/Carlin_all_releases.rds", sep = ""))

Calculate number of circuli deposited after the last marine annulus

How many circuli are deposited after the annulus?

Carlin_full_growth %>% 
  mutate(M1.circ = ifelse(is.na(M1) == FALSE, (smolt.circ + FS.circ + FW.circ), NA)) %>% 
  mutate(M2.circ = ifelse(is.na(M2) == FALSE, (M1.circ + SS.circ + SW.circ), NA)) %>% 
  select(JoinID,FreshAge, SeaAge, Circ, M1.circ, M2.circ, RecaptureYear, RecaptureMonthNum) %>% 
  filter(!is.na(M1.circ)) %>% 
  filter(!is.na(RecaptureMonthNum)) %>% 
  filter(SeaAge == 1 | SeaAge == 2) %>% 
  mutate(postannulus.circ = ifelse(is.na(M2.circ) == FALSE, (Circ - M2.circ), (Circ - M1.circ))) %>%
  ggplot(aes(postannulus.circ)) + geom_histogram() + facet_wrap(~SeaAge)

Do fish caught later in the year have more circuli after the annulus?

It doesn’t seem that way. Months are pretty even.

Carlin_full_growth %>% 
  mutate(M1.circ = ifelse(is.na(M1) == FALSE, (smolt.circ + FS.circ + FW.circ), NA)) %>% 
  mutate(M2.circ = ifelse(is.na(M2) == FALSE, (M1.circ + SS.circ + SW.circ), NA)) %>% 
  select(JoinID,FreshAge, SeaAge, Circ, M1.circ, M2.circ, RecaptureYear, RecaptureMonthNum) %>% 
  filter(!is.na(M1.circ)) %>% 
  filter(!is.na(RecaptureMonthNum)) %>% 
  filter(SeaAge == 1) %>% 
  mutate(postannulus.circ = ifelse(is.na(M2.circ) == FALSE, (Circ - M2.circ), (Circ - M1.circ))) %>% 
  tidyr::complete(postannulus.circ,RecaptureMonthNum, fill = list(n=0)) %>%
  group_by(postannulus.circ, RecaptureMonthNum) %>% 
  dplyr::summarise(n = n()) %>% 
  mutate(percent = (n / sum(n) * 100)) %>% 
  ggplot(aes(postannulus.circ,percent, fill = as.factor(RecaptureMonthNum))) + geom_area() + xlim(5,25) +
  labs(x = "Number of postannulus circuli", y = "Percent", fill = "Month caught", title = "1SW") + theme(panel.background = element_blank()) + theme(panel.grid = element_blank())

Carlin_full_growth %>% 
  mutate(M1.circ = ifelse(is.na(M1) == FALSE, (smolt.circ + FS.circ + FW.circ), NA)) %>% 
  mutate(M2.circ = ifelse(is.na(M2) == FALSE, (M1.circ + SS.circ + SW.circ), NA)) %>% 
  select(JoinID,FreshAge, SeaAge, Circ, M1.circ, M2.circ, RecaptureYear, RecaptureMonthNum) %>% 
  filter(!is.na(M1.circ)) %>% 
  filter(!is.na(RecaptureMonthNum)) %>% 
  filter(SeaAge == 2) %>% 
  mutate(postannulus.circ = ifelse(is.na(M2.circ) == FALSE, (Circ - M2.circ), (Circ - M1.circ))) %>% 
  tidyr::complete(postannulus.circ,RecaptureMonthNum, fill = list(n = 0)) %>%
  group_by(postannulus.circ, RecaptureMonthNum) %>% 
  dplyr::summarise(n = n()) %>% 
  mutate(percent = (n / sum(n)*100)) %>% 
  ggplot(aes(postannulus.circ,percent, fill = as.factor(RecaptureMonthNum))) + geom_area() + xlim(3,15) +
    labs(x = "Number of postannulus circuli", y = "Percent", fill = "Month caught" , title = "2SW") + 
     theme(panel.background = element_blank()) + theme(panel.grid = element_blank())

Sea Age errors?

There are 5 fish classified as 0SW that have a marine annulus.

##       JoinID FreshAge SeaAge Circ M1.circ M2.circ
## 1  1968_6931       H1      0   71      61      NA
## 2 1970_44155       H2      0   74      61      NA
## 3 1973_61966       H2      0   98      72      NA
## 4 1984_79462       H1      0  108      84      NA
## 5 1984_89176       H1      0   93      74      NA

There are 6 fish classified as 1SW that have a second marine annulus.

##        JoinID FreshAge SeaAge Circ M1.circ M2.circ
## 1 1966_661008       H2      1  111      71     100
## 2  1973_66686       H2      1  119      73     101
## 3  1975_89317       H2      1   81      64      77
## 4 1979_152340       H2      1   81      48      74
## 5 1981_285462       H2      1   78      52      71
## 6  1984_55278       H1      1  103      55      82

There are 18 fish classified as 2SW that don’t have a second marine annulus.

##         JoinID FreshAge SeaAge Circ M1.circ M2.circ
## 1  1966_663052       H2      2   90      60      NA
## 2  1966_663067       H2      2   99      78      NA
## 3  1966_664021       H1      2  106      79      NA
## 4    1968_7138       H2      2  107      75      NA
## 5    1969_5314       H2      2   92      78      NA
## 6    1969_9178       H2      2   90      75      NA
## 7   1971_74901       H1      2  111      81      NA
## 8   1971_87680       H1      2   93      79      NA
## 9   1972_31365       H2      2  111      90      NA
## 10  1972_53511       H2      2   95      75      NA
## 11  1972_56068       H2      2   84      67      NA
## 12   1972_6446       H2      2  105      85      NA
## 13   1972_8910       H2      2   73      59      NA
## 14  1973_87760       H2      2  101      80      NA
## 15  1975_81371       H2      2   77      63      NA
## 16 1979_182389       H2      2   69      54      NA
## 17 1980_206348       H1      2   97      84      NA
## 18  1984_87190       H1      2   93      71      NA

How many circuli are deposited after the annulus?

Carlin_full_growth %>% 
  mutate(M1.circ = ifelse(is.na(M1) == FALSE, (smolt.circ + FS.circ + FW.circ), NA)) %>% 
  mutate(M2.circ = ifelse(is.na(M2) == FALSE, (M1.circ + SS.circ + SW.circ), NA)) %>% 
  select(JoinID,FreshAge, SeaAge, Circ, M1.circ, M2.circ) %>% 
  filter(!is.na(M1.circ)) %>% 
  filter(SeaAge == 1 | SeaAge == 2) %>% 
  mutate(postannulus.circ = ifelse(is.na(M2.circ) == FALSE, (Circ - M2.circ), (Circ - M1.circ))) %>% 
  ggplot() + geom_histogram(aes(postannulus.circ, fill = SeaAge)) + labs(x = "Number of circuli after last winter annulus", y = "n") + theme(panel.grid = element_blank())

Number of circuli between second annulus and first annulus ~ 24.5 circuli.

##   mean(M2.circ - M1.circ, na.rm = TRUE)
## 1                              24.62264

Calculate mean recapture dates

Create “RecaptureDate” formatted as a date.

Create and format range of release dates (Date 1 and Date 2). Calculate # days between Release Date 1 and Release Date 2.

Write function to calculate midpoint of interval. Calculate midpoint of release interval using “int_midpoint” function. Add it to the dataframe as “EmigrationDate.”

Add release dates dataframe to full growth dataframe. Remove fish with unknown recapture or emigration dates.

Calculate mean release dates

library(dplyr)
meanrelease<-Carlin_simpledata %>% 
  mutate(ReleaseMonth = month(EmigrationDate)) %>% 
  mutate(ReleaseYear = year(EmigrationDate)) %>% 
  dplyr::group_by(ReleaseYear) %>% 
  dplyr::summarise(meanReleaseDate = mean(EmigrationDate), meanReleaseMonth = mean(ReleaseMonth), sdMonth = sd(ReleaseMonth), n = n())
meanrelease
## # A tibble: 25 x 5
##    ReleaseYear meanReleaseDate meanReleaseMonth sdMonth     n
##          <dbl> <date>                     <dbl>   <dbl> <int>
##  1        1966 1966-04-23                  4.2    1.10     30
##  2        1967 1967-04-11                  4      0        10
##  3        1968 1968-04-22                  4.4    0.507    15
##  4        1969 1969-05-18                  5.35   0.521   188
##  5        1970 1970-05-05                  5      0       244
##  6        1971 1971-05-14                  5      0        68
##  7        1972 1972-05-13                  5      0       103
##  8        1973 1973-05-09                  5      0       158
##  9        1974 1974-05-05                  4.93   0.264    81
## 10        1975 1975-05-05                  4.97   0.184    58
## # ... with 15 more rows
#write.csv(meanrelease, "meanrelease.csv")

Postsmolt increment relationship with emigration DOY

## Warning: Column `JoinID` joining character vector and factor, coercing into
## character vector

The relationship between emigration and postsmolt increment doesn’t seem particularily strong, though DOY is significant in the lm.

term estimate std.error statistic p.value
(Intercept) 1.85 0.12 15.59 0.0000
smoltgrowth$EmigrationDOY 0.00 0.00 -3.03 0.0025

Marine increment relationship with emigration DOY

The relationship between emigration and marine increment doesn’t seem particularily strong, though DOY is significant in the lm.

term estimate std.error statistic p.value
(Intercept) 2.83 0.17 16.29 0.0000
smoltgrowth$EmigrationDOY 0.00 0.00 -2.87 0.0042

Perhaps being an early emigrator doesn’t make you grow any faster or larger!