Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #23: ADVS template program #35

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

AndersAskeland
Copy link
Member

@AndersAskeland AndersAskeland commented Oct 5, 2024

Closes #23
Thank you for your Pull Request! We have developed this task checklist from the Development Process Guide to help with the final steps of the process. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the admiral family codebase remains robust and consistent.

Please check off each taskbox as an acknowledgment that you completed the task or check off that it is not relevant to your Pull Request. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the main branch until you have checked off each task.

  • Place Closes #<insert_issue_number> into the beginning of your Pull Request Title (Use Edit button in top-right if you need to update)
  • Code is formatted according to the tidyverse style guide. Run styler::style_file() to style R and Rmd files
  • Updated relevant unit tests or have written new unit tests, which should consider realistic data scenarios and edge cases, e.g. empty datasets, errors, boundary cases etc. - See Unit Test Guide
  • If you removed/replaced any function and/or function parameters, did you fully follow the deprecation guidance?
  • Update to all relevant roxygen headers and examples, including keywords and families. Refer to the categorization of functions to tag appropriate keyword/family.
  • Run devtools::document() so all .Rd files in the man folder and the NAMESPACE file in the project root are updated appropriately
  • Address any updates needed for vignettes and/or templates
  • Update NEWS.md under the header # admiral<ext> (development version) if the changes pertain to a user-facing function (i.e. it has an @export tag) or documentation aimed at users (rather than developers)
  • Build site pkgdown::build_site() and check that all affected examples are displayed correctly and that all new functions occur on the Reference page.
  • Address or fix all lintr warnings and errors - lintr::lint_package()
  • Run R CMD check locally and address all errors and warnings - devtools::check()
  • Link the issue in the Development Section on the right hand side.
  • Address all merge conflicts and resolve appropriately
  • Pat yourself on the back for a job well done! Much love to your accomplishment!

@AndersAskeland AndersAskeland changed the title Closes #23 ADVS template program Closes #23: ADVS template program Oct 5, 2024
@AndersAskeland AndersAskeland self-assigned this Oct 5, 2024
Copy link

github-actions bot commented Oct 5, 2024

Code Coverage

Package Line Rate Health
admiralmetabolic 100%
Summary 100% (3 / 3)

@AndersAskeland AndersAskeland marked this pull request as ready for review October 5, 2024 16:34
@AndersAskeland
Copy link
Member Author

Think it should be ready for review now. Feel free to review @pharmaverse/admiralmetabolic .

I've used a somewhat different layout/setup compared to the other admiral packages. For me it makes more sense, but please let me know if it appears strange.

Copy link
Collaborator

@manciniedoardo manciniedoardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AndersAskeland!

I did a quick review and left some initial comments - I haven't tired executing the template yet.

In general, I am wondering if we would benefit from building on the existing ADVS template from {admiral} (rather than starting afresh like here) and just adding our extra bits? It would make review easier as well. interested in your thoughts.

inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated
advs <- advs |>
derive_vars_merged(
dataset_add = adsl,
new_vars = exprs(TRTSDT, TRTEDT, TRT01P, TRT01A),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exprs(TRTSDT, TRTEDT, TRT01P, TRT01A) should be stored as adsl_vars (see here) because you then re-use them on line 239 anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually disagree here. I personally believe that a template like this is often used nonsequential, where having arguments stored into objects can be confusing.

Furthermore, not having it stored in an object enables us to not use the injection operator (!!!) later in the code, which is in my opinion a fairly advanced feature which will confuse people.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your point. I myself sometimes struggle with these operators myself!!

However:

  1. Within the {admiral} programming concepts and conventions sheet we specifically indicate that we use this style of quoting/unquoting, see here
  2. This is already used throughout all admiral templates so would be strange to vary within the extension package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am still very hesitant about this change. I will implement it now, but I think it needs to be revisited in the future. I personally believe as Admiral becomes more widespread, we would need to lower the bar of entry. Especially considering many people coming in are coming from SAS with little to no experience in R.

Would also love the team (@pharmaverse/admiralmetabolic) to also give their input.

inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
Copy link

@starosto starosto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @AndersAskeland , I have posted some comments. Well done!

inst/ad_advs.R Outdated
library(stringr)


# Define look-up tables ----
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would place link to the function directly before using the function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean? Would you place the library calls directly before using any functionalities within that package? I.e. that we load stringr() right before the code where we actually use it?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would place "https://pharmaverse.github.io/admiral/reference/derive_vars_merged_lookup.html" link directly before using the function derive_vars_merged_lookup(), same with derive_vars_cat()

Copy link
Member Author

@AndersAskeland AndersAskeland Oct 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lookup table creations were moved a bit around, where they now reside under their respective use places. That actually means that the functions are not referenced directly. Instead the respective BDS vignette part is referenced, which should have some description about lookup tables. I think this is adequate, do you agree @starosto ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndersAskeland thanks for the update.
Please consider to add link to the function/BDS vignette part right before derive_vars_merged_lookup() function call.

inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
inst/ad_advs.R Outdated Show resolved Hide resolved
@AndersAskeland
Copy link
Member Author

@pharmaverse/admiralmetabolic If anyone have time, please have a review of the template.

# Define parameter look-up table used for merging parameter codes to ADVS
param_lookup <- tribble(
~VSTESTCD, ~PARAMCD, ~PARAM, ~PARAMN, ~PARCAT1, ~PARCAT1N,
"HEIGHT", "HEIGHT", "Height (cm)", 1, "Anthropometric measurements", 1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"HEIGHT", "HEIGHT", "Height (cm)", 1, "Anthropometric measurements", 1,
"HEIGHT", "HEIGHT", "Height (cm)", 1, "Anthropometric Measurement", 1,

For consistency with the ADVS vignette

# place
set_admiral_options(subject_keys = exprs(STUDYID, USUBJID))

# Store ADSL join variables as an R object, enabling simplified usage throughout

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Store ADSL join variables as an R object, enabling simplified usage throughout
# Store ADSL variables required for derivations as an R object, enabling simplified usage throughout

vs_metabolic <- admiralmetabolic::vs_metabolic
adsl <- admiral::admiral_adsl

# Convert SAS empty values to NA

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Convert SAS empty values to NA
# Convert SAS missing character values values to NA

Comment on lines +40 to +41
# Merge ADSL variables (stored in `adsl_vars`) needed for ADVS
# derivations

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Merge ADSL variables (stored in `adsl_vars`) needed for ADVS
# derivations
# Derivations ----
# Merge ADSL variables (stored in `adsl_vars`) needed for ADVS

Comment on lines +63 to +65
# Add parameter (PARAMCD) info to enable later ADVS derivations. Additional
# parameter information will be merged again, after all AVDS derivations are
# completed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Add parameter (PARAMCD) info to enable later ADVS derivations. Additional
# parameter information will be merged again, after all AVDS derivations are
# completed.
# Add parameter (PARAMCD) info to enable later ADVS derivations. Additional
# parameter information will be merged again, after all AVDS derivations are
# completed.
# See function documentation for `derive_vars_merged_lookup()`:
# (https://pharmaverse.github.io/admiral/reference/derive_vars_merged_lookup.html)

Comment on lines +234 to +235
dataset_add = param_lookup,
new_vars = exprs(PARAMCD, PARAM, PARAMN, PARCAT1, PARCAT1N),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dataset_add = param_lookup,
new_vars = exprs(PARAMCD, PARAM, PARAMN, PARCAT1, PARCAT1N),
dataset_add = select(param_lookup, -VSTESTCD),

inst/ad_advs.R Outdated
library(stringr)


# Define look-up tables ----

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndersAskeland thanks for the update.
Please consider to add link to the function/BDS vignette part right before derive_vars_merged_lookup() function call.

Copy link

@starosto starosto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndersAskeland I added some comments. I also wonder if we should not build on existing ADVS templates from {admiral}. If not now, then for future templates.

# Define project options/variables ----
# Use the admiral option functionality to store subject key variables in one
# place
set_admiral_options(subject_keys = exprs(STUDYID, USUBJID))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set_admiral_options(subject_keys = exprs(STUDYID, USUBJID))

subject_keys defaults to exprs(STUDYID, USUBJID), we don't need to set this up

Copy link
Collaborator

@manciniedoardo manciniedoardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM @AndersAskeland 😄 (after comments from @starosto are addressd)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Template: ADVS
4 participants