Skip to content

Commit

Permalink
Merge pull request #5 from afsc-gap-products/add_nbs
Browse files Browse the repository at this point in the history
Start improving NBS analysis
  • Loading branch information
sean-rohan-NOAA authored Nov 9, 2024
2 parents 6570eb1 + 8b4c183 commit 7c44fe3
Show file tree
Hide file tree
Showing 52 changed files with 291 additions and 10 deletions.
18 changes: 13 additions & 5 deletions 00_setup_internal_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,24 @@ library(devtools)
# Region settings for years to include and area_ids for ESR areas/subareas
region_settings <- list(GOA = list(esr_subarea_id = c(919, 929, 939, 949, 959),
esr_area_id = 99903,
min_year = 1990),
min_year = 1990,
min_rema_year = 1990,
exclude_years = 2001),
AI = list(esr_subarea_id = c(299, 799, 3499, 5699),
esr_area_id = 99904,
min_year = 1991),
min_year = 1991,
min_rema_year = 1991,
exclude_years = NULL),
EBS = list(esr_subarea_id = c(1:6),
esr_area_id = 99901,
min_year = 1982),
NBS = list(esr_subarea_id = NULL,
min_year = 1982,
min_rema_year = 1982,
exclude_years = NULL),
NBS = list(esr_subarea_id = c(70, 71, 81),
esr_area_id = 99902,
min_year = 2010))
min_year = 2010,
min_rema_year = 2017,
exclude_years = NULL))

save(region_settings, file = "./data/region_settings.rda")

Expand Down
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
Package: esrindex
Type: Package
Title: Abundance index products for Alaska ESRs
Version: 0.1.4
Date: 2024-10-01
Version: 1.0.0
Date: 2024-11-08
Authors@R: c(person("Sean", "Rohan", email = "sean.rohan@noaa.gov", role = c("aut", "cre")),
person("Thaddaeus", "Buser", email = "thaddaeus.buser@noaa.gov", role = "ctb"),
person("Christina", "Conrath", email = "christina.conrath@noaa.gov", role = "ctb"),
person("Sarah", "Friedman", email = "sarah.friedman@noaa.gov", role = "ctb"),
person("Ned", "Laman", email = "ned.laman@noaa.gov", role = "ctb"),
person("Susanne", "McDermott", email = "susanne.mcdermott@noaa.gov", role = "ctb"),
person("Margaret", "Siple", email = "margaret.siple@noaa.gov", role = "ctb"))
Maintainer: Sean Rohan <sean.rohan@noaa.gov>
Description: Make abundance index products for Alaska Ecosystem Status Reports.
Expand All @@ -18,4 +19,4 @@ Depends: R (>= 4.1), gapindex
Imports: dplyr, ggplot2, RODBC, getPass, knitr, rmarkdown, rema, scales, here, methods, akgfmaps,
ragg, sf, classInt, cowplot
Remotes: afsc-gap-products/gapindex, afsc-assessments/rema, afsc-gap-products/akgfmaps
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
9 changes: 9 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
esrindex 1.0.0 (November 8, 2024) - First production release
----------------------------------------------------------------

NEW FEATURES

- plot_region_rema() makes individual timeseries plots for each
group.


esrindex 0.1.4 (October 1, 2024)
----------------------------------------------------------------

Expand Down
233 changes: 233 additions & 0 deletions R/plot_region_rema.R
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,239 @@ plot_region_rema <- function(x,

plot_list[[ii]] <- p1

# Plots for individual groups
for(kk in 1:length(group_name)) {

sel_group_fit <- fit_dat[fit_dat$group_name == group_name[kk], ]

sel_group_obs <- obs_dat[obs_dat$group_name == group_name[kk], ]

sel_group_ts_summary <- ts_summary[ts_summary$group_name == group_name[kk], ]

if(error_bar & benchmarks == "none") {

p1 <- ggplot() +
geom_ribbon(data = sel_group_fit,
mapping = aes(x = year,
ymin = pred_lci,
ymax = pred_uci),
alpha = 0.3,
fill = ribbon_fill) +
geom_errorbar(data = sel_group_obs,
mapping = aes(x = YEAR,
ymin = BIOMASS_PLUS2_SD,
ymax = BIOMASS_MINUS2_SD),
width = 0.5,
color = errorbar_color) +
geom_point(data = sel_group_obs,
mapping = aes(x = YEAR, y = BIOMASS_MT),
color = point_color) +
geom_path(data = sel_group_fit,
mapping = aes(x = year, y = pred),
color = timeseries_color,
size = rel(1.1)) +
scale_y_continuous(name = paste0("Biomass Index (", set_unit, ")"),
expand = expansion(mult = c(0, 0.05)),
labels = lab_fun(trim = lab_trim)) +
scale_x_continuous(name = "Year",
breaks = year_breaks,
labels = year_labels) +
expand_limits(y = y_axis_min) +
facet_wrap(~group_name[kk]) +
theme_blue_strip()

}

if(error_bar & benchmarks == "zscore") {

p1 <- ggplot() +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = z_mean),
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = plus1),
linetype = 2,
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = minus1),
linetype = 2,
color = hline_color) +
geom_ribbon(data = sel_group_fit,
mapping = aes(x = year,
ymin = pred_lci,
ymax = pred_uci),
alpha = 0.3,
fill = ribbon_fill) +
geom_errorbar(data = sel_group_obs,
mapping = aes(x = YEAR,
ymin = BIOMASS_PLUS2_SD,
ymax = BIOMASS_MINUS2_SD),
width = 0.5,
color = errorbar_color) +
geom_path(data = sel_group_fit,
mapping = aes(x = year,
y = pred),
color = timeseries_color,
size = rel(1.1)) +
geom_point(data = sel_group_obs,
mapping = aes(x = YEAR, y = BIOMASS_MT),
color = point_color) +
scale_y_continuous(name = paste0("Biomass Index (", set_unit, ")"),
expand = expansion(mult = c(0, 0.05)),
labels = lab_fun(trim = lab_trim)) +
scale_x_continuous(name = "Year",
breaks = year_breaks,
labels = year_labels) +
expand_limits(y = y_axis_min) +
facet_wrap(~group_name) +
theme_blue_strip()

}

if(!error_bar & benchmarks == "zscore") {
p1 <- ggplot() +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = z_mean)) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = plus1),
linetype = 2,
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = minus1),
linetype = 2,
color = hline_color) +
geom_ribbon(data = sel_group_fit,
mapping = aes(x = year,
ymin = pred_lci,
ymax = pred_uci),
alpha = 0.3,
fill = ribbon_fill) +
geom_path(data = sel_group_fit,
mapping = aes(x = year, y = pred),
color = timeseries_color,
size = rel(1.1)) +
geom_point(data = sel_group_obs,
mapping = aes(x = YEAR, y = BIOMASS_MT),
color = point_color) +
scale_y_continuous(name = paste0("Biomass Index (", set_unit, ")"),
expand = expansion(mult = c(0, 0.05)),
labels = lab_fun(trim = lab_trim)) +
scale_x_continuous(name = "Year",
breaks = year_breaks,
labels = year_labels) +
expand_limits(y = y_axis_min) +
facet_wrap(~group_name) +
theme_blue_strip()
}


if(error_bar & benchmarks == "quantile") {

p1 <- ggplot() +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q50)) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q75),
linetype = 2,
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q100),
linetype = 3,
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q25),
linetype = 2,
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q0),
linetype = 3,
color = hline_color) +
geom_ribbon(data = sel_group_fit,
mapping = aes(x = year,
ymin = pred_lci,
ymax = pred_uci),
alpha = 0.3,
fill = ribbon_fill) +
geom_path(data = sel_group_fit,
mapping = aes(x = year, y = pred),
color = timeseries_color,
size = rel(1.1)) +
geom_point(data = sel_group_obs,
mapping = aes(x = YEAR, y = BIOMASS_MT),
color = point_color) +
scale_y_continuous(name = paste0("Biomass Index (", set_unit, ")"),
expand = expansion(mult = c(0, 0.05)),
labels = lab_fun(trim = lab_trim)) +
scale_x_continuous(name = "Year",
breaks = year_breaks,
labels = year_labels) +
expand_limits(y = y_axis_min) +
facet_wrap(~group_name) +
theme_blue_strip()

}

if(!error_bar & benchmarks == "quantile") {
p1 <- ggplot() +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q50)) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q75),
linetype = 2,
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q100),
linetype = 3,
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q25),
linetype = 2,
color = hline_color) +
geom_hline(data = sel_group_ts_summary,
mapping = aes(yintercept = q0),
linetype = 3,
color = hline_color) +
geom_ribbon(data = sel_group_fit,
mapping = aes(x = year,
ymin = pred_lci,
ymax = pred_uci),
alpha = 0.3,
fill = ribbon_fill) +
geom_path(data = sel_group_fit,
mapping = aes(x = year, y = pred),
color = timeseries_color,
size = rel(1.1)) +
geom_point(data = sel_group_obs,
mapping = aes(x = YEAR, y = BIOMASS_MT),
color = point_color) +
scale_y_continuous(name = paste0("Biomass Index (", set_unit, ")"),
expand = expansion(mult = c(0, 0.05)),
labels = lab_fun(trim = lab_trim)) +
scale_x_continuous(name = "Year",
breaks = year_breaks,
labels = year_labels) +
expand_limits(y = y_axis_min) +
facet_wrap(~group_name) +
theme_blue_strip()
}

suppressWarnings(dir.create(paste0("./plots/", region, "/plots_by_group"), recursive = TRUE))

grDevices::png(filename = paste0("./plots/", region, "/", "/plots_by_group/", region, "_rema_",
gsub(x = indicator_name[ii], pattern = " ", replacement = "_"),
"_",
gsub(x = group_name[kk], pattern = " ", replacement = "_"),
"_full_region", append_filename, ".png"),
width = 169,
height = 60,
units = "mm",
res = 300)
print(p1)
grDevices::dev.off()


}

}

return(plot_list)
Expand Down
11 changes: 11 additions & 0 deletions R/themes.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ set_stratum_order <- function(stratum = NULL, area_id = NULL, region, use_abbrev
"4.0",
"5.0",
"6.0"),
"NBS" = c("Inner Domain",
"Middle Domain"),
"AI" = c("Southern Bering Sea",
"Eastern Aleutians",
"Central Aleutians",
Expand All @@ -97,6 +99,9 @@ set_stratum_order <- function(stratum = NULL, area_id = NULL, region, use_abbrev
"4",
"5",
"6"),
"NBS" = c("70",
"71",
"81"),
"AI" = c("799",
"5699",
"3499",
Expand All @@ -120,6 +125,9 @@ set_stratum_order <- function(stratum = NULL, area_id = NULL, region, use_abbrev
"Stratum 40",
"Stratum 50",
"Stratum 60"),
"NBS" = c("Stratum 70",
"Stratum 71",
"Stratum 81"),
"AI" = c("Southern Bering Sea",
"Eastern Aleutians",
"Central Aleutians",
Expand All @@ -143,6 +151,9 @@ set_stratum_order <- function(stratum = NULL, area_id = NULL, region, use_abbrev
"40",
"50",
"60"),
"NBS" = c("70",
"71",
"81"),
"AI" = c("SBS",
"EAI",
"CAI",
Expand Down
22 changes: 20 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@

# esrindex

*In development*
The esrindex package is used to estimate bottom trawl survey abundance indices for Structural Epifauna, Jellyfish, Miscellaneous Benthic Fauna, and Forage Fish contributions for [Alaska Ecosystem Status Reports (ESRs)](https://apps-afsc.fisheries.noaa.gov/refm/reem/ecoweb/index.php). Time series for each taxonomic group and region (Aleutian Islands [AI], Gulf of Alaska [GOA], Eastern Bering Sea [EBS], and Northern Bering Sea [NBS]) are included in the package as built-in data sets. Indicator time series figures are available in [/plots/](./plots/). Indicator time series are updated in September following the finalization of catch and effort data from summer bottom trawl surveys.

The esrindex package is used to estimate bottom trawl survey abundance trends for Alaska Ecosystem Status Reports for Groundfish Assessment Program survey regions (Aleutian Islands, Gulf of Alaska, Eastern Bering Sea, and Northern Bering Sea).

### ESR contribution leads

| Contribution | AI | GOA | EBS/NBS |
|--------------|------------------|----------------|----------------------------------------|
| Forage Fish | NA | [Megsie Siple](https://github.com/margaret-siple-noaa) | NA |
| Jellyfish | [Ned Laman](https://github.com/ned-laman-noaa) | [Alexandra Dowlin](https://github.com/orgs/afsc-gap-products/people/AlexandraDowlin-NOAA) | [Thaddaeus Buser](https://github.com/ThaddaeusBuser-NOAA) |
| Miscellaneous Benthic Fauna | [Sarah Friedman](https://github.com/SarahFriedman-NOAA) | [Sarah Friedman](https://github.com/SarahFriedman-NOAA) | [Thaddaeus Buser](https://github.com/ThaddaeusBuser-NOAA) |
| Structural Epifauna | [Christina Conrath](https://github.com/orgs/afsc-gap-products/people/Conrathcl) | [Christina Conrath](https://github.com/orgs/afsc-gap-products/people/Conrathcl) | [Thaddaeus Buser](https://github.com/ThaddaeusBuser-NOAA) |


# Methodology

The esrindex package produces estimates of regional and subarea/stratum indices of abundance (biomass in kilotons) and confidence intervals for each ESR taxa by fitting a multivariate random effects model (REM) to design-based abundance index time series from individual survey strata (EBS groundfish strata) or subareas (AI or GOA INPFC subareas). Abundance indices are calculated from AFSC summer bottom trawl survey catch and effort data using the [gapindex R package](https://afsc-gap-products.github.io/gapindex/). Random effects models are fitted to abundance index time series using the [rema R package](https://afsc-assessments.github.io/rema/).


# Legal disclaimer

This repository is a software product and is not official communication of the National Oceanic and Atmospheric Administration (NOAA), or the United States Department of Commerce (DOC). All NOAA GitHub project code is provided on an ‘as is’ basis and the user assumes responsibility for its use. Any claims against the DOC or DOC bureaus stemming from the use of this GitHub project will be governed by all applicable Federal law. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation, or favoring by the DOC. The DOC seal and logo, or the seal and logo of a DOC bureau, shall not be used in any manner to imply endorsement of any commercial product or activity by the DOC or the United States Government.
1 change: 1 addition & 0 deletions man/esrindex-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified plots/AI/AI_rema_forage_fish_full_region_ze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plots/AI/AI_rema_misc_species_full_region_ze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plots/AI/AI_rema_structural_epifauna_full_region_ze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plots/GOA/GOA_rema_forage_fish_full_region_ze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plots/GOA/GOA_rema_misc_species_full_region_ze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plots/GOA/GOA_rema_structural_epifauna_full_region_ze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7c44fe3

Please sign in to comment.