The vignette provides a demonstration on how to use the fishprior package to obtain priors for life-history parameters that will be applicable in the assessment of the status of the population.
Data for priors can be obtained from either FishBase using
get_fishbase_traits() and
summarize_fishbase_traits(), which is a wrapper around the
rfishbase package.
This example provides code used to query FishBase for traits for
three species. The rfishbase package provides a flexible
approach for querying tables in FishBase, and our functions act as
wrappers for these calls.
species_list <- c(
"Merluccius merluccius",
"Gadus chalcogrammus",
"Anoplopoma fimbria"
)
example_base_raw <- get_fishbase_traits(spec_names = species_list)
example_base_raw## # A tibble: 1,436 × 22
## rfishbase SpecCode Sex PopGrowthRef DataSourceRef Locality YearStart
## <chr> <int> <chr> <int> <int> <chr> <int>
## 1 popgrowth 512 female 312 733 Oregon 1954
## 2 popgrowth 512 female 312 733 Oregon 1954
## 3 popgrowth 512 female 312 733 Oregon 1954
## 4 popgrowth 512 female 312 733 Oregon 1954
## 5 popgrowth 512 male 312 733 Oregon 1954
## 6 popgrowth 512 male 312 733 Oregon 1954
## 7 popgrowth 512 male 312 733 Oregon 1954
## 8 popgrowth 512 male 312 733 Oregon 1954
## 9 popgrowth 512 unsexed 5760 5818 Northeast Pa… 1968
## 10 popgrowth 512 unsexed 5760 5818 Northeast Pa… 1968
## # ℹ 1,426 more rows
## # ℹ 15 more variables: YearEnd <int>, Number <dbl>, Type <chr>, C_Code <chr>,
## # E_CODE <dbl>, SourceRef <int>, StockCode <dbl>, AgeMatRef <int>,
## # trait <chr>, value <dbl>, SE <dbl>, SD <dbl>, country <chr>,
## # EcosystemName <chr>, Species <chr>
This data can be summarized to provide output similar to what is returned from FishLife. Only a handful of traits are currently summarized but more can be provided in the future should it be desired. Feel free to fill out a GitHub Issue if you would like to see more traits summarized.
example_base <- summarize_fishbase_traits(example_base_raw)
example_base## # A tibble: 19 × 6
## Species trait mean_normal sd_normal mean sd
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Alaska pollock log(growth_coefficient) 0.237 0.121 -1.58 0.552
## 2 Alaska pollock log(length_maturity) 35.7 3.49 3.57 0.0966
## 3 Alaska pollock log(length_max) 64.1 28.2 4.02 0.692
## 4 Alaska pollock log(length_infinity) 69.8 16.4 4.22 0.213
## 5 Alaska pollock log(natural_mortality) 0.344 0.191 -1.20 0.545
## 6 Alaska pollock log(age_maturity) 4 0.798 1.37 0.200
## 7 Alaska pollock log(age_max) 19 8.15 2.84 0.521
## 8 European hake log(growth_coefficient) 0.166 0.102 -1.95 0.558
## 9 European hake log(length_maturity) 36.8 11.0 3.56 0.292
## 10 European hake log(length_max) 76.8 24.1 4.30 0.277
## 11 European hake log(length_infinity) 85.6 34.0 4.38 0.372
## 12 European hake log(natural_mortality) 0.354 0.144 -1.12 0.419
## 13 European hake log(age_maturity) 3.43 1.36 1.15 0.430
## 14 European hake log(age_max) 9.67 3.75 2.22 0.321
## 15 Sablefish log(growth_coefficient) 0.239 0.134 -1.57 0.508
## 16 Sablefish log(length_maturity) 59.1 4.02 4.08 0.0687
## 17 Sablefish log(length_infinity) 79.0 17.7 4.35 0.213
## 18 Sablefish log(age_maturity) 5.64 0.789 1.72 0.137
## 19 Sablefish log(age_max) 79.5 20.5 4.36 0.261
As an example of querying data and building custom priors, we will start with a simple example based on Atlantic cod (Gadus morhua). The data pulled from FishBase can be limited to just the data that pertains to cod. Each row represents a unique combination of study and trait. Initial columns store metadata about the study and the value column stores the value of the trait found in that study.
cod_traits <- get_fishbase_traits(spec_names = "Gadus morhua")The study-specific traits can be summarized as we did before but now
just for cod using summarize_fishbase_traits().
cod_summary <- summarize_fishbase_traits(cod_traits)This approach is simple because it uses all studies in FishBase to
summarize data; in practice, it may be of interest to only use studies
from a specific region. As a demonstration of how to do this, we provide
a slightly more complex example. Each of the tables returned by
get_fishbase_traits() has a Locality field,
e.g.,
cod_traits |>
dplyr::count(Locality)## # A tibble: 193 × 2
## Locality n
## <chr> <int>
## 1 Aberdeen Bay, 1969-1970 (INS) 4
## 2 Atlantic coast / Autumn 1992-1999. 3
## 3 Atlantic coast / Spring 1992-1999. 3
## 4 Atlantic coast / Winter 1992-1999. 3
## 5 Baltic 7
## 6 Baltic Sea 1
## 7 Baltic Sea (SD 25-32), 2016, 1st quarter 1
## 8 Baltic Sea (SD 25-32), early 1990s 1
## 9 Baltic Sea (SD 25-32), late 2000s 1
## 10 Baltic subdiv. 26 4
## # ℹ 183 more rows
Looking at the locality for growth for example, a handful of studies are from eastern Canada and the northeastern United States. If we wanted to summarize only these studies, we can use some custom filtering.
cod_traits_filtered <- cod_traits |>
dplyr::filter(
rfishbase == "popgrowth",
grepl(
"Southern Gulf of St\\. Lawrence|Gulf of Maine|Southern New England",
Locality
)
)
dplyr::count(cod_traits_filtered, trait, Locality)## # A tibble: 14 × 3
## trait Locality n
## <chr> <chr> <int>
## 1 K Georges Bank and Gulf of Maine 1
## 2 K Gulf of Maine Bank (5Y) 1
## 3 K Southern Gulf of St. Lawrence 11
## 4 K Southern New England (200 m depth) 1
## 5 Loo Georges Bank and Gulf of Maine 1
## 6 Loo Gulf of Maine Bank (5Y) 1
## 7 Loo Southern Gulf of St. Lawrence 11
## 8 Loo Southern New England (200 m depth) 1
## 9 M Southern Gulf of St. Lawrence 1
## 10 Winfinity Georges Bank and Gulf of Maine 1
## 11 Winfinity Gulf of Maine Bank (5Y) 1
## 12 Winfinity Southern Gulf of St. Lawrence 11
## 13 Winfinity Southern New England (200 m depth) 1
## 14 to Southern Gulf of St. Lawrence 11
And then we can pass our filtered dataframe into
summarize_fishbase_traits()
cod_summary_filtered <- summarize_fishbase_traits(cod_traits_filtered)
cod_summary_filtered## # A tibble: 3 × 6
## Species trait mean_normal sd_normal mean sd
## <chr> <chr> <dbl> <dbl> <dbl> <dbl>
## 1 Atlantic cod log(growth_coefficient) 0.178 0.0728 -1.81 0.435
## 2 Atlantic cod log(length_infinity) 93.3 36.7 4.47 0.379
## 3 Atlantic cod log(natural_mortality) 0.44 NA -0.821 NA
Because we only filtered locality for the results from
rfishbase::popgrowth(), this filtering only affects
summaries for parameters coming from this table
(“log(growth_coefficient)”, “log(length_infinity)”).