Joyce Ong
4 November 2019
This is an R Markdown document containing the results for the analyses of recruitment timeseries (11 species, 29 years) for the NSF CNH project on CCLME.
library(wsyn, warn.conflicts = F, quietly = T)#for wavelet analyses
library(reshape2)#to use melt function
library(ggplot2)#to plot times series
library(dplyr, warn.conflicts = F, quietly = T)
library(corrplot)#to plot correlation matrix## corrplot 0.84 loaded
library(Hmisc)#for pearsons and spearmans correlation matrices## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
##
## src, summarize
## The following objects are masked from 'package:base':
##
## format.pval, units
library(colorednoise)#to figure out autocorrelation values of timeseriesRecruitment timeseries for multiple groundfish species (recruitment deviations), dungeness crabs and pink shrimp (log-recruitment) were obtained from stock assessments. Survival estimates were used for Chinook salmon from NCA and SFB (logit transformation), resource availability indices were used for albacore tuna from Yutaro's model (raw data from fish ticket data). All data from all sites (if available) were compiled and a box-cox transformation done on each separate timeseries using the function in the package wsyn.
sp11cd<-read.csv("D:/Rutgers_postdoc/data/recruitment timeseries/csv files for wavelet analyses/sp11cd_20191104.csv")
rownames(sp11cd)<-sp11cd[,1]
sp11cd<-sp11cd[,-1]
colnames(sp11cd)<-seq(1982, 2010, 1)
sp11cd<-as.matrix(sp11cd)sp11df<-as.data.frame(t(sp11cd))
sp11df$year<-seq(1982,2010,1)
sp11df2<-melt(sp11df, id.vars="year", value.name = "cleandat")
sp11df2<-sp11df2 %>% mutate(sp=substr(variable, 1,4), loc=substr(variable, 6,8))
sp11df2$sp<-as.factor(sp11df2$sp)
sp11df2$loc<-as.factor(sp11df2$loc)
grdfishsp7<-c("HAKE","POPF", "PSOL", "SABF", "SSTH", "WDRF", "YTRF")
grdfish7df<- filter(sp11df2, sp %in% grdfishsp7)
grdfish7<-ggplot(grdfish7df, aes(x=year, y=cleandat, color=sp))
grdfish7 + geom_line() + theme_bw() + labs(x="Year", y="Transformed index", title="Groundfish species")One potentially interesting observation is that from 2006-2010, most groundfish (except SSTH and PSOL) had below average recruitment, followed by an increase in 2008.
nongrdfishdf2<-filter(sp11df2, !sp %in% grdfishsp7)
nongrdfishdf2$loc<-factor(nongrdfishdf2$loc, levels=c("WA", "OR","NCA", "SFB", "CA", "CCA"))
oth4.29yr<-ggplot(nongrdfishdf2, aes(x=year, y=cleandat, color=sp))
oth4.29yr + geom_line() + theme_bw() + facet_wrap(~loc, scales="free", nrow=2) +
labs(x="Year", y="Transformed index", title="Non-groundfish species")Some observations from non-groundfish species are that:
In WA, alb and crab seem to have some similar peaks and lows.
In OR, shrimp and albacore seem similar before 1995, the patterns reverse after.
In NCA, chinook and crab seem to be lagged.
sp11wmf<-wmf(sp11cd, times=1982:2010, scale.min = 2, scale.max.input = 10)
plotmag(sp11wmf, colorbar=T, title="11 species 1982-2010 wmf")sp11wpmf<-wpmf(sp11cd, times=1982:2010, scale.min = 2, scale.max.input = 10, sigmethod = "quick", nrand=1000)
plotmag(sp11wpmf, colorbar=T, title="11 species 1982-2010 wpmf", sigthresh=0.95)Observations from wmf and wpmf plots
Wmf plot: 6yr ts (medium strength) throughout that seems to be decreasing, strong 2 yr ts 2005-2008.
Wpmf plot: strong 6yr ts from 1988-2000, weaker 2.5yr ts 2003-2007.
Overall: do coherence with 2-4 yr and 4-8 yr timescales.Seems like there was a change from 2000 onwards, with shorter timescales being more important, especially for phases.
Wavelet coherence = consistent phase relationships and magnitude fluctuations through time. Note that wavelet coherence analyses were run and results saved in sp11mat list. Coherence values were obtained and p-values (using 10,000 surrogates) were adjusted with false detection rate.
load(file="sp11mat.RData")
sp11coh2.4<-sp11mat[[1]]
rownames(sp11coh2.4)<-dimnames(sp11cd)[[1]]
colnames(sp11coh2.4)<-dimnames(sp11cd)[[1]]
sp11coh2.4fdr<-sp11mat[[2]]
colbwr<-colorRampPalette(c("blue", "white", "red"))#to specify colour palette
corrplot(sp11coh2.4, method="number", type="lower", tl.pos="ld", tl.srt=20, tl.offset=0.2,
col=colbwr(10), is.corr=TRUE, diag=F, tl.col="black", tl.cex=0.6, number.cex=0.6, p.mat=sp11coh2.4fdr, sig.level=0.1, insig="blank", mar=c(0.5,0.5,1.5,0.5))
mtext("11 sp coh, timescale 2-4 years (fdr<10%)", side=3, line=1)Result: With fdr<10%, only 3 pairs of coherent relationships show up, all groundfish species.
Widow rockfish and yellowtail rockfish (coh = 0.8)
Sablefish and Pacific ocean perch (coh = 0.62)
Sablefish and shortspine thornyhead (coh = 0.41)
Spearman's rank correlation is shown below, with 7 pairwise comparisons showing up (note that Pearson's had 9).
#sp11cdmat<-t(sp11cd)
#sp11sr<-rcorr(sp11cdmat, type="spearman")
sp11sr.rho<-sp11mat[[3]]
sp11sr.qv<-sp11mat[[4]]
corrplot(sp11sr.rho, method="number", type="lower", tl.pos="ld", tl.srt=20, tl.offset=0.2,
col=colbwr(10), is.corr=TRUE, diag=F, tl.col="black", p.mat=sp11sr.qv,
sig.level=0.1, insig="blank", mar=c(0.5,0.5,1.5,0.5))
mtext("11 sp Spearman's rho (fdr<10%)", side=3, line=0)#could put this as title in corrplotTimeseries plots of species that show up in correlations but not coherence analyses
crab.OR.NCA.sp11<-ggplot(subset(sp11df2, variable=="CRAB_OR"|variable=="CRAB_NCA"), aes(x=year, y=cleandat, color=variable))
crab.OR.NCA.sp11 + geom_line() + theme_bw() + labs(x="Year", y="Transformed index", title="Crab OR and NCA", color=NULL) +theme(legend.position = c(0.3, 0.15))Crabs from OR and NCA are more synchronous from 1993 onwards.
chis.SFB.ssth.sp11<-ggplot(subset(sp11df2, variable=="CHIS_SFB"|variable=="SSTH_ALL"), aes(x=year, y=cleandat, color=variable))
chis.SFB.ssth.sp11 + geom_line() + theme_bw() + labs(x="Year", y="Transformed index", title="Chinook SFB and shortspine thornyhead", color=NULL) +
theme(legend.position = c(0.3, 0.15))Chinook salmon from SFB and shortspine thornyhead are anti-synchronous at long timescales from 1994 onwards.
sabf.ytrf.sp11<-ggplot(subset(sp11df2, variable=="SABF_ALL"|variable=="YTRF_ALL"), aes(x=year, y=cleandat, color=variable))
sabf.ytrf.sp11 + geom_line() + theme_bw() + labs(x="Year", y="Transformed index", title="Sablefish and yellowtail rockfish", color=NULL) +
theme(legend.position = c(0.3, 0.15))Sablefish and yellowtail rockfish synchronous from ~1990-1993 onwards.
wdrf.ytrf.coh<-sp11mat[[5]]
plotmag(wdrf.ytrf.coh)Plot shows that coherence between these two timeseries were significant from 2-3 yr timescales, where the dotted red line is above the two black lines and p<0.0.
plotphase(wdrf.ytrf.coh)## NULL
Plot shows that at the 2-3 yr timescales that were significant from the previous plots, the two timeseries were in-phase. This is reflected in the timeseries plot below.
wdrf.ytrf.sp11<-ggplot(subset(sp11df2, variable=="WDRF_ALL"|variable=="YTRF_ALL"), aes(x=year, y=cleandat, color=variable))
wdrf.ytrf.sp11 + geom_line() + theme_bw() + labs(x="Year", y="Transformed index", title="Widow and Yellowtail rockfish", color=NULL) +
theme(legend.position = c(0.65, 0.15))sabf.popf.coh<-sp11mat[[6]]
plotmag(sabf.popf.coh)Plot shows that coherence between these two timeseries were significant from 2-2.5 yr and 5-7 yr timescales, where the dotted red line is above the two black lines and p<0.05.
plotphase(sabf.popf.coh)## NULL
Plot shows that at the 2-2.5 yr and 5-7 yr timescales that were significant from the previous plots, the two timeseries were in-phase. This is reflected in the timeseries plot below.
sabf.popf.sp11<-ggplot(subset(sp11df2, variable=="SABF_ALL"|variable=="POPF_ALL"), aes(x=year, y=cleandat, color=variable))
sabf.popf.sp11 + geom_line() + theme_bw() + labs(x="Year", y="Transformed index", title="Sablefish and Pacific ocean perch", color=NULL) +
theme(legend.position = c(0.3, 0.15))sabf.ssth.coh<-sp11mat[[7]]
plotmag(sabf.ssth.coh)Plot shows that coherence between these two timeseries were significant from 2.5 to 5 yr timescales, where the dotted red line is above the two black lines and p<0.05.
plotphase(sabf.ssth.coh)## NULL
Plot shows that at the 2.5 to 5 yr timescales that were significant from the previous plots, the two timeseries were in-phase from 2.5-3.5yr timescales and sabf lagging ssth at ~4 yr timescales by pi/2, half a cycle. This is reflected in the timeseries plot below. Note also that coherence is clearly visible in the timeseries plot, which was picked up by wavelet coherence but not by pearsons or spearmans correlations.
sabf.ssth.sp11<-ggplot(subset(sp11df2, variable=="SABF_ALL"|variable=="SSTH_ALL"), aes(x=year, y=cleandat, color=variable))
sabf.popf.sp11 + geom_line() + theme_bw() + labs(x="Year", y="Transformed index", title="Sablefish and shortspine thornyhead", color=NULL) +
theme(legend.position = c(0.3, 0.15))Analyses above point out the groundfish as having stronger coherences/correlations. Plot below shows the wpmf for only the 7 groundfish species over the years 1982-2010. It shows that there was a strong 4-6 yr timescale throughout, with a very strong 2-3 yr timescale after 2000, visible in the previous few groundfish timeseries.
grdfish7mat<-sp11cd[11:17,]
grdfish7wpmf<-wpmf(grdfish7mat, times=1982:2010, scale.min = 2, scale.max.input = 10, sigmethod = "quick", nrand=1000)
plotmag(grdfish7wpmf, colorbar=T, title="Groundfish7 wpmf", sigthresh=0.95)Plot below shows the strength of the coherences of 2 timescale bands over time. It suggests that the 4-6 year timescale was stronger in the 90s, with a sudden increase in coherence for 2-3 year timescales after 2000. Implications are that groundfish recruitment is more synchronous at short timescales of 2-3 years since the year 2000?
gf7.ts.pow<-matrix(NA, nrow=29, ncol=3)
gf7.ts.pow[,1]<-seq(1982, 2010, 1)
colnames(gf7.ts.pow)<-c("year", "ts2-3", "ts4-6")
gf7.ts.pow[,2]<-rowMeans(Mod(grdfish7wpmf$values[,grdfish7wpmf$timescales<3.5]), na.rm=T)
gf7.ts.pow[,3]<-rowMeans(Mod(grdfish7wpmf$values[,(grdfish7wpmf$timescales>4) & (grdfish7wpmf$timescales<7)]), na.rm=T)
gf7.ts.pow<-as.data.frame(gf7.ts.pow)
gf7tspowdf<-melt(gf7.ts.pow, id.vars="year", variable.name = "ts", value.name = "power")
gf7.pow.p1<-ggplot(gf7tspowdf, aes(x=year, y=power, color=ts))
gf7.pow.p1 + geom_line() + theme_bw() + labs(x="Year", y="Power", title="7 groundfish species", color=NULL) +
theme(legend.position = c(0.9, 0.2)) + scale_x_continuous(breaks=seq(1985,2010,5), limits=c(1985,2010)) +
scale_color_discrete(name="Timescales", labels=c("2-3 years", "4-6 years"))## Warning: Removed 16 rows containing missing values (geom_path).