Skip to content

Commit acbe4f8

Browse files
committed
tweaked interface
1 parent 2739c18 commit acbe4f8

1 file changed

Lines changed: 30 additions & 10 deletions

File tree

app.R

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,25 @@ ui <- fluidPage(
5555

5656
tags$head(tags$style(
5757
HTML("textarea{font-family: monospace; font-size: 9px;}
58-
#errormsg{color: tomato; font-size: 16px; font-style: bold;}")
58+
#msg1,#msg2{color: tomato; font-size: 14px;}
59+
#errormsg{color: tomato; font-size: 16px; font-style: bold;}
60+
#github{color: white; background-color:grey;}
61+
#actButton{color: white; background-color:cadetblue;}")
5962
)),
6063

6164
titlePanel("clmp: clustering with Markov-modulated Poisson processes"),
6265

6366
sidebarLayout(
6467
sidebarPanel(
65-
h4("Do not submit trees labeled with any potentially
68+
p("Do not submit trees labeled with any potentially
6669
identifying information."),
6770
textAreaInput(
6871
inputId="newick",
6972
label="Input tree (Newick format)",
7073
height='400px',
7174
value=default.tree
7275
),
73-
fileInput("nwkFile", "or upload Newick file", multiple=FALSE, accept=c('text/plain')),
76+
fileInput("nwkFile", "Upload Newick file", multiple=FALSE, accept=c('text/plain')),
7477
strong(textOutput("errormsg")),
7578
actionButton(inputId="exampleButton", label="Example",
7679
icon=icon("cat", lib="font-awesome")),
@@ -81,7 +84,8 @@ ui <- fluidPage(
8184
#h4("Tree plot:"),
8285
plotOutput(outputId="clmpPlot"), #, height='500px'),
8386
#h4("Summary:"),
84-
textOutput("warnings"),
87+
textOutput("msg1"),
88+
textOutput("msg2"),
8589
textOutput("summary"),
8690
#h4("Model selection:"),
8791
textOutput("dAIC"),
@@ -91,29 +95,44 @@ ui <- fluidPage(
9195
h5("If you use clmp in your work, please cite:"),
9296
helpText("McCloskey RM, Poon AF. A model-based clustering method to detect
9397
infectious disease transmission outbreaks from sequence variation.
94-
PLoS Comput Biol. 2017 Nov 13;13(11):e1005868.")
98+
PLoS Comput Biol. 2017 Nov 13;13(11):e1005868."),
99+
actionButton("github", label="Go to GitHub",
100+
icon("github", lib="font-awesome"),
101+
onclick="window.open('http://github.com/PoonLab/clmp', '_blank')")
95102
)
96103
)
97104
)
98105

99106
server <- function(input, output, session) {
100107
# main logic
101108
v <- eventReactive(input$actButton, {
109+
# reset messages
102110
output$errormsg <- renderText("")
111+
output$msg1 <- renderText("")
112+
output$msg2 <- renderText("")
113+
103114
phy <- read.tree(text=input$newick)
104115

105116
validate(need(class(phy) == "phylo", "Failed to parse Newick string"))
106117

107118
phy$node.label <- NULL # discard internal node labels
108119

109120
validate(need(length(phy$tip.label) < MAXTREESIZE,
110-
"Sorry, tree is too large. Please use standalone clmp package in R."))
121+
paste("Sorry, tree is too large (limit ", MAXTREESIZE,
122+
" tips). Please use standalone clmp package in R.",
123+
sep='')
124+
))
111125
nsites <- detect.ml(phy)
126+
if (!is.na(nsites)) {
127+
output$msg1 <- renderText(paste(
128+
"Warning: detected ML tree - padded near-zero branch lengths to ",
129+
1/nsites, sep=''))
130+
}
112131
res1 <- clmp(phy, nrates=1, nsites=nsites)
113132
res2 <- clmp(phy, nrates=2, nsites=nsites)
114133

115134
list(phy=phy, res1=res1, res2=res2)
116-
})
135+
}, ignoreNULL=FALSE)
117136

118137
# user resets input to default tree
119138
observeEvent(
@@ -165,9 +184,10 @@ server <- function(input, output, session) {
165184
output$summary <- renderText({
166185
res2 <- v()$res2
167186
#TODO: check if root state 0
168-
validate(need(res2$states["Node1"]==0,
169-
"Warning: root was assigned to cluster, results from 2-class model are invalid. You may be sampling from a recently expanding epidemic."))
170-
187+
if (res2$states["Node1"]!=0) {
188+
output$msg2 <- renderText("Warning: root was assigned to cluster, results from 2-class model may be invalid. Tree may be rooted incorrectly, or you may be sampling from a recently expanding epidemic.")
189+
}
190+
171191
clu <- res2$clusters
172192
n.clusters <- max(clu)
173193

0 commit comments

Comments
 (0)