0.4.0
Browse files
app.R
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
# shiny::runApp("./")
|
6 |
# Setup
|
7 |
-
rtemisseq_version <- "0.
|
8 |
library(rtemis)
|
9 |
library(rtemisbio)
|
10 |
library(shiny)
|
@@ -29,31 +29,50 @@ source("data.R")
|
|
29 |
#' @return A shiny app that can be converted to a shinylive app
|
30 |
|
31 |
rtemisseq <- function(
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
36 |
# Logo
|
37 |
logo <- base64enc::dataURI(
|
38 |
-
file = "./www/rtemisseq_gray.png",
|
|
|
39 |
)
|
40 |
# Version
|
41 |
platform <- sessionInfo()[["platform"]]
|
42 |
svl <- paste0(
|
43 |
-
"rtemisseq v",
|
44 |
-
|
45 |
-
" | ",
|
46 |
-
"
|
47 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
)
|
49 |
|
50 |
# Shinylive info
|
51 |
shinylive_info <- if (substr(platform, 1, 4) == "wasm") {
|
52 |
paste0(
|
53 |
"<br><br>This application has been compiled to ",
|
54 |
-
as.character(a(
|
|
|
|
|
|
|
|
|
55 |
" using ",
|
56 |
-
as.character(a(
|
|
|
|
|
|
|
|
|
57 |
"<br>and is best viewed with the latest version of Chrome."
|
58 |
)
|
59 |
} else {
|
@@ -107,10 +126,18 @@ rtemisseq <- function(
|
|
107 |
br(),
|
108 |
HTML(paste0(
|
109 |
"rtemisSeq is a web interface for ",
|
110 |
-
as.character(a(
|
|
|
|
|
|
|
|
|
111 |
", <br>providing interactive visualization of sequence data.",
|
112 |
"<br>Created for the ",
|
113 |
-
as.character(a(
|
|
|
|
|
|
|
|
|
114 |
".<br><br>",
|
115 |
rthelp_inline(
|
116 |
"To get started, use the navigation tabs at the top.",
|
@@ -118,7 +145,8 @@ rtemisseq <- function(
|
|
118 |
),
|
119 |
shinylive_info
|
120 |
)),
|
121 |
-
br(),
|
|
|
122 |
bslib::card_image(
|
123 |
file = "./www/rtemisseq-splash.webp",
|
124 |
alt = "rtemisseq",
|
@@ -191,6 +219,37 @@ rtemisseq <- function(
|
|
191 |
# ) # /nav_panel jsonedit
|
192 |
# ) # /navset_card_tab
|
193 |
), # /nav_panel Protein Visualization
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
## [] About ----
|
195 |
bslib::nav_panel(
|
196 |
title = "About",
|
@@ -202,10 +261,18 @@ rtemisseq <- function(
|
|
202 |
class = "text-center",
|
203 |
HTML(paste0(
|
204 |
"Created by the ",
|
205 |
-
as.character(a(
|
|
|
|
|
|
|
|
|
206 |
" Genomics & Transcriptomics core.<br/>",
|
207 |
"Powered by rtemis & rtemisbio (",
|
208 |
-
as.character(a(
|
|
|
|
|
|
|
|
|
209 |
")."
|
210 |
))
|
211 |
), # /div
|
@@ -288,10 +355,14 @@ rtemisseq <- function(
|
|
288 |
|
289 |
# GitHub files runs when github_files_update_button is clicked ----
|
290 |
github_files <- reactive({
|
291 |
-
get_github_files(
|
|
|
|
|
|
|
|
|
292 |
}) |>
|
293 |
bindEvent(input$github_files_update_button)
|
294 |
-
|
295 |
# GitHub file list output ----
|
296 |
output$ui_github_files <- shiny::renderUI({
|
297 |
req(github_files())
|
@@ -337,8 +408,16 @@ rtemisseq <- function(
|
|
337 |
shiny::selectizeInput(
|
338 |
inputId = "a3_builtin_data",
|
339 |
label = "Select built-in a3 dataset",
|
340 |
-
choices = c(
|
341 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
)
|
343 |
}
|
344 |
}) # /ui_a3_data_load
|
@@ -396,8 +475,12 @@ rtemisseq <- function(
|
|
396 |
}
|
397 |
# index with input$github_file
|
398 |
jsondat <- httr::GET(
|
399 |
-
github_files()[
|
400 |
-
|
|
|
|
|
|
|
|
|
401 |
dat <- as.a3(jsonlite::parse_json(
|
402 |
jsondat,
|
403 |
simplifyVector = TRUE,
|
@@ -435,7 +518,11 @@ rtemisseq <- function(
|
|
435 |
output$dplot3_protein <- plotly::renderPlotly({
|
436 |
req(a3_obj())
|
437 |
if (verbosity > 0) {
|
438 |
-
message(
|
|
|
|
|
|
|
|
|
439 |
}
|
440 |
plot(
|
441 |
a3_obj(),
|
@@ -447,7 +534,8 @@ rtemisseq <- function(
|
|
447 |
bg = input$plot.bg, # legend.bg defaults to transparent, this sets paper bg
|
448 |
plot.bg = input$plot.bg,
|
449 |
marker.col = input$marker.col,
|
450 |
-
n.per.row = if (input$n.per.row == "auto") NULL else
|
|
|
451 |
)
|
452 |
}) |> # /dplot3_protein
|
453 |
bindEvent(input$a3_plot_button, input$a3_plot_update_button)
|
@@ -462,7 +550,8 @@ rtemisseq <- function(
|
|
462 |
output$ui_a3_tooltip <- shiny::renderUI({
|
463 |
bslib::tooltip(
|
464 |
trigger = span(
|
465 |
-
"Plot help",
|
|
|
466 |
style = "text-align: right;",
|
467 |
class = "rtanihi"
|
468 |
),
|
@@ -490,10 +579,36 @@ rtemisseq <- function(
|
|
490 |
# "Plot settings", bsicons::bs_icon("gear", class = "ms-auto"),
|
491 |
# style = "text-align: right;"
|
492 |
# shiny::selectizeInput("a3.theme", label = "Theme", choices = c("dark", "light"), selected = default_theme),
|
493 |
-
shiny::sliderInput(
|
494 |
-
|
495 |
-
|
496 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
497 |
shinyWidgets::colorPickr(
|
498 |
"plot.bg",
|
499 |
label = "Plot background",
|
@@ -529,7 +644,6 @@ rtemisseq <- function(
|
|
529 |
}
|
530 |
}) # /ui_a3_popover
|
531 |
|
532 |
-
|
533 |
# UI dplot3_protein ----
|
534 |
output$ui_dplot3_protein <- renderUI({
|
535 |
if (clicked() == FALSE || is.null(a3_obj())) {
|
@@ -559,6 +673,73 @@ rtemisseq <- function(
|
|
559 |
height = jsonedit_height
|
560 |
)
|
561 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
} # /server
|
563 |
|
564 |
# Shiny app ----
|
|
|
4 |
|
5 |
# shiny::runApp("./")
|
6 |
# Setup
|
7 |
+
rtemisseq_version <- "0.4.0"
|
8 |
library(rtemis)
|
9 |
library(rtemisbio)
|
10 |
library(shiny)
|
|
|
29 |
#' @return A shiny app that can be converted to a shinylive app
|
30 |
|
31 |
rtemisseq <- function(
|
32 |
+
default_theme = "dark",
|
33 |
+
protein_plotly_height = "900px",
|
34 |
+
jsonedit_height = "900px",
|
35 |
+
verbosity = 0L
|
36 |
+
) {
|
37 |
# Logo
|
38 |
logo <- base64enc::dataURI(
|
39 |
+
file = "./www/rtemisseq_gray.png",
|
40 |
+
mime = "image/png"
|
41 |
)
|
42 |
# Version
|
43 |
platform <- sessionInfo()[["platform"]]
|
44 |
svl <- paste0(
|
45 |
+
"rtemisseq v",
|
46 |
+
rtemisseq_version,
|
47 |
+
" | ",
|
48 |
+
"rtemisbio v",
|
49 |
+
utils::packageVersion("rtemisbio"),
|
50 |
+
" | ",
|
51 |
+
"rtemis v",
|
52 |
+
utils::packageVersion("rtemis"),
|
53 |
+
" | R v",
|
54 |
+
version$major,
|
55 |
+
".",
|
56 |
+
version$minor,
|
57 |
+
" | running on ",
|
58 |
+
platform
|
59 |
)
|
60 |
|
61 |
# Shinylive info
|
62 |
shinylive_info <- if (substr(platform, 1, 4) == "wasm") {
|
63 |
paste0(
|
64 |
"<br><br>This application has been compiled to ",
|
65 |
+
as.character(a(
|
66 |
+
"WebAssembly",
|
67 |
+
href = "https://webassembly.org/",
|
68 |
+
target = "_blank"
|
69 |
+
)),
|
70 |
" using ",
|
71 |
+
as.character(a(
|
72 |
+
"shinylive",
|
73 |
+
href = "https://posit-dev.github.io/r-shinylive/",
|
74 |
+
target = "_blank"
|
75 |
+
)),
|
76 |
"<br>and is best viewed with the latest version of Chrome."
|
77 |
)
|
78 |
} else {
|
|
|
126 |
br(),
|
127 |
HTML(paste0(
|
128 |
"rtemisSeq is a web interface for ",
|
129 |
+
as.character(a(
|
130 |
+
"rtemisbio",
|
131 |
+
href = "https://rtemis.org/rtemisbio",
|
132 |
+
target = "_blank"
|
133 |
+
)),
|
134 |
", <br>providing interactive visualization of sequence data.",
|
135 |
"<br>Created for the ",
|
136 |
+
as.character(a(
|
137 |
+
"FTD CWOW",
|
138 |
+
href = "https://cwow.ucsf.edu/",
|
139 |
+
target = "_blank"
|
140 |
+
)),
|
141 |
".<br><br>",
|
142 |
rthelp_inline(
|
143 |
"To get started, use the navigation tabs at the top.",
|
|
|
145 |
),
|
146 |
shinylive_info
|
147 |
)),
|
148 |
+
br(),
|
149 |
+
br(),
|
150 |
bslib::card_image(
|
151 |
file = "./www/rtemisseq-splash.webp",
|
152 |
alt = "rtemisseq",
|
|
|
219 |
# ) # /nav_panel jsonedit
|
220 |
# ) # /navset_card_tab
|
221 |
), # /nav_panel Protein Visualization
|
222 |
+
## [] PDB Viewer ----
|
223 |
+
bslib::nav_panel(
|
224 |
+
title = "PDB Viewer",
|
225 |
+
icon = bsicons::bs_icon("box"),
|
226 |
+
card(
|
227 |
+
full_screen = TRUE,
|
228 |
+
class = "p-0",
|
229 |
+
# allow items side by side ----
|
230 |
+
card_header(
|
231 |
+
class = "d-flex justify-content-end",
|
232 |
+
# tooltip UI output ----
|
233 |
+
# uiOutput("ui_pdb_tooltip"),
|
234 |
+
# popover UI output ----
|
235 |
+
# uiOutput("ui_pdb_popover")
|
236 |
+
),
|
237 |
+
layout_sidebar(
|
238 |
+
fillable = TRUE,
|
239 |
+
# Data Load Sidebar ----
|
240 |
+
sidebar = bslib::sidebar(
|
241 |
+
uiOutput("ui_pdb_settings"), # PDB settings
|
242 |
+
# uiOutput("ui_a3_load_switch"), # Switch between file upload and built-in data
|
243 |
+
# uiOutput("ui_a3_data_load"), # File upload or built-in data selection depending on switch
|
244 |
+
# uiOutput("ui_a3_data_info"), # Shows dataset info
|
245 |
+
# uiOutput("ui_a3_plot_button"), # Click to plot
|
246 |
+
# uiOutput("ui_a3_tooltip")
|
247 |
+
),
|
248 |
+
# Plot Output ----
|
249 |
+
NGLVieweR::NGLVieweROutput("pdb", width = "100%", height = "900px")
|
250 |
+
)
|
251 |
+
) # /card
|
252 |
+
), # /nav_panel PDB Viewer
|
253 |
## [] About ----
|
254 |
bslib::nav_panel(
|
255 |
title = "About",
|
|
|
261 |
class = "text-center",
|
262 |
HTML(paste0(
|
263 |
"Created by the ",
|
264 |
+
as.character(a(
|
265 |
+
"FTD CWOW",
|
266 |
+
href = "https://cwow.ucsf.edu/",
|
267 |
+
target = "_blank"
|
268 |
+
)),
|
269 |
" Genomics & Transcriptomics core.<br/>",
|
270 |
"Powered by rtemis & rtemisbio (",
|
271 |
+
as.character(a(
|
272 |
+
"rtemis.org",
|
273 |
+
href = "https://rtemis.org",
|
274 |
+
target = "_blank"
|
275 |
+
)),
|
276 |
")."
|
277 |
))
|
278 |
), # /div
|
|
|
355 |
|
356 |
# GitHub files runs when github_files_update_button is clicked ----
|
357 |
github_files <- reactive({
|
358 |
+
get_github_files(
|
359 |
+
repo_owner = "rtemis-org",
|
360 |
+
repo_name = "seq-data",
|
361 |
+
verbosity = verbosity
|
362 |
+
)
|
363 |
}) |>
|
364 |
bindEvent(input$github_files_update_button)
|
365 |
+
|
366 |
# GitHub file list output ----
|
367 |
output$ui_github_files <- shiny::renderUI({
|
368 |
req(github_files())
|
|
|
408 |
shiny::selectizeInput(
|
409 |
inputId = "a3_builtin_data",
|
410 |
label = "Select built-in a3 dataset",
|
411 |
+
choices = c(
|
412 |
+
"MAPT_PTM",
|
413 |
+
"MAPT_Cathepsin_Cleavage",
|
414 |
+
"MAPT_APP_Cleavage_3_4",
|
415 |
+
"MAPT_APP_Cleavage_4_5",
|
416 |
+
"MAPT_APP_Cleavage_5_5",
|
417 |
+
"MAPT_APP_Cleavage_7_4",
|
418 |
+
"MAPT_Citrullination"
|
419 |
+
),
|
420 |
+
selected = "MAPT_PTM"
|
421 |
)
|
422 |
}
|
423 |
}) # /ui_a3_data_load
|
|
|
475 |
}
|
476 |
# index with input$github_file
|
477 |
jsondat <- httr::GET(
|
478 |
+
github_files()[
|
479 |
+
github_files()$file_name == input$github_file,
|
480 |
+
"download_url"
|
481 |
+
]
|
482 |
+
) |>
|
483 |
+
httr::content(as = "text", encoding = "UTF-8")
|
484 |
dat <- as.a3(jsonlite::parse_json(
|
485 |
jsondat,
|
486 |
simplifyVector = TRUE,
|
|
|
518 |
output$dplot3_protein <- plotly::renderPlotly({
|
519 |
req(a3_obj())
|
520 |
if (verbosity > 0) {
|
521 |
+
message(
|
522 |
+
"Rendering dplot3_protein of object with class '",
|
523 |
+
class(a3_obj())[1],
|
524 |
+
"'"
|
525 |
+
)
|
526 |
}
|
527 |
plot(
|
528 |
a3_obj(),
|
|
|
534 |
bg = input$plot.bg, # legend.bg defaults to transparent, this sets paper bg
|
535 |
plot.bg = input$plot.bg,
|
536 |
marker.col = input$marker.col,
|
537 |
+
n.per.row = if (input$n.per.row == "auto") NULL else
|
538 |
+
as.integer(input$n.per.row)
|
539 |
)
|
540 |
}) |> # /dplot3_protein
|
541 |
bindEvent(input$a3_plot_button, input$a3_plot_update_button)
|
|
|
550 |
output$ui_a3_tooltip <- shiny::renderUI({
|
551 |
bslib::tooltip(
|
552 |
trigger = span(
|
553 |
+
"Plot help",
|
554 |
+
bsicons::bs_icon("info-circle", class = "text-info"),
|
555 |
style = "text-align: right;",
|
556 |
class = "rtanihi"
|
557 |
),
|
|
|
579 |
# "Plot settings", bsicons::bs_icon("gear", class = "ms-auto"),
|
580 |
# style = "text-align: right;"
|
581 |
# shiny::selectizeInput("a3.theme", label = "Theme", choices = c("dark", "light"), selected = default_theme),
|
582 |
+
shiny::sliderInput(
|
583 |
+
"marker.size",
|
584 |
+
label = "Marker size",
|
585 |
+
min = 1,
|
586 |
+
max = 100,
|
587 |
+
value = 28
|
588 |
+
),
|
589 |
+
shiny::sliderInput(
|
590 |
+
"font.size",
|
591 |
+
label = "Font size",
|
592 |
+
min = 1,
|
593 |
+
max = 72,
|
594 |
+
value = 18
|
595 |
+
),
|
596 |
+
if (length(a3_obj()$Annotations$PTM) > 0)
|
597 |
+
shiny::sliderInput(
|
598 |
+
"ptm.marker.size",
|
599 |
+
label = "PTM Marker size",
|
600 |
+
min = .1,
|
601 |
+
max = 36,
|
602 |
+
value = 28 / 4.5
|
603 |
+
),
|
604 |
+
if (length(a3_obj()$Annotations$Cleavage_site) > 0)
|
605 |
+
shiny::sliderInput(
|
606 |
+
"clv.marker.size",
|
607 |
+
label = "Cleavage Site Marker size",
|
608 |
+
min = .1,
|
609 |
+
max = 36,
|
610 |
+
value = 28 / 4
|
611 |
+
),
|
612 |
shinyWidgets::colorPickr(
|
613 |
"plot.bg",
|
614 |
label = "Plot background",
|
|
|
644 |
}
|
645 |
}) # /ui_a3_popover
|
646 |
|
|
|
647 |
# UI dplot3_protein ----
|
648 |
output$ui_dplot3_protein <- renderUI({
|
649 |
if (clicked() == FALSE || is.null(a3_obj())) {
|
|
|
673 |
height = jsonedit_height
|
674 |
)
|
675 |
})
|
676 |
+
|
677 |
+
# UI PDB settings ----
|
678 |
+
output$ui_pdb_settings <- renderUI({
|
679 |
+
list(
|
680 |
+
shiny::textInput(
|
681 |
+
inputId = "pdbcode",
|
682 |
+
label = "PDB code",
|
683 |
+
value = "2MZ7"
|
684 |
+
),
|
685 |
+
shiny::selectInput(
|
686 |
+
inputId = "pdbrepresentation",
|
687 |
+
label = "Representation type",
|
688 |
+
choices = c(
|
689 |
+
"cartoon",
|
690 |
+
"ball+stick",
|
691 |
+
"line",
|
692 |
+
"surface",
|
693 |
+
"ribbon"
|
694 |
+
),
|
695 |
+
selected = "cartoon"
|
696 |
+
),
|
697 |
+
shiny::selectInput(
|
698 |
+
inputId = "pdbcolorscheme",
|
699 |
+
label = "Color Scheme",
|
700 |
+
choices = c(
|
701 |
+
"residueindex",
|
702 |
+
"element",
|
703 |
+
"hydrophobicity",
|
704 |
+
"occupancy",
|
705 |
+
"partialcharge"
|
706 |
+
),
|
707 |
+
selected = "residueindex"
|
708 |
+
),
|
709 |
+
shiny::radioButtons(
|
710 |
+
inputId = "pdbanimate",
|
711 |
+
label = hilite1("Animation"),
|
712 |
+
choices = c("Off", "Rock", "Spin"),
|
713 |
+
selected = "Off",
|
714 |
+
inline = TRUE
|
715 |
+
)
|
716 |
+
) # /list
|
717 |
+
})
|
718 |
+
|
719 |
+
# PDB Viewer ----
|
720 |
+
output$pdb <- NGLVieweR::renderNGLVieweR({
|
721 |
+
req(input$pdbcode, input$pdbrepresentation, input$pdbcolorscheme)
|
722 |
+
NGLVieweR::NGLVieweR(input$pdbcode) |>
|
723 |
+
NGLVieweR::addRepresentation(
|
724 |
+
input$pdbrepresentation,
|
725 |
+
param = list(color = input$pdbcolorscheme)
|
726 |
+
) |>
|
727 |
+
NGLVieweR::stageParameters(backgroundColor = "#161616") |>
|
728 |
+
NGLVieweR::setQuality("high") |>
|
729 |
+
NGLVieweR::setFocus(0)
|
730 |
+
})
|
731 |
+
|
732 |
+
observeEvent(input$pdbanimate, {
|
733 |
+
if (input$pdbanimate == "Rock") {
|
734 |
+
NGLVieweR::NGLVieweR_proxy("pdb") |> NGLVieweR::updateRock(TRUE)
|
735 |
+
} else if (input$pdbanimate == "Spin") {
|
736 |
+
NGLVieweR::NGLVieweR_proxy("pdb") |> NGLVieweR::updateSpin(TRUE)
|
737 |
+
} else {
|
738 |
+
NGLVieweR::NGLVieweR_proxy("pdb") |>
|
739 |
+
NGLVieweR::updateRock(FALSE) |>
|
740 |
+
NGLVieweR::updateSpin(FALSE)
|
741 |
+
}
|
742 |
+
})
|
743 |
} # /server
|
744 |
|
745 |
# Shiny app ----
|