Skip to content
Snippets Groups Projects
Commit 3ab1df76 authored by Berges, Benoit's avatar Berges, Benoit
Browse files

2021 update

parent bedf3e50
No related branches found
No related tags found
No related merge requests found
Showing
with 283 additions and 202 deletions
stoxPath <- file.path(".","StoX")
outPath <- file.path(".","output")
functionPath <- file.path(".","functions")
resultsPath <- file.path(".","results")
figurePath <- file.path(".","figures",'StoX','2_baseline_final')
load(file.path(resultsPath,'VIaSPAWN_baseline.RData'))
load(file.path(resultsPath,'VIaSPAWN_bootstrap.RData'))
project_mapping <- read.csv(file.path(dataPath,"2_project_mapping_baseline.csv"))
wos_index <- read.csv(file.path(dataPath,'WSAS_AbundanceAge.csv'))
currentYear <- 2021
################################################################
# compute final tables
################################################################
project_mapping_final <- project_mapping[project_mapping$select == 1,]
for(idxYear in project_mapping_final$year){
if(project_mapping_final$component[project_mapping_final$year == idxYear] != 'final'){
VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_strata[,ac(idxYear),'final'] <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_strata[,ac(idxYear),as.character(project_mapping_final$component[project_mapping_final$year == idxYear])]
VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,ac(idxYear),'final'] <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,ac(idxYear),as.character(project_mapping_final$component[project_mapping_final$year == idxYear])]
VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_strata[,ac(idxYear),'final'] <- VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_strata[,ac(idxYear),as.character(project_mapping_final$component[project_mapping_final$year == idxYear])]
VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all[,ac(idxYear),'final'] <- VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all[,ac(idxYear),as.character(project_mapping_final$component[project_mapping_final$year == idxYear])]
VIaSPAWN_bootstrap$VIaSPAWN.stock[,ac(idxYear),'final'] <- VIaSPAWN_bootstrap$VIaSPAWN.stock[,ac(idxYear),as.character(project_mapping_final$component[project_mapping_final$year == idxYear])]
VIaSPAWN_baseline$VIaSPAWN.stock[,ac(idxYear),'final'] <- VIaSPAWN_baseline$VIaSPAWN.stock[,ac(idxYear),as.character(project_mapping_final$component[project_mapping_final$year == idxYear])]
}
}
VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_strata <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_strata[,,'final']
VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,,'final']
VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_strata <- VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_strata[,,'final']
VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all <- VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all[,,'final']
VIaSPAWN_bootstrap$VIaSPAWN.stock <- VIaSPAWN_bootstrap$VIaSPAWN.stock[,,'final']
VIaSPAWN_baseline$VIaSPAWN.stock <- VIaSPAWN_baseline$VIaSPAWN.stock[,,'final']
################################################################
# compute df
################################################################
# N at age
VIaSPAWN_df <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_strata@index[,,,'all'])
temp <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all@index[,,,'all'])
VIaSPAWN_df <- rbind(VIaSPAWN_df,temp)
VIaSPAWN_df$age <- as.factor(VIaSPAWN_df$age)
VIaSPAWN_df <- VIaSPAWN_df[VIaSPAWN_df$data != 0,]
# modify df to compare as facet_wrap
VIaSPAWN_comp_df <- VIaSPAWN_df
# N matyrity df
VIaSPAWN_mat_df <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_strata@index[,,,c('IMM','MAT')])
temp <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all@index[,ac(2016:2021),,c('IMM','MAT')])
VIaSPAWN_mat_df <- rbind(VIaSPAWN_mat_df,temp)
VIaSPAWN_mat_df$age <- as.factor(VIaSPAWN_mat_df$age)
VIaSPAWN_mat_df <- VIaSPAWN_mat_df[VIaSPAWN_mat_df$data != 0,]
# SSB
VIaSPAWN_SSB <- as.data.frame(quantSums(VIaSPAWN_baseline$VIaSPAWN.stock@stock.n*
VIaSPAWN_baseline$VIaSPAWN.stock@stock.wt*1e-3*
VIaSPAWN_baseline$VIaSPAWN.stock@mat))
VIaSPAWN_SSB <- VIaSPAWN_SSB[VIaSPAWN_SSB$data != 0,]
VIaSPAWN_SSB$type <- 'SSB'
VIaSPAWN_SPAWN <- as.data.frame(quantSums(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all@index[,,,'SPAWN']*
VIaSPAWN_baseline$VIaSPAWN.stock@stock.wt*1e-3))
VIaSPAWN_SPAWN$type <- 'spawning'
VIaSPAWN_biomass_df <- rbind(VIaSPAWN_SSB,VIaSPAWN_SPAWN)
# bio df
VIaSPAWN_len <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.stock@catch.wt*1e-2)
VIaSPAWN_len <- VIaSPAWN_len[VIaSPAWN_len$data != 0,]
VIaSPAWN_len$type <- 'length'
VIaSPAWN_wt <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.stock@stock.wt*1e-3)
VIaSPAWN_wt <- VIaSPAWN_wt[VIaSPAWN_wt$data != 0,]
VIaSPAWN_wt$type <- 'weight'
VIaSPAWN_mat <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.stock@mat)
VIaSPAWN_mat <- VIaSPAWN_mat[VIaSPAWN_mat$data != 0,]
VIaSPAWN_mat$type <- 'maturity'
VIaSPAWN_bio <- rbind(VIaSPAWN_len,
VIaSPAWN_wt,
VIaSPAWN_mat)
# N bootstrap
VIaSPAWN_N_boot_strata <- as.data.frame(VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_strata@index[,,,'all'])
VIaSPAWN_N_boot_all <- as.data.frame(VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all@index[,,,'all'])
VIaSPAWN_N_boot <- rbind(VIaSPAWN_N_boot_strata,VIaSPAWN_N_boot_all)
# CV
# N
VIaSPAWN_CV_N_strata <- as.data.frame(iterCVs(VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_strata@index[,,,'all']))
VIaSPAWN_CV_N_strata$type <- 'N'
VIaSPAWN_CV_N_all <- as.data.frame(iterCVs(VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all@index[,,,'all']))
VIaSPAWN_CV_N_all$type <- 'N'
VIaSPAWN_CV_N_all_tot <- as.data.frame(quantMeans(iterCVs(VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all@index[,,,'all'])))
VIaSPAWN_CV_N_all_tot$type <- 'N'
# biomass
VIaSPAWN_CV_biom_strata <- as.data.frame(iterCVs(VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_strata@index.q[,,,'all']))
VIaSPAWN_CV_biom_strata$type <- 'biomass'
VIaSPAWN_CV_biom_all <- as.data.frame(iterCVs(VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all@index.q[,,,'all']))
VIaSPAWN_CV_biom_all$type <- 'biomass'
VIaSPAWN_CV_biom_all_tot <- as.data.frame(quantMeans(iterCVs(VIaSPAWN_bootstrap$VIaSPAWN.ind$VIaSPAWN_all@index.q[,,,'all'])))
VIaSPAWN_CV_biom_all_tot$type <- 'biomass'
# SSB
VIaSPAWN_CV_SSB_all <- as.data.frame(iterCVs( quantSums(VIaSPAWN_bootstrap$VIaSPAWN.stock@stock.n*
VIaSPAWN_bootstrap$VIaSPAWN.stock@stock.wt*1e-3*
VIaSPAWN_bootstrap$VIaSPAWN.stock@mat)))
VIaSPAWN_CV_SSB_all$type <- 'SSB'
VIaSPAWN_CV <- rbind( VIaSPAWN_CV_N_strata,
VIaSPAWN_CV_N_all,
VIaSPAWN_CV_N_all_tot,
VIaSPAWN_CV_biom_strata,
VIaSPAWN_CV_biom_all,
VIaSPAWN_CV_biom_all_tot,
VIaSPAWN_CV_SSB_all)
VIaSPAWN_CV <- VIaSPAWN_CV[!is.na(VIaSPAWN_CV$data),]
abuVIaSPAWN <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all@index[,,'final','all','all'])
abuVIaSPAWN <- mutate(abuVIaSPAWN, yc =year-age)
nyc <- length(unique(abuVIaSPAWN$yc))
ageClass <- c("0" = "0","1" = "1", "2" = "2", "3" = "3", "4" = "4", "5" = "5", "6" = "6", "7" = "7", "8" = "8", "9" = "9+")
PAIRED <- rep(brewer.pal(15,"Paired"),100)
# computing indices for comparison
IVaSPAWN_index <- as.data.frame(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all@index)
IVaSPAWN_index <- IVaSPAWN_index[IVaSPAWN_index$season == 'all',]
IVaSPAWN_index <- IVaSPAWN_index[,c(1,2,7)]
IVaSPAWN_index$dataNorm <- NA
IVaSPAWN_index$survey <- 'VIaSPAWN'
wos_index <- wos_index[wos_index$year %in% IVaSPAWN_index$year,]
wos_index$dataNorm <- NA
wos_index$survey <- 'WoS'
# z norm
for(idxAge in 0:9){
IVaSPAWN_index$dataNorm[IVaSPAWN_index$age == idxAge] <-
(IVaSPAWN_index$data[IVaSPAWN_index$age == idxAge]-
mean(IVaSPAWN_index$data[IVaSPAWN_index$age == idxAge]))/
sd(IVaSPAWN_index$data[IVaSPAWN_index$age == idxAge])
wos_index$dataNorm[wos_index$age == idxAge] <-
(wos_index$data[wos_index$age == idxAge]-
mean(wos_index$data[wos_index$age == idxAge]))/
sd(wos_index$data[wos_index$age == idxAge])
}
indicesAll <- rbind(IVaSPAWN_index,wos_index)
ggplot(indicesAll,aes(x=year,y=data,col=survey))+
geom_line()
ggplot(indicesAll,aes(x=year,y=data,col=survey))+
geom_line()+
facet_wrap(.~age)
windows()
ggplot(indicesAll,aes(x=year,y=data,col=survey))+
geom_point()+
theme(axis.text.x = element_text(angle=90))+
ylab('CV')+
ylim(0,0.7)+
xlab('year')
print(p)
dev.off()
# comparion baseline and bootstrap runs current year
scaling_factor <- 1
png(file.path(figurePath,'VIaSPAWN_bootstrap_comp_current.png'),
width = 12*scaling_factor, height = 12*scaling_factor, units = "cm", res = 300, pointsize = 10)
p <- ggplot()+
theme_bw()+
geom_boxplot(data=subset(VIaSPAWN_N_boot,data != 0 & year == currentYear),aes(x=as.factor(age),y=data,fill = unit))+
geom_point(data=subset(VIaSPAWN_df,area=='all' & data != 0 & year == currentYear),aes(x = age,y=data,group=1,shape=unit,col=unit))+
scale_colour_manual(values=c("red", "blue", "#E69F00"))+
labs(colour='',shape='',fill='',shape='',linetype='')+
ylab('Abundance (millions)')+
xlab('Age')
print(p)
dev.off()
# historical bootstrap
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_bootstrap_comp.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
p <- ggplot()+
theme_bw()+
geom_boxplot(data=subset(VIaSPAWN_N_boot,data != 0),aes(x=as.factor(age),y=data,fill = unit))+
labs(colour='',shape='',fill='',shape='',linetype='')+
ylab('Abundance (millions)')+
xlab('Age')+
facet_wrap(~year,scale='free_y')
print(p)
dev.off()
# cariola plot
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_cariola.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
p <- ggplot(abuVIaSPAWN,aes(x=year,y=data,fill=factor(yc))) +
theme_bw() +
geom_bar(stat="identity") +
facet_grid(age ~ .,scale="free_y", labeller = labeller(age = ageClass)) +
theme(legend.position = "none") +
scale_fill_manual(values=PAIRED[1:15])+
# scale_y_continuous(breaks=seq(0, 25000, 5000)) +
labs(#title = "NSAS Survey indices by age and year class",
x = 'Year',
y = 'Abundance (millions)')
print(p)
dev.off()
# internal consistency
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_ICES.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,,'final','all','all']))
dev.off()
# comparison induces abundance
scaling_factor <- 1.5
png(file.path(figurePath,'comp_indices_abu.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
p <- ggplot(indicesAll,aes(x=year,y=data,col=survey))+
geom_line()+
ylab('Abundance (millions)')+
theme(axis.text.x = element_text(angle=90))+
facet_wrap(.~age,scales='free')
ggplot(indicesAll,aes(x=year,y=dataNorm,col=survey))+
print(p)
dev.off()
# comparison induces z norm
scaling_factor <- 1.5
png(file.path(figurePath,'comp_indices_znorm.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
p <- ggplot(indicesAll,aes(x=year,y=dataNorm,col=survey))+
geom_line()+
ylab('z norm')+
theme(axis.text.x = element_text(angle=90))+
facet_wrap(.~age,scales='free')
windows()
ggplot(indicesAll,aes(x=year,y=dataNorm,col=survey))+
geom_line()+
print(p)
dev.off()
# correlation matrix WoS
scaling_factor <- 1.5
png(file.path(figurePath,'corMat_znorm_WoS.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
cor.indicesAll <- indicesAll[,c(1,2,4,5)]
cor.indicesAll$survey %in% c('WoS', 'VIaSPAWN')
#cor.indicesAll$dataNorm <- log10(cor.indicesAll$dataNorm)
cor.indicesAll <- cor.indicesAll[cor.indicesAll$age != 0,]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = survey, values_from = dataNorm)
#cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll$year <- as.factor(cor.indicesAll$year)
cor.indicesAll$age <- as.factor(cor.indicesAll$age)
p <- ggcorrm(cor.indicesAll,mapping = aes(col = age, fill = age)) +
lotri(geom_smooth(method = "lm"))+
lotri(geom_point(alpha = 0.5))+
utri_corrtext(col='black')+
facet_wrap(.~age,scales='free')
print(p)
dev.off()
# correlation matrix WoS
scaling_factor <- 1.5
png(file.path(figurePath,'corMat_znorm_MHAS.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
cor.indicesAll <- indicesAll[,c(1,2,4,5)]
cor.indicesAll$survey %in% c('MHAS', 'VIaSPAWN')
#cor.indicesAll$dataNorm <- log10(cor.indicesAll$dataNorm)
cor.indicesAll <- cor.indicesAll[cor.indicesAll$age != 0,]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = survey, values_from = dataNorm)
#cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll$year <- as.factor(cor.indicesAll$year)
cor.indicesAll$age <- as.factor(cor.indicesAll$age)
p <- ggcorrm(cor.indicesAll,mapping = aes(col = age, fill = age)) +
lotri(geom_smooth(method = "lm"))+
lotri(geom_point(alpha = 0.5))+
utri_corrtext(col='black')+
facet_wrap(.~age,scales='free')
print(p)
dev.off()
# internal consistency abundance
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_N_all.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx1[ac(1:9)]))
dev.off()
# internal consistency abundance mature
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_N_mat.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx2[ac(1:9)]))
dev.off()
# internal consistency SSB
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_SSB.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx3[ac(1:9)]))
dev.off()
# script that derives the HERAS index directly from the StoX projects.
rm(list=ls())
library(Rstox)
......@@ -151,6 +141,7 @@ library(mgcv)
library(tidyverse)
library(ggplot2)
library(RColorBrewer)
library(corrmorant)
#Set up directories
#path <- 'J:/git/HERAS/'
path <- 'E:/git/6a_spawn_her'
......@@ -166,6 +157,7 @@ load(file.path(resultsPath,'VIaSPAWN_baseline.RData'))
load(file.path(resultsPath,'VIaSPAWN_bootstrap.RData'))
project_mapping <- read.csv(file.path(dataPath,"2_project_mapping_baseline.csv"))
wos_index <- read.csv(file.path(dataPath,'WSAS_AbundanceAge.csv'))
MHAS_vian_index <- read.csv(file.path(dataPath,'MHAS_vian_AbundanceAge.csv'),check.names=FALSE)
currentYear <- 2021
################################################################
# compute final tables
......@@ -273,6 +265,10 @@ IVaSPAWN_index$survey <- 'VIaSPAWN'
wos_index <- wos_index[wos_index$year %in% IVaSPAWN_index$year,]
wos_index$dataNorm <- NA
wos_index$survey <- 'WoS'
MHAS_vian_index <- MHAS_vian_index %>% pivot_longer(!year,names_to='age',values_to='data')
MHAS_vian_index <- MHAS_vian_index[MHAS_vian_index$year %in% IVaSPAWN_index$year,]
MHAS_vian_index$dataNorm <- NA
MHAS_vian_index$survey <- 'MHAS'
# z norm
for(idxAge in 0:9){
IVaSPAWN_index$dataNorm[IVaSPAWN_index$age == idxAge] <-
......@@ -283,8 +279,17 @@ wos_index$dataNorm[wos_index$age == idxAge] <-
(wos_index$data[wos_index$age == idxAge]-
mean(wos_index$data[wos_index$age == idxAge]))/
sd(wos_index$data[wos_index$age == idxAge])
MHAS_vian_index$dataNorm[MHAS_vian_index$age == idxAge] <-
(MHAS_vian_index$data[MHAS_vian_index$age == idxAge]-
mean(MHAS_vian_index$data[MHAS_vian_index$age == idxAge]))/
sd(MHAS_vian_index$data[MHAS_vian_index$age == idxAge])
}
indicesAll <- rbind(IVaSPAWN_index,wos_index)
indicesAll <- rbind(IVaSPAWN_index,wos_index,MHAS_vian_index)
idx1 <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,,'final','all','all']
idx2 <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,,'final','MAT','all']
idx3 <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,,'final','MAT','all']
idx3@index <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all@index[,,,'MAT',]*
VIaSPAWN_baseline$VIaSPAWN.stock@stock.wt*1e-3
################################################################
# plots
################################################################
......@@ -433,6 +438,8 @@ png(file.path(figurePath,'comp_indices_abu.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
p <- ggplot(indicesAll,aes(x=year,y=data,col=survey))+
geom_line()+
ylab('Abundance (millions)')+
theme(axis.text.x = element_text(angle=90))+
facet_wrap(.~age,scales='free')
print(p)
dev.off()
......@@ -442,71 +449,64 @@ png(file.path(figurePath,'comp_indices_znorm.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
p <- ggplot(indicesAll,aes(x=year,y=dataNorm,col=survey))+
geom_line()+
ylab('z norm')+
theme(axis.text.x = element_text(angle=90))+
facet_wrap(.~age,scales='free')
print(p)
dev.off()
library(corrmorant)
cor.VIaSPAWN <- as.data.frame(FLCohort(VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all@index[,,'final','all','all']))
ageUnique <- unique(cor.VIaSPAWN$age)
cor.VIaSPAWN <- cor.VIaSPAWN %>% pivot_wider(names_from = age, values_from = data)
cor.VIaSPAWN <- log10(cor.VIaSPAWN[,ac(ageUnique)])
cor.VIaSPAWN
ggcorrm(drosera) +
lotri(geom_point(alpha = 0.5)) +
utri_corrtext() +
dia_names(y_pos = 0.15, size = 3) +
dia_density(lower = 0.3, fill = "grey80", color = 1)
drosera
ggcorrm(drosera)
ggcorrm(drosera) +
lotri(geom_point(alpha = 0.5))
indicesAll
cor.indicesAll <- indicesAll[,c(1,3,5)]
cor.indicesAll
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll
cor.indicesAll <- indicesAll[,c(1,3,5)]
cor.indicesAll
cor.indicesAll <- indicesAll
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll
indicesAll
cor.indicesAll <- indicesAll[,c(1,2,3,5)]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll
ggcorrm(cor.indicesAll) +
lotri(geom_point(alpha = 0.5))
cor.indicesAll <- indicesAll[,c(1,2,3,5)]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll$year <- as.factor(cor.indicesAll$year)
ggcorrm(cor.indicesAll) +
lotri(geom_point(alpha = 0.5))
cor.indicesAll
cor.indicesAll <- indicesAll[,c(1,2,3,5)]
cor.indicesAll <- indicesAll[,c(1,2,3,5)]
# correlation matrix WoS
scaling_factor <- 1.5
png(file.path(figurePath,'corMat_znorm_WoS.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
cor.indicesAll <- indicesAll[,c(1,2,4,5)]
cor.indicesAll$survey %in% c('WoS', 'VIaSPAWN')
#cor.indicesAll$dataNorm <- log10(cor.indicesAll$dataNorm)
cor.indicesAll <- cor.indicesAll[cor.indicesAll$age != 0,]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = survey, values_from = dataNorm)
#cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll$year <- as.factor(cor.indicesAll$year)
ggcorrm(cor.indicesAll) +
lotri(geom_point(alpha = 0.5))
cor.indicesAll
ggcorrm(cor.indicesAll,mapping = aes(col = survey, fill = survey)) +
lotri(geom_point(alpha = 0.5))
drosera
nba = read.csv("http://datasets.flowingdata.com/ppg2008.csv")
ggcorr(nba)
install.packages("GGally")
install.packages("GGally")
source("https://raw.githubusercontent.com/briatte/ggcorr/master/ggcorr.R")
install.packages("GGally")
cor.indicesAll <- indicesAll[,c(1,2,3,5)]
cor.indicesAll <- cor.indicesAll[cor.indicesAll$age != 0,]
cor.indicesAll <- indicesAll[,c(1,2,3,5)]
cor.indicesAll$age <- as.factor(cor.indicesAll$age)
p <- ggcorrm(cor.indicesAll,mapping = aes(col = age, fill = age)) +
lotri(geom_smooth(method = "lm"))+
lotri(geom_point(alpha = 0.5))+
utri_corrtext(col='black')+
facet_wrap(.~age,scales='free')
print(p)
dev.off()
# correlation matrix WoS
scaling_factor <- 1.5
png(file.path(figurePath,'corMat_znorm_MHAS.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
cor.indicesAll <- indicesAll[,c(1,2,4,5)]
cor.indicesAll <- cor.indicesAll[cor.indicesAll$survey %in% c('MHAS', 'VIaSPAWN'),]
#cor.indicesAll$dataNorm <- log10(cor.indicesAll$dataNorm)
cor.indicesAll <- cor.indicesAll[cor.indicesAll$age != 0,]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = survey, values_from = data)
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = survey, values_from = dataNorm)
#cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll$year <- as.factor(cor.indicesAll$year)
cor.indicesAll$age <- as.factor(cor.indicesAll$age)
cor.indicesAll <- indicesAll[,c(1,2,3,5)]
cor.indicesAll <- cor.indicesAll[cor.indicesAll$age != 0,]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = survey, values_from = data)
p <- ggcorrm(cor.indicesAll,mapping = aes(col = age, fill = age)) +
lotri(geom_smooth(method = "lm"))+
lotri(geom_point(alpha = 0.5))+
utri_corrtext(col='black')+
facet_wrap(.~age,scales='free')
print(p)
dev.off()
# internal consistency abundance
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_N_all.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx1[ac(1:9)]))
dev.off()
# internal consistency abundance mature
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_N_mat.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx2[ac(1:9)]))
dev.off()
# internal consistency SSB
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_SSB.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx3[ac(1:9)]))
dev.off()
......@@ -32,6 +32,7 @@ load(file.path(resultsPath,'VIaSPAWN_bootstrap.RData'))
project_mapping <- read.csv(file.path(dataPath,"2_project_mapping_baseline.csv"))
wos_index <- read.csv(file.path(dataPath,'WSAS_AbundanceAge.csv'))
MHAS_vian_index <- read.csv(file.path(dataPath,'MHAS_vian_AbundanceAge.csv'),check.names=FALSE)
currentYear <- 2021
......@@ -175,6 +176,10 @@ IVaSPAWN_index$survey <- 'VIaSPAWN'
wos_index <- wos_index[wos_index$year %in% IVaSPAWN_index$year,]
wos_index$dataNorm <- NA
wos_index$survey <- 'WoS'
MHAS_vian_index <- MHAS_vian_index %>% pivot_longer(!year,names_to='age',values_to='data')
MHAS_vian_index <- MHAS_vian_index[MHAS_vian_index$year %in% IVaSPAWN_index$year,]
MHAS_vian_index$dataNorm <- NA
MHAS_vian_index$survey <- 'MHAS'
# z norm
for(idxAge in 0:9){
......@@ -182,13 +187,28 @@ for(idxAge in 0:9){
(IVaSPAWN_index$data[IVaSPAWN_index$age == idxAge]-
mean(IVaSPAWN_index$data[IVaSPAWN_index$age == idxAge]))/
sd(IVaSPAWN_index$data[IVaSPAWN_index$age == idxAge])
wos_index$dataNorm[wos_index$age == idxAge] <-
(wos_index$data[wos_index$age == idxAge]-
mean(wos_index$data[wos_index$age == idxAge]))/
sd(wos_index$data[wos_index$age == idxAge])
MHAS_vian_index$dataNorm[MHAS_vian_index$age == idxAge] <-
(MHAS_vian_index$data[MHAS_vian_index$age == idxAge]-
mean(MHAS_vian_index$data[MHAS_vian_index$age == idxAge]))/
sd(MHAS_vian_index$data[MHAS_vian_index$age == idxAge])
}
indicesAll <- rbind(IVaSPAWN_index,wos_index)
indicesAll <- rbind(IVaSPAWN_index,wos_index,MHAS_vian_index)
idx1 <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,,'final','all','all']
idx2 <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,,'final','MAT','all']
idx3 <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all[,,'final','MAT','all']
idx3@index <- VIaSPAWN_baseline$VIaSPAWN.ind$VIaSPAWN_all@index[,,,'MAT',]*
VIaSPAWN_baseline$VIaSPAWN.stock@stock.wt*1e-3
################################################################
# plots
......@@ -393,12 +413,13 @@ p <- ggplot(indicesAll,aes(x=year,y=dataNorm,col=survey))+
print(p)
dev.off()
# correlation matrix
# correlation matrix WoS
scaling_factor <- 1.5
png(file.path(figurePath,'corMat_znorm.png'),
png(file.path(figurePath,'corMat_znorm_WoS.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
cor.indicesAll <- indicesAll[,c(1,2,4,5)]
cor.indicesAll$survey %in% c('WoS', 'VIaSPAWN')
#cor.indicesAll$dataNorm <- log10(cor.indicesAll$dataNorm)
cor.indicesAll <- cor.indicesAll[cor.indicesAll$age != 0,]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = survey, values_from = dataNorm)
......@@ -413,4 +434,55 @@ p <- ggcorrm(cor.indicesAll,mapping = aes(col = age, fill = age)) +
facet_wrap(.~age,scales='free')
print(p)
dev.off()
# correlation matrix WoS
scaling_factor <- 1.5
png(file.path(figurePath,'corMat_znorm_MHAS.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
cor.indicesAll <- indicesAll[,c(1,2,4,5)]
cor.indicesAll <- cor.indicesAll[cor.indicesAll$survey %in% c('MHAS', 'VIaSPAWN'),]
#cor.indicesAll$dataNorm <- log10(cor.indicesAll$dataNorm)
cor.indicesAll <- cor.indicesAll[cor.indicesAll$age != 0,]
cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = survey, values_from = dataNorm)
#cor.indicesAll <- cor.indicesAll %>% pivot_wider(names_from = age, values_from = data)
cor.indicesAll$year <- as.factor(cor.indicesAll$year)
cor.indicesAll$age <- as.factor(cor.indicesAll$age)
p <- ggcorrm(cor.indicesAll,mapping = aes(col = age, fill = age)) +
lotri(geom_smooth(method = "lm"))+
lotri(geom_point(alpha = 0.5))+
utri_corrtext(col='black')+
facet_wrap(.~age,scales='free')
print(p)
dev.off()
# internal consistency abundance
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_N_all.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx1[ac(1:9)]))
dev.off()
# internal consistency abundance mature
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_N_mat.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx2[ac(1:9)]))
dev.off()
# internal consistency SSB
scaling_factor <- 1.5
png(file.path(figurePath,'VIaSPAWN_internal_consistency_SSB.png'),
width = 12*scaling_factor, height = 8*scaling_factor, units = "cm", res = 300, pointsize = 10)
print(FLCore:::plotInternalConsistency(idx3[ac(1:9)]))
dev.off()
\ No newline at end of file
File added
year,1,2,3,4,5,6,7,8,9
2014,0,30.0215,118.633,271.0141,252.208,99.3417,31.3819,10.3914,4.8973
2015,0,122.5152,255.6748,395.2611,254.8183,225.2797,58.9608,9.3817,0
2016,0,8.0892,45.2178,42.1824,38.0626,42.3432,26.0502,1.7079,0.9087
2017,0,6.5547,112.5661,87.6862,39.2217,58.6593,39.2075,21.647,0.3307
2018,572.945,303.5882,68.301,199.1444,92.3418,36.8026,47.078,14.6288,6.1442
2019,3.8002,170.6983,213.9642,103.4593,91.9746,47.1626,5.9276,17.2714,8.9242
2020,895.1145,776.2013,401.7521,188.2019,71.4467,120.2135,24.7746,6.6401,8.5084
2021,176.3191696,1483.090528,556.8831299,109.3436122,66.77537437,26.11316719,47.77623745,9.808269792,11.72672597
figures/StoX/2_baseline_final/VIaSPAWN_internal_consistency.png

128 KiB

figures/StoX/2_baseline_final/VIaSPAWN_internal_consistency_N_all.png

82.8 KiB

figures/StoX/2_baseline_final/VIaSPAWN_internal_consistency_N_mat.png

82.7 KiB

figures/StoX/2_baseline_final/VIaSPAWN_internal_consistency_SSB.png

80.1 KiB

figures/StoX/2_baseline_final/comp_indices_abu.png

66.3 KiB | W: | H:

figures/StoX/2_baseline_final/comp_indices_abu.png

74.6 KiB | W: | H:

figures/StoX/2_baseline_final/comp_indices_abu.png
figures/StoX/2_baseline_final/comp_indices_abu.png
figures/StoX/2_baseline_final/comp_indices_abu.png
figures/StoX/2_baseline_final/comp_indices_abu.png
  • 2-up
  • Swipe
  • Onion skin
figures/StoX/2_baseline_final/comp_indices_znorm.png

62.5 KiB | W: | H:

figures/StoX/2_baseline_final/comp_indices_znorm.png

69.3 KiB | W: | H:

figures/StoX/2_baseline_final/comp_indices_znorm.png
figures/StoX/2_baseline_final/comp_indices_znorm.png
figures/StoX/2_baseline_final/comp_indices_znorm.png
figures/StoX/2_baseline_final/comp_indices_znorm.png
  • 2-up
  • Swipe
  • Onion skin
figures/StoX/2_baseline_final/corMat_znorm.png

76.3 KiB

figures/StoX/2_baseline_final/corMat_znorm_MHAS.png

77.2 KiB

figures/StoX/2_baseline_final/corMat_znorm_WoS.png

86.9 KiB

figures/StoX/2_baseline_final/length_age.png

60.3 KiB

figures/StoX/2_baseline_final/map_final.png

57.1 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment