Skip to content

Commit

Permalink
Restore files from main
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif committed Oct 5, 2023
1 parent 1630cea commit 7222155
Show file tree
Hide file tree
Showing 10 changed files with 906 additions and 0 deletions.
79 changes: 79 additions & 0 deletions book/tables/ADA/adat03.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,85 @@ anl <- merge(anl, adpc, by = c("USUBJID", "NFRLT")) %>%
mutate(AVAL_LT = ifelse(AVAL <= max_conc, TRUE, FALSE))
```

## Standard Table (μg/mL)

```{r variant1, test = list(result_v1 = "result")}
# parameters in columns
adat03_stats <- c("n", "mean", "sd", "median", "min", "max", "cv", "geom_mean", "count_fraction")
adat03_lbls <- c(
n = "Total Number\nof Measurable\n Samples",
mean = "Mean",
sd = "SD",
median = "Median",
min = "Minimum",
max = "Maximum",
cv = "CV (%)",
geom_mean = "Geometric Mean",
count_fraction = paste0("Samples with\nConcentration\n≤ ", max_conc, "μg/mL")
)
adat03_fmts <- c(
n = "xx.",
mean = format_sigfig(3),
sd = format_sigfig(3),
median = format_sigfig(3),
min = format_sigfig(3),
max = format_sigfig(3),
cv = "xx.x",
geom_mean = format_sigfig(3),
count_fraction = format_count_fraction
)
afun_list <- lapply(
1:9,
function(i) make_afun(s_summary, .stats = adat03_stats[i], .formats = adat03_fmts[i], .labels = "Overall")
)
# lyt creation
lyt <- basic_table() %>%
split_rows_by(
var = "ARM",
label_pos = "topleft",
split_label = "Treatment Group",
split_fun = drop_split_levels,
section_div = ""
) %>%
add_rowcounts() %>%
split_rows_by(
var = "VISIT",
label_pos = "topleft",
split_label = "Visit",
split_fun = drop_split_levels,
child_labels = "hidden"
) %>%
analyze_vars_in_cols(
vars = c(rep("AVAL", 8), "AVAL_LT"),
.stats = adat03_stats,
.labels = adat03_lbls,
.formats = adat03_fmts
) %>%
analyze_colvars(
afun_list,
nested = FALSE,
extra_args = list(".labels" = "Overall")
)
result <- build_table(lyt, anl, alt_counts_df = adsl)
main_title(result) <- paste(
"Summary of Serum Concentrations (μg/mL) at Timepoints Where ADA Samples Were Collected and Analyzed\n
Protocol:", unique(adab$PARCAT1)[1]
)
subtitles(result) <- paste("Analyte:", unique(adab$PARAMCD)[1])
fnotes_at_path(result, rowpath = NULL, colpath = c("multivars", "AVAL")) <- "Refers to the total no. of measurable ADA samples that have a corresponding measurable drug concentration sample (i.e. results with
valid numeric values and LTRs). LTR results on post-dose samples are replaced by aaa µg/mL i.e. half of MQC value."
fnotes_at_path(result, rowpath = NULL, colpath = c("multivars", "AVAL_LT")) <- "In validation, the assay was able to detect yyy ng/mL of surrogate ADA in the presence of zzz µg/mL of [drug]. BLQ = Below Limit of
Quantitation, LTR = Lower than Reportable, MQC = Minimum Quantifiable Concentration, ADA = Anti-Drug Antibodies (is also referred to as ATA,
or Anti-Therapeutic Antibodies). RXXXXXXX is also known as [drug]"
result
```

{{< include ../../test-utils/save_results.qmd >}}

## `teal` App

Expand Down
134 changes: 134 additions & 0 deletions book/tables/pharmacokinetic/pkct01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,140 @@ subtitle: Summary Concentration Table
::: panel-tabset
## Data Setup

```{r setup, message=FALSE}
#| code-fold: show
library(scda)
library(dplyr)
library(tern)
adsl <- synthetic_cdisc_dataset("latest", "adsl") %>%
filter(ACTARM == "A: Drug X")
adpc <- synthetic_cdisc_dataset("latest", "adpc") %>%
filter(ACTARM == "A: Drug X", PARAM == "Plasma Drug X")
# Setting up the data
adpc_1 <- adpc %>%
mutate(
NFRLT = as.factor(NFRLT),
AVALCAT1 = as.factor(AVALCAT1)
) %>%
select(NFRLT, ACTARM, VISIT, AVAL, PARAM, AVALCAT1) %>%
var_relabel(NFRLT = "Nominal Time from First Dose (hr)")
# Row structure
lyt_rows <- basic_table() %>%
split_rows_by(
var = "ACTARM",
split_fun = drop_split_levels,
split_label = "Treatment Group",
label_pos = "topleft"
) %>%
add_rowcounts(alt_counts = TRUE) %>%
split_rows_by(
var = "VISIT",
split_fun = drop_split_levels,
split_label = "Visit",
label_pos = "topleft"
) %>%
split_rows_by(
var = "NFRLT",
split_fun = drop_split_levels,
split_label = obj_label(adpc_1$NFRLT),
label_pos = "topleft",
child_labels = "hidden"
)
```

## Standard Table (Stats in Columns)

```{r variant1, test = list(result_v1 = "result")}
lyt <- lyt_rows %>%
analyze_vars_in_cols(
vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)),
.stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"),
.formats = c(
n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3),
geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3)
),
.labels = c(
n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean",
geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum"
),
na_level = "NE",
.aligns = "decimal"
)
result <- build_table(lyt, df = adpc_1, alt_counts_df = adsl) %>% prune_table()
# Decorating
main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable"
subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM)))
main_footer(result) <- "NE: Not Estimable"
result
```

## Table Implementing 1/3 Imputation Rule

```{r variant2, test = list(result_v2 = "result")}
lyt <- lyt_rows %>%
analyze_vars_in_cols(
vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)),
.stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"),
.formats = c(
n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3),
geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3)
),
.labels = c(
n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean",
geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum"
),
imp_rule = "1/3",
.aligns = "decimal"
)
result <- build_table(lyt, df = adpc_1, alt_counts_df = adsl) %>% prune_table()
# Decorating
main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable"
subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM)))
main_footer(result) <- c("NE: Not Estimable", "ND: Not Derived")
result
```

## Table Implementing 1/2 Imputation Rule

```{r variant3, test = list(result_v3 = "result")}
lyt <- lyt_rows %>%
analyze_vars_in_cols(
vars = c("AVAL", "AVALCAT1", rep("AVAL", 8)),
.stats = c("n", "n_blq", "mean", "sd", "cv", "geom_mean", "geom_cv", "median", "min", "max"),
.formats = c(
n = "xx.", n_blq = "xx.", mean = format_sigfig(3), sd = format_sigfig(3), cv = "xx.x", median = format_sigfig(3),
geom_mean = format_sigfig(3), geom_cv = "xx.x", min = format_sigfig(3), max = format_sigfig(3)
),
.labels = c(
n = "n", n_blq = "Number\nof\nLTRs/BLQs", mean = "Mean", sd = "SD", cv = "CV (%) Mean",
geom_mean = "Geometric Mean", geom_cv = "CV % Geometric Mean", median = "Median", min = "Minimum", max = "Maximum"
),
imp_rule = "1/2",
.aligns = "decimal"
)
result <- build_table(lyt, df = adpc_1, alt_counts_df = adsl) %>% prune_table()
# Decorate table
main_title(result) <- "Summary of PK Concentrations by Nominal Time and Treatment: PK Evaluable"
subtitles(result) <- c("Protocol: xxxxx", paste("Analyte: ", unique(adpc_1$PARAM)), paste("Treatment:", unique(adpc_1$ACTARM)))
main_footer(result) <- "ND: Not Derived"
result
```

{{< include ../../test-utils/save_results.qmd >}}

## `teal` App

```{r teal, message=FALSE, opts.label='skip_if_testing'}
Expand Down
60 changes: 60 additions & 0 deletions book/tables/pharmacokinetic/pkpt02.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,66 @@ adpp <- adpp %>% filter(PPSPEC == "Plasma", AVISIT == "CYCLE 1 DAY 1")

## Standard Table -- Plasma

```{r}
# lyt creation
lyt <- basic_table() %>%
split_cols_by(
var = "ARMCD",
split_fun = trim_levels_in_group("ARMCD"),
# label_pos = "topleft",
split_label = "Treatment Arm"
) %>%
split_rows_by(
var = "PKPARAM",
label_pos = "topleft",
split_label = "PK Parameter"
) %>%
tern::analyze_vars(
vars = "AVAL",
.stats = c("n", "mean_sd", "cv", "geom_mean", "geom_cv", "median", "range"),
.formats = c(
n = "xx.",
mean_sd = format_sigfig(3, "xx (xx)"),
cv = "xx.x",
geom_mean = format_sigfig(3),
geom_cv = "xx.x",
median = format_sigfig(3),
range = format_sigfig(3, "xx - xx")
)
)
```

#### Plasma Drug X

```{r variant1, test = list(result_v1 = "result")}
adpp0 <- adpp %>%
filter(PPCAT == "Plasma Drug X") %>%
h_pkparam_sort() %>%
mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) %>%
mutate(PKPARAM = reorder(PKPARAM, TLG_ORDER))
result <- build_table(lyt, df = adpp0)
main_title(result) <- paste("Summary of", unique(adpp0$PPSPEC), "PK Parameter by Treatment Arm, PK Population")
subtitles(result) <- paste("Analyte:", unique(adpp0$PPCAT), "\nVisit:", unique(adpp0$AVISIT))
result
```

#### Plasma Drug Y

```{r variant2, test = list(result_v2 = "result")}
adpp1 <- adpp %>%
filter(PPCAT == "Plasma Drug Y") %>%
h_pkparam_sort() %>%
mutate(PKPARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) %>%
mutate(PKPARAM = reorder(PKPARAM, TLG_ORDER))
result <- build_table(lyt, df = adpp1)
main_title(result) <- paste("Summary of", unique(adpp1$PPSPEC), "PK Parameter by Treatment Arm, PK Population")
subtitles(result) <- paste("Analyte:", unique(adpp1$PPCAT), "\nVisit:", unique(adpp1$AVISIT))
result
```

{{< include ../../test-utils/save_results.qmd >}}

## `teal` App

Expand Down
Loading

0 comments on commit 7222155

Please sign in to comment.