4
4
# The path variable needs to be defined by using example code below
5
5
#
6
6
# path = list(adam = "path/to/esub/analysis/adam/datasets") # Modify path to the actual location
7
- # path$outtable = path$outgraph = "." # Output saved in current folder
7
+ # path$output = "." # Output saved in current folder
8
8
9
-
10
- # # ------------------------------------------------------------------------------------------
9
+ # # ------------------------------------------------------------------------------------------------------------------------------
11
10
# Working directory requires write permission
12
11
if (file.access(" ." , 2 ) != 0 ){
13
12
warning(
@@ -17,7 +16,7 @@ if(file.access(".", 2) != 0){
17
16
}
18
17
19
18
20
- # # ----setup, message=FALSE------------------------------------------------------------------
19
+ # # ----setup, message=FALSE------------------------------------------------------------------------------------------------------
21
20
knitr :: opts_chunk $ set(echo = TRUE )
22
21
23
22
# CRAN package, please using install.packages() to install
@@ -30,12 +29,18 @@ library(emmeans)
30
29
library(pilot1wrappers )
31
30
32
31
33
- # # ------------------------------------------------------------------------------------------
32
+ # # ------------------------------------------------------------------------------------------------------------------------------
33
+ adsl <- read_xpt(file.path(path $ adam , " adsl.xpt" ))
34
34
adlb <- read_xpt(file.path(path $ adam , " adlbc.xpt" ))
35
35
36
36
37
- # # ------------------------------------------------------------------------------------------
38
- adlb1 <- subset(adlb , TRTPN %in% c(0 , 81 ) & PARAMCD == " GLUC" & ! is.na(AVISITN )) %> %
37
+ # # ------------------------------------------------------------------------------------------------------------------------------
38
+
39
+ itt <- adsl [adsl [[" ITTFL" ]] == " Y" , c(" STUDYID" , " USUBJID" )]
40
+
41
+ adlb1 <- adlb %> %
42
+ dplyr :: right_join(itt , by = c(" STUDYID" , " USUBJID" )) %> %
43
+ subset(TRTPN %in% c(0 , 81 ) & PARAMCD == " GLUC" & ! is.na(AVISITN )) %> %
39
44
mutate(TRTPN = ifelse(TRTPN == 0 , 99 , TRTPN )) # change treatment order for pairwise comparison
40
45
41
46
# # Fit data for linear model
@@ -54,7 +59,7 @@ t10 <- adlb1 %>%
54
59
)
55
60
56
61
t11 <- adlb1 %> %
57
- filter(AVISITN == 20 ) %> %
62
+ filter(AVISITN == 20 , ! is.na( CHG ), ! is.na( BASE ) ) %> %
58
63
group_by(TRTPN , TRTP ) %> %
59
64
summarise(
60
65
N_20 = n(),
@@ -72,7 +77,7 @@ apr0ancova1 <- merge(t10, t11) %>%
72
77
merge(t12 ) %> %
73
78
mutate(emmean_sd = SE * sqrt(df )) %> %
74
79
mutate(
75
- Trt = c(" Study Drug " , " Placebo" ),
80
+ Trt = c(" Xanomeline High Dose " , " Placebo" ),
76
81
N1 = N ,
77
82
Mean1 = pilot1wrappers :: fmt_est(mean_bl , sd_bl ),
78
83
N2 = N_20 ,
@@ -86,7 +91,7 @@ apr0ancova1 <- merge(t10, t11) %>%
86
91
apr0ancova1
87
92
88
93
89
- # # ------------------------------------------------------------------------------------------
94
+ # # ------------------------------------------------------------------------------------------------------------------------------
90
95
t2 <- data.frame (pairs(t12 ))
91
96
92
97
# # Treatment Comparison
@@ -96,7 +101,7 @@ apr0ancova2 <- t2 %>%
96
101
upper = estimate + 1.96 * SE
97
102
) %> %
98
103
mutate(
99
- comp = " Study Drug vs. Placebo" ,
104
+ comp = " Xanomeline High Dose vs. Placebo" ,
100
105
mean = pilot1wrappers :: fmt_ci(estimate , lower , upper ),
101
106
p = pilot1wrappers :: fmt_pval(p.value )
102
107
) %> %
@@ -105,31 +110,31 @@ apr0ancova2 <- t2 %>%
105
110
apr0ancova2
106
111
107
112
108
- # # ------------------------------------------------------------------------------------------
113
+ # # ------------------------------------------------------------------------------------------------------------------------------
109
114
# ## Calculate root mean square and save data in output folder
110
115
apr0ancova3 <- data.frame (rmse = paste0(
111
116
" Root Mean Squared Error of Change = " ,
112
- formatC(sd( gluc_lmfit $ residuals ), digits = 2 , format = " f" , flag = " 0" )
117
+ formatC(sqrt(mean(( gluc_lmfit $ residuals ) ^ 2 ) ), digits = 2 , format = " f" , flag = " 0" )
113
118
))
114
119
115
120
apr0ancova3
116
121
117
122
118
- # # ------------------------------------------------------------------------------------------
123
+ # # ------------------------------------------------------------------------------------------------------------------------------
119
124
tbl_1 <- apr0ancova1 %> %
120
125
rtf_title(
121
126
title = " ANCOVA of Change from Baseline at Week 20"
122
127
) %> %
123
128
rtf_colheader(
124
129
colheader = " | Baseline{^a} | Week 20 | Change from Baseline" ,
125
- col_rel_width = c(3 , 4 , 4 , 9 )
130
+ col_rel_width = c(4 , 3.5 , 3.5 , 7.5 )
126
131
) %> %
127
132
rtf_colheader(
128
133
colheader = " Treatment | N | Mean (SD) | N | Mean (SD) | N | Mean (SD) | LS Mean (95% CI){^b}" ,
129
- col_rel_width = c(3 , 1 , 3 , 1 , 3 , 1 , 3 , 5 )
134
+ col_rel_width = c(4 , 1 , 2.5 , 1 , 2.5 , 1 , 2.5 , 4 )
130
135
) %> %
131
136
rtf_body(
132
- col_rel_width = c(3 , 1 , 3 , 1 , 3 , 1 , 3 , 5 ),
137
+ col_rel_width = c(4 , 1 , 2.5 , 1 , 2.5 , 1 , 2.5 , 4 ),
133
138
text_justification = c(" l" , rep(" c" , 7 )),
134
139
last_row = FALSE
135
140
) %> %
@@ -141,40 +146,37 @@ tbl_1 <- apr0ancova1 %>%
141
146
)
142
147
) %> %
143
148
rtf_source(
144
- source = " Source: [pilot1wrappers: adam-adlbc]" ,
149
+ source = " Source: [pilot1wrappers: adam-adsl; adlbc]" ,
145
150
text_justification = " c"
146
151
)
147
152
148
153
149
- # # ------------------------------------------------------------------------------------------
154
+ # # ------------------------------------------------------------------------------------------------------------------------------
150
155
tbl_2 <- apr0ancova2 %> %
151
156
rtf_colheader(
152
157
colheader = " Pairwise Comparison | Difference in LS Mean (95% CI){^b} | p-Value" ,
153
158
text_justification = c(" l" , " c" , " c" ),
154
- col_rel_width = c(8 , 7 , 5 )
159
+ col_rel_width = c(7.5 , 7 , 4 )
155
160
) %> %
156
161
rtf_body(
157
- col_rel_width = c(8 , 7 , 5 ),
162
+ col_rel_width = c(7.5 , 7 , 4 ),
158
163
text_justification = c(" l" , " c" , " c" ),
159
164
last_row = FALSE
160
165
)
161
166
162
167
163
- # # ------------------------------------------------------------------------------------------
168
+ # # ------------------------------------------------------------------------------------------------------------------------------
164
169
tbl_3 <- apr0ancova3 %> %
165
170
rtf_body(
166
171
as_colheader = FALSE ,
167
172
text_justification = " l"
168
173
)
169
174
170
175
171
- # # ------------------------------------------------------------------------------------------
176
+ # # ------------------------------------------------------------------------------------------------------------------------------
172
177
tbl <- list (tbl_1 , tbl_2 , tbl_3 )
173
178
tbl %> %
174
179
rtf_encode() %> %
175
180
write_rtf(file.path(path $ output , " tlf-efficacy.rtf" ))
176
181
177
182
178
- # # ---- out.width = "100%", out.height = "400px", echo = FALSE, fig.align = "center"---------
179
- knitr :: include_graphics(" pdf/tlf-efficacy.pdf" )
180
-
0 commit comments