-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
base: main
Are you sure you want to change the base?
Changes from 6 commits
869d5e4
7b2b2c7
cf2f415
0107ea2
4129d6e
997dfb1
b5ee067
f97a095
4f007cc
b06f3be
41207e8
a4dd74e
72ce45b
312f3b4
5142122
ff28482
ac59228
d3209fb
1f560a9
2ba35ab
572e79e
5f2d0f0
06b9942
5873f39
2b230f6
5287ec1
f22ff47
a426a39
e5501c4
34fb219
ad9e4c9
982d7e6
b57f962
a08dbbc
60cdde0
71fd248
2efc471
cd9fe3e
a54c145
918d258
d799532
453db79
628972e
d4d2f76
658dd60
ae3bf05
9f0d388
9c0f8c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
# ael02_main ---- | ||
|
||
#' @describeIn ael02 Main TLG function | ||
#' | ||
#' @inheritParams gen_args | ||
#' @param dataset (`string`) 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`]. | ||
#' | ||
#' @export | ||
#' | ||
ael02_main <- function(adam_db, | ||
dataset = "adae", | ||
key_cols = c("CPID", "ASR", "TRT01A"), | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
disp_cols = names(adam_db[[dataset]]), | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
default_formatting = list( | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
all = fmt_config(align = "left"), | ||
numeric = fmt_config(align = "center") | ||
), | ||
col_formatting = NULL, | ||
unique_rows = TRUE, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am thinking that these arguments are not necessary; we can remove these arguments and use
The reason is that these arguments actually is from |
||
...) { | ||
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]], | ||
key_cols = key_cols, | ||
disp_cols = disp_cols, | ||
default_formatting = default_formatting, | ||
col_formatting = col_formatting, | ||
unique_rows = unique_rows | ||
) | ||
} | ||
|
||
#' @describeIn ael02 Preprocessing | ||
#' | ||
#' @inheritParams ael02_main | ||
#' | ||
#' @export | ||
#' | ||
ael02_pre <- function(adam_db, | ||
dataset = "adae", | ||
...) { | ||
adam_db[[dataset]] <- adam_db[[dataset]] %>% | ||
filter(.data$ANL01FL == "Y") %>% | ||
mutate( | ||
across( | ||
all_of(c("TRT01A", "AEDECOD", "AESEV", "AEOUT", "AEACN")), | ||
~ reformat(.x, missing_rule) | ||
) | ||
) %>% | ||
mutate( | ||
CPID = with_label(paste(.data$SITEID, .data$SUBJID, sep = "/"), "Center/Patient ID"), | ||
ASR = with_label(paste(.data$AGE, .data$SEX, .data$RACE, sep = "/"), "Age/Sex/Race"), | ||
Date_First = with_label( | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
toupper(format(as.Date(.data$TRTSDTM), "%d%b%Y")), | ||
"Date of\nFirst Study\nDrug\nAdministration" | ||
), | ||
Duration = with_label(.data$AENDY - .data$ASTDY + 1, "AE\nDuration\nin Days"), | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Serious = with_label(ifelse(.data$AESER == "Y", "Yes", ifelse(.data$AESER == "N", "No", "")), "Serious"), | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Related = with_label( | ||
ifelse(.data$AEREL == "Y", "Yes", ifelse(.data$AEREL == "N", "No", "")), | ||
"Caused by\nStudy\nDrug" | ||
), | ||
Outcome = with_label(case_when( | ||
AEOUT == "FATAL" ~ 1, | ||
AEOUT == "NOT RECOVERED/NOT RESOLVED" ~ 2, | ||
AEOUT == "RECOVERED/RESOLVED" ~ 3, | ||
AEOUT == "RECOVERED/RESOLVED WITH SEQUELAE" ~ 4, | ||
AEOUT == "RECOVERING/RESOLVING" ~ 5, | ||
AEOUT == "UNKNOWN" ~ 6 | ||
), "Outcome\n(1)"), | ||
Treated = with_label( | ||
ifelse(.data$AECONTRT == "Y", "Yes", ifelse(.data$AECONTRT == "N", "No", "")), | ||
"Treatment\nfor AE" | ||
), | ||
Action = with_label(case_when( | ||
AEACN == "DOSE INCREASED" ~ 1, | ||
AEACN == "DOSE NOT CHANGED" ~ 2, | ||
AEACN == "DOSE REDUCED" | AEACN == "DOSE RATE REDUCED" ~ 3, | ||
AEACN == "DRUG INTERRUPTED" ~ 4, | ||
AEACN == "DRUG WITHDRAWN" ~ 5, | ||
AEACN == "NOT APPLICABLE" | AEACN == "NOT EVALUABLE" ~ 6, | ||
AEACN == "UNKNOWN" ~ 7 | ||
), "Action\nTaken\n(2)"), | ||
TRT01A = with_label(.data$TRT01A, "Treatment"), | ||
AEDECOD = with_label(reformat(as.factor(.data$AEDECOD), nocoding), "Adverse\nEvent MedDRA\nPreferred Term"), | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ASTDY = with_label(.data$ASTDY, "Study\nDay of\nOnset"), | ||
AESEV = with_label(.data$AESEV, "Most\nExtreme\nIntensity") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for these labels, I am wondering if there are differences compared to our default labels? If the only difference is the line breaks, maybe rlistings can solve that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are a bit different (in default, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to edit the synthetic data, but keep the preprocessing is fine
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) %>% | ||
select(all_of(c( | ||
"CPID", "ASR", "TRT01A", "AEDECOD", "Date_First", "ASTDY", "Duration", | ||
"Serious", "AESEV", "Related", "Outcome", "Treated", "Action" | ||
))) | ||
|
||
adam_db | ||
} | ||
|
||
#' @describeIn ael02 Postprocessing | ||
#' | ||
#' @inheritParams gen_args | ||
#' | ||
ael02_post <- function(tlg, ...) { | ||
if (nrow(tlg) == 0) tlg <- null_report | ||
|
||
tlg | ||
} | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#' `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, | ||
postprocess = ael02_post | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
# ael03_main ---- | ||
|
||
#' @describeIn ael03 Main TLG function | ||
#' | ||
#' @inheritParams gen_args | ||
#' @param dataset (`string`) 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`]. | ||
#' | ||
#' @export | ||
#' | ||
ael03_main <- function(adam_db, | ||
dataset = "adae", | ||
key_cols = c("CPID", "ASR", "TRT01A"), | ||
disp_cols = names(adam_db[[dataset]]), | ||
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]], | ||
key_cols = key_cols, | ||
disp_cols = disp_cols, | ||
default_formatting = default_formatting, | ||
col_formatting = col_formatting, | ||
unique_rows = unique_rows | ||
) | ||
} | ||
|
||
#' @describeIn ael03 Preprocessing | ||
#' | ||
#' @inheritParams ael03_main | ||
#' | ||
#' @export | ||
#' | ||
ael03_pre <- function(adam_db, | ||
dataset = "adae", | ||
...) { | ||
adam_db[[dataset]] <- adam_db[[dataset]] %>% | ||
filter(.data$ANL01FL == "Y") %>% | ||
filter(.data$AESER == "Y") %>% | ||
mutate( | ||
across( | ||
all_of(c("TRT01A", "AEDECOD", "AESEV", "AEOUT", "AEACN")), | ||
~ reformat(.x, missing_rule) | ||
) | ||
) %>% | ||
mutate( | ||
CPID = with_label(paste(.data$SITEID, .data$SUBJID, sep = "/"), "Center/Patient ID"), | ||
ASR = with_label(paste(.data$AGE, .data$SEX, .data$RACE, sep = "/"), "Age/Sex/Race"), | ||
Date_First = with_label( | ||
toupper(format(as.Date(.data$TRTSDTM), "%d%b%Y")), | ||
"Date of\nFirst Study\nDrug\nAdministration" | ||
), | ||
Duration = with_label(.data$AENDY - .data$ASTDY + 1, "AE\nDuration\nin Days"), | ||
Related = with_label( | ||
ifelse(.data$AEREL == "Y", "Yes", ifelse(.data$AEREL == "N", "No", "")), | ||
"Caused by\nStudy\nDrug" | ||
), | ||
Outcome = with_label(case_when( | ||
AEOUT == "FATAL" ~ 1, | ||
AEOUT == "NOT RECOVERED/NOT RESOLVED" ~ 2, | ||
AEOUT == "RECOVERED/RESOLVED" ~ 3, | ||
AEOUT == "RECOVERED/RESOLVED WITH SEQUELAE" ~ 4, | ||
AEOUT == "RECOVERING/RESOLVING" ~ 5, | ||
AEOUT == "UNKNOWN" ~ 6 | ||
), "Outcome\n(1)"), | ||
Treated = with_label( | ||
ifelse(.data$AECONTRT == "Y", "Yes", ifelse(.data$AECONTRT == "N", "No", "")), | ||
"Treatment\nfor AE" | ||
), | ||
Action = with_label(case_when( | ||
AEACN == "DOSE INCREASED" ~ 1, | ||
AEACN == "DOSE NOT CHANGED" ~ 2, | ||
AEACN == "DOSE REDUCED" | AEACN == "DOSE RATE REDUCED" ~ 3, | ||
AEACN == "DRUG INTERRUPTED" ~ 4, | ||
AEACN == "DRUG WITHDRAWN" ~ 5, | ||
AEACN == "NOT APPLICABLE" | AEACN == "NOT EVALUABLE" ~ 6, | ||
AEACN == "UNKNOWN" ~ 7 | ||
), "Action\nTaken\n(2)"), | ||
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)"), | ||
TRT01A = with_label(.data$TRT01A, "Treatment"), | ||
AEDECOD = with_label(reformat(as.factor(.data$AEDECOD), nocoding), "Adverse\nEvent MedDRA\nPreferred Term"), | ||
ASTDY = with_label(.data$ASTDY, "Study\nDay of\nOnset"), | ||
AESEV = with_label(.data$AESEV, "Most\nExtreme\nIntensity") | ||
) %>% | ||
select(all_of(c( | ||
"CPID", "ASR", "TRT01A", "AEDECOD", "Date_First", "ASTDY", "Duration", | ||
"AESEV", "Related", "Outcome", "Treated", "Action", "SERREAS" | ||
))) | ||
|
||
adam_db | ||
} | ||
|
||
#' @describeIn ael03 Postprocessing | ||
#' | ||
#' @inheritParams gen_args | ||
#' | ||
ael03_post <- function(tlg, ...) { | ||
if (nrow(tlg) == 0) tlg <- null_report | ||
|
||
tlg | ||
} | ||
|
||
#' `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, | ||
postprocess = ael03_post | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# ael04_main ---- | ||
|
||
#' @describeIn ael04 Main TLG function | ||
#' | ||
#' @inheritParams gen_args | ||
#' @param dataset (`string`) 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`]. | ||
#' | ||
#' @export | ||
#' | ||
ael04_main <- function(adam_db, | ||
dataset = "adsl", | ||
key_cols = c("CPID"), | ||
disp_cols = names(adam_db[[dataset]]), | ||
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]], | ||
key_cols = key_cols, | ||
disp_cols = disp_cols, | ||
default_formatting = default_formatting, | ||
col_formatting = col_formatting, | ||
unique_rows = unique_rows | ||
) | ||
} | ||
|
||
#' @describeIn ael04 Preprocessing | ||
#' | ||
#' @inheritParams ael04_main | ||
#' | ||
#' @export | ||
#' | ||
ael04_pre <- function(adam_db, | ||
dataset = "adsl", | ||
...) { | ||
adam_db[[dataset]] <- adam_db[[dataset]] %>% | ||
filter(!is.na(.data$DTHADY)) %>% | ||
mutate( | ||
across( | ||
all_of(c("TRT01A", "DTHCAUS", "ADTHAUT")), | ||
~ reformat(.x, missing_rule) | ||
) | ||
) %>% | ||
mutate( | ||
CPID = with_label(paste(.data$SITEID, .data$SUBJID, sep = "/"), "Center/Patient ID"), | ||
ASR = with_label(paste(.data$AGE, .data$SEX, .data$RACE, sep = "/"), "Age/Sex/Race"), | ||
Date_First = with_label( | ||
toupper(format(as.Date(.data$TRTSDTM), "%d%b%Y")), | ||
"Date of\nFirst Study\nDrug\nAdministration" | ||
), | ||
TRT01A = with_label(.data$TRT01A, "Treatment"), | ||
EOSDY = with_label(.data$EOSDY, "Day of Last\nStudy Drug\nAdministration"), | ||
DTHADY = with_label(.data$DTHADY, "Day of\nDeath"), | ||
DTHCAUS = with_label(.data$DTHCAUS, "Cause of Death"), | ||
ADTHAUT = with_label(.data$ADTHAUT, "Autopsy\nPerformed?") | ||
) %>% | ||
select(all_of(c( | ||
BFalquet marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"CPID", "ASR", "TRT01A", "Date_First", "EOSDY", "DTHADY", "DTHCAUS", "ADTHAUT" | ||
))) | ||
|
||
adam_db | ||
} | ||
|
||
#' @describeIn ael04 Postprocessing | ||
#' | ||
#' @inheritParams gen_args | ||
#' | ||
ael04_post <- function(tlg, ...) { | ||
if (nrow(tlg) == 0) tlg <- null_report | ||
|
||
tlg | ||
} | ||
|
||
#' `AEL04` Listing 1 (Default) Listing of Patient Deaths. | ||
#' | ||
#' @include chevron_tlg-S4class.R | ||
#' @export | ||
#' | ||
#' @examples | ||
#' res <- run(ael04, syn_data) | ||
ael04 <- chevron_l( | ||
main = ael04_main, | ||
preprocess = ael04_pre, | ||
postprocess = ael04_post | ||
) |
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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