-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.R
279 lines (222 loc) · 9.73 KB
/
ui.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
## ui.R ##
library(shinydashboard)
library(DT)
library(shinyAce)
library(formattable)
library(shinyjs)
library(plotly)
useShinyjs()
# this below will suppress the output-error
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
)
dashboardPage(
# Header
dashboardHeader(title = "Decision Curve Analysis dashboard"),
# Sidebar Menus
dashboardSidebar(
sidebarMenu(
menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
menuItem("Data and Summary", tabName = "data", icon = icon("th")),
menuItem("Model Specification", tabName = "model", icon = icon("th")),
menuItem('Result', tabName = 'results', icon = icon('th'),
collapsible =
menuSubItem('random', tabName = 'random'),
menuSubItem('Prediction Model Summary', tabName = 'regresult'),
menuSubItem("ROC and Confusion Matrix", tabName = "roc"),
menuSubItem('Decision Curve Plot', tabName = 'plot')
)
)
),
# Body of the Dashboard
dashboardBody(
tabItems(
# First tab content DashBoard
tabItem(tabName = "dashboard",
h2("Introduction"),
fluidRow(
box(
h4('This is a dashboard for determining the predictive utility of decision models.'),
h4('This dashboard is based on', a("Vickers et al.", href="http://journals.sagepub.com/doi/abs/10.1177/0272989x06295361", target="_blank"), "'s work on determining the clinical utility of prediction models. Vicker's et al. have used a formula to weigh the impact of false positive and false negatives into a 'Net Benefit' equation whereby a predictive model with higher 'Net Benefit' is preferred."),
h4("There are several important key points to remember"),
h4(strong("Number 1:"),"User needs to have his/her own .csv file to input into the 'Data and Summary' Tab (Second tab on the left"),
h4(strong("Number 2:"),"User needs to have enough domain knowledge and information regarding the relationship between variables to set up the model equation in the 'Model Specification' Tab (Fourth tab on the left"),
h4(strong("Number 3:"),"In addition to the model specification, user needs to be familiar with the R syntax in setting up the equations for predictive modeling (i.e. logistic regression, decision tree, random forest, svm)"),
h4(strong("Number 4:"),"The outputs that are generated in the 'Result' tab (Bottom tab on the left) needs the user to be comfortable with the 'dca' function output. (There is a link in the model specification to the dca() vignette)"),
h4(strong("Number 5:"),"Those interested in the source code, the link to Github is ", a("here", href="https://github.com/ck2136/DecisionCurve", target="_blank"))
,width = 13)
)
),
# Second Tab content: Data and SUmmary
tabItem(tabName = "data",
h2("Please Enter CSV Data"),
fileInput('datafile', 'Choose CSV file',
accept=c('text/csv', 'text/comma-separated-values,text/plain')),
h3("Descriptive Statistics: Select variables"),
uiOutput("Variables"),
# View summary statistics
h3("1. Summary Statistics"),
fluidRow(
box(
dataTableOutput("sum"),
width = 12
) ),
h3("2. Correlation"),
fluidRow(
box(
plotOutput("corPlot"),
width = 12
)
),
# Create row to check the data
h3("3. Data View"),
fluidRow(
box(
dataTableOutput("filetable"),
width = 12
)
),
h3("4. R session info"),
fluidRow(
box(
verbatimTextOutput("info"),
width = 12
)
)
),
# Third Tab Content
tabItem(tabName = "model",
h4(strong("*Note"),'Estimation may take a few seconds to minutes depending on the dataset.'),
h3("Predictive Model Specification"),
h4("Specify the model formula with variables"),
fluidRow(
box(
width = 4,
uiOutput("outcomevariable")
),
box(
width = 4,
uiOutput("independentvariable")
)
),
fluidRow(
box(width = 12,
h2("Predicted Probabilities")),
hr(),
br(),
box(
width = 12,
dataTableOutput("preddat")
)
),
h3("Specify the modeling options"),
fluidRow(
box(
h3("GLM Option"),
numericInput("prob_thresh","Pr. Threshold for classification", min = 0.01, max = 1, value = 0.5)
,width = 2
),
box(
h3("RandomForest Options"),
sliderInput("mtry","Number of randomly sampled variables", min = 1, max = 100, value = 2, step = 1),
sliderInput("ntree","Number of trees to grow", min = 1, max = 100, value = 5, step = 1),
width = 3
),
box(
h3("Decision Tree Options"),
selectInput("rpartmethod","Method", choices = c("anova","poisson","class","exp"), selected = "class"),
sliderInput("minsplit","Min # of obs in node to split", min = 1, max = 100, value = 20, step = 1),
sliderInput("cp","Min # of obs in node to split", min = 0.000001, max = 1, value = 0.01, step = 0.01),
width = 3
),
box(
h3("SVM Options"),
selectInput("svmkernel","Kernel", choices = c("linear","polynomial","radial","sigmoid"), selected = "radial"),
numericInput("gamma","Gamma", min = 0.00000001, max = 1, value = 0.01),
numericInput("cp","Complexity Parameter", min = 0.000001, max = 1, value = 0.01),
width = 3
)
),
hr(),
br(),br(),br(),br(),
fluidRow(
box(
p('For Decision Curve Analysis See',
a("dca", href="https://www.mskcc.org/departments/epidemiology-biostatistics/health-outcomes/decision-curve-analysis-01", target="_blank"),
'for the documentation, tutorial, and more.')
)
)
),
# Fourth tab content
tabItem(tabName = "regresult",
h2("Analysis Result"),
fluidRow(
column(6,
box(title = "GLM regression table", uiOutput("glm_sum"),
width = 12)
),
column(6,
box(title = "Decision Tree summary", plotOutput("dtplot"),
width = 12)
)
),
fluidRow(
column(6,
box(title = "Random Forest summary", verbatimTextOutput("rfsum")
,
width = 12)
),
column(6,
box(title = "SVM summary", verbatimTextOutput("svmsum")
,
width = 12)
)
)
),
# Fifth tab content
tabItem(tabName = 'roc',
h3('ROC curve'),
fluidRow(
box(
plotlyOutput("roc")
,width = 12
)
),
br(),
hr(),
h3("Confusion Matrices"),
fluidRow(
box(
h3("GLM confusion matrix"),
plotOutput("glmcmplot")
,width = 3
),
box(
h3("Decision Tree confusion matrix"),
plotOutput("dtcmplot")
,width = 3
),
box(
h3("Random Forest confusion matrix"),
plotOutput("rfcmplot")
,width = 3
),
box(
h3("SVM confusion matrix"),
plotOutput("svmcmplot")
,width = 3
)
),
br(),br(), hr(),
fluidRow(
box(
h3("Prediction Performance Measures"),
dataTableOutput("pred_perf")
,width = 6
)
)
)
)
)
)