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

643 AEL02 [Spec Added] #655

Open
wants to merge 48 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
869d5e4
ael02 prototype
Sep 11, 2023
7b2b2c7
add test snapshots
Sep 11, 2023
cf2f415
remove note
Sep 11, 2023
0107ea2
prototype cml02a_gl
Sep 11, 2023
4129d6e
increase test coverage
Sep 11, 2023
997dfb1
increase coverage
Sep 11, 2023
b5ee067
change title of test
Sep 11, 2023
f97a095
dsl1 and dsl2
Sep 11, 2023
4f007cc
styler
Sep 11, 2023
b06f3be
fix note
Sep 11, 2023
41207e8
ael03 and ael04
Sep 13, 2023
a4dd74e
dml01
Sep 13, 2023
72ce45b
linter
Sep 13, 2023
312f3b4
document
Sep 13, 2023
5142122
change argument
Sep 13, 2023
ff28482
dml02
Sep 13, 2023
ac59228
pdl01
Sep 13, 2023
d3209fb
update pkgdown
Sep 13, 2023
1f560a9
document
Sep 14, 2023
2ba35ab
adding missing value handling
Sep 15, 2023
572e79e
across oll key_cols
Sep 15, 2023
5f2d0f0
use render safe
Sep 18, 2023
06b9942
sorting date as first column
Sep 18, 2023
5873f39
limings suggestion
Sep 18, 2023
2b230f6
Merge branch '642-cml02a_gl-spec-added@main' into 643-ael02-spec-adde…
Sep 18, 2023
5287ec1
explicit parameter value for listings
Sep 19, 2023
f22ff47
add null report
Sep 19, 2023
a426a39
correct argument default and tests
Sep 19, 2023
e5501c4
Merge branch 'main' into 643-ael02-spec-added@main
BFalquet Sep 19, 2023
34fb219
update syn_data
Sep 20, 2023
ad9e4c9
utility function for ID
Sep 20, 2023
982d7e6
add date format
Sep 20, 2023
b57f962
use execute_with_args
Sep 20, 2023
a08dbbc
remove unused tests
Sep 20, 2023
60cdde0
simplify arguments
Sep 22, 2023
71fd248
remove default format from arguments
Sep 25, 2023
2efc471
Merge branch 'main' into 643-ael02-spec-added@main
Sep 25, 2023
cd9fe3e
fix tests
Sep 25, 2023
a54c145
correct documentation
Sep 25, 2023
918d258
add TRTDURD in syn_data
Sep 26, 2023
d799532
update dsl02 snapshot
Sep 26, 2023
453db79
update pkgdown
Sep 26, 2023
628972e
Merge remote-tracking branch 'origin/main' into 643-ael02-spec-added@…
Sep 27, 2023
d4d2f76
update linter
Sep 27, 2023
658dd60
Merge branch 'main' into 643-ael02-spec-added@main
BFalquet Oct 6, 2023
ae3bf05
update patient label
Oct 6, 2023
9f0d388
adapt dml02
Oct 6, 2023
9c0f8c3
update dml0x listings
Oct 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .lintr
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
linters: linters_with_defaults(
line_length_linter = line_length_linter(120),
cyclocomp_linter = NULL,
object_usage_linter = NULL
object_usage_linter = NULL,
indentation_linter = NULL
)
9 changes: 9 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Collate:
'utils.R'
'chevron_tlg-S4class.R'
'ael01_nollt.R'
'ael02.R'
'ael03.R'
'ael04.R'
'aet01.R'
'aet01_aesi.R'
'aet02.R'
Expand All @@ -76,12 +79,17 @@ Collate:
'cfbt01.R'
'checks.R'
'chevron_tlg-S4methods.R'
'cml02a_gl.R'
'cmt01a.R'
'cmt02_pt.R'
'coxt01.R'
'coxt02.R'
'data.R'
'dml01.R'
'dml02.R'
'dmt01.R'
'dsl01.R'
'dsl02.R'
'dst01.R'
'dtht01.R'
'egt01.R'
Expand All @@ -103,6 +111,7 @@ Collate:
'mht01.R'
'mng01.R'
'package.R'
'pdl01.R'
'pdt01.R'
'pdt02.R'
'reexports.R'
Expand Down
36 changes: 36 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,25 @@ S3method(droplevels,character)
S3method(lvls,character)
S3method(lvls,default)
S3method(lvls,factor)
S3method(report_null,"NULL")
S3method(report_null,ElementaryTable)
S3method(report_null,TableTree)
S3method(report_null,listing_df)
export("main<-")
export("postprocess<-")
export("preprocess<-")
export(ael01_nollt)
export(ael01_nollt_main)
export(ael01_nollt_pre)
export(ael02)
export(ael02_main)
export(ael02_pre)
export(ael03)
export(ael03_main)
export(ael03_pre)
export(ael04)
export(ael04_main)
export(ael04_pre)
export(aet01)
export(aet01_aesi)
export(aet01_aesi_main)
Expand Down Expand Up @@ -58,6 +71,9 @@ export(cfbt01_pre)
export(chevron_g)
export(chevron_l)
export(chevron_t)
export(cml02a_gl)
export(cml02a_gl_main)
export(cml02a_gl_pre)
export(cmt01_label)
export(cmt01a)
export(cmt01a_main)
Expand All @@ -74,10 +90,24 @@ export(coxt01_post)
export(coxt01_pre)
export(coxt02)
export(coxt02_main)
export(create_id_listings)
export(dml01)
export(dml01_main)
export(dml01_pre)
export(dml02)
export(dml02_main)
export(dml02_pre)
export(dmt01)
export(dmt01_main)
export(dmt01_post)
export(dmt01_pre)
export(dose_change_rule)
export(dsl01)
export(dsl01_main)
export(dsl01_pre)
export(dsl02)
export(dsl02_main)
export(dsl02_pre)
export(dst01)
export(dst01_main)
export(dst01_post)
Expand Down Expand Up @@ -108,6 +138,7 @@ export(ext01)
export(ext01_main)
export(ext01_post)
export(ext01_pre)
export(format_date)
export(fstg01)
export(fstg01_main)
export(fstg01_pre)
Expand Down Expand Up @@ -162,6 +193,10 @@ export(mng01_pre)
export(nocoding)
export(null_listing)
export(null_report)
export(outcome_rule)
export(pdl01)
export(pdl01_main)
export(pdl01_pre)
export(pdt01)
export(pdt01_main)
export(pdt01_post)
Expand Down Expand Up @@ -213,6 +248,7 @@ export(vst02_2_main)
export(vst02_post)
export(vst02_pre)
export(with_label)
export(yes_no_rule)
exportClasses(chevron_g)
exportClasses(chevron_l)
exportClasses(chevron_t)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ variables do not exist in analysis dataset.
and `legend_pos` arguments. The `table` arguments now controls the behavior of the table. The arguments `show_n` and
`show_table` are now defunct.
* Add `RMPT06` template.
* Add `AEL02`, `AEL03` and `AEL04`, `CML02A_GL`, `DSL01`, `DSL02`, `DML01`, `DML02` and `PDL01` listing templates.
* The `stats` and `precision` arguments now control the statistical analysis and numbers of digits presented in `DMT01`.
* `FSTG01` and `FSTG02` template removes the `max_colwidth` argument. Default font size of the plot is set to 7.
* Introduce `set_section_div` function to add empty line separator between specified row splits.
Expand Down
28 changes: 9 additions & 19 deletions R/ael01_nollt.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#' @describeIn ael01_nollt Main TLG function
#'
#' @inheritParams gen_args
#' @param dataset (`character`) the name of a table in the `adam_db` object.
#' @param default_formatting (`list`) the default format of the listing columns. See [`rlistings::as_listing`].
#' @param col_formatting (`list`) the format of specific listing columns. See [`rlistings::as_listing`].
#' @param dataset (`string`) the name of a table in the `adam_db` object.
#'
#' @details
#' * Removes duplicate rows.
Expand All @@ -22,25 +20,18 @@ ael01_nollt_main <- function(adam_db,
dataset = "adae",
key_cols = c("AEBODSYS", "AEDECOD"),
disp_cols = "AETERM",
default_formatting = list(
all = fmt_config(align = "left"),
numeric = fmt_config(align = "center")
),
col_formatting = NULL,
unique_rows = TRUE,
...) {
assert_all_tablenames(adam_db, dataset)
assert_valid_variable(adam_db[[dataset]], c(key_cols, disp_cols), label = paste0("adam_db$", dataset))
assert_list(default_formatting, types = "fmt_config", names = "unique")
assert_list(col_formatting, null.ok = TRUE, types = "fmt_config", names = "unique")
assert_flag(unique_rows)
as_listing(
adam_db[[dataset]],

execute_with_args(
as_listing,
df = adam_db[[dataset]],
key_cols = key_cols,
disp_cols = disp_cols,
default_formatting = default_formatting,
col_formatting = col_formatting,
unique_rows = unique_rows
...,
default_formatting = listing_format_chevron(),
unique_rows = TRUE
)
}

Expand All @@ -58,8 +49,7 @@ ael01_nollt_pre <- function(adam_db,
adam_db[[dataset]] <- adam_db[[dataset]] %>%
mutate(
across(all_of(c(key_cols, disp_cols)), ~ reformat(.x, nocoding))
) %>%
arrange(pick(all_of(c(key_cols, disp_cols))))
)

adam_db
}
Expand Down
83 changes: 83 additions & 0 deletions R/ael02.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# ael02_main ----

#' @describeIn ael02 Main TLG function
#'
#' @inheritParams gen_args
#' @param dataset (`string`) the name of a table in the `adam_db` object.
#'
#' @export
#'
ael02_main <- function(adam_db,
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems that all the listing functions should have the same main function?

Copy link
Contributor

Choose a reason for hiding this comment

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

apart from the default arguments, it seems that all the main functions are identical

dataset = "adae",
arm_var = "ACTARM",
key_cols = c("ID", "ASR", arm_var),
disp_cols = c(
"AEDECOD", "TRTSDTM", "ASTDY", "ADURN", "AESER",
"ASEV", "AREL", "AEOUT", "AECONTRT", "AEACN"
),
...) {
assert_all_tablenames(adam_db, dataset)
assert_valid_variable(adam_db[[dataset]], c(arm_var, key_cols, disp_cols), label = paste0("adam_db$", dataset))

execute_with_args(
as_listing,
df = adam_db[[dataset]],
key_cols = key_cols,
disp_cols = disp_cols,
...,
default_formatting = listing_format_chevron(),
unique_rows = TRUE
)
}

#' @describeIn ael02 Preprocessing
#'
#' @inheritParams ael02_main
#'
#' @export
#'
ael02_pre <- function(adam_db,
dataset = "adae",
arm_var = "ACTARM",
...) {
adam_db[[dataset]] <- adam_db[[dataset]] %>%
filter(.data$ANL01FL == "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),
ASR = with_label(paste(.data$AGE, .data$SEX, .data$RACE, sep = "/"), "Age/Sex/Race"),
TRTSDTM = with_label(
.data$TRTSDTM,
"Date of\nFirst Study\nDrug\nAdministration"
),
AEDECOD = with_label(reformat(.data$AEDECOD, nocoding), "Adverse\nEvent MedDRA\nPreferred Term"),
ASTDY = with_label(.data$ASTDY, "Study\nDay of\nOnset"),
ADURN = with_label(.data$ADURN, "AE\nDuration\nin Days"),
AESER = with_label(reformat(.data$AESER, yes_no_rule), "Serious"),
ASEV = with_label(.data$ASEV, "Most\nExtreme\nIntensity"),
AREL = with_label(reformat(.data$AREL, yes_no_rule), "Caused by\nStudy\nDrug"),
AEOUT = with_label(as.numeric(reformat(.data$AEOUT, outcome_rule)), "Outcome\n(1)"),
AECONTRT = with_label(reformat(.data$AECONTRT, yes_no_rule), "Treatment\nfor AE"),
AEACN = with_label(as.numeric(reformat(.data$AEACN, dose_change_rule)), "Action\nTaken\n(2)")
)

adam_db
}

#' `AEL02` Listing 1 (Default) Listing of Adverse Events.
#'
#' @include chevron_tlg-S4class.R
#' @export
#'
#' @examples
#' res <- run(ael02, syn_data)
ael02 <- chevron_l(
main = ael02_main,
preprocess = ael02_pre
)
92 changes: 92 additions & 0 deletions R/ael03.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# ael03_main ----

#' @describeIn ael03 Main TLG function
#'
#' @inheritParams gen_args
#' @param dataset (`string`) the name of a table in the `adam_db` object.
#'
#' @export
#'
ael03_main <- function(adam_db,
dataset = "adae",
arm_var = "ACTARM",
key_cols = c("ID", "ASR", arm_var),
disp_cols = c(
"AEDECOD", "TRTSDTM", "ASTDY", "ADURN", "ASEV",
"AREL", "AEOUT", "AECONTRT", "AEACN", "SERREAS"
),
...) {
assert_all_tablenames(adam_db, dataset)
assert_valid_variable(adam_db[[dataset]], c(arm_var, key_cols, disp_cols), label = paste0("adam_db$", dataset))

execute_with_args(
as_listing,
df = adam_db[[dataset]],
key_cols = key_cols,
disp_cols = disp_cols,
...,
default_formatting = listing_format_chevron(),
unique_rows = TRUE
)
}

#' @describeIn ael03 Preprocessing
#'
#' @inheritParams ael03_main
#'
#' @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(as.numeric(reformat(.data$AEOUT, outcome_rule)), "Outcome\n(1)"),
AECONTRT = with_label(reformat(.data$AECONTRT, yes_no_rule), "Treatment\nfor AE"),
AEACN = with_label(as.numeric(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
)
Loading
Loading