Skip to content

Commit

Permalink
Merge branch 'main' into stable-tlg-catalog
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif committed Sep 25, 2023
2 parents 5753568 + e7d6c82 commit fd757ef
Show file tree
Hide file tree
Showing 75 changed files with 3,897 additions and 3,543 deletions.
Binary file modified book/assets/img/logo-nest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 22 additions & 2 deletions book/generate-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,41 @@ cat(
# Tables

section_header("Tables")
create_subsection("./tables/ADA", "ADA")
create_subsection("./tables/adverse-events", "Adverse Events")
create_subsection("./tables/concomitant-medications", "Concomitant Medications")
create_subsection("./tables/deaths", "Deaths")
create_subsection("./tables/demography", "Demography")
create_subsection("./tables/disclosures", "Disclosures")
create_subsection("./tables/disposition", "Disposition")
create_subsection("./tables/ECG", "ECG")
create_subsection("./tables/efficacy", "Efficacy")
create_subsection("./tables/exposure", "Exposure")
create_subsection("./tables/lab-results", "Lab Results")
create_subsection("./tables/medical-history", "Medical History")
create_subsection("./tables/pharmacokinetic", "Pharmacokinetic")
create_subsection("./tables/risk-management-plan", "Risk Management Plan")
create_subsection("./tables/safety", "Safety")
create_subsection("./tables/other", "Other")
create_subsection("./tables/vital-signs", "Vital Signs")

# Listings

section_header("Listings")
create_subsection("./listings/ADA", "ADA")
create_subsection("./listings/adverse-events", "Adverse Events")
create_subsection("./listings/concomitant-medications", "Concomitant Medications") # nolint
create_subsection("./listings/disposition", "Disposition")
create_subsection("./listings/development-safety-update-report", "Development Safety Update Report") # nolint
create_subsection("./listings/ECG", "ECG")
create_subsection("./listings/exposure", "Exposure")
create_subsection("./listings/lab-results", "Lab Results")
create_subsection("./listings/medical-history", "Medical History")
create_subsection("./listings/pharmacokinetic", "Pharmacokinetic")
create_subsection("./listings/other", "Other")
create_subsection("./listings/vital-signs", "Vital Signs")

# Graphs

section_header("Graphs")
create_subsection("./graphs/efficacy", "Efficacy")
create_subsection("./graphs/pharmacokinetic", "Pharmacokinetic")
create_subsection("./graphs/other", "Other")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
133 changes: 133 additions & 0 deletions book/tables/pharmacokinetic/pkct01.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,139 @@ 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

Expand Down
116 changes: 88 additions & 28 deletions book/tables/pharmacokinetic/pkpt03.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,80 @@ library(scda)
library(dplyr)
library(tern)
# Preprocess analysis data ----
adpp <- synthetic_cdisc_dataset("latest", "adpp")
adpp <- adpp %>% filter(PPSPEC == "Plasma", AVISIT == "CYCLE 1 DAY 1")
adpp <- adpp %>%
filter(PPSPEC == "Plasma") %>%
filter(AVISIT %in% c("CYCLE 1 DAY 1", "CYCLE 1 DAY 2")) %>%
h_pkparam_sort() %>%
mutate(PARAM = factor(paste0(TLG_DISPLAY, " (", AVALU, ")"))) %>%
mutate(PARAM = reorder(PARAM, TLG_ORDER))
# Preprocess subject-level data ----
adsl <- synthetic_cdisc_dataset("latest", "adsl")
# Workaround needed to include (N=xx) population counts
# Repeat ADSL by the number of levels in AVISIT
# Include AVISIT and dummy PARAM as it's needed for trim_levels_in_group
adsl_tmp <- adsl %>%
select(STUDYID, USUBJID, ARMCD) %>%
unique() %>%
mutate(PARAM = factor(NA_character_, levels = levels(adpp$PARAM)))
# Data for Plasma Drug X example ----
adpp_x <- adpp %>%
filter(PPCAT == "Plasma Drug X") %>%
# Please do not replicate mutate statement below!
# It is used to make the random data in this example more realistic
# as not all parameters are always available across all visits.
mutate(
AVAL = if_else(
ARMCD == "ARM A" & AVISIT == "CYCLE 1 DAY 1" & PARAM == "Cmax (ug/mL)",
NA_real_, AVAL
)
)
adpp_x_tmp <- adpp_x %>%
select(STUDYID, USUBJID, ARMCD, AVISIT) %>%
unique()
adsl_x_splitvars <- adsl_tmp %>%
left_join(adpp_x_tmp, by = c("STUDYID", "USUBJID", "ARMCD")) %>%
filter(!is.na(AVISIT))
# Data for Plasma Drug Y example ----
adpp_y <- adpp %>%
filter(PPCAT == "Plasma Drug Y")
adpp_y_tmp <- adpp_y %>%
select(STUDYID, USUBJID, ARMCD, AVISIT) %>%
unique()
adsl_y_splitvars <- adsl_tmp %>%
left_join(adpp_y_tmp, by = c("STUDYID", "USUBJID", "ARMCD")) %>%
filter(!is.na(AVISIT))
```

## Standard Table

```{r}
# lyt creation
lyt <- basic_table() %>%
split_rows_by(
var = "AVISIT",
split_fun = drop_split_levels,
split_label = "Visit",
page_by = TRUE
) %>%
split_rows_by(
var = "ARMCD",
split_fun = trim_levels_in_group("ARMCD"),
split_fun = trim_levels_in_group("PARAM"),
label_pos = "topleft",
split_label = "Treatment Arm"
) %>%
add_rowcounts(alt_counts = TRUE) %>%
split_rows_by(
var = "PKPARAM",
var = "PARAM",
label_pos = "topleft",
split_label = "PK Parameter",
child_labels = "hidden"
Expand All @@ -58,45 +115,48 @@ lyt <- basic_table() %>%
),
.formats = c(
n = "xx.",
mean = sprintf_format("%.3e"),
sd = sprintf_format("%.3e"),
mean = format_sigfig(3),
sd = format_sigfig(3),
cv = "xx.x",
median = sprintf_format("%.3e"),
geom_mean = sprintf_format("%.3e"),
median = format_sigfig(3),
geom_mean = format_sigfig(3),
geom_cv = "xx.x",
min = sprintf_format("%.3e"),
max = sprintf_format("%.3e")
)
min = format_sigfig(3),
max = format_sigfig(3)
),
na_level = "NE"
)
```

#### 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 <- build_table(lyt, df = adpp_x, alt_counts_df = adsl_x_splitvars)
main_title(result) <- paste("Summary of", unique(adpp_x$PPSPEC), "PK Parameter by Treatment Arm, PK Population")
subtitles(result) <- paste("Analyte:", unique(adpp_x$PPCAT))
result <- paginate_table(result, landscape = TRUE)
result
```

#### Plasma Drug Y
#### Plasma Drug X: Remove Rows with 0s

```{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 = adpp_x, alt_counts_df = adsl_x_splitvars) %>%
prune_table()
main_title(result) <- paste("Summary of", unique(adpp_x$PPSPEC), "PK Parameter by Treatment Arm, PK Population")
subtitles(result) <- paste("Analyte:", unique(adpp_x$PPCAT))
result <- paginate_table(result, landscape = TRUE)
result
```

#### Plasma Drug Y

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))
```{r variant3, test = list(result_v3 = "result")}
result <- build_table(lyt, df = adpp_y, alt_counts_df = adsl_y_splitvars)
main_title(result) <- paste("Summary of", unique(adpp_y$PPSPEC), "PK Parameter by Treatment Arm, PK Population")
subtitles(result) <- paste("Analyte:", unique(adpp_y$PPCAT))
result <- paginate_table(result, landscape = TRUE)
result
```

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fd757ef

Please sign in to comment.