knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 6,
  fig.height = 6
)

This vignette shows how to extract and analyse the data for a restricted area (rather than the full coast). The example area is for predators of Haida Gwaii Herring, and we'll stick with Yelloweye Rockfish as the example species (since those data are saved in the package).

Quick version -- there is a wrapper function, iphc_get_calc_plot_area(sp) that does all the extraction, calculations, and plotting for a given species (see examples in analysis of HG herring predators vignette. This vignette shows the details to aid understanding. So for a quick look to see if the data look potentially useful, just do, for example, iphc_get_calc_plot_area("bocaccio"). If the resulting series looks useful then repeat this vignette for your species of interest to understand the results.

library(gfiphc)

Data for species of interest

Define common species name:

sp <- "yelloweye rockfish"
sp_short_name <- "Yelloweye"  # short name for legends

As for the analysis of one species vignette, change the above names to your species of interest and have someone at PBS run the next chunk of code to extract data from the GFBio database.

# This chunk will only work within PBS
cache_pbs_data_iphc(sp)

Once an external person has the species-name.rds file, the two lines in the next chunk can be appropriately commented/uncommented to load the data. For the vignette to always run we will stick with the Yelloweye Rockfish data.

# Comment this out to analyse non-yelloweye data:
sp_set_counts <- yelloweye_rockfish

# Uncomment this to analyse non-yelloweye data:
# sp_set_counts <- readRDS(paste0(gsub(" ", "-", sp), ".rds"))

Analyses for subset of stations

The area of interest is saved in gfiphc as HG_herring_pred_area:

plot_BC(main = "All 2008 stations")

PBSmapping::addPolys(HG_herring_pred_area,
                     col = "pink")

plot_iphc_map(sp_set_counts$set_counts,
              sp = NULL,
              years = 2008,
              lat_cut_off = NULL,
              add_to_existing = TRUE)

Create tibble of set counts with extra column in_area, which is TRUE/FALSE whether or not that set is within the area of interest:

sp_set_counts_with_area <- add_in_area(sp_set_counts$set_counts,
                                       area = HG_herring_pred_area)

Each catch count now also has an in_area logical attribute:

dplyr::select(sp_set_counts_with_area, year, station, lat, lon, E_it, C_it, usable,
              standard, in_area)

Colour code on map:

plot_BC(main = "All 2008 stations")

PBSmapping::addPolys(HG_herring_pred_area,
                     col = "pink")

plot_iphc_map(sp_set_counts_with_area,
              sp = NULL,
              years = 2008,
              lat_cut_off = NULL,
              add_to_existing = TRUE,
              indicate_in_area = TRUE)

2022 (and 2018, 2020-2021) had expanded (non-standard) stations, which are shown as crosses:

plot_BC(main = "All 2022 stations")

PBSmapping::addPolys(HG_herring_pred_area,
                     col = "pink")

plot_iphc_map(sp_set_counts_with_area,
              sp = NULL,
              years = 2022,
              lat_cut_off = NULL,
              add_to_existing = TRUE,
              indicate_in_area = TRUE)

Make a movie to check each year:

IPHC-stations-HG-area-movie-1995-2022.gif.

As for data_for_one_species vignette, the movie is saved and the code is given here but not run:

# ```r
for(i in unique(sp_set_counts_with_area$year)){
  plot_BC(main = paste0("All ", i, " stations"))

  PBSmapping::addPolys(HG_herring_pred_area,
                       col = "pink")

  plot_iphc_map(sp_set_counts_with_area,
                sp = NULL,
                years = i,
                lat_cut_off = NULL,
                add_to_existing = TRUE,
                indicate_in_area = TRUE)
}

Calculate longest time series possible for the area of interest

In Appendix G of the synopsis report we described analyses to calculate as long a time series as possible by combining data from years when only the first 20 hooks were enumerated for each skate (Series A) and from years when all hooks could be enumerated from each skate (Series B); there are overlapping years when all hooks were enumerated and the data are available at the hook-by-hook level. The resulting Series AB applied only to the area north of WCVI, but was tested to see if it was representative of the whole coast.

For stations restricted to the area of interest, here we define Series E to be based on the first 20 hooks from each skate, and Series F to be based on all hooks from each skate. We do a similar analysis as described in the synopsis report to generate the longer Series EF (or just one of Series E and F if there are insufficient data). It is up to the user to generate maps (or movie) of their area of interest to confirm that it makes sense to use all stations with the area. For example, considering an area that reaches further down the west coast of Vancouver Island would not be appropriate since it was not surveyed in some years (Table G.2 of synopsis report).

The calculations are as follows, yielding figure with four plots similar to Figures G.1 and G.2 of the synopsis report (that were for Series A and B):

ser_E_and_F <- calc_iphc_ser_E_and_F(sp_set_counts_with_area)
ser_E_and_F

Then to calculate the longest possible time series:

series_longest <- calc_iphc_ser_EF(ser_E_and_F)
series_longest

plot_IPHC_ser_four_panels(ser_E_and_F,
                          series_longest,
                          sp = sp)

Comparing this figure in 2021 with an earlier version (before excluding non-standard stations), for 2020 (but not really 2018) excluding the non-standard stations increases the 2020 value somewhat. Interestingly, 2019 bootstrapped values change very slightly also, because of less random numbers now used for 2018 calculations (this motivates changing the default to 10,000 samples -- see commented out text here for more info).

Recall there is a wrapper function, iphc_get_calc_plot_area(sp), mentioned at the start of this vignette.

Note that the code may not yet fully account for all possibilities (for all areas and species) for the different Series, particularly for rarer species with, by definition, low count numbers. So do check that the output is sensible. The code may calculate a longest series, but it may not be ecologically useful.



pbs-assess/gfiphc documentation built on July 4, 2023, 1:13 p.m.