title: {{STOCK_NAME}} always_allow_html: yes output: html_document: fig_caption: yes favicon: favicon.ico
## Load packages # library(tidyverse) library(ggplot2) library(tidyr) library(dplyr) library(plotly) library(DT) library(jpeg) library(patchwork) library(ggthemes) library(AICcmodavg) library(ecotrend) library(magrittr) library(raster) library(stars) library(here) library(zoo) library(gt) library(kableExtra) library(ggiraph) knitr::opts_chunk$set(echo = F, message = F, warning = F, fig.align = 'center', eval.after = 'fig.cap') ## Read in stock area vectors all_stock_season <- readr::read_csv(here::here("data/stock_data/stock_list.csv"), col_types = readr::cols( common_name = readr::col_character(), sci_name = readr::col_character(), cc_name = readr::col_character(), stock_name = readr::col_character(), species_code = readr::col_character(), svspp = readr::col_double(), stock_season = readr::col_character(), strata = readr::col_double())) #zooplankton lookup table zoo_lookup <- read.csv(here::here("data-raw/zooplankton_lookup.csv"), stringsAsFactors = F) ## Put all mustaches here stock_code <- "{{SPECIES_CODE}}" stock_name <- "{{STOCK_NAME}}" cc_name <- "{{CC_NAME}}" common_name <- "{{COMMON_NAME}}" interactive <- ifelse(knitr::is_latex_output(), F,T) #Special case for when north/south is included in the stock name if (grepl("north", stock_name)){ map_lab <- paste0('Strata map for the northern component of the {{COMMON_NAME}} (', ifelse(knitr::is_latex_output(), '\\textit{{{SCI_NAME}}}','*{{SCI_NAME}}*'),') stock on the NE shelf.') } else if (grepl("south", stock_name)){ map_lab <- paste0('Strata map for the southern component of the {{COMMON_NAME}} (', ifelse(knitr::is_latex_output(), '\\textit{{{SCI_NAME}}}','*{{SCI_NAME}}*'),') stock on the NE shelf.') } else { map_lab <- "Strata map for the {{COMMON_NAME}} ({{SCI_NAME}}) stock on the NE shelf." } #Get stock strata and unique identifiers strata <- all_stock_season %>% dplyr::filter(stock_name == !!stock_name) source(here::here("R/map_strata.R")) source(here::here("R/get_strata.R")) source(here::here("R/crop_to_strata.R")) source(here::here("R/stars_to_series.R")) source(here::here("R/tab_plotly.R")) source(here::here("R/create_buttons.R")) source(here::here("R/STARS_v18.R")) source(here::here("R/gls_summary.R")) source(here::here("R/plot_sae.R")) source(here::here("R/fit_regime_and_trend.R")) svspp <- strata %>% pull(svspp) %>% unique() sixcode <- strata %>% pull(species_code) %>% unique() subarea <- strata %>% pull(stock_subarea) %>% unique() if (is.na(subarea)){ subarea <- "unit" } #Specific analytical treatments were selected beforehand for each stock. These data are in data-raw/treatment_selection.csv. We import here and filter the below SAE data by treatment selection. treatment_selection <- read.csv(here::here("data-raw/treatment-selection.csv"), stringsAsFactors = F) %>% filter(svspp == !!svspp, stock == subarea) #Load swept area estimate data. Filter by svspp code and treatment selection spring_sae <- read.csv(here::here("data-raw/spring_sae_tb_sum.csv"), stringsAsFactors = F) %>% filter(svspp == !!svspp, stocks == subarea) fall_sae <- read.csv(here::here("data-raw/fall_sae_tb_sum.csv"), stringsAsFactors = F) %>% filter(svspp == !!svspp, stocks == subarea) #Adjust knitr fig height if a facet plot is needed if (nrow(spring_sae) > 0 & length(unique(spring_sae$stocks)) > 1){ adjust_for_facet <- 9 } else if (nrow(spring_sae) > 0 & length(unique(spring_sae$stocks)) > 1){ adjust_for_facet <- 9 } else { adjust_for_facet <- 6 } #Get available seasons for stocks stock_season <- strata %>% pull(stock_season) %>% unique() #Get estimates for ecosystem and stock habitat area stock_habitat_area <- read.csv(here::here("data-raw/sum_ocl_byunit_sprfall.csv"), stringsAsFactors = F) %>% filter(species.code == sixcode) ecosystem_habitat_area <- read.csv(here::here("data-raw/sum_ocl_spr and fall.csv"), stringsAsFactors = F) %>% filter(species.code == sixcode) #Set interactive to F when pushing a draft document to google drive. Otherwise, the ggiraph figures will render as interactive. Interactive figures should only be used during the creation of the final bookdown document. #Switches the encoding for the degree symbol (i.e. LaTeX or HTML) degree <- ifelse(knitr::is_latex_output(),"\\textdegree " ,'°') kable_format <- ifelse(knitr::is_latex_output(), "latex", "html")
{{READMEStart}}
Welcome to the newest iteration of the Ecosystem Context for Stock Advice product for {{STOCK_SUBAREA}}{{COMMON_NAME}}. You are looking at an intermediate draft that still needs some work. Check out github.com/noaa-edab/ecsa for more information on the build process that moves raw data -> stock-name_draft.rmd/Google Doc template -> stock-name.rmd/.html/.pdf final series of documents.
Do:
Don't:
{{READMEEnd}}
{{IntroductionStart}}
This report provides contextual ecosystem information for {{STOCK_SUBAREA}}{{COMMON_NAME}} ({{SCI_NAME}}) on the Northeast U.S. Continental Shelf. Data extractions for spring and fall are confined to the {{COMMON_NAME}} stock area based on respective survey strata sets. The information is intended to span a range of potential factors affecting the productivity and distribution of {{COMMON_NAME}}, including: surface and bottom temperature and salinity, chlorophyll concentrations, indices of habitat, diet composition, and abundance of key zooplankton prey of larval {{COMMON_NAME}}. These factors can be used to qualitatively inform the interpretation of population status and/or quantitatively to improve model responsiveness to ecosystem factors. The range and complexity of ecosystem data makes it unlikely to find the most relevant and comprehensive factor variables with a first evaluation; this process will require an iterative approach of evaluation and feedback. Additional indices can be included to address the needs of the working group.
{{IntroductionEnd}}
map_strata(stock_name = stock_name, common_name = common_name, stock_season = stock_season, strata = strata, overwrite = FALSE, save_plot = FALSE)
A note on figures
Unless otherwise noted, time series in this document are represented by dark blue lines. Estimates of linear trends and regime shifts are included on plots when found to be significant (p < 0.05), and are shown by light blue and green lines respectively. Trend strengths and confidence intervals are also included in plot titles when trends are present. Trends were modeled using a GLS model selection approach [see @hardison2019 for details].
Last updated on r format(Sys.Date(), format = "%B %e %Y")
.
{{TemperatureStart}}
An optimal interpolation procedure was used to estimate NE Shelf surface and bottom temperatures for two seasonal time frames (see #methodstempsalin). The temperature estimates were standardized to April 3 and October 11 for spring and fall over the period 1968-2018. Surface and bottom temperature within the r common_name
stock areas are shown below.
{{TemperatureEnd}}
{{BottomTemperatureStart}}
{{BottomTemperatureEnd}}
spring_bottom_temp <- fit_regime_and_trend(r = "temperature_spring_bottom.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "spring", measure_name = "bottom_temp") spring_title <- spring_bottom_temp$plot_title fall_bottom_temp <- fit_regime_and_trend(r = "temperature_fall_bottom.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "fall", measure_name = "bottom_temp") fall_title <- fall_bottom_temp$plot_title #Only show plots based on what seasons are available. If strata are available for spring and fall, show both plots. Otherwise just one. # Spring is print_plot[1] and fall is print_plot[2] if (any(stock_season == "both") | all(stock_season == c('spring','fall'))){ print_plot <- c(T,T) } else if (stock_season == "spring") { print_plot <- c(T,F) } else if (stock_season == "fall"){ print_plot <- c(F,T) }
spring_bottom_temp_plt <- spring_bottom_temp$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Temperature (°C)") + ggtitle(spring_title) if (interactive){ girafe_options(girafe(code = print(spring_bottom_temp_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { spring_bottom_temp_plt }
fall_bottom_temp_plt <- fall_bottom_temp$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Temperature (°C)") + ggtitle(fall_title) if (interactive){ girafe_options(girafe(code = print(fall_bottom_temp_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { fall_bottom_temp_plt }
{{SurfaceTemperatureStart}}
{{SurfaceTemperatureEnd}}
spring_surface_temp <- fit_regime_and_trend(r = "temperature_spring_surface.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "spring", measure_name = "surface_temp") spring_title <- spring_surface_temp$plot_title fall_surface_temp <- fit_regime_and_trend(r = "temperature_fall_surface.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "fall", measure_name = "surface_temp") fall_title <- fall_surface_temp$plot_title
spring_surface_temp_plt <- spring_surface_temp$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Temperature (°C)") + ggtitle(spring_title) if (interactive){ girafe_options(girafe(code = print(spring_surface_temp_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { spring_surface_temp_plt }
fall_surface_temp_plt <- fall_surface_temp$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Temperature (°C)") + ggtitle(fall_title) if (interactive){ girafe_options(girafe(code = print(fall_surface_temp_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { fall_surface_temp_plt }
{{SalinityStart}}
An optimal interpolation procedure was used to estimate NE Shelf surface and bottom salinity for two seasonal time frames (see #methodstempsalin). Though collected with temperature data, reliable instrumentation limits this time series to 1992-2018. The salinity estimates were standardized to April 3 and October 11 for spring and fall. Surface and bottom salinities within the r common_name
stock areas are shown below.
{{SalinityEnd}}
{{BottomSalinityStart}}
{{BottomSalinityEnd}}
spring_bottom_sal <- fit_regime_and_trend(r = "salinity_spring_bottom.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "spring", measure_name = "bottom_sal") spring_title <- spring_bottom_sal$plot_title fall_bottom_sal <- fit_regime_and_trend(r = "salinity_fall_bottom.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "fall", measure_name = "bottom_sal") fall_title <- fall_bottom_sal$plot_title
spring_bottom_sal_plt <- spring_bottom_sal$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Salinity (PSU)") + ggtitle(spring_title) if (interactive){ girafe_options(girafe(code = print(spring_bottom_sal_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { spring_bottom_sal_plt }
fall_bottom_sal_plt <- fall_bottom_sal$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Salinity (PSU)") + ggtitle(fall_title) if (interactive){ girafe_options(girafe(code = print(fall_bottom_sal_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { fall_bottom_sal_plt }
{{SurfaceSalinityStart}}
{{SurfaceSalinityEnd}}
spring_surface_sal <- fit_regime_and_trend(r = "salinity_spring_surface.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "spring", measure_name = "surface_sal") spring_title <- spring_surface_sal$plot_title fall_surface_sal <- fit_regime_and_trend(r = "salinity_fall_surface.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "fall", measure_name = "surface_sal") fall_title <- fall_surface_sal$plot_title
spring_surface_sal_plt <- spring_surface_sal$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Salinity (PSU)") + ggtitle(spring_title) if (interactive){ girafe_options(girafe(code = print(spring_surface_sal_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { spring_surface_sal_plt }
fall_surface_sal_plt <- fall_surface_sal$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Salinity (PSU)") + ggtitle(fall_title) if (interactive){ girafe_options(girafe(code = print(fall_surface_sal_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { fall_surface_sal_plt }
{{ChlorophyllStart}}
{{ChlorophyllEnd}}
{{ChlorophyllConcStart}}
The concentration of chlorophyll was measured with a suite of satellite sensors and merged into a single dataset (see #methodschl). Chlorophyll concentrations in the spring and fall r common_name
stock areas are shown below.
{{ChlorophyllConcEnd}}
spring_chl <- fit_regime_and_trend(r = "chlorophyll_conc_spring.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "spring", measure_name = "biomass", process_to_season = "spring") spring_title <- spring_chl$plot_title fall_chl <- fit_regime_and_trend(r = "chlorophyll_conc_fall.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "fall", measure_name = "biomass", process_to_season = "fall") fall_title <- fall_chl$plot_title
spring_chl_plt <- spring_chl$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab(expression(paste("Chlorophyll (mg ", m^{-3}, ")")))+ ggtitle(spring_title) if (interactive){ girafe_options(girafe(code = print(spring_chl_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { spring_chl_plt }
fall_chl_plt <- fall_chl$df %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Regime mean" = "#b2df8a", "Trend" = "#a6cee3", "Series" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab(expression(paste("Chlorophyll (mg ", m^{-3}, ")")))+ ggtitle(fall_title) if (interactive){ girafe_options(girafe(code = print(fall_chl_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { fall_chl_plt }
{{ZooplanktonStart}}
{{ZooplanktonEnd}}
{{CopepodStart}}
{{CopepodEnd}}
spring_cope <- fit_regime_and_trend(r = "zoo_spring_rasters_1yr.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "spring", measure_name = "zoo", group_regex = "[^A-Z_](.*)(?=_)") %>% mutate(season = "spring") %>% left_join(.,zoo_lookup, by = "Grouping") %>% dplyr::filter(copepod == "y") %>% dplyr::select(-Grouping, -season, -copepod) %>% tidyr::spread(full_name, Mean) spring_min <- min(spring_cope$Time) fall_cope <- fit_regime_and_trend(r = "zoo_fall_rasters_1yr.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "fall", measure_name = "zoo", group_regex = "[^A-Z_](.*)(?=_)") %>% mutate(season = "fall") %>% left_join(.,zoo_lookup, by = "Grouping") %>% dplyr::filter(copepod == "y") %>% dplyr::select(-Grouping, -season, -copepod) %>% tidyr::spread(full_name, Mean) fall_min <- min(fall_cope$Time)
if (interactive){ buttons <- create_buttons(spring_cope) spring_cope_plt <- tab_plotly(spring_cope, add_smoother = F, showlegend = F) %>% layout(title = "Spring copepod abundance", yaxis = list(title = "Abundance (log num m<sup>-3</sup>)", hoverformat = '.3f', mirror = TRUE, showline = TRUE), xaxis = list(title = "", mirror = TRUE, showline = TRUE), updatemenus = list( list( buttons = list(buttons[[1]],buttons[[2]],buttons[[3]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.2 ), list( buttons = list(buttons[[4]],buttons[[5]],buttons[[6]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.3 ), list( buttons = list(buttons[[7]],buttons[[8]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.4 ) ) ) spring_cope_plt } else { spring_cope %>% tidyr::gather(Var, Value, -Time) %>% ggplot() + geom_line(aes(x = Time, y = Value, group = Var)) + facet_wrap(Var~., scales = "free_y") + theme_bw() + ylab(expression(paste("Abundance (log num ", m^{-3}, ")"))) + theme(strip.text = element_text(face = "italic"), strip.background = element_blank(), axis.text.x = element_text(angle = 45, hjust = 1)) + ggtitle("Spring copepod abundance") }
if (interactive){ buttons <- create_buttons(fall_cope) fall_cope_plt <- tab_plotly(fall_cope, add_smoother = F, showlegend = F) %>% layout(title = "Fall copepod abundance", yaxis = list(title = "Abundance (log num m<sup>-3</sup>)", hoverformat = '.3f', mirror = TRUE, showline = TRUE), xaxis = list(title = "", mirror = TRUE, showline = TRUE), updatemenus = list( list( buttons = list(buttons[[1]],buttons[[2]],buttons[[3]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.2 ), list( buttons = list(buttons[[4]],buttons[[5]],buttons[[6]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.3 ), list( buttons = list(buttons[[7]],buttons[[8]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.4 ) ) ) fall_cope_plt } else { fall_cope %>% tidyr::gather(Var, Value, -Time) %>% ggplot() + geom_line(aes(x = Time, y = Value, group = Var)) + facet_wrap(Var~., scales = "free_y") + theme_bw() + ylab(expression(paste("Abundance (log num ", m^{-3}, ")"))) + theme(strip.text = element_text(face = "italic"), strip.background = element_blank(), axis.text.x = element_text(angle = 45, hjust = 1)) + ggtitle("Fall copepod abundance") }
{{NonCopepodStart}}
{{NonCopepodEnd}}
spring_noncope <- fit_regime_and_trend(r = "zoo_spring_rasters_1yr.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "spring", measure_name = "zoo", group_regex = "[^A-Z_](.*)(?=_)") %>% mutate(season = "spring") %>% left_join(.,zoo_lookup, by = "Grouping") %>% dplyr::filter(copepod == "n") %>% dplyr::select(-Grouping, -season, -copepod) %>% tidyr::spread(full_name, Mean) spring_min <- min(spring_noncope$Time) fall_noncope <- fit_regime_and_trend(r = "zoo_fall_rasters_1yr.rdata", stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "fall", measure_name = "zoo", group_regex = "[^A-Z_](.*)(?=_)") %>% mutate(season = "fall") %>% left_join(.,zoo_lookup, by = "Grouping") %>% dplyr::filter(copepod == "n") %>% dplyr::select(-Grouping, -season, -copepod) %>% tidyr::spread(full_name, Mean) fall_min <- min(fall_noncope$Time)
if (interactive){ buttons <- create_buttons(spring_noncope) spring_noncope_plt <- tab_plotly(spring_noncope, add_smoother = F, showlegend = F) %>% layout(title = "Spring non-copepod zoo. abundance", yaxis = list(title = "Abundance (log num m<sup>-3</sup>)", hoverformat = '.3f', mirror = TRUE, showline = TRUE), showlegend = F, updatemenus = list( list( buttons = list(buttons[[1]],buttons[[2]],buttons[[3]],buttons[[4]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.2 ), list( buttons = list(buttons[[5]],buttons[[6]],buttons[[7]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.3 ), list( buttons = list(buttons[[8]],buttons[[9]],buttons[[10]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.4 ) ) ) spring_noncope_plt } else { spring_noncope %>% tidyr::gather(Var, Value, -Time) %>% ggplot() + geom_line(aes(x = Time, y = Value, group = Var)) + facet_wrap(Var~., scales = "free_y") + theme_bw() + ylab(expression(paste("Abundance (log num ", m^{-3}, ")"))) + theme(strip.text = element_text(face = "italic"), strip.background = element_blank(), axis.text.x = element_text(angle = 45, hjust = 1)) + ggtitle("Spring non-copepod zoo. abundance") }
if (interactive){ buttons <- create_buttons(fall_noncope) fall_noncope_plt <- tab_plotly(fall_noncope, add_smoother = F, showlegend = F) %>% layout(title = "Fall non-copepod zoo. abundance", yaxis = list(title = "Abundance (log num m<sup>-3</sup>)", hoverformat = '.3f', mirror = TRUE, showline = TRUE), showlegend = F, updatemenus = list( list( buttons = list(buttons[[1]],buttons[[2]],buttons[[3]],buttons[[4]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.2 ), list( buttons = list(buttons[[5]],buttons[[6]],buttons[[7]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.3 ), list( buttons = list(buttons[[8]],buttons[[9]],buttons[[10]]), type = "buttons", direction = "right", xanchor = "center", yanchor = "top", pad = list("r"= 0, "t"= 10, "b" = 10), x = 0.5, y = -0.4 ) ) ) fall_noncope_plt } else { fall_noncope %>% tidyr::gather(Var, Value, -Time) %>% ggplot() + geom_line(aes(x = Time, y = Value, group = Var)) + facet_wrap(Var~., scales = "free_y") + theme_bw() + ylab(expression(paste("Abundance (log num ", m^{-3}, ")"))) + theme(strip.text = element_text(face = "italic"), strip.background = element_blank(), axis.text.x = element_text(angle = 45, hjust = 1)) + ggtitle("Fall non-copepod zoo. abundance") }
{{HabitatStart}}
{{HabitatEnd}}
{{OccurrenceStart}}
The probability of occurrence was estimated using random forest classification models (see #methodsocc). The mean annual probabilities were extracted for the spring and/or fall stock definition areas. These data provide an estimate of the potential use of the habitat associated with the stock definition.
{{OccurrenceEnd}}
spring_occ_prob <- fit_regime_and_trend(r = paste0("spri_",sixcode,"_occ_prob.rdata"), stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "spring", measure_name = "occurrence")$df %>% dplyr::select(Time, Spring = Series) fall_occ_prob <- fit_regime_and_trend(r = paste0("fall_",sixcode,"_occ_prob.rdata"), stock_name = stock_name, common_name = common_name, stock_season = stock_season, data_season = "fall", measure_name = "occurrence")$df %>% dplyr::select(Time, Fall = Series) if (all(print_plot)){ occ_prob <- spring_occ_prob %>% left_join(.,fall_occ_prob, by = "Time") %>% dplyr::select(Time, Spring, Fall) } else if (print_plot[1]){ occ_prob <- spring_occ_prob %>% dplyr::select(Time, Spring) } else if (print_plot[2]){ occ_prob <- fall_occ_prob %>% dplyr::select(Time, Fall) } occ_prob_plt <- occ_prob %>% tidyr::gather(Var, Value, -Time) %>% mutate(tooltip = paste0("<table><tr><td>Year:</td><td>",Time,"</td></tr><tr><td>Value: </td><td>",round(Value,3),"</td></tr></table>")) %>% ggplot(aes(x = Time, y = Value, color = Var, group = Var, tooltip = tooltip, data_id = Time)) + geom_line(size = 1)+ {if(interactive) geom_point_interactive(size = 0) else geom_line(size = 1)} + scale_color_manual(values = c("Fall" = "#a6cee3", "Spring" = "#1f78b4"))+ theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom") + ylab("Occupancy probability")+ ggtitle("Occupancy probability") if (interactive){ girafe_options(girafe(code = print(occ_prob_plt), width_svg = 8.5),opts_hover(css = "r:2pt;") ) } else { occ_prob_plt }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.