Skip to content

Commit 8c828eb

Browse files
committed
Adaptive tip-point size implementation for UPGMA and NJ trees
1 parent 57271df commit 8c828eb

File tree

1 file changed

+95
-44
lines changed

1 file changed

+95
-44
lines changed

App.R

Lines changed: 95 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,15 +2061,7 @@ ui <- dashboardPage(
20612061
column(
20622062
width = 6,
20632063
align = "center",
2064-
numericInput(
2065-
"tiplab_size",
2066-
label = h5("Label size", style = "color:white; margin-bottom: 0px"),
2067-
min = 1,
2068-
max = 10,
2069-
step = 0.5,
2070-
value = 4,
2071-
width = "80px"
2072-
),
2064+
uiOutput("nj_tiplab_size"),
20732065
br(),
20742066
selectInput(
20752067
"nj_tiplab_fontface",
@@ -2410,15 +2402,7 @@ ui <- dashboardPage(
24102402
ticks = FALSE
24112403
),
24122404
br(),
2413-
sliderInput(
2414-
inputId = "nj_tippoint_size",
2415-
label = h5("Size", style = "color:white; margin-bottom: 0px"),
2416-
min = 1,
2417-
max = 20,
2418-
value = 5,
2419-
width = "150px",
2420-
ticks = FALSE
2421-
)
2405+
uiOutput("nj_tippoint_size")
24222406
)
24232407
)
24242408
)
@@ -4432,15 +4416,7 @@ ui <- dashboardPage(
44324416
ticks = FALSE
44334417
),
44344418
br(),
4435-
sliderInput(
4436-
inputId = "upgma_tippoint_size",
4437-
label = h5("Size", style = "color:white; margin-bottom: 0px"),
4438-
min = 1,
4439-
max = 20,
4440-
value = 5,
4441-
width = "150px",
4442-
ticks = FALSE
4443-
)
4419+
uiOutput("upgma_tippoint_size")
44444420
)
44454421
)
44464422
)
@@ -9030,8 +9006,7 @@ server <- function(input, output, session) {
90309006
# Change scheme
90319007
observeEvent(input$reload_db, {
90329008

9033-
testt <<- upgma_tiplab_size()
9034-
test <<- input$upgma_tiplab_size
9009+
test <<- input$nj_layout
90359010

90369011
if(tail(readLines(paste0(getwd(), "/execute/script_log.txt")), 1)!= "0") {
90379012
show_toast(
@@ -10164,6 +10139,33 @@ server <- function(input, output, session) {
1016410139

1016510140
#### NJ and UPGMA controls ----
1016610141

10142+
##### Tippoint size ----
10143+
output$nj_tippoint_size <- renderUI(
10144+
sliderInput(
10145+
inputId = "nj_tippoint_size",
10146+
label = h5("Size", style = "color:white; margin-bottom: 0px"),
10147+
min = 1,
10148+
max = 20,
10149+
step = 0.5,
10150+
value = Vis$tippointsize_nj,
10151+
width = "150px",
10152+
ticks = FALSE
10153+
)
10154+
)
10155+
10156+
output$upgma_tippoint_size <- renderUI(
10157+
sliderInput(
10158+
inputId = "upgma_tippoint_size",
10159+
label = h5("Size", style = "color:white; margin-bottom: 0px"),
10160+
min = 1,
10161+
max = 20,
10162+
step = 0.5,
10163+
value = Vis$tippointsize_upgma,
10164+
width = "150px",
10165+
ticks = FALSE
10166+
)
10167+
)
10168+
1016710169
##### Tiplabel size ----
1016810170
output$upgma_tiplab_size <- renderUI(
1016910171
numericInput(
@@ -11406,7 +11408,6 @@ server <- function(input, output, session) {
1140611408
})
1140711409

1140811410
# No label clip off for linear NJ tree
11409-
1141011411
clip_label <- reactive({
1141111412
if(!(input$nj_layout == "circular" | input$nj_layout == "inward")) {
1141211413
coord_cartesian(clip = "off")
@@ -11611,37 +11612,37 @@ server <- function(input, output, session) {
1161111612
aes(shape = !!sym(input$nj_tipcolor_mapping)),
1161211613
alpha = input$nj_tippoint_alpha,
1161311614
color = input$nj_tippoint_color,
11614-
size = input$nj_tippoint_size
11615+
size = nj_tippoint_size()
1161511616
)
1161611617
} else {
1161711618
geom_tippoint(
1161811619
aes(color = !!sym(input$nj_tipcolor_mapping)),
1161911620
alpha = input$nj_tippoint_alpha,
1162011621
shape = input$nj_tippoint_shape,
11621-
size = input$nj_tippoint_size
11622+
size = nj_tippoint_size()
1162211623
)
1162311624
}
1162411625
} else if (input$nj_tipcolor_mapping_show == FALSE & input$nj_tipshape_mapping_show == TRUE) {
1162511626
geom_tippoint(
1162611627
aes(shape = !!sym(input$nj_tipshape_mapping)),
1162711628
alpha = input$nj_tippoint_alpha,
1162811629
color = input$nj_tippoint_color,
11629-
size = input$nj_tippoint_size
11630+
size = nj_tippoint_size()
1163011631
)
1163111632
} else if (input$nj_tipcolor_mapping_show == TRUE & input$nj_tipshape_mapping_show == TRUE) {
1163211633
if(input$nj_mapping_show == TRUE) {
1163311634
geom_tippoint(
1163411635
aes(shape = !!sym(input$nj_tipshape_mapping)),
1163511636
color = input$nj_tippoint_color,
1163611637
alpha = input$nj_tippoint_alpha,
11637-
size = input$nj_tippoint_size
11638+
size = nj_tippoint_size()
1163811639
)
1163911640
} else {
1164011641
geom_tippoint(
1164111642
aes(shape = !!sym(input$nj_tipshape_mapping),
1164211643
color = !!sym(input$nj_tipcolor_mapping)),
1164311644
alpha = input$nj_tippoint_alpha,
11644-
size = input$nj_tippoint_size
11645+
size = nj_tippoint_size()
1164511646
)
1164611647
}
1164711648
} else {
@@ -11650,7 +11651,7 @@ server <- function(input, output, session) {
1165011651
colour = input$nj_tippoint_color,
1165111652
fill = input$nj_tippoint_color,
1165211653
shape = input$nj_tippoint_shape,
11653-
size = input$nj_tippoint_size
11654+
size = nj_tippoint_size()
1165411655
)
1165511656
}
1165611657
} else {NULL
@@ -11783,6 +11784,15 @@ server <- function(input, output, session) {
1178311784
}
1178411785
})
1178511786

11787+
# Tippoint size
11788+
nj_tippoint_size <- reactive({
11789+
if(!is.null(input$nj_tippoint_size)) {
11790+
input$nj_tippoint_size
11791+
} else {
11792+
Vis$tippointsize_nj
11793+
}
11794+
})
11795+
1178611796
# Show Label Panels?
1178711797
nj_geom <- reactive({
1178811798
if(input$nj_geom == TRUE) {
@@ -12256,37 +12266,37 @@ server <- function(input, output, session) {
1225612266
aes(shape = !!sym(input$upgma_tipcolor_mapping)),
1225712267
alpha = input$upgma_tippoint_alpha,
1225812268
color = input$upgma_tippoint_color,
12259-
size = input$upgma_tippoint_size
12269+
size = upgma_tippoint_size()
1226012270
)
1226112271
} else {
1226212272
geom_tippoint(
1226312273
aes(color = !!sym(input$upgma_tipcolor_mapping)),
1226412274
alpha = input$upgma_tippoint_alpha,
1226512275
shape = input$upgma_tippoint_shape,
12266-
size = input$upgma_tippoint_size
12276+
size = upgma_tippoint_size()
1226712277
)
1226812278
}
1226912279
} else if (input$upgma_tipcolor_mapping_show == FALSE & input$upgma_tipshape_mapping_show == TRUE) {
1227012280
geom_tippoint(
1227112281
aes(shape = !!sym(input$upgma_tipshape_mapping)),
1227212282
alpha = input$upgma_tippoint_alpha,
1227312283
color = input$upgma_tippoint_color,
12274-
size = input$upgma_tippoint_size
12284+
size = upgma_tippoint_size()
1227512285
)
1227612286
} else if (input$upgma_tipcolor_mapping_show == TRUE & input$upgma_tipshape_mapping_show == TRUE) {
1227712287
if(input$upgma_mapping_show == TRUE) {
1227812288
geom_tippoint(
1227912289
aes(shape = !!sym(input$upgma_tipshape_mapping)),
1228012290
color = input$upgma_tippoint_color,
1228112291
alpha = input$upgma_tippoint_alpha,
12282-
size = input$upgma_tippoint_size
12292+
size = upgma_tippoint_size()
1228312293
)
1228412294
} else {
1228512295
geom_tippoint(
1228612296
aes(shape = !!sym(input$upgma_tipshape_mapping),
1228712297
color = !!sym(input$upgma_tipcolor_mapping)),
1228812298
alpha = input$upgma_tippoint_alpha,
12289-
size = input$upgma_tippoint_size
12299+
size = upgma_tippoint_size()
1229012300
)
1229112301
}
1229212302
} else {
@@ -12295,7 +12305,7 @@ server <- function(input, output, session) {
1229512305
colour = input$upgma_tippoint_color,
1229612306
fill = input$upgma_tippoint_color,
1229712307
shape = input$upgma_tippoint_shape,
12298-
size = input$upgma_tippoint_size
12308+
size = upgma_tippoint_size()
1229912309
)
1230012310
}
1230112311
} else {NULL
@@ -12419,6 +12429,15 @@ server <- function(input, output, session) {
1241912429

1242012430
})
1242112431

12432+
# TIppoint size
12433+
upgma_tippoint_size <- reactive({
12434+
if(!is.null(input$upgma_tippoint_size)) {
12435+
input$upgma_tippoint_size
12436+
} else {
12437+
Vis$tippointsize_upgma
12438+
}
12439+
})
12440+
1242212441
# Tiplab size
1242312442
upgma_tiplab_size <- reactive({
1242412443
if(!is.null(input$upgma_tiplab_size)) {
@@ -13049,40 +13068,56 @@ server <- function(input, output, session) {
1304913068
if(input$nj_layout == "circular" | input$nj_layout == "inward") {
1305013069
if(sum(DB$data$Include) < 21) {
1305113070
Vis$labelsize_nj <- 5.5
13071+
Vis$tippointsize_nj <- 5.5
1305213072
} else if (between(sum(DB$data$Include), 21, 40)) {
1305313073
Vis$labelsize_nj <- 5
13074+
Vis$tippointsize_nj <- 5
1305413075
} else if (between(sum(DB$data$Include), 41, 60)) {
1305513076
Vis$labelsize_nj <- 4.5
13077+
Vis$tippointsize_nj <- 4.5
1305613078
} else if (between(sum(DB$data$Include), 61, 80)) {
1305713079
Vis$labelsize_nj <- 4
13058-
} else if (between(sum(DB$data$Include), 81, 120)) {
13080+
Vis$tippointsize_nj <- 4
13081+
} else if (between(sum(DB$data$Include), 81, 100)) {
1305913082
Vis$labelsize_nj <- 3.5
13083+
Vis$tippointsize_nj <- 3.5
1306013084
} else {
1306113085
Vis$labelsize_nj <- 3
13086+
Vis$tippointsize_nj <- 3
1306213087
}
1306313088
} else {
1306413089
if(sum(DB$data$Include) < 21) {
1306513090
Vis$labelsize_nj <- 5
13091+
Vis$tippointsize_nj <- 5
1306613092
} else if (between(sum(DB$data$Include), 21, 40)) {
1306713093
Vis$labelsize_nj <- 4.5
13094+
Vis$tippointsize_nj <- 4.5
1306813095
} else if (between(sum(DB$data$Include), 41, 60)) {
1306913096
Vis$labelsize_nj <- 4
13097+
Vis$tippointsize_nj <- 4
1307013098
} else if (between(sum(DB$data$Include), 61, 80)) {
1307113099
Vis$labelsize_nj <- 3.5
13100+
Vis$tippointsize_nj <- 3.5
1307213101
} else if (between(sum(DB$data$Include), 81, 100)) {
1307313102
Vis$labelsize_nj <- 3
13103+
Vis$tippointsize_nj <- 3
1307413104
} else {
1307513105
Vis$labelsize_nj <- 2.5
13106+
Vis$tippointsize_nj <- 2.5
1307613107
}
1307713108
}
1307813109
} else {
1307913110
Vis$labelsize_nj <- 4
13111+
Vis$tippointsize_nj <- 4
1308013112
}
1308113113

1308213114
# Update visualization control inputs
1308313115
if(!is.null(input$nj_tiplab_size)) {
1308413116
updateNumericInput(session, "nj_tiplab_size", value = Vis$labelsize_nj)
1308513117
}
13118+
if(!is.null(input$nj_tippoint_size)) {
13119+
updateSliderInput(session, "nj_tippoint_size", value = Vis$tippointsize_nj)
13120+
}
1308613121

1308713122
# Create phylogenetic tree
1308813123
Vis$nj <- ape::nj(hamming_nj())
@@ -13113,40 +13148,56 @@ server <- function(input, output, session) {
1311313148
if(input$upgma_layout == "circular" | input$upgma_layout == "inward") {
1311413149
if(sum(DB$data$Include) < 21) {
1311513150
Vis$labelsize_upgma <- 5.5
13151+
Vis$tippointsize_upgma <- 5.5
1311613152
} else if (between(sum(DB$data$Include), 21, 40)) {
1311713153
Vis$labelsize_upgma <- 5
13154+
Vis$tippointsize_upgma <- 5
1311813155
} else if (between(sum(DB$data$Include), 41, 60)) {
1311913156
Vis$labelsize_upgma <- 4.5
13157+
Vis$tippointsize_upgma <- 4.5
1312013158
} else if (between(sum(DB$data$Include), 61, 80)) {
1312113159
Vis$labelsize_upgma <- 4
13122-
} else if (between(sum(DB$data$Include), 81, 120)) {
13160+
Vis$tippointsize_upgma <- 4
13161+
} else if (between(sum(DB$data$Include), 81, 100)) {
1312313162
Vis$labelsize_upgma <- 3.5
13163+
Vis$tippointsize_upgma <- 3.5
1312413164
} else {
1312513165
Vis$labelsize_upgma <- 3
13166+
Vis$tippointsize_upgma <- 3
1312613167
}
1312713168
} else {
1312813169
if(sum(DB$data$Include) < 21) {
1312913170
Vis$labelsize_upgma <- 5
13171+
Vis$tippointsize_upgma <- 5
1313013172
} else if (between(sum(DB$data$Include), 21, 40)) {
1313113173
Vis$labelsize_upgma <- 4.5
13174+
Vis$tippointsize_upgma <- 4.5
1313213175
} else if (between(sum(DB$data$Include), 41, 60)) {
1313313176
Vis$labelsize_upgma <- 4
13177+
Vis$tippointsize_upgma <- 4
1313413178
} else if (between(sum(DB$data$Include), 61, 80)) {
1313513179
Vis$labelsize_upgma <- 3.5
13180+
Vis$tippointsize_upgma <- 3.5
1313613181
} else if (between(sum(DB$data$Include), 81, 100)) {
1313713182
Vis$labelsize_upgma <- 3
13183+
Vis$tippointsize_upgma <- 3
1313813184
} else {
1313913185
Vis$labelsize_upgma <- 2.5
13186+
Vis$tippointsize_upgma <- 2.5
1314013187
}
1314113188
}
1314213189
} else {
1314313190
Vis$labelsize_upgma <- 4
13191+
Vis$tippointsize_upgma <- 4
1314413192
}
1314513193

1314613194
# Update visualization control inputs
1314713195
if(!is.null(input$upgma_tiplab_size)) {
1314813196
updateNumericInput(session, "upgma_tiplab_size", value = Vis$labelsize_upgma)
1314913197
}
13198+
if(!is.null(input$upgma_tippoint_size)) {
13199+
updateSliderInput(session, "upgma_tippoint_size", value = Vis$tippointsize_upgma)
13200+
}
1315013201

1315113202
# Create phylogenetic tree
1315213203
Vis$upgma <- phangorn::upgma(hamming_nj())

0 commit comments

Comments
 (0)