From e0f2a375bc2988f4e4d65cd7f64d9ca1e533f663 Mon Sep 17 00:00:00 2001 From: Liming Li Date: Mon, 17 Apr 2023 05:02:07 +0000 Subject: [PATCH 01/13] export checks --- R/ael01_nollt.R | 2 +- R/aet01.R | 4 ++-- R/aet01_aesi.R | 2 +- R/aet02.R | 2 +- R/aet10.R | 2 +- R/egt03.R | 2 +- R/lbt04.R | 2 +- R/lbt05.R | 2 +- R/lbt07.R | 2 +- R/lbt14.R | 4 ++-- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/R/ael01_nollt.R b/R/ael01_nollt.R index eecc0e6b7..377081839 100644 --- a/R/ael01_nollt.R +++ b/R/ael01_nollt.R @@ -73,7 +73,7 @@ ael01_nollt_1_pre <- function(adam_db, #' #' @inheritParams gen_args #' @param vars (`character`) variables to be included in the listing. -#' +#' @export ael01_nollt_1_check <- function(adam_db, dataset, vars) { diff --git a/R/aet01.R b/R/aet01.R index dbbd3f73c..b73b30d60 100755 --- a/R/aet01.R +++ b/R/aet01.R @@ -200,7 +200,7 @@ aet01_1_pre <- function(adam_db, #' @describeIn aet01_1 Checks #' #' @inheritParams gen_args -#' +#' @export aet01_1_check <- function(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM", @@ -518,7 +518,7 @@ aet01_2_pre <- function(adam_db, ...) { #' @describeIn aet01_2 Checks #' #' @inheritParams gen_args -#' +#' @export aet01_2_check <- function(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM", diff --git a/R/aet01_aesi.R b/R/aet01_aesi.R index 9d43cfc6b..9dc68ee47 100755 --- a/R/aet01_aesi.R +++ b/R/aet01_aesi.R @@ -226,7 +226,7 @@ aet01_aesi_1_pre <- function(adam_db, #' @describeIn aet01_aesi_1 Checks #' #' @inheritParams gen_args -#' +#' @export aet01_aesi_1_check <- function(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM") { diff --git a/R/aet02.R b/R/aet02.R index ae71134e4..15a865df8 100644 --- a/R/aet02.R +++ b/R/aet02.R @@ -117,7 +117,7 @@ aet02_1_pre <- function(adam_db, ...) { #' @describeIn aet02_1 Checks #' #' @inheritParams gen_args -#' +#' @export aet02_1_check <- function(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM") { diff --git a/R/aet10.R b/R/aet10.R index fe9060de6..07b9dce05 100644 --- a/R/aet10.R +++ b/R/aet10.R @@ -84,7 +84,7 @@ aet10_1_pre <- function(adam_db, ...) { #' @describeIn aet10_1 Checks #' #' @inheritParams gen_args -#' +#' @export aet10_1_check <- function(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM") { diff --git a/R/egt03.R b/R/egt03.R index 3f64d0e8f..1eeafc42a 100755 --- a/R/egt03.R +++ b/R/egt03.R @@ -92,7 +92,7 @@ egt03_1_lyt <- function(arm_var, #' @describeIn egt03_1 Checks #' #' @inheritParams gen_args -#' +#' @export egt03_1_check <- function(adam_db, req_tables, visit_var, diff --git a/R/lbt04.R b/R/lbt04.R index aacc73670..abdcdca15 100755 --- a/R/lbt04.R +++ b/R/lbt04.R @@ -101,7 +101,7 @@ lbt04_1_pre <- function(adam_db, req_tables = c("adsl", "adlb"), arm_var = "ACTA #' @describeIn lbt04_1 Checks #' #' @inheritParams gen_args -#' +#' @export lbt04_1_check <- function(adam_db, req_tables = c("adsl", "adlb"), arm_var = "ACTARM") { diff --git a/R/lbt05.R b/R/lbt05.R index a9d10f37b..4cc8649a6 100755 --- a/R/lbt05.R +++ b/R/lbt05.R @@ -120,7 +120,7 @@ lbt05_1_pre <- function(adam_db, arm_var = "ACTARM", ...) { #' @describeIn lbt05_1 Checks #' #' @inheritParams gen_args -#' +#' @export lbt05_1_check <- function(adam_db, req_tables, arm_var) { diff --git a/R/lbt07.R b/R/lbt07.R index afdc80bde..8bab959d5 100755 --- a/R/lbt07.R +++ b/R/lbt07.R @@ -151,7 +151,7 @@ lbt07_1_pre <- function(adam_db, ...) { #' @describeIn lbt07_1 Checks #' #' @inheritParams gen_args -#' +#' @export lbt07_1_check <- function(adam_db, req_tables = c("adsl", "adlb"), arm_var = "ACTARM") { diff --git a/R/lbt14.R b/R/lbt14.R index 394a0857d..afbb8a21c 100755 --- a/R/lbt14.R +++ b/R/lbt14.R @@ -159,7 +159,7 @@ lbt14_1_pre <- function(adam_db, #' @describeIn lbt14_1 Checks #' #' @inheritParams gen_args -#' +#' @export lbt14_1_check <- function(adam_db, req_tables = c("adsl", "adlb"), arm_var = "ACTARM") { @@ -367,7 +367,7 @@ lbt14_2_pre <- function(adam_db, #' @describeIn lbt14_2 Checks #' #' @inheritParams gen_args -#' +#' @export lbt14_2_check <- function(adam_db, req_tables = c("adsl", "adlb"), arm_var = "ACTARM") { From 80475b9622b9e3b67123a07bc1c6d6b100367a34 Mon Sep 17 00:00:00 2001 From: Liming Li Date: Mon, 17 Apr 2023 05:27:09 +0000 Subject: [PATCH 02/13] fix ext01_1_pre --- R/ext01.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/R/ext01.R b/R/ext01.R index 8ffaf112e..466c3feb5 100755 --- a/R/ext01.R +++ b/R/ext01.R @@ -80,10 +80,11 @@ ext01_1_lyt <- function(arm_var, #' @export #' ext01_1_pre <- function(adam_db, - paramcd_order = c("TNDOSE", "DOSE", "NDOSE", "TDOSE"), + paramcd_order = list("TNDOSE", "DOSE", "NDOSE", "TDOSE"), ...) { checkmate::assert_class(adam_db, "dm") - + checkmate::assert_list(paramcd_order) + paramcd_order <- unlist(paramcd_order) db <- adam_db %>% dm_zoom_to("adex") %>% filter(.data$PARCAT1 == "OVERALL") %>% From 034410ae100c71eb9f79111f99fa5ef0f4400a0e Mon Sep 17 00:00:00 2001 From: Liming Li Date: Mon, 17 Apr 2023 05:28:48 +0000 Subject: [PATCH 03/13] update docs --- NAMESPACE | 12 ++++++++++++ man/ext01_1.Rd | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 0811c308f..3306377f8 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,23 +5,28 @@ export("main<-") export("postprocess<-") export("preprocess<-") export(ael01_nollt_1) +export(ael01_nollt_1_check) export(ael01_nollt_1_main) export(ael01_nollt_1_pre) export(aet01_1) +export(aet01_1_check) export(aet01_1_lyt) export(aet01_1_main) export(aet01_1_pre) export(aet01_2) +export(aet01_2_check) export(aet01_2_lyt) export(aet01_2_main) export(aet01_2_pre) export(aet01_aesi_1) +export(aet01_aesi_1_check) export(aet01_aesi_1_lyt) export(aet01_aesi_1_main) export(aet01_aesi_1_pre) export(aet01_aesi_post) export(aet01_post) export(aet02_1) +export(aet02_1_check) export(aet02_1_lyt) export(aet02_1_main) export(aet02_1_post) @@ -47,6 +52,7 @@ export(aet04_1_main) export(aet04_1_post) export(aet04_1_pre) export(aet10_1) +export(aet10_1_check) export(aet10_1_lyt) export(aet10_1_main) export(aet10_1_post) @@ -117,6 +123,7 @@ export(egt02_2_main) export(egt02_2_post) export(egt02_2_pre) export(egt03_1) +export(egt03_1_check) export(egt03_1_lyt) export(egt03_1_main) export(egt03_1_post) @@ -154,26 +161,31 @@ export(lbt01_1_main) export(lbt01_1_post) export(lbt01_1_pre) export(lbt04_1) +export(lbt04_1_check) export(lbt04_1_lyt) export(lbt04_1_main) export(lbt04_1_post) export(lbt04_1_pre) export(lbt05_1) +export(lbt05_1_check) export(lbt05_1_lyt) export(lbt05_1_main) export(lbt05_1_post) export(lbt05_1_pre) export(lbt07_1) +export(lbt07_1_check) export(lbt07_1_lyt) export(lbt07_1_main) export(lbt07_1_post) export(lbt07_1_pre) export(lbt14_1) +export(lbt14_1_check) export(lbt14_1_lyt) export(lbt14_1_main) export(lbt14_1_post) export(lbt14_1_pre) export(lbt14_2) +export(lbt14_2_check) export(lbt14_2_lyt) export(lbt14_2_main) export(lbt14_2_post) diff --git a/man/ext01_1.Rd b/man/ext01_1.Rd index 7f9035a74..cd8ae46e2 100644 --- a/man/ext01_1.Rd +++ b/man/ext01_1.Rd @@ -25,7 +25,7 @@ ext01_1_lyt(arm_var, summaryvars, summaryvars_lbls, lbl_overall, deco) ext01_1_pre( adam_db, - paramcd_order = c("TNDOSE", "DOSE", "NDOSE", "TDOSE"), + paramcd_order = list("TNDOSE", "DOSE", "NDOSE", "TDOSE"), ... ) From 29046c726fff8a791fcda8fc0b96ed63edf1513f Mon Sep 17 00:00:00 2001 From: Liming Li Date: Mon, 17 Apr 2023 05:49:08 +0000 Subject: [PATCH 04/13] fix issue --- R/aet01.R | 4 ++-- R/aet02.R | 4 ++-- R/aet10.R | 4 ++-- man/aet01_2.Rd | 2 +- man/aet02_1.Rd | 2 +- man/aet10_1.Rd | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/R/aet01.R b/R/aet01.R index b73b30d60..2f717aced 100755 --- a/R/aet01.R +++ b/R/aet01.R @@ -440,10 +440,10 @@ aet01_2_lyt <- function(arm_var, #' #' @export #' -aet01_2_pre <- function(adam_db, ...) { +aet01_2_pre <- function(adam_db, arm_var, safety_var, medconcept_var, ...) { checkmate::assert_class(adam_db, "dm") - aet01_2_check(adam_db) + aet01_2_check(adam_db, arm_var = arm_var, safety_var = safety_var, medconcept_var = medconcept_var) df <- adam_db$adae labs <- formatters::var_labels(df) diff --git a/R/aet02.R b/R/aet02.R index 15a865df8..8471bd42a 100644 --- a/R/aet02.R +++ b/R/aet02.R @@ -95,10 +95,10 @@ aet02_1_lyt <- function(arm_var, #' #' @export #' -aet02_1_pre <- function(adam_db, ...) { +aet02_1_pre <- function(adam_db, arm_var, ...) { checkmate::assert_class(adam_db, "dm") - aet02_1_check(adam_db) + aet02_1_check(adam_db, arm_var = arm_var) new_format <- list( adae = list( diff --git a/R/aet10.R b/R/aet10.R index 07b9dce05..01a080b9c 100644 --- a/R/aet10.R +++ b/R/aet10.R @@ -67,10 +67,10 @@ aet10_1_lyt <- function(arm_var, #' #' @export #' -aet10_1_pre <- function(adam_db, ...) { +aet10_1_pre <- function(adam_db, arm_var, ...) { checkmate::assert_class(adam_db, "dm") - aet10_1_check(adam_db) + aet10_1_check(adam_db, arm_var = arm_var) adam_db %>% dm_zoom_to("adae") %>% diff --git a/man/aet01_2.Rd b/man/aet01_2.Rd index 1f1cf85e1..b6bda3e3c 100644 --- a/man/aet01_2.Rd +++ b/man/aet01_2.Rd @@ -36,7 +36,7 @@ aet01_2_lyt( lbl_medconcept_var ) -aet01_2_pre(adam_db, ...) +aet01_2_pre(adam_db, arm_var, safety_var, medconcept_var, ...) aet01_2_check( adam_db, diff --git a/man/aet02_1.Rd b/man/aet02_1.Rd index ff92c024b..188cea257 100644 --- a/man/aet02_1.Rd +++ b/man/aet02_1.Rd @@ -25,7 +25,7 @@ aet02_1_main( aet02_1_lyt(arm_var, lbl_overall, lbl_aebodsys, lbl_aedecod, deco) -aet02_1_pre(adam_db, ...) +aet02_1_pre(adam_db, arm_var, ...) aet02_1_check(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM") diff --git a/man/aet10_1.Rd b/man/aet10_1.Rd index d44cbde49..397f12699 100644 --- a/man/aet10_1.Rd +++ b/man/aet10_1.Rd @@ -24,7 +24,7 @@ aet10_1_main( aet10_1_lyt(arm_var, lbl_overall, lbl_aedecod, deco) -aet10_1_pre(adam_db, ...) +aet10_1_pre(adam_db, arm_var, ...) aet10_1_check(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM") From 474830804539d0b4a42faade9b52eb5a82d12243 Mon Sep 17 00:00:00 2001 From: Liming Li Date: Mon, 17 Apr 2023 06:04:49 +0000 Subject: [PATCH 05/13] export assert_colnames --- NAMESPACE | 2 ++ R/assertions.R | 1 + R/checks.R | 1 + 3 files changed, 4 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 3306377f8..7fdf73740 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -58,6 +58,8 @@ export(aet10_1_main) export(aet10_1_post) export(aet10_1_pre) export(args_ls) +export(assert_colnames) +export(check_col_contains) export(chevron_g) export(chevron_l) export(chevron_t) diff --git a/R/assertions.R b/R/assertions.R index d5312060a..3d815f7fd 100644 --- a/R/assertions.R +++ b/R/assertions.R @@ -9,6 +9,7 @@ #' @param null_ok (`logical`) can `x` be NULL. #' #' @keywords internal +#' @export #' #' @examples #' \dontrun{ diff --git a/R/checks.R b/R/checks.R index c48259eb8..8af5da051 100644 --- a/R/checks.R +++ b/R/checks.R @@ -60,6 +60,7 @@ check_one_colnames <- function(df, x, null_ok = TRUE, qualifier = NULL) { #' @param df_name (`string`) name of the data frame #' #' @keywords internal +#' @export #' #' @examples #' \dontrun{ From a50d2394516330e91f767530bc20be8ef03e4cfd Mon Sep 17 00:00:00 2001 From: Liming Li Date: Mon, 17 Apr 2023 06:38:19 +0000 Subject: [PATCH 06/13] minor update --- R/aet01_aesi.R | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/R/aet01_aesi.R b/R/aet01_aesi.R index 9dc68ee47..015703545 100755 --- a/R/aet01_aesi.R +++ b/R/aet01_aesi.R @@ -209,13 +209,16 @@ aet01_aesi_1_pre <- function(adam_db, ) ) %>% mutate( - ATOXGR = forcats::fct_recode( + ATOXGR = reformat( .data$ATOXGR, - "Grade 1" = "1", - "Grade 2" = "2", - "Grade 3" = "3", - "Grade 4" = "4", - "Grade 5 (fatal outcome)" = "5" + dunlin::rule( + "Missing" = c("", NA_character_), + "Grade 1" = "1", + "Grade 2" = "2", + "Grade 3" = "3", + "Grade 4" = "4", + "Grade 5 (fatal outcome)" = "5" + ) ) ) %>% dm_update_zoomed() From df9642df0fd97041fceb652b731953d5e9ffcdb9 Mon Sep 17 00:00:00 2001 From: Liming Li Date: Tue, 25 Apr 2023 04:36:48 +0000 Subject: [PATCH 07/13] update according to main --- R/aet01.R | 15 ++++----- R/aet01_aesi.R | 2 +- R/aet02.R | 2 +- R/aet10.R | 2 +- R/ext01.R | 2 +- tests/testthat/_snaps/aet01_aesi.md | 3 ++ tests/testthat/_snaps/chevron_tlg-methods.md | 32 -------------------- tests/testthat/_snaps/default_tlg.md | 1 + 8 files changed, 16 insertions(+), 43 deletions(-) diff --git a/R/aet01.R b/R/aet01.R index 823ea9fba..6b1bd8db5 100755 --- a/R/aet01.R +++ b/R/aet01.R @@ -436,7 +436,11 @@ aet01_2_lyt <- function(arm_var, #' #' @export #' -aet01_2_pre <- function(adam_db, arm_var, safety_var, medconcept_var, ...) { +aet01_2_pre <- function(adam_db, arm_var = "ACTARM", safety_var = list( + "FATAL", "SER", "SERWD", "SERDSM", + "RELSER", "WD", "DSM", "REL", "RELWD", "RELDSM", "SEV" + ), + medconcept_var = list("SMQ01", "SMQ02", "CQ01"), ...) { assert_all_tablenames(adam_db, c("adsl", "adae")) aet01_2_check(adam_db, arm_var = arm_var, safety_var = safety_var, medconcept_var = medconcept_var) @@ -513,12 +517,9 @@ aet01_2_pre <- function(adam_db, arm_var, safety_var, medconcept_var, ...) { #' @export aet01_2_check <- function(adam_db, req_tables = c("adsl", "adae"), - arm_var = "ACTARM", - safety_var = list( - "FATAL", "SER", "SERWD", "SERDSM", - "RELSER", "WD", "DSM", "REL", "RELWD", "RELDSM", "SEV" - ), - medconcept_var = list("SMQ01", "SMQ02", "CQ01")) { + arm_var, + safety_var, + medconcept_var) { assert_all_tablenames(adam_db, req_tables) checkmate::assert_list(safety_var, types = "character") safety_var <- unlist(safety_var) diff --git a/R/aet01_aesi.R b/R/aet01_aesi.R index 3bfa49a30..649e1411f 100755 --- a/R/aet01_aesi.R +++ b/R/aet01_aesi.R @@ -206,7 +206,7 @@ aet01_aesi_1_pre <- function(adam_db, ) ) %>% mutate( - ATOXGR = reformat( + ATOXGR = dunlin::reformat( .data$ATOXGR, dunlin::rule( "Missing" = c("", NA_character_), diff --git a/R/aet02.R b/R/aet02.R index 16e9cb368..d5d7f0752 100644 --- a/R/aet02.R +++ b/R/aet02.R @@ -95,7 +95,7 @@ aet02_1_lyt <- function(arm_var, #' #' @export #' -aet02_1_pre <- function(adam_db, arm_var, ...) { +aet02_1_pre <- function(adam_db, arm_var = "ACTARM", ...) { assert_all_tablenames(adam_db, c("adsl", "adae")) aet02_1_check(adam_db, arm_var = arm_var) new_format <- list( diff --git a/R/aet10.R b/R/aet10.R index f2c05f7bb..5ecf20246 100644 --- a/R/aet10.R +++ b/R/aet10.R @@ -67,7 +67,7 @@ aet10_1_lyt <- function(arm_var, #' #' @export #' -aet10_1_pre <- function(adam_db, arm_var, ...) { +aet10_1_pre <- function(adam_db, arm_var = "ACTARM", ...) { aet10_1_check(adam_db, arm_var = arm_var) adam_db$adae <- adam_db$adae %>% diff --git a/R/ext01.R b/R/ext01.R index 19cf5430f..5442e81b1 100755 --- a/R/ext01.R +++ b/R/ext01.R @@ -90,7 +90,7 @@ ext01_1_pre <- function(adam_db, if (nrow(adam_db$adex) > 0L) { param_vars <- adam_db$adex %>% dplyr::select("PARAM", "PARAMCD") %>% - dunlin::co_relevels("PARAMCD", "PARAM", paramcd_order) + dunlin::co_relevels("PARAMCD", "PARAM", unlist(paramcd_order)) adam_db$adex <- adam_db$adex %>% mutate(PARAM = param_vars$PARAM, PARAMCD = param_vars$PARAMCD) diff --git a/tests/testthat/_snaps/aet01_aesi.md b/tests/testthat/_snaps/aet01_aesi.md index ce15a3096..8081a6811 100644 --- a/tests/testthat/_snaps/aet01_aesi.md +++ b/tests/testthat/_snaps/aet01_aesi.md @@ -14,6 +14,7 @@ Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Missing 0 0 0 Total number of patients with study drug withdrawn due to AE 0 0 0 Total number of patients with dose modified/interrupted due to AE 0 0 0 Total number of patients with treatment received for AE 0 0 0 @@ -58,6 +59,7 @@ Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Missing 0 0 0 Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) Total number of patients with treatment received for AE 98 (73.1%) 102 (76.1%) 103 (78.0%) @@ -82,6 +84,7 @@ Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Missing 0 0 0 Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) Total number of patients with treatment received for AE 98 (73.1%) 102 (76.1%) 103 (78.0%) diff --git a/tests/testthat/_snaps/chevron_tlg-methods.md b/tests/testthat/_snaps/chevron_tlg-methods.md index 4c0786bf5..b80953825 100644 --- a/tests/testthat/_snaps/chevron_tlg-methods.md +++ b/tests/testthat/_snaps/chevron_tlg-methods.md @@ -131,38 +131,6 @@ # script_funs works as expected in interactive mode - Code - res - Output - [1] "# Edit Preprocessing Function." - [2] "pre_fun <- function(adam_db, ...) {" - [3] " checkmate::assert_class(adam_db, \"dm\")" - [4] "" - [5] " new_format <- list(" - [6] " adae = list(" - [7] " AEBODSYS = rule(\"No Coding Available\" = c(\"\", NA, \"\"))," - [8] " AEDECOD = rule(\"No Coding Available\" = c(\"\", NA, \"\"))," - [9] " ATOXGR = rule(\"No Grading Available\" = c(\"\", NA, \"\"))" - [10] " )" - [11] " )" - [12] "" - [13] " adam_db <- dunlin::reformat(adam_db, new_format, na_last = TRUE)" - [14] "" - [15] " adam_db %>%" - [16] " dm_zoom_to(\"adae\") %>%" - [17] " filter(.data$ANL01FL == \"Y\") %>%" - [18] " filter(.data$ATOXGR != \"No Grading Available\") %>%" - [19] " mutate(ATOXGR = factor(.data$ATOXGR," - [20] " levels = setdiff(levels(.data$ATOXGR), \"No Grading Available\")" - [21] " )) %>%" - [22] " dm_update_zoomed()" - [23] "}" - [24] "" - [25] "# Create TLG" - [26] "tlg_output <- rlang::exec(.fn = pre_fun, adam_db = data, !!!args_ls) %>% \nrlang::exec(.fn = run, object = aet04_1, !!!args_ls, auto_pre = FALSE, check_arg = FALSE)" - -# script_funs works as expected in non interactive mode - Code res Output diff --git a/tests/testthat/_snaps/default_tlg.md b/tests/testthat/_snaps/default_tlg.md index 6d1fc4e22..f3e8629a7 100644 --- a/tests/testthat/_snaps/default_tlg.md +++ b/tests/testthat/_snaps/default_tlg.md @@ -68,6 +68,7 @@ Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Missing 0 0 0 Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) Total number of patients with treatment received for AE 98 (73.1%) 102 (76.1%) 103 (78.0%) From 2c6a8219abee4ab54fb04ab8b3220ee9cbc63f38 Mon Sep 17 00:00:00 2001 From: Liming Li Date: Tue, 25 Apr 2023 05:35:56 +0000 Subject: [PATCH 08/13] add grade_groups to argument --- R/aet01_aesi.R | 31 +++++++++++++++++----------- tests/testthat/_snaps/aet01_aesi.md | 8 +++---- tests/testthat/_snaps/default_tlg.md | 2 +- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/R/aet01_aesi.R b/R/aet01_aesi.R index 649e1411f..fb2c28436 100755 --- a/R/aet01_aesi.R +++ b/R/aet01_aesi.R @@ -4,7 +4,7 @@ #' #' @inheritParams gen_args #' @param aesi_vars (`list`) the AESI variables to be included in the summary. Defaults to `NA`. -#' +#' @param grade_groups (`list`) the grade groups to be displayed. #' @details #' * Does not remove rows with zero counts by default. #' @@ -34,8 +34,19 @@ aet01_aesi_1_main <- function(adam_db, arm_var = "ACTARM", aesi_vars = list(NA_character_), deco = std_deco("AET01_AESI"), + grade_groups = NULL, ...) { checkmate::assert_list(aesi_vars, types = "character") + checkmate::assert_list(grade_groups, null.ok = TRUE) + if (is.null(grade_groups)) { + grade_groups <- list( + "Grade 1" = "1", + "Grade 2" = "2", + "Grade 3" = "3", + "Grade 4" = "4", + "Grade 5" = "5" + ) + } aesi_vars <- unlist(aesi_vars) if ("ALL" %in% aesi_vars) aesi_vars <- c("ALL_ALLRES", "ALL_NOTRES", "ALL_SER", "ALL_REL") if (any(grepl("^ALL_", aesi_vars))) { @@ -58,7 +69,8 @@ aet01_aesi_1_main <- function(adam_db, arm_var = arm_var, aesi_vars = all_aesi_vars, deco = deco, - lbl_aesi_vars = lbl_aesi_vars + lbl_aesi_vars = lbl_aesi_vars, + grade_groups ) tbl <- build_table(lyt, adam_db$adae, alt_counts_df = adam_db$adsl) @@ -76,7 +88,8 @@ aet01_aesi_1_main <- function(adam_db, aet01_aesi_1_lyt <- function(arm_var, aesi_vars, deco, - lbl_aesi_vars) { + lbl_aesi_vars, + grade_groups) { names(lbl_aesi_vars) <- aesi_vars basic_table_deco(deco, show_colcounts = TRUE) %>% split_cols_by(var = arm_var) %>% @@ -96,7 +109,8 @@ aet01_aesi_1_lyt <- function(arm_var, count_occurrences_by_grade( var = "ATOXGR", var_labels = "Total number of patients with at least one AE by worst grade", - show_labels = "visible" + show_labels = "visible", + grade_groups = grade_groups ) %>% count_patients_with_flags( "USUBJID", @@ -208,14 +222,7 @@ aet01_aesi_1_pre <- function(adam_db, mutate( ATOXGR = dunlin::reformat( .data$ATOXGR, - dunlin::rule( - "Missing" = c("", NA_character_), - "Grade 1" = "1", - "Grade 2" = "2", - "Grade 3" = "3", - "Grade 4" = "4", - "Grade 5 (fatal outcome)" = "5" - ) + dunlin::rule("Missing" = c("", NA_character_)) ) ) diff --git a/tests/testthat/_snaps/aet01_aesi.md b/tests/testthat/_snaps/aet01_aesi.md index 8081a6811..ded065f4c 100644 --- a/tests/testthat/_snaps/aet01_aesi.md +++ b/tests/testthat/_snaps/aet01_aesi.md @@ -13,7 +13,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) Missing 0 0 0 Total number of patients with study drug withdrawn due to AE 0 0 0 Total number of patients with dose modified/interrupted due to AE 0 0 0 @@ -38,7 +38,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) Total number of patients with all non-fatal AEs resolved 84 (62.7%) 92 (68.7%) 97 (73.5%) Total number of patients with at least one unresolved or ongoing non-fatal AE 102 (76.1%) 110 (82.1%) 107 (81.1%) Total number of patients with at least one related AE 105 (78.4%) 108 (80.6%) 109 (82.6%) @@ -58,7 +58,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) Missing 0 0 0 Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) @@ -83,7 +83,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) Missing 0 0 0 Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) diff --git a/tests/testthat/_snaps/default_tlg.md b/tests/testthat/_snaps/default_tlg.md index f3e8629a7..ff97b5035 100644 --- a/tests/testthat/_snaps/default_tlg.md +++ b/tests/testthat/_snaps/default_tlg.md @@ -67,7 +67,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) + Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) Missing 0 0 0 Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) From 44aa09282de3f558e163005cb935924b2952a91f Mon Sep 17 00:00:00 2001 From: Liming Li Date: Tue, 25 Apr 2023 05:42:01 +0000 Subject: [PATCH 09/13] update docs --- NAMESPACE | 3 +-- man/aet01_2.Rd | 16 +++++++++++----- man/aet01_aesi_1.Rd | 5 ++++- man/aet02_1.Rd | 2 +- man/aet10_1.Rd | 2 +- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 6cf27fe4a..c07c9143e 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -58,11 +58,10 @@ export(aet10_1_main) export(aet10_1_post) export(aet10_1_pre) export(args_ls) -export(assert_colnames) -export(check_col_contains) export(assert_all_tablenames) export(assert_colnames) export(assert_only_one_paramcd) +export(check_col_contains) export(chevron_g) export(chevron_l) export(chevron_t) diff --git a/man/aet01_2.Rd b/man/aet01_2.Rd index afe9229ec..713a45559 100644 --- a/man/aet01_2.Rd +++ b/man/aet01_2.Rd @@ -36,15 +36,21 @@ aet01_2_lyt( lbl_medconcept_var ) -aet01_2_pre(adam_db, arm_var, safety_var, medconcept_var, ...) - -aet01_2_check( +aet01_2_pre( adam_db, - req_tables = c("adsl", "adae"), arm_var = "ACTARM", safety_var = list("FATAL", "SER", "SERWD", "SERDSM", "RELSER", "WD", "DSM", "REL", "RELWD", "RELDSM", "SEV"), - medconcept_var = list("SMQ01", "SMQ02", "CQ01") + medconcept_var = list("SMQ01", "SMQ02", "CQ01"), + ... +) + +aet01_2_check( + adam_db, + req_tables = c("adsl", "adae"), + arm_var, + safety_var, + medconcept_var ) aet01_2 diff --git a/man/aet01_aesi_1.Rd b/man/aet01_aesi_1.Rd index 8fde311ba..0fe295de0 100755 --- a/man/aet01_aesi_1.Rd +++ b/man/aet01_aesi_1.Rd @@ -18,10 +18,11 @@ aet01_aesi_1_main( arm_var = "ACTARM", aesi_vars = list(NA_character_), deco = std_deco("AET01_AESI"), + grade_groups = NULL, ... ) -aet01_aesi_1_lyt(arm_var, aesi_vars, deco, lbl_aesi_vars) +aet01_aesi_1_lyt(arm_var, aesi_vars, deco, lbl_aesi_vars, grade_groups) aet01_aesi_1_pre( adam_db, @@ -45,6 +46,8 @@ aet01_aesi_1 \item{deco}{(\code{character}) decoration with \code{title}, \code{subtitles} and \code{main_footer} content} +\item{grade_groups}{(\code{list}) the grade groups to be displayed.} + \item{...}{not used.} \item{lbl_aesi_vars}{(\code{character}) the labels of the AESI variables to be summarized.} diff --git a/man/aet02_1.Rd b/man/aet02_1.Rd index b7928a45b..1eb837ea6 100644 --- a/man/aet02_1.Rd +++ b/man/aet02_1.Rd @@ -25,7 +25,7 @@ aet02_1_main( aet02_1_lyt(arm_var, lbl_overall, lbl_aebodsys, lbl_aedecod, deco) -aet02_1_pre(adam_db, arm_var, ...) +aet02_1_pre(adam_db, arm_var = "ACTARM", ...) aet02_1_check(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM") diff --git a/man/aet10_1.Rd b/man/aet10_1.Rd index 6cfac640a..cbd394d7d 100644 --- a/man/aet10_1.Rd +++ b/man/aet10_1.Rd @@ -24,7 +24,7 @@ aet10_1_main( aet10_1_lyt(arm_var, lbl_overall, lbl_aedecod, deco) -aet10_1_pre(adam_db, arm_var, ...) +aet10_1_pre(adam_db, arm_var = "ACTARM", ...) aet10_1_check(adam_db, req_tables = c("adsl", "adae"), arm_var = "ACTARM") From 811ce7114223b915733330f3265a167d743928d4 Mon Sep 17 00:00:00 2001 From: Liming Li Date: Tue, 25 Apr 2023 06:22:56 +0000 Subject: [PATCH 10/13] style update --- R/aet01.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/aet01.R b/R/aet01.R index 6b1bd8db5..542f7ddcf 100755 --- a/R/aet01.R +++ b/R/aet01.R @@ -437,10 +437,10 @@ aet01_2_lyt <- function(arm_var, #' @export #' aet01_2_pre <- function(adam_db, arm_var = "ACTARM", safety_var = list( - "FATAL", "SER", "SERWD", "SERDSM", - "RELSER", "WD", "DSM", "REL", "RELWD", "RELDSM", "SEV" - ), - medconcept_var = list("SMQ01", "SMQ02", "CQ01"), ...) { + "FATAL", "SER", "SERWD", "SERDSM", + "RELSER", "WD", "DSM", "REL", "RELWD", "RELDSM", "SEV" + ), + medconcept_var = list("SMQ01", "SMQ02", "CQ01"), ...) { assert_all_tablenames(adam_db, c("adsl", "adae")) aet01_2_check(adam_db, arm_var = arm_var, safety_var = safety_var, medconcept_var = medconcept_var) From 94d0c0e144e0c8adde340060ae44f1f940f3cc29 Mon Sep 17 00:00:00 2001 From: Liming <36079400+clarkliming@users.noreply.github.com> Date: Tue, 25 Apr 2023 23:54:24 +0800 Subject: [PATCH 11/13] Update R/aet01_aesi.R Co-authored-by: b_falquet <64274616+BFalquet@users.noreply.github.com> Signed-off-by: Liming <36079400+clarkliming@users.noreply.github.com> --- R/aet01_aesi.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/aet01_aesi.R b/R/aet01_aesi.R index fb2c28436..44822045a 100755 --- a/R/aet01_aesi.R +++ b/R/aet01_aesi.R @@ -70,7 +70,7 @@ aet01_aesi_1_main <- function(adam_db, aesi_vars = all_aesi_vars, deco = deco, lbl_aesi_vars = lbl_aesi_vars, - grade_groups + grade_groups = grade_groups ) tbl <- build_table(lyt, adam_db$adae, alt_counts_df = adam_db$adsl) From 8c49c6e4158556b4209e066fa87772c42132341a Mon Sep 17 00:00:00 2001 From: Liming Li Date: Wed, 26 Apr 2023 02:49:09 +0000 Subject: [PATCH 12/13] fix aet01_aesi issue --- R/aet01_aesi.R | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/R/aet01_aesi.R b/R/aet01_aesi.R index 44822045a..53e83b5bd 100755 --- a/R/aet01_aesi.R +++ b/R/aet01_aesi.R @@ -44,7 +44,7 @@ aet01_aesi_1_main <- function(adam_db, "Grade 2" = "2", "Grade 3" = "3", "Grade 4" = "4", - "Grade 5" = "5" + "Grade 5 (fatal outcome)" = "5" ) } aesi_vars <- unlist(aesi_vars) @@ -220,10 +220,7 @@ aet01_aesi_1_pre <- function(adam_db, ) ) %>% mutate( - ATOXGR = dunlin::reformat( - .data$ATOXGR, - dunlin::rule("Missing" = c("", NA_character_)) - ) + ATOXGR = factor(ATOXGR, levels = 1:5) ) adam_db From 6d13c28951f997bf18e13ed74645ed3549fba6b0 Mon Sep 17 00:00:00 2001 From: Liming Li Date: Wed, 26 Apr 2023 03:15:57 +0000 Subject: [PATCH 13/13] fix issue --- tests/testthat/_snaps/aet01_aesi.md | 11 ++++------- tests/testthat/_snaps/default_tlg.md | 3 +-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/testthat/_snaps/aet01_aesi.md b/tests/testthat/_snaps/aet01_aesi.md index ded065f4c..ce15a3096 100644 --- a/tests/testthat/_snaps/aet01_aesi.md +++ b/tests/testthat/_snaps/aet01_aesi.md @@ -13,8 +13,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) - Missing 0 0 0 + Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) Total number of patients with study drug withdrawn due to AE 0 0 0 Total number of patients with dose modified/interrupted due to AE 0 0 0 Total number of patients with treatment received for AE 0 0 0 @@ -38,7 +37,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) + Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) Total number of patients with all non-fatal AEs resolved 84 (62.7%) 92 (68.7%) 97 (73.5%) Total number of patients with at least one unresolved or ongoing non-fatal AE 102 (76.1%) 110 (82.1%) 107 (81.1%) Total number of patients with at least one related AE 105 (78.4%) 108 (80.6%) 109 (82.6%) @@ -58,8 +57,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) - Missing 0 0 0 + Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) Total number of patients with treatment received for AE 98 (73.1%) 102 (76.1%) 103 (78.0%) @@ -83,8 +81,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) - Missing 0 0 0 + Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) Total number of patients with treatment received for AE 98 (73.1%) 102 (76.1%) 103 (78.0%) diff --git a/tests/testthat/_snaps/default_tlg.md b/tests/testthat/_snaps/default_tlg.md index ff97b5035..6d1fc4e22 100644 --- a/tests/testthat/_snaps/default_tlg.md +++ b/tests/testthat/_snaps/default_tlg.md @@ -67,8 +67,7 @@ Grade 2 6 (4.5%) 10 (7.5%) 7 (5.3%) Grade 3 18 (13.4%) 14 (10.4%) 16 (12.1%) Grade 4 15 (11.2%) 20 (14.9%) 18 (13.6%) - Grade 5 76 (56.7%) 70 (52.2%) 75 (56.8%) - Missing 0 0 0 + Grade 5 (fatal outcome) 76 (56.7%) 70 (52.2%) 75 (56.8%) Total number of patients with study drug withdrawn due to AE 27 (20.1%) 26 (19.4%) 30 (22.7%) Total number of patients with dose modified/interrupted due to AE 66 (49.3%) 76 (56.7%) 74 (56.1%) Total number of patients with treatment received for AE 98 (73.1%) 102 (76.1%) 103 (78.0%)