Skip to content

Commit 33a5664

Browse files
YoshitoKoujingithub-actions[bot]dependabot-preview[bot]edelarua
authored
196-new-table-38 (#204)
* 1st commitment for all documents * [skip actions] Restyle files * [skip actions] Roxygen Man Pages Auto Update * Fix table 35 title * Update index * Update label indentation --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Emily de la Rua <[email protected]>
1 parent 90eca39 commit 33a5664

13 files changed

+498
-5
lines changed

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export(make_table_32_gtsum)
3333
export(make_table_33)
3434
export(make_table_34)
3535
export(make_table_35)
36+
export(make_table_38)
3637
export(split_cols_by_arm)
3738
import(Tplyr)
3839
import(dplyr)

R/argument_convention.R

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#' be included in the column labels by default. The length of `col_label` must be equal to the length of `arm_y`.
4141
#' * `pct`: (optional) whether the output should be returned as percentages. Defaults to `TRUE`.
4242
#' @param saffl_var (`character`)\cr flag variable used to indicate inclusion in safety population.
43+
#' @param trtemfl_var (`character`)\cr flag variable used to identify Treatment-emergent AE.
4344
#' @param sex_scope (`character`)\cr Level of `SEX` to output in table.
4445
#' @param soc_var (`character`)\cr flag variable used to indicate system organ class.
4546
#' @param show_colcounts (`flag`)\cr whether column counts should be printed.

R/fda-table_35.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Table 35. Patients With Adverse Events1 by System Organ Class,
1+
#' Table 35. Patients With Adverse Events by System Organ Class,
22
#' Safety Population, Pooled Analysis (or Trial X)
33
#'
44
#' @details

R/fda-table_38.R

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#' FDA Table 38: Patients With Adverse Events by System Organ Class, FDA Medical Query (Broad) and Preferred Term,
2+
#' Safety Population, Pooled Analysis (or Trial X)
3+
#'
4+
#' @details
5+
#' * `adae` must contain the variables `AEBODSYS`, `AESER`, and the variables specified by
6+
#' `arm_var`, `id_var`, `saffl_var`, `trtemfl_var`, `fmqsc_var`, `fmqnam_var`, and `pref_var`.
7+
#' * If specified, `alt_counts_df` must contain the variables specified by `arm_var`, `id_var`, and `saffl_var`.
8+
#' * Flag variables (i.e. `XXXFL`) are expected to have two levels: `"Y"` (true) and `"N"` (false). Missing values in
9+
#' flag variables are treated as `"N"`.
10+
#' * Columns are split by arm. Overall population column is excluded by default (see `lbl_overall` argument).
11+
#' * Numbers in table represent the absolute numbers of patients and fraction of `N`.
12+
#' * All-zero rows are removed by default (see `prune_0` argument).
13+
#'
14+
#' @inheritParams argument_convention
15+
#'
16+
#' @examples
17+
#' library(dplyr)
18+
#'
19+
#' adae <- random.cdisc.data::cadae
20+
#' adsl <- random.cdisc.data::cadsl
21+
#'
22+
#' set.seed(1)
23+
#' adae <- adae %>%
24+
#' rename(FMQ01SC = SMQ01SC) %>%
25+
#' mutate(
26+
#' AESER = sample(c("Y", "N"), size = nrow(adae), replace = TRUE),
27+
#' FMQ01NAM = sample(c("FMQ1", "FMQ2", "FMQ3"), size = nrow(adae), replace = TRUE)
28+
#' )
29+
#' adae$FMQ01SC[is.na(adae$FMQ01SC)] <- "Broad"
30+
#'
31+
#' tbl <- make_table_38(adae = adae, alt_counts_df = adsl)
32+
#' tbl
33+
#'
34+
#' @export
35+
make_table_38 <- function(adae,
36+
alt_counts_df = NULL,
37+
show_colcounts = TRUE,
38+
id_var = "USUBJID",
39+
arm_var = "ARM",
40+
saffl_var = "SAFFL",
41+
trtemfl_var = "TRTEMFL",
42+
fmqsc_var = "FMQ01SC",
43+
fmqnam_var = "FMQ01NAM",
44+
fmq_scope = "BROAD",
45+
pref_var = "AEDECOD",
46+
lbl_overall = NULL,
47+
lbl_pref_var = formatters::var_labels(adae, fill = TRUE)[pref_var],
48+
risk_diff = NULL,
49+
prune_0 = TRUE,
50+
na_level = "<Missing>",
51+
annotations = NULL) {
52+
checkmate::assert_subset(c(
53+
"AEBODSYS", arm_var, id_var, saffl_var, trtemfl_var, fmqsc_var,
54+
fmqnam_var, pref_var
55+
), names(adae))
56+
assert_flag_variables(adae, saffl_var, trtemfl_var)
57+
checkmate::assert_subset(toupper(fmq_scope), c("NARROW", "BROAD"))
58+
59+
adae <- adae %>%
60+
filter(.data[[saffl_var]] == "Y", .data[[trtemfl_var]] == "Y", .data[[fmqsc_var]] == fmq_scope) %>%
61+
df_explicit_na(na_level = na_level)
62+
adae[[fmqnam_var]] <- with_label(adae[[fmqnam_var]], paste0("FMQ (", tools::toTitleCase(tolower(fmq_scope)), ")"))
63+
64+
alt_counts_df <- alt_counts_df_preproc(alt_counts_df, id_var, arm_var, saffl_var)
65+
66+
lyt <- basic_table_annot(show_colcounts, annotations) %>%
67+
split_cols_by_arm(arm_var, lbl_overall, risk_diff) %>%
68+
split_rows_by(
69+
var = "AEBODSYS",
70+
split_fun = drop_split_levels,
71+
split_label = obj_label(adae$AEBODSYS),
72+
label_pos = "topleft"
73+
) %>%
74+
split_rows_by(
75+
fmqnam_var,
76+
child_labels = "hidden",
77+
label_pos = "topleft",
78+
split_label = obj_label(adae[[fmqnam_var]])
79+
) %>%
80+
summarize_num_patients(
81+
var = id_var,
82+
.stats = "unique",
83+
.labels = c(unique = NULL),
84+
riskdiff = !is.null(risk_diff)
85+
) %>%
86+
count_occurrences(
87+
vars = pref_var,
88+
riskdiff = !is.null(risk_diff)
89+
) %>%
90+
append_topleft(paste(" ", lbl_pref_var))
91+
92+
tbl <- build_table(lyt, df = adae, alt_counts_df = alt_counts_df)
93+
if (prune_0) tbl <- prune_table(tbl)
94+
95+
tbl
96+
}

man/argument_convention.Rd

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/make_table_35.Rd

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/make_table_38.Rd

+111
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
80.2 KB
Loading

quarto/index-templates.qmd

+3-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ title: Template Library Index
5151

5252
- [FDA Table 34 -- Patients With Serious Adverse Events by System Organ Class, FDA Medical Query (Narrow), and Preferred Term, Safety Population, Pooled Analysis (or Trial X)](table-templates/template-table_34.qmd)
5353

54-
- [FDA Table 35 -- Patients With Adverse Events1 by System Organ Class, Safety Population, Pooled Analysis (or Trial X)](table-templates/template-table_35.qmd)
54+
- [FDA Table 35 -- Patients With Adverse Events by System Organ Class, Safety Population, Pooled Analysis (or Trial X)](table-templates/template-table_35.qmd)
55+
56+
- [FDA Table 38 -- Patients With Adverse Events by System Organ Class, FDA Medical Query (Broad) and Preferred Term, Safety Population, Pooled Analysis (or Trial X)](table-templates/template-table_38.qmd)
5557

5658

5759
------------------------------------------------------------------------

quarto/table-templates/template-table_35.qmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: FDA Table 35
3-
subtitle: Patients With Adverse Events1 by System Organ Class, Safety Population, Pooled Analysis (or Trial X)
3+
subtitle: Patients With Adverse Events by System Organ Class, Safety Population, Pooled Analysis (or Trial X)
44
format: html
55
---
66

0 commit comments

Comments
 (0)