From a4a81b9784cca4ee5f6074508b80bb77cffdb38f Mon Sep 17 00:00:00 2001 From: Amanda Hart Date: Wed, 2 Dec 2026 14:58:37 -0500 Subject: [PATCH 1/3] Document standard naming for plot_fishing_mortality - plot_selectivity functions. --- vignettes/convert_output_details.Rmd | 136 +++++++++++++++------------ 1 file changed, 76 insertions(+), 60 deletions(-) diff --git a/vignettes/convert_output_details.Rmd b/vignettes/convert_output_details.Rmd index 09b2678e..fb375365 100644 --- a/vignettes/convert_output_details.Rmd +++ b/vignettes/convert_output_details.Rmd @@ -9,6 +9,7 @@ vignette: > %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- + ```{css, echo=FALSE} pre { overflow-x: auto; @@ -28,11 +29,13 @@ knitr::opts_chunk$set(echo = TRUE) This article describes the process behind developing the `stockplotr::convert_output` function and its setup so users who want to use {asar} or {stockplotr} are still able until [`convert_output.R`](https://github.com/nmfs-ost/stockplotr/blob/main/R/convert_output.R) includes functionality for other models. +```{=html} +``` Additionally, after following this article, users who use it to manipulate their assessment model output are encouraged to submit a [pull request](https://github.com/nmfs-ost/stockplotr/pulls) or [issue](https://github.com/nmfs-ost/stockplotr/issues) to use as an example to include in the function. This collaboration will not only allow us to expand the converter to include many assessment models, but also do it *much faster*. @@ -46,98 +49,104 @@ The converter manipulates data sets by recognizing patterns based on the assessm The data is manipulated to follow the format in @tbl-cols. The majority of the code in the function is specific for how one would manipulate the output with the following exceptions. The code in the converter creates an empty data frame with the columns referenced in @tbl-cols (See [code](https://github.com/nmfs-ost/stockplotr/blob/c8db61f325e9926461c70ef2d62349eb8d2bf2dd/R/convert_output.R#L45-L81)). At the end of the function, standard naming conventions are applied to rename labels of parameters or quantities as followed in @sec-namecon. Currently, we have files to use as examples to change the names of labels following our convention. One of the example files can be downloaded [here](https://github.com/nmfs-ost/stockplotr/blob/main/inst/resources/ss3_var_names.xlsx). The final data frame is exported to the user's environment as an object, if it is assigned an object name (e.g., `my_converted_output <- convert_output(...)`). - ```{r, echo=TRUE} #| eval: false load("example_conout.rda") head(hake_conout) ``` - The data frame is structured in following the convention of FIMS but removing the use of S4 or S3 data frame classes encouraging a more user friendly set up to start. The following format outlines the standard data frame: -| Column label | Description | -|--------------|---------------------------------------------| -| label | standard name for the estimate/parameter/quantity (cha) | -| estimate | the actual value for the estimate/parameter/quantity | -| module_name | describes the category of data found in the original data - allows us and familiar users to validate the converter is operating correctly and the correct data is being pulled | +| Column label | Description | +|----|----| +| label | standard name for the estimate/parameter/quantity (cha) | +| estimate | the actual value for the estimate/parameter/quantity | +| module_name | describes the category of data found in the original data - allows us and familiar users to validate the converter is operating correctly and the correct data is being pulled | | year | year of the data point if applicable otherwise NA | | uncertainty | uncertainty *value* (for estimates) | | uncertainty_label | label for the uncertainty value (i.e. se, sd, cv...) | | {strata} | a series of additional columns when stratification of the stock is present (fleet, age, time, area, season, sex, growth pattern) | | likelihood | if present, the likelihood value for the label; typically NA | -| initial | the initial estimate input into the model associated with the label, if applicable |:Descriptions of column names found in a standardized model output made from `convert_output()`.{#tbl-cols} +| initial | the initial estimate input into the model associated with the label, if applicable | There are a variety of ways to stratify the stock. The current converter is built to recognize the following: +```{=html} +``` +```{=html} +``` -* month -* fleet -* fleet_name -* age -* time -* area -* season -* subseason -* sex -* sexes (only if indicating difference from above) -* growth_pattern / gp - +- month +- fleet +- fleet_name +- age +- time +- area +- season +- subseason +- sex +- sexes (only if indicating difference from above) +- growth_pattern / gp + +```{=html} +``` -* len_bins (length bins for length-at-age models or related length series outputs) -* birthseas -* settlement -* morph -* type -* platoon -* part -* bin -* kind -* nsim -* age_a - +- len_bins (length bins for length-at-age models or related length series outputs) +- birthseas +- settlement +- morph +- type +- platoon +- part +- bin +- kind +- nsim +- age_a + +```{=html} +``` **Notes:** - *NA is present in any of the above columns if there isn't an occurrence from the original assessment model output* +*NA is present in any of the above columns if there isn't an occurrence from the original assessment model output* - *Era was removed as a factor from SS3 converted output files since this is something that could be assumed due to the set up of the data* +*Era was removed as a factor from SS3 converted output files since this is something that could be assumed due to the set up of the data* ## Naming Conventions {#sec-namecon} Another hurdle to tackle is naming conventions. We have attempted to create a standard naming convention system so that the same values are called each time no matter the assessment model. Here are approaches we took to standardize naming as best as we could: -1. Labels and other strings are lowercase, +1. Labels and other strings are lowercase, -2. Fleet names are inherited (not changed) so they are easily called by the analyst familiar with the data. +2. Fleet names are inherited (not changed) so they are easily called by the analyst familiar with the data. -3. Labels with more than one word use string case (i.e. spawning_biomass). +3. Labels with more than one word use string case (i.e. spawning_biomass). -4. The full name is used for the label, unless there is a common and *well known* acronym for it such as R0, msy, or it is a point relative to a reference point (i.e. biomass_msy = $Biomass_{msy}$, biomass_biomass_msy = $B/B_{msy}$) +4. The full name is used for the label, unless there is a common and *well known* acronym for it such as R0, msy, or it is a point relative to a reference point (i.e. biomass_msy = $Biomass_{msy}$, biomass_biomass_msy = $B/B_{msy}$) -5. For labels specific to a stock or assessment model, they were kept in the converted output, but edited/expanded upon following the above conventions. +5. For labels specific to a stock or assessment model, they were kept in the converted output, but edited/expanded upon following the above conventions. -6. Labels follow a hierarchy of the sorts where the leading word is the topic followed by descriptive adjectives. For example, catch_discard, catch_retained, biomass_msy, etc. +6. Labels follow a hierarchy of the sorts where the leading word is the topic followed by descriptive adjectives. For example, catch_discard, catch_retained, biomass_msy, etc. -7. All labels are singular and *not* plural. For example, catch instead of catches, landing instead of landings, or index instead of indices. +7. All labels are singular and *not* plural. For example, catch instead of catches, landing instead of landings, or index instead of indices. -7. In cases where a label could not be standardized, the same label was kept in the converted output. We hope that these remaining names can be standardized in the future through collaboration with the respective analysts using them. +8. In cases where a label could not be standardized, the same label was kept in the converted output. We hope that these remaining names can be standardized in the future through collaboration with the respective analysts using them. We will continue to work with model developers to identify the best approaches for indicating reference points; however, we currently follow the above naming conventions for reference points and the meaning will be up to the analyst to identify/note. @@ -149,30 +158,37 @@ We will continue to work with model developers to identify the best approaches f The final data frame does not manipulate column typing (character, numeric, etc.). We have left that to the analyst or other functions since there can be conflicts within the estimates due to NAs. Ideally, all columns beside the following with remain as characters or factors and the following will be converted to numeric: - - estimate - - uncertainty - - initial - - likelihood - +- estimate +- uncertainty +- initial +- likelihood + In conclusion, the final data frame should be very long with repeating years and factors to represent each point of data from the output file. Some metrics such as estimated stock-recruitment curve, weight-length relationship or other similar parameters are not currently in this function. There are also a number of "keywords" found in the SS3 Report.sso file that are not in the converted output file. We plan to update this in the future, but we prioritized the converter to contain information for plotting. ## Standard naming in Functions - - -- +- plot_fishing_mortality(): = "\^fishing_mortality\$" +- plot_index(): "\^index\_(observed\|predicted)\$" +- plot_joint_residuals(): "\^index\_(observed\|predicted)\$" +- plot_landings(): "catch", "catch_predicted", "landings_observed", "landings_observed_weight", "landings_observed_numbers", "catch_predicted", "landings" +- plot_natural_mortality(): "natural_mortality" +- plot_recruitment_deviations(): "recruitment_deviations" +- plot_recruitment(): "recruitment\$", "predicted_recruitment", "expected_recruitment" +- plot_retrospective(): Inherits naming from plot_biomass(), plot_spawning_biomass(), plot_fishing_mortality(), plot_recruitment(), or plot_spr() +- plot_runs_test(): "\^index\_(observed\|predicted)\$" +- plot_selectivity(): "selectivity" ## Helpful Functions to Manipulate Data The following functions were used in the [`convert_output()`](https://github.com/nmfs-ost/stockplotr/blob/main/R/convert_output.R) function that could be helpful for users replicating it for other assessment models: -- dplyr::mutate -- dplyr::case_when -- dplyr::inner_join/dplyr::outer_join -- tidyr::pivot_longer/tidyr::pivot_wider -- tidyr::rownames_to_column -- stringr::str_replace -- stringr::str_remove -- stringr::str_extract -- tibble::rowid_to_columns -- tidyselect::any_of/tidyselect::all_of +- dplyr::mutate +- dplyr::case_when +- dplyr::inner_join/dplyr::outer_join +- tidyr::pivot_longer/tidyr::pivot_wider +- tidyr::rownames_to_column +- stringr::str_replace +- stringr::str_remove +- stringr::str_extract +- tibble::rowid_to_columns +- tidyselect::any_of/tidyselect::all_of From 8822972834abb74cc764878753eb700a08e27754 Mon Sep 17 00:00:00 2001 From: Amanda Hart Date: Wed, 2 Dec 2026 15:14:56 -0500 Subject: [PATCH 2/3] Restore original indentation for lists. --- vignettes/convert_output_details.Rmd | 120 ++++++++++++--------------- 1 file changed, 55 insertions(+), 65 deletions(-) diff --git a/vignettes/convert_output_details.Rmd b/vignettes/convert_output_details.Rmd index fb375365..f748dd82 100644 --- a/vignettes/convert_output_details.Rmd +++ b/vignettes/convert_output_details.Rmd @@ -9,7 +9,6 @@ vignette: > %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- - ```{css, echo=FALSE} pre { overflow-x: auto; @@ -29,13 +28,11 @@ knitr::opts_chunk$set(echo = TRUE) This article describes the process behind developing the `stockplotr::convert_output` function and its setup so users who want to use {asar} or {stockplotr} are still able until [`convert_output.R`](https://github.com/nmfs-ost/stockplotr/blob/main/R/convert_output.R) includes functionality for other models. -```{=html} -``` Additionally, after following this article, users who use it to manipulate their assessment model output are encouraged to submit a [pull request](https://github.com/nmfs-ost/stockplotr/pulls) or [issue](https://github.com/nmfs-ost/stockplotr/issues) to use as an example to include in the function. This collaboration will not only allow us to expand the converter to include many assessment models, but also do it *much faster*. @@ -57,96 +54,89 @@ head(hake_conout) The data frame is structured in following the convention of FIMS but removing the use of S4 or S3 data frame classes encouraging a more user friendly set up to start. The following format outlines the standard data frame: -| Column label | Description | -|----|----| -| label | standard name for the estimate/parameter/quantity (cha) | -| estimate | the actual value for the estimate/parameter/quantity | -| module_name | describes the category of data found in the original data - allows us and familiar users to validate the converter is operating correctly and the correct data is being pulled | +| Column label | Description | +|--------------|---------------------------------------------| +| label | standard name for the estimate/parameter/quantity (cha) | +| estimate | the actual value for the estimate/parameter/quantity | +| module_name | describes the category of data found in the original data - allows us and familiar users to validate the converter is operating correctly and the correct data is being pulled | | year | year of the data point if applicable otherwise NA | | uncertainty | uncertainty *value* (for estimates) | | uncertainty_label | label for the uncertainty value (i.e. se, sd, cv...) | | {strata} | a series of additional columns when stratification of the stock is present (fleet, age, time, area, season, sex, growth pattern) | | likelihood | if present, the likelihood value for the label; typically NA | -| initial | the initial estimate input into the model associated with the label, if applicable | +| initial | the initial estimate input into the model associated with the label, if applicable |:Descriptions of column names found in a standardized model output made from `convert_output()`.{#tbl-cols} + There are a variety of ways to stratify the stock. The current converter is built to recognize the following: -```{=html} -``` -```{=html} -``` -- month -- fleet -- fleet_name -- age -- time -- area -- season -- subseason -- sex -- sexes (only if indicating difference from above) -- growth_pattern / gp - -```{=html} +* month +* fleet +* fleet_name +* age +* time +* area +* season +* subseason +* sex +* sexes (only if indicating difference from above) +* growth_pattern / gp + -``` -- len_bins (length bins for length-at-age models or related length series outputs) -- birthseas -- settlement -- morph -- type -- platoon -- part -- bin -- kind -- nsim -- age_a - -```{=html} +* len_bins (length bins for length-at-age models or related length series outputs) +* birthseas +* settlement +* morph +* type +* platoon +* part +* bin +* kind +* nsim +* age_a + -``` **Notes:** -*NA is present in any of the above columns if there isn't an occurrence from the original assessment model output* + *NA is present in any of the above columns if there isn't an occurrence from the original assessment model output* -*Era was removed as a factor from SS3 converted output files since this is something that could be assumed due to the set up of the data* + *Era was removed as a factor from SS3 converted output files since this is something that could be assumed due to the set up of the data* ## Naming Conventions {#sec-namecon} Another hurdle to tackle is naming conventions. We have attempted to create a standard naming convention system so that the same values are called each time no matter the assessment model. Here are approaches we took to standardize naming as best as we could: -1. Labels and other strings are lowercase, +1. Labels and other strings are lowercase, -2. Fleet names are inherited (not changed) so they are easily called by the analyst familiar with the data. +2. Fleet names are inherited (not changed) so they are easily called by the analyst familiar with the data. -3. Labels with more than one word use string case (i.e. spawning_biomass). +3. Labels with more than one word use string case (i.e. spawning_biomass). -4. The full name is used for the label, unless there is a common and *well known* acronym for it such as R0, msy, or it is a point relative to a reference point (i.e. biomass_msy = $Biomass_{msy}$, biomass_biomass_msy = $B/B_{msy}$) +4. The full name is used for the label, unless there is a common and *well known* acronym for it such as R0, msy, or it is a point relative to a reference point (i.e. biomass_msy = $Biomass_{msy}$, biomass_biomass_msy = $B/B_{msy}$) -5. For labels specific to a stock or assessment model, they were kept in the converted output, but edited/expanded upon following the above conventions. +5. For labels specific to a stock or assessment model, they were kept in the converted output, but edited/expanded upon following the above conventions. -6. Labels follow a hierarchy of the sorts where the leading word is the topic followed by descriptive adjectives. For example, catch_discard, catch_retained, biomass_msy, etc. +6. Labels follow a hierarchy of the sorts where the leading word is the topic followed by descriptive adjectives. For example, catch_discard, catch_retained, biomass_msy, etc. -7. All labels are singular and *not* plural. For example, catch instead of catches, landing instead of landings, or index instead of indices. +7. All labels are singular and *not* plural. For example, catch instead of catches, landing instead of landings, or index instead of indices. -8. In cases where a label could not be standardized, the same label was kept in the converted output. We hope that these remaining names can be standardized in the future through collaboration with the respective analysts using them. +7. In cases where a label could not be standardized, the same label was kept in the converted output. We hope that these remaining names can be standardized in the future through collaboration with the respective analysts using them. We will continue to work with model developers to identify the best approaches for indicating reference points; however, we currently follow the above naming conventions for reference points and the meaning will be up to the analyst to identify/note. @@ -158,10 +148,10 @@ We will continue to work with model developers to identify the best approaches f The final data frame does not manipulate column typing (character, numeric, etc.). We have left that to the analyst or other functions since there can be conflicts within the estimates due to NAs. Ideally, all columns beside the following with remain as characters or factors and the following will be converted to numeric: -- estimate -- uncertainty -- initial -- likelihood + - estimate + - uncertainty + - initial + - likelihood In conclusion, the final data frame should be very long with repeating years and factors to represent each point of data from the output file. Some metrics such as estimated stock-recruitment curve, weight-length relationship or other similar parameters are not currently in this function. There are also a number of "keywords" found in the SS3 Report.sso file that are not in the converted output file. We plan to update this in the future, but we prioritized the converter to contain information for plotting. @@ -182,13 +172,13 @@ In conclusion, the final data frame should be very long with repeating years and The following functions were used in the [`convert_output()`](https://github.com/nmfs-ost/stockplotr/blob/main/R/convert_output.R) function that could be helpful for users replicating it for other assessment models: -- dplyr::mutate -- dplyr::case_when -- dplyr::inner_join/dplyr::outer_join -- tidyr::pivot_longer/tidyr::pivot_wider -- tidyr::rownames_to_column -- stringr::str_replace -- stringr::str_remove -- stringr::str_extract -- tibble::rowid_to_columns -- tidyselect::any_of/tidyselect::all_of +- dplyr::mutate +- dplyr::case_when +- dplyr::inner_join/dplyr::outer_join +- tidyr::pivot_longer/tidyr::pivot_wider +- tidyr::rownames_to_column +- stringr::str_replace +- stringr::str_remove +- stringr::str_extract +- tibble::rowid_to_columns +- tidyselect::any_of/tidyselect::all_of From 255eed8cadcb0bf24b686dcdffac2c3b15f22390 Mon Sep 17 00:00:00 2001 From: Amanda Hart Date: Wed, 2 Dec 2026 15:17:35 -0500 Subject: [PATCH 3/3] Restore original indentation for lists. --- vignettes/convert_output_details.Rmd | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vignettes/convert_output_details.Rmd b/vignettes/convert_output_details.Rmd index f748dd82..86fd8afa 100644 --- a/vignettes/convert_output_details.Rmd +++ b/vignettes/convert_output_details.Rmd @@ -66,7 +66,6 @@ The data frame is structured in following the convention of FIMS but removing th | likelihood | if present, the likelihood value for the label; typically NA | | initial | the initial estimate input into the model associated with the label, if applicable |:Descriptions of column names found in a standardized model output made from `convert_output()`.{#tbl-cols} - There are a variety of ways to stratify the stock. The current converter is built to recognize the following: