Skip to content

Commit

Permalink
rerun at 2022/02/01
Browse files Browse the repository at this point in the history
  • Loading branch information
elong0527 committed Feb 1, 2022
1 parent a46e694 commit 694a207
Show file tree
Hide file tree
Showing 10 changed files with 74 additions and 71 deletions.
2 changes: 1 addition & 1 deletion output/tlf-demographic.out
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ MMSE Total
------------------------------------------------------------------------------------------------

Program: tlf_demographic.Rmd
2022-01-19 01:08:16
2022-02-01 17:21:29

Binary file modified output/tlf-kmplot.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions output/tlf-primary.rtf
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
\par\ql
{\f1\fs20\i [3] Pairwise comparison with treatment as a categorical variable: p-values without adjustment for multiple comparisons.}
\par\ql\tx7245\tqr\tx12960
{\f1\fs20\i Source: <run interactively>}\pmartabqr
{\f1\fs20\i 21:47 Monday, January 31, 2022}\par
{\f1\fs20\i }\pmartabqr
{\f1\fs20\i 17:21 Tuesday, February 01, 2022}\par
}
{
\trowd
Expand Down
14 changes: 9 additions & 5 deletions vignettes/ectd/r0pkg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Package: pilot1wrappers
File: NEWS.md
Format: text
Content:
# pilot1wrappers 0.1.0
# pilot1wrappers 0.1.1

* Address reviewer comments for `tlf-efficacy.Rmd` and `tlf-primary`.
* Change running R version to R4.1.2
Expand Down Expand Up @@ -141,8 +141,10 @@ Content:

## FDA Response

- Response to initial submission
+ response letter <
- Initial submission
+ version: [v0.1.0](https://github.com/RConsortium/submissions-pilot1/releases/tag/v0.1.0)
+ [FDA statistical review and evaluation](https://github.com/RConsortium/submissions-pilot1/blob/main/vignettes/fda/fda-response-2021-11-22.pdf)

## Running Environment

The project is developed and tested in the environment below:
Expand All @@ -159,6 +161,9 @@ Content:
- [Marwick, B., Boettiger, C., & Mullen, L. (2018). Packaging data analytical work reproducibly using R (and friends). The American Statistician, 72(1), 80-88.](https://peerj.com/preprints/3192/)
- [Wu, P., Palukuru, U. P., Luo, Y., Nepal, S., & Zhang, Y. (2021) Analysis and reporting in regulated clinical trial environment using R. PharmaSUG 2021](https://www.pharmasug.org/proceedings/2021/AD/PharmaSUG-2021-AD-079.pdf)

More details related to organize a clinical project and submission package can be found in Chapter 9-14
of the [R for Clinical Study Reports and Submission](https://r4csr.org/index.html) book.

### R function and Analysis Scripts

In short, the project is organized as an R package.
Expand Down Expand Up @@ -214,8 +219,7 @@ Content:
#' @export
#'
efficacy_models <- function(data, var=NULL, wk=NULL) {



# Need to set contrasts to work for Type III SS. See analysis results metadata for
# table 14-3.01. Reference for R here: https://www.r-bloggers.com/anova-%E2%80%93-type-iiiiii-ss-explained/
op <- options(contrasts = c("contr.sum","contr.poly"))
Expand Down
14 changes: 7 additions & 7 deletions vignettes/ectd/tlf-demographic.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
# The path variable needs to be defined by using example code below
#
# path = list(adam = "path/to/esub/analysis/adam/datasets") # Modify path to the actual location
# path$outtable = path$outgraph = "." # Output saved in current folder
# path$output = "." # Output saved in current folder

## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
# Working directory requires write permission
if(file.access(".", 2) != 0){
warning(
Expand All @@ -16,7 +16,7 @@ if(file.access(".", 2) != 0){
}


## ----setup, message=FALSE------------------------------------------------------------------
## ----setup, message=FALSE------------------------------------------------------------------------------------------------------
# CRAN package, please using install.packages() to install
library(haven)
library(dplyr)
Expand All @@ -26,12 +26,12 @@ library(rtables)
library(pilot1wrappers)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
adsl <- read_xpt(file.path(path$adam, "adsl.xpt"))
adsl_labels <- var_labels(adsl)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
adsl <- adsl %>%
dplyr::filter(
STUDYID == "CDISCPILOT01",
Expand All @@ -44,7 +44,7 @@ adsl <- adsl %>%
)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
# Table layout
vars <- c("AGE", "AGEGR1", "RACE", "HEIGHTBL", "WEIGHTBL", "BMIBL", "MMSETOT")
lyt <- basic_table(title = "Protocol: CDISCPILOT01",
Expand Down Expand Up @@ -75,7 +75,7 @@ tbl <- build_table(lyt, adsl)
tbl


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
# Output .out file
tbl %>%
toString() %>%
Expand Down
54 changes: 28 additions & 26 deletions vignettes/ectd/tlf-efficacy.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
# The path variable needs to be defined by using example code below
#
# path = list(adam = "path/to/esub/analysis/adam/datasets") # Modify path to the actual location
# path$outtable = path$outgraph = "." # Output saved in current folder
# path$output = "." # Output saved in current folder


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
# Working directory requires write permission
if(file.access(".", 2) != 0){
warning(
Expand All @@ -17,7 +16,7 @@ if(file.access(".", 2) != 0){
}


## ----setup, message=FALSE------------------------------------------------------------------
## ----setup, message=FALSE------------------------------------------------------------------------------------------------------
knitr::opts_chunk$set(echo = TRUE)

# CRAN package, please using install.packages() to install
Expand All @@ -30,12 +29,18 @@ library(emmeans)
library(pilot1wrappers)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
adsl <- read_xpt(file.path(path$adam, "adsl.xpt"))
adlb <- read_xpt(file.path(path$adam, "adlbc.xpt"))


## ------------------------------------------------------------------------------------------
adlb1 <- subset(adlb, TRTPN %in% c(0, 81) & PARAMCD == "GLUC" & !is.na(AVISITN)) %>%
## ------------------------------------------------------------------------------------------------------------------------------

itt <- adsl[adsl[["ITTFL"]] == "Y", c("STUDYID", "USUBJID")]

adlb1 <- adlb %>%
dplyr::right_join(itt, by = c("STUDYID", "USUBJID")) %>%
subset(TRTPN %in% c(0, 81) & PARAMCD == "GLUC" & !is.na(AVISITN)) %>%
mutate(TRTPN = ifelse(TRTPN == 0, 99, TRTPN)) # change treatment order for pairwise comparison

## Fit data for linear model
Expand All @@ -54,7 +59,7 @@ t10 <- adlb1 %>%
)

t11 <- adlb1 %>%
filter(AVISITN == 20) %>%
filter(AVISITN == 20, !is.na(CHG), !is.na(BASE)) %>%
group_by(TRTPN, TRTP) %>%
summarise(
N_20 = n(),
Expand All @@ -72,7 +77,7 @@ apr0ancova1 <- merge(t10, t11) %>%
merge(t12) %>%
mutate(emmean_sd = SE * sqrt(df)) %>%
mutate(
Trt = c("Study Drug", "Placebo"),
Trt = c("Xanomeline High Dose", "Placebo"),
N1 = N,
Mean1 = pilot1wrappers::fmt_est(mean_bl, sd_bl),
N2 = N_20,
Expand All @@ -86,7 +91,7 @@ apr0ancova1 <- merge(t10, t11) %>%
apr0ancova1


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
t2 <- data.frame(pairs(t12))

## Treatment Comparison
Expand All @@ -96,7 +101,7 @@ apr0ancova2 <- t2 %>%
upper = estimate + 1.96 * SE
) %>%
mutate(
comp = "Study Drug vs. Placebo",
comp = "Xanomeline High Dose vs. Placebo",
mean = pilot1wrappers::fmt_ci(estimate, lower, upper),
p = pilot1wrappers::fmt_pval(p.value)
) %>%
Expand All @@ -105,31 +110,31 @@ apr0ancova2 <- t2 %>%
apr0ancova2


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
### Calculate root mean square and save data in output folder
apr0ancova3 <- data.frame(rmse = paste0(
"Root Mean Squared Error of Change = ",
formatC(sd(gluc_lmfit$residuals), digits = 2, format = "f", flag = "0")
formatC(sqrt(mean((gluc_lmfit$residuals)^2)), digits = 2, format = "f", flag = "0")
))

apr0ancova3


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
tbl_1 <- apr0ancova1 %>%
rtf_title(
title = "ANCOVA of Change from Baseline at Week 20"
) %>%
rtf_colheader(
colheader = " | Baseline{^a} | Week 20 | Change from Baseline",
col_rel_width = c(3, 4, 4, 9)
col_rel_width = c(4, 3.5, 3.5, 7.5)
) %>%
rtf_colheader(
colheader = "Treatment | N | Mean (SD) | N | Mean (SD) | N | Mean (SD) | LS Mean (95% CI){^b}",
col_rel_width = c(3, 1, 3, 1, 3, 1, 3, 5)
col_rel_width = c(4, 1, 2.5, 1, 2.5, 1, 2.5, 4)
) %>%
rtf_body(
col_rel_width = c(3, 1, 3, 1, 3, 1, 3, 5),
col_rel_width = c(4, 1, 2.5, 1, 2.5, 1, 2.5, 4),
text_justification = c("l", rep("c", 7)),
last_row = FALSE
) %>%
Expand All @@ -141,40 +146,37 @@ tbl_1 <- apr0ancova1 %>%
)
) %>%
rtf_source(
source = "Source: [pilot1wrappers: adam-adlbc]",
source = "Source: [pilot1wrappers: adam-adsl; adlbc]",
text_justification = "c"
)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
tbl_2 <- apr0ancova2 %>%
rtf_colheader(
colheader = "Pairwise Comparison | Difference in LS Mean (95% CI){^b} | p-Value",
text_justification = c("l", "c", "c"),
col_rel_width = c(8, 7, 5)
col_rel_width = c(7.5, 7, 4)
) %>%
rtf_body(
col_rel_width = c(8, 7, 5),
col_rel_width = c(7.5, 7, 4),
text_justification = c("l", "c", "c"),
last_row = FALSE
)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
tbl_3 <- apr0ancova3 %>%
rtf_body(
as_colheader = FALSE,
text_justification = "l"
)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
tbl <- list(tbl_1, tbl_2, tbl_3)
tbl %>%
rtf_encode() %>%
write_rtf(file.path(path$output, "tlf-efficacy.rtf"))


## ---- out.width = "100%", out.height = "400px", echo = FALSE, fig.align = "center"---------
knitr::include_graphics("pdf/tlf-efficacy.pdf")

18 changes: 6 additions & 12 deletions vignettes/ectd/tlf-kmplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
# The path variable needs to be defined by using example code below
#
# path = list(adam = "path/to/esub/analysis/adam/datasets") # Modify path to the actual location
# path$outtable = path$outgraph = "." # Output saved in current folder
# path$output = "." # Output saved in current folder


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
# Working directory requires write permission
if(file.access(".", 2) != 0){
warning(
Expand All @@ -17,7 +16,7 @@ if(file.access(".", 2) != 0){
}


## ----setup, message=FALSE------------------------------------------------------------------
## ----setup, message=FALSE------------------------------------------------------------------------------------------------------
knitr::opts_chunk$set(echo = TRUE)

# CRAN package, please using install.packages() to install
Expand All @@ -31,12 +30,12 @@ library(visR)
library(pilot1wrappers)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
adsl <- read_xpt(file.path(path$adam, "adsl.xpt"))
adtte <- read_xpt(file.path(path$adam, "adtte.xpt"))


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
anl <- adsl %>%
dplyr::filter(
SAFFL == "Y",
Expand All @@ -54,7 +53,7 @@ anl <- adsl %>%
)


## ------------------------------------------------------------------------------------------
## ------------------------------------------------------------------------------------------------------------------------------
# estimate survival
surv_mod <- visR::estimate_KM(data = anl, strata = "TRT01A")

Expand Down Expand Up @@ -101,8 +100,3 @@ KM <- cowplot::plot_grid(

print(KM)
dev.off()


## ---- out.width = "100%", out.height = "400px", echo = FALSE, fig.align = "center"---------
knitr::include_graphics("pdf/tlf-kmplot.pdf")

Loading

0 comments on commit 694a207

Please sign in to comment.