From f0b34048c0f590a9bd0360bf7b8e34f50f8c5a0f Mon Sep 17 00:00:00 2001 From: Edoardo Mancini Date: Fri, 10 Nov 2023 13:59:35 +0000 Subject: [PATCH 1/7] #204 updates to `derive_summary_records()` --- DESCRIPTION | 2 +- NEWS.md | 5 ++++ inst/templates/ad_advfq.R | 56 ++++++++++++++++++++++++--------------- 3 files changed, 41 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1528899a..b4397768 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: admiralophtha Type: Package Title: ADaM in R Asset Library - Ophthalmology -Version: 0.3.0.9002 +Version: 0.3.0.9003 Authors@R: c( person("Edoardo", "Mancini", email = "edoardo.mancini@roche.com", role = c("aut", "cre")), person("Ritika", "Aggarwal", email = "ritika.aggarwal@novartis.com", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index d34030a4..3c7a1c9f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,11 +4,16 @@ - Removed `analysis_value` argument in the calls to `derive_param_computed()` in ADBCVA template in line with the deprecation of this argument in the new version of `{admiral}`. Variable values for parameters of interest are now all populated through the `set_values_to` argument (#207). +- Modified calls to `derive_summary_records()` in ADVFQ template in line with the updates to this function in the new version of the `{admiral}` package. The argument `dataset_add` is now always specified and the variable values are now all populated through the `set_values_to` argument (#204). + ## Updates to Documentation - Added release date for `{admiralophtha}` 1.0 to the front page (#203). + - Removed `analysis_value` argument in the calls to `derive_param_computed()` in ADBCVA vignette in line with the deprecation of this argument in the new version of `{admiral}`. Variable values for parameters of interest are now all populated through the `set_values_to` argument (#207). +- Modified calls to `derive_summary_records()` in ADVFQ vignette in line with the updates to this function in the new version of the `{admiral}` package. The argument `dataset_add` is now always specified and the variable values are now all populated through the `set_values_to` argument (#204). + ## Various - Website now has button/links to Slack channel and GitHub Issues (#206). diff --git a/inst/templates/ad_advfq.R b/inst/templates/ad_advfq.R index 2cf4f589..056ee326 100644 --- a/inst/templates/ad_advfq.R +++ b/inst/templates/ad_advfq.R @@ -75,11 +75,13 @@ advfq_aval <- advfq_dtdy %>% # else set to 0 if [advfq.AVAL] = 5 advfq_qr01 <- advfq_aval %>% derive_summary_records( + dataset_add = advfq_aval, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, VISITNUM, VISIT, ADT, ADY), filter = QSTESTCD == "VFQ1" & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = identity, - set_values_to = exprs(PARAMCD = "QR01") + set_values_to = exprs( + AVAL = identity(AVAL), + PARAMCD = "QR01" + ) ) %>% mutate(AVAL = ifelse(PARAMCD == "QR01", case_when( @@ -101,11 +103,13 @@ advfq_qr01 <- advfq_aval %>% # else set to 0 if [advfq.AVAL] = 6 advfq_qr02 <- advfq_qr01 %>% derive_summary_records( + dataset_add = advfq_qr01, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, VISITNUM, VISIT, ADT, ADY), filter = QSTESTCD == "VFQ2" & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = identity, - set_values_to = exprs(PARAMCD = "QR02") + set_values_to = exprs( + AVAL = identity(AVAL), + PARAMCD = "QR02" + ) ) %>% mutate(AVAL = ifelse(PARAMCD == "QR02", case_when( @@ -127,11 +131,13 @@ advfq_qr02 <- advfq_qr01 %>% # else set to 0 if [advfq.AVAL] = 1 advfq_qr03 <- advfq_qr02 %>% derive_summary_records( + dataset_add = advfq_qr02, by_vars = exprs(STUDYID, USUBJID, PARAMCD, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), filter = QSTESTCD == "VFQ3" & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = identity, - set_values_to = exprs(PARAMCD = "QR03") + set_values_to = exprs( + AVAL = identity(AVAL), + PARAMCD = "QR03" + ) ) %>% mutate(AVAL = ifelse(PARAMCD == "QR03", case_when( @@ -153,11 +159,13 @@ advfq_qr03 <- advfq_qr02 %>% # else set to 0 if [advfq.AVAL] = 1 advfq_qr04 <- advfq_qr03 %>% derive_summary_records( + dataset_add = advfq_qr03, by_vars = exprs(STUDYID, USUBJID, PARAMCD, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), filter = QSTESTCD == "VFQ4" & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = identity, - set_values_to = exprs(PARAMCD = "QR04") + set_values_to = exprs( + AVAL = identity(AVAL), + PARAMCD = "QR04" + ) ) %>% mutate(AVAL = ifelse(PARAMCD == "QR04", case_when( @@ -175,11 +183,13 @@ advfq_qr04 <- advfq_qr03 %>% # Average of QR01 and QR02 records advfq_qsg01 <- advfq_qr04 %>% derive_summary_records( + dataset_add = advfq_qr04, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), filter = PARAMCD %in% c("QR01", "QR02") & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = mean, - set_values_to = exprs(PARAMCD = "QSG01") + set_values_to = exprs( + AVAL = mean(AVAL), + PARAMCD = "QSG01" + ) ) ## Derive a new record as a summary record ---- @@ -187,11 +197,13 @@ advfq_qsg01 <- advfq_qr04 %>% # Average of QR03 and QR04 records advfq_qsg02 <- advfq_qsg01 %>% derive_summary_records( + dataset_add = advfq_qsg01, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), filter = PARAMCD %in% c("QR03", "QR04") & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = mean, - set_values_to = exprs(PARAMCD = "QSG02") + set_values_to = exprs( + AVAL = mean(AVAL), + PARAMCD = "QSG02" + ) ) @@ -200,11 +212,13 @@ advfq_qsg02 <- advfq_qsg01 %>% # Average of QSG01 and QSG02 records advfq_qbcs <- advfq_qsg02 %>% derive_summary_records( + dataset_add = advfq_qsg02, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), filter = PARAMCD %in% c("QSG01", "QSG02") & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = sum, - set_values_to = exprs(PARAMCD = "QBCSCORE") + set_values_to = exprs( + AVAL = sum(AVAL), + PARAMCD = "QBSCORE" + ) ) ## Get visit info ---- From d8a08bed8f870e3dd74d61f14a333554d10ce76b Mon Sep 17 00:00:00 2001 From: Edoardo Mancini Date: Fri, 10 Nov 2023 14:00:35 +0000 Subject: [PATCH 2/7] #204 vignette updates --- vignettes/advfq.Rmd | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/vignettes/advfq.Rmd b/vignettes/advfq.Rmd index f60e964c..498983bd 100644 --- a/vignettes/advfq.Rmd +++ b/vignettes/advfq.Rmd @@ -153,11 +153,13 @@ Run this section of code for every question that you need recoding. This gives a # else set to 0 if [advfq.AVAL] = 5 advfq <- advfq %>% derive_summary_records( + dataset_add = advfq, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, VISITNUM, VISIT), filter = QSTESTCD == "VFQ1" & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = identity, - set_values_to = exprs(PARAMCD = "QR01") + set_values_to = exprs( + AVAL = identity(AVAL), + PARAMCD = "QR01" + ) ) %>% mutate(AVAL = ifelse(PARAMCD == "QR01", case_when( @@ -179,11 +181,13 @@ Next, the programmer should create summary records as average of recoded questio # Average of QR01 and QR02 records advfq <- advfq %>% derive_summary_records( + dataset_add = advfq, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), filter = PARAMCD %in% c("QR01", "QR02") & !is.na(AVAL), - analysis_var = AVAL, - summary_fun = mean, - set_values_to = exprs(PARAMCD = "QSG01") + set_values_to = exprs( + AVAL = mean(AVAL), + PARAMCD = "QSG01" + ) ) ``` From 1cc56020b4a9a3440b71c3e43fc0adffac6a0fa1 Mon Sep 17 00:00:00 2001 From: Edoardo Mancini Date: Fri, 10 Nov 2023 14:05:35 +0000 Subject: [PATCH 3/7] #204 renamed `filter` argument to `filter_add` in advfq vignette and template --- NEWS.md | 4 ++-- inst/templates/ad_advfq.R | 14 +++++++------- vignettes/advfq.Rmd | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3c7a1c9f..1749ae65 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,7 +4,7 @@ - Removed `analysis_value` argument in the calls to `derive_param_computed()` in ADBCVA template in line with the deprecation of this argument in the new version of `{admiral}`. Variable values for parameters of interest are now all populated through the `set_values_to` argument (#207). -- Modified calls to `derive_summary_records()` in ADVFQ template in line with the updates to this function in the new version of the `{admiral}` package. The argument `dataset_add` is now always specified and the variable values are now all populated through the `set_values_to` argument (#204). +- Modified calls to `derive_summary_records()` in ADVFQ template in line with the updates to this function in the new version of the `{admiral}` package. The `filter` argument is now renamed to `filter_add`, the argument `dataset_add` is now always specified and the variable values are now all populated through the `set_values_to` argument (#204). ## Updates to Documentation @@ -12,7 +12,7 @@ - Removed `analysis_value` argument in the calls to `derive_param_computed()` in ADBCVA vignette in line with the deprecation of this argument in the new version of `{admiral}`. Variable values for parameters of interest are now all populated through the `set_values_to` argument (#207). -- Modified calls to `derive_summary_records()` in ADVFQ vignette in line with the updates to this function in the new version of the `{admiral}` package. The argument `dataset_add` is now always specified and the variable values are now all populated through the `set_values_to` argument (#204). +- Modified calls to `derive_summary_records()` in ADVFQ vignette in line with the updates to this function in the new version of the `{admiral}` package. The `filter` argument is now renamed to `filter_add`, the argument `dataset_add` is now always specified and the variable values are now all populated through the `set_values_to` argument (#204). ## Various diff --git a/inst/templates/ad_advfq.R b/inst/templates/ad_advfq.R index 056ee326..e8453e9d 100644 --- a/inst/templates/ad_advfq.R +++ b/inst/templates/ad_advfq.R @@ -77,7 +77,7 @@ advfq_qr01 <- advfq_aval %>% derive_summary_records( dataset_add = advfq_aval, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, VISITNUM, VISIT, ADT, ADY), - filter = QSTESTCD == "VFQ1" & !is.na(AVAL), + filter_add = QSTESTCD == "VFQ1" & !is.na(AVAL), set_values_to = exprs( AVAL = identity(AVAL), PARAMCD = "QR01" @@ -105,7 +105,7 @@ advfq_qr02 <- advfq_qr01 %>% derive_summary_records( dataset_add = advfq_qr01, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, VISITNUM, VISIT, ADT, ADY), - filter = QSTESTCD == "VFQ2" & !is.na(AVAL), + filter_add = QSTESTCD == "VFQ2" & !is.na(AVAL), set_values_to = exprs( AVAL = identity(AVAL), PARAMCD = "QR02" @@ -133,7 +133,7 @@ advfq_qr03 <- advfq_qr02 %>% derive_summary_records( dataset_add = advfq_qr02, by_vars = exprs(STUDYID, USUBJID, PARAMCD, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), - filter = QSTESTCD == "VFQ3" & !is.na(AVAL), + filter_add = QSTESTCD == "VFQ3" & !is.na(AVAL), set_values_to = exprs( AVAL = identity(AVAL), PARAMCD = "QR03" @@ -161,7 +161,7 @@ advfq_qr04 <- advfq_qr03 %>% derive_summary_records( dataset_add = advfq_qr03, by_vars = exprs(STUDYID, USUBJID, PARAMCD, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), - filter = QSTESTCD == "VFQ4" & !is.na(AVAL), + filter_add = QSTESTCD == "VFQ4" & !is.na(AVAL), set_values_to = exprs( AVAL = identity(AVAL), PARAMCD = "QR04" @@ -185,7 +185,7 @@ advfq_qsg01 <- advfq_qr04 %>% derive_summary_records( dataset_add = advfq_qr04, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), - filter = PARAMCD %in% c("QR01", "QR02") & !is.na(AVAL), + filter_add = PARAMCD %in% c("QR01", "QR02") & !is.na(AVAL), set_values_to = exprs( AVAL = mean(AVAL), PARAMCD = "QSG01" @@ -199,7 +199,7 @@ advfq_qsg02 <- advfq_qsg01 %>% derive_summary_records( dataset_add = advfq_qsg01, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), - filter = PARAMCD %in% c("QR03", "QR04") & !is.na(AVAL), + filter_add = PARAMCD %in% c("QR03", "QR04") & !is.na(AVAL), set_values_to = exprs( AVAL = mean(AVAL), PARAMCD = "QSG02" @@ -214,7 +214,7 @@ advfq_qbcs <- advfq_qsg02 %>% derive_summary_records( dataset_add = advfq_qsg02, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), - filter = PARAMCD %in% c("QSG01", "QSG02") & !is.na(AVAL), + filter_add = PARAMCD %in% c("QSG01", "QSG02") & !is.na(AVAL), set_values_to = exprs( AVAL = sum(AVAL), PARAMCD = "QBSCORE" diff --git a/vignettes/advfq.Rmd b/vignettes/advfq.Rmd index 498983bd..8a8751c4 100644 --- a/vignettes/advfq.Rmd +++ b/vignettes/advfq.Rmd @@ -155,7 +155,7 @@ advfq <- advfq %>% derive_summary_records( dataset_add = advfq, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, PARAMCD, VISITNUM, VISIT), - filter = QSTESTCD == "VFQ1" & !is.na(AVAL), + filter_add = QSTESTCD == "VFQ1" & !is.na(AVAL), set_values_to = exprs( AVAL = identity(AVAL), PARAMCD = "QR01" @@ -183,7 +183,7 @@ advfq <- advfq %>% derive_summary_records( dataset_add = advfq, by_vars = exprs(STUDYID, USUBJID, !!!adsl_vars, VISITNUM, VISIT, ADT, ADY), - filter = PARAMCD %in% c("QR01", "QR02") & !is.na(AVAL), + filter_add = PARAMCD %in% c("QR01", "QR02") & !is.na(AVAL), set_values_to = exprs( AVAL = mean(AVAL), PARAMCD = "QSG01" From 1679fb63d315aea14c77a48e0a741b908d0e6080 Mon Sep 17 00:00:00 2001 From: Edoardo Mancini Date: Fri, 10 Nov 2023 14:36:18 +0000 Subject: [PATCH 4/7] #204 updates to fix avisitn and qbcscore --- inst/templates/ad_advfq.R | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/inst/templates/ad_advfq.R b/inst/templates/ad_advfq.R index e8453e9d..f4100033 100644 --- a/inst/templates/ad_advfq.R +++ b/inst/templates/ad_advfq.R @@ -217,7 +217,7 @@ advfq_qbcs <- advfq_qsg02 %>% filter_add = PARAMCD %in% c("QSG01", "QSG02") & !is.na(AVAL), set_values_to = exprs( AVAL = sum(AVAL), - PARAMCD = "QBSCORE" + PARAMCD = "QBCSCORE" ) ) @@ -234,11 +234,15 @@ advfq_visit <- advfq_qbcs %>% !is.na(VISIT) ~ str_to_title(VISIT), TRUE ~ NA_character_ ), - AVISITN = as.numeric(case_when( + AVISITN = case_when( VISIT == "BASELINE" ~ "0", - str_detect(VISIT, "WEEK") ~ str_trim(str_replace(VISIT, "WEEK", "")), - TRUE ~ NA_character_ - )) + str_detect(VISIT, "WEEK") ~ VISIT %>% + str_replace("WEEK", "") %>% + str_replace("\\(T\\)", "") %>% + str_trim(), + + TRUE ~ NA + ), ) advfq_ontrt <- advfq_visit %>% From 33a4c5492a28febd0f9e1442b9dd352b69787e73 Mon Sep 17 00:00:00 2001 From: Edoardo Mancini Date: Fri, 10 Nov 2023 14:55:59 +0000 Subject: [PATCH 5/7] #204 chore: styler changes --- inst/templates/ad_advfq.R | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/inst/templates/ad_advfq.R b/inst/templates/ad_advfq.R index f4100033..8c3e967c 100644 --- a/inst/templates/ad_advfq.R +++ b/inst/templates/ad_advfq.R @@ -81,7 +81,7 @@ advfq_qr01 <- advfq_aval %>% set_values_to = exprs( AVAL = identity(AVAL), PARAMCD = "QR01" - ) + ) ) %>% mutate(AVAL = ifelse(PARAMCD == "QR01", case_when( @@ -236,11 +236,10 @@ advfq_visit <- advfq_qbcs %>% ), AVISITN = case_when( VISIT == "BASELINE" ~ "0", - str_detect(VISIT, "WEEK") ~ VISIT %>% + str_detect(VISIT, "WEEK") ~ VISIT %>% str_replace("WEEK", "") %>% str_replace("\\(T\\)", "") %>% str_trim(), - TRUE ~ NA ), ) From b127924bd665d371aa143193521ccb307a295f3f Mon Sep 17 00:00:00 2001 From: Edoardo Mancini Date: Thu, 16 Nov 2023 10:48:05 +0000 Subject: [PATCH 6/7] #204 chores: lint and spelling --- inst/WORDLIST | 2 ++ vignettes/articles/website-versions.Rmd | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/inst/WORDLIST b/inst/WORDLIST index 0e1dd2c6..1afc3bb3 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -113,3 +113,5 @@ doi et ADIOP OE +adoe +advfq diff --git a/vignettes/articles/website-versions.Rmd b/vignettes/articles/website-versions.Rmd index 378214e3..0a4edf5d 100644 --- a/vignettes/articles/website-versions.Rmd +++ b/vignettes/articles/website-versions.Rmd @@ -3,9 +3,9 @@ title: "Previous Versions of Website" --- ```{r, include = FALSE} -# TO USE THIS ARTICLE, THE DESCRIPTION FILE MUST INCLUDE -# Config/Needs/website: gert -# Make sure to copy the gh-pages branch to your local git +# TO USE THIS ARTICLE, THE DESCRIPTION FILE MUST INCLUDE #nolint +# Config/Needs/website: gert #nolint +# Make sure to copy the gh-pages branch to your local git #nolint knitr::opts_chunk$set( collapse = TRUE, From 01d0da74b0318f0ed83f9e368ee07b23627833cf Mon Sep 17 00:00:00 2001 From: Edoardo Mancini Date: Thu, 16 Nov 2023 10:52:22 +0000 Subject: [PATCH 7/7] #204 chore: broken links --- .github/pull_request_template.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index d3c390ba..ae99c12a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,11 +1,11 @@ -Thank you for your Pull Request! We have developed this task checklist from the [Development Process Guide](https://pharmaverse.github.io/admiraldev/main/articles/development_process.html) 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 codebase remains robust and consistent. +Thank you for your Pull Request! We have developed this task checklist from the [Development Process Guide](https://pharmaverse.github.io/admiraldev/articles/development_process.html) 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 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 `devel` branch until you have checked off each task. - [ ] Place Closes # 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](https://style.tidyverse.org/). Run `styler::style_file()` to style R and Rmd files -- [ ] Updated relevant unit tests or have written new unit tests - See [Unit Test Guide](https://pharmaverse.github.io/admiraldev/main/articles/unit_test_guidance.html) -- [ ] If you removed/replaced any function and/or function parameters, did you fully follow the [deprecation guidance](https://pharmaverse.github.io/admiraldev/main/articles/programming_strategy.html#deprecation)? +- [ ] Updated relevant unit tests or have written new unit tests - See [Unit Test Guide](https://pharmaverse.github.io/admiraldev/articles/unit_test_guidance.html) +- [ ] If you removed/replaced any function and/or function parameters, did you fully follow the [deprecation guidance](https://pharmaverse.github.io/admiraldev/articles/programming_strategy.html#deprecation)? - [ ] Update to all relevant roxygen headers and examples. - [ ] 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