Skip to content

Commit

Permalink
add prototype (#747)
Browse files Browse the repository at this point in the history
new ael03 template

thank you for the review

---------

Signed-off-by: b_falquet <[email protected]>
  • Loading branch information
BFalquet authored May 23, 2024
1 parent e8f3fd0 commit 7971388
Show file tree
Hide file tree
Showing 18 changed files with 1,238 additions and 674 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Collate:
'chevron_tlg-S4class.R'
'ael01_nollt.R'
'ael02.R'
'ael03.R'
'aet01.R'
'aet01_aesi.R'
'aet02.R'
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export(ael01_nollt_pre)
export(ael02)
export(ael02_main)
export(ael02_pre)
export(ael03)
export(ael03_main)
export(ael03_pre)
export(aet01)
export(aet01_aesi)
export(aet01_aesi_main)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# chevron 0.2.6.9004

* Add `AEL02` template.
* Add `AEL02`, `AEL03` templates.
* Modify the post processing of `MHT01` to allow multiple `row_split_var`.

# chevron 0.2.6
Expand Down
3 changes: 2 additions & 1 deletion R/ael01_nollt.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ ael01_nollt_main <- modify_default_args(
std_listing,
dataset = "adae",
key_cols = c("AEBODSYS", "AEDECOD"),
disp_cols = "AETERM"
disp_cols = "AETERM",
split_into_pages_by_var = NULL
)

#' @describeIn ael01_nollt Preprocessing
Expand Down
5 changes: 3 additions & 2 deletions R/ael02.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
#'
ael02_main <- modify_default_args(std_listing,
dataset = "adae",
key_cols = c("ID", "ASR", "ACTARM"),
key_cols = c("ID", "ASR"),
disp_cols = c(
"AEDECOD", "TRTSDTM", "ASTDY", "ADURN", "AESER",
"ASEV", "AREL", "AEOUT", "AECONTRT", "AEACN"
)
),
split_into_pages_by_var = "ACTARM"
)

#' @describeIn ael02 Preprocessing
Expand Down
80 changes: 80 additions & 0 deletions R/ael03.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# ael03_main ----

#' @describeIn ael03 Main TLG function
#'
#' @inheritParams gen_args
#' @returns the main function returns an `rlistings` or a `list` object.
#' @export
#'
ael03_main <- modify_default_args(
std_listing,
dataset = "adae",
key_cols = c("ID", "ASR"),
disp_cols = c(
"AEDECOD", "TRTSDTM", "ASTDY", "ADURN", "ASEV",
"AREL", "AEOUT", "AECONTRT", "AEACN", "SERREAS"
),
split_into_pages_by_var = "ACTARM"
)

#' @describeIn ael03 Preprocessing
#'
#' @inheritParams ael03_main
#' @inheritParams gen_args
#'
#' @export
#'
ael03_pre <- function(adam_db,
dataset = "adae",
arm_var = "ACTARM",
...) {
adam_db[[dataset]] <- adam_db[[dataset]] %>%
filter(.data$ANL01FL == "Y") %>%
filter(.data$AESER == "Y") %>%
mutate(
across(
all_of(c(arm_var, "AEDECOD", "ASEV", "AEOUT", "AEACN")),
~ reformat(.x, missing_rule)
)
) %>%
mutate(
!!arm_var := with_label(.data[[arm_var]], "Treatment"),
ID = create_id_listings(.data$SITEID, .data$SUBJID),
AEDECOD = with_label(reformat(.data$AEDECOD, nocoding), "Adverse\nEvent MedDRA\nPreferred Term"),
ASR = with_label(paste(.data$AGE, .data$SEX, .data$RACE, sep = "/"), "Age/Sex/Race"),
# Datetime of First Exposure to Treatment
TRTSDTM = with_label(.data$TRTSDTM, "Date of\nFirst Study\nDrug\nAdministration"),
ASTDY = with_label(.data$ASTDY, "Study\nDay of\nOnset"),
ADURN = with_label(.data$AENDY - .data$ASTDY + 1, "AE\nDuration\nin Days"),
AESER = with_label(.data$AESER, "Serious"),
ASEV = with_label(.data$ASEV, "Most\nExtreme\nIntensity"),
AREL = with_label(reformat(.data$AREL, yes_no_rule), "Caused by\nStudy\nDrug"), # Analysis Causality
AEOUT = with_label(reformat(.data$AEOUT, outcome_rule), "Outcome\n(1)"),
AECONTRT = with_label(reformat(.data$AECONTRT, yes_no_rule), "Treatment\nfor AE"),
AEACN = with_label(reformat(.data$AEACN, dose_change_rule), "Action\nTaken\n(2)"),
# New derived column
SERREAS = with_label(case_when(
AESDTH == "Y" ~ "1",
AESLIFE == "Y" ~ "2",
AESHOSP == "Y" ~ "3",
AESDISAB == "Y" ~ "4",
AESCONG == "Y" ~ "5",
AESMIE == "Y" ~ "6",
TRUE ~ " "
), "Reason\nClassified\nas Serious\n(3)"),
)

adam_db
}

#' `AEL03` Listing 1 (Default) Listing of Serious Adverse Events.
#'
#' @include chevron_tlg-S4class.R
#' @export
#'
#' @examples
#' res <- run(ael03, syn_data)
ael03 <- chevron_l(
main = ael03_main,
preprocess = ael03_pre
)
3 changes: 2 additions & 1 deletion R/gen_args.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#' Key columns allow you to group repeat occurrences.
#' @param disp_cols (`character`) names of non-key columns which should be displayed when the listing is rendered.
#' @param row_split_var (`character`) additional row split variables.
#' @param split_into_pages_by_var (`character` or `NULL`) the name of the variable to split the listing by.
#' @param page_var (`string`) variable name prior to which the row split is by page.
#' @param unique_rows (`flag`) whether to keep only unique rows in listing.
#' @param ... not used.
Expand All @@ -32,5 +33,5 @@
gen_args <- function(adam_db, main, preprocess, postprocess, dataset,
type, arm_var, lbl_overall, prune_0, req_tables, deco, group,
tlg, visitvar, visit_value, paramcd_value,
key_cols, disp_cols, row_split_var, page_var, unique_rows, ...) {
key_cols, disp_cols, row_split_var, split_into_pages_by_var, page_var, unique_rows, ...) {
}
2 changes: 2 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ std_listing <- function(adam_db,
dataset,
key_cols,
disp_cols,
split_into_pages_by_var,
...) {
assert_all_tablenames(adam_db, dataset)
assert_valid_variable(adam_db[[dataset]], c(key_cols, disp_cols), label = paste0("adam_db$", dataset))
Expand All @@ -76,6 +77,7 @@ std_listing <- function(adam_db,
df = adam_db[[dataset]],
key_cols = key_cols,
disp_cols = disp_cols,
split_into_pages_by_var = split_into_pages_by_var,
...,
default_formatting = listing_format_chevron(),
unique_rows = TRUE
Expand Down
1 change: 1 addition & 0 deletions _pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ reference:
contents:
- ael01_nollt
- ael02
- ael03
- aet01
- aet01_aesi
- aet02
Expand Down
3 changes: 3 additions & 0 deletions man/ael01_nollt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/ael02.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions man/ael03.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/gen_args.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion man/std_listing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7971388

Please sign in to comment.