feature complete dashboard
This commit is contained in:
parent
6f2cb5bb70
commit
e7725235bb
1 changed files with 118 additions and 25 deletions
143
tb_host/app.R
143
tb_host/app.R
|
@ -18,13 +18,29 @@ library(grid) # for the info box
|
||||||
library(plotly)
|
library(plotly)
|
||||||
library(shinycssloaders)
|
library(shinycssloaders)
|
||||||
library(NGLVieweR)
|
library(NGLVieweR)
|
||||||
|
library(httr)
|
||||||
|
library(readr)
|
||||||
|
library(RCurl)
|
||||||
# make shiny non-stupid
|
# make shiny non-stupid
|
||||||
options(shiny.launch.browser = FALSE) # i am a big girl and can tie my own laces
|
options(shiny.launch.browser = FALSE) # i am a big girl and can tie my own laces
|
||||||
options(shiny.port = 8000) # don't change the port every time
|
options(shiny.port = 8000) # don't change the port every time
|
||||||
options(shiny.host = '0.0.0.0') # This means "listen to all addresses on all interfaces"
|
options(shiny.host = '0.0.0.0') # This means "listen to all addresses on all interfaces"
|
||||||
|
options(DT.options = list(scrollX = TRUE))
|
||||||
|
|
||||||
genes = c("Gene 1", "Gene 2", "Gene 3", "Gene 4", "Gene 5")
|
|
||||||
|
# An "application token" is required here. I generated this one like this:
|
||||||
|
# curl -H "Content-Type: application/json" -d '{"name":"r-data"}' -u <username>:<password> https://git.tunstall.in/api/v1/users/sethp/tokens
|
||||||
|
|
||||||
|
# Gitea access token
|
||||||
|
access_token = read_lines("~/secret-token")
|
||||||
|
|
||||||
|
gene_url = "https://git.tunstall.in/api/v1/repos/tanu/fellowship_dcdf/raw/tb_data_fc/dashboard/list_unique_missense_genes.csv"
|
||||||
|
missense_gene_url = "https://git.tunstall.in/api/v1/repos/tanu/fellowship_dcdf/raw/tb_data_fc/dashboard/missense_genes_params.csv"
|
||||||
|
alphafold_url = "https://alphafold.ebi.ac.uk/files/"
|
||||||
|
|
||||||
|
genes=read_csv(paste0(gene_url,"?token=",access_token))
|
||||||
|
unique_missense_genes = read_delim(paste0(missense_gene_url,"?token=",access_token))
|
||||||
|
#genes = c("Gene 1", "Gene 2", "Gene 3", "Gene 4", "Gene 5")
|
||||||
|
|
||||||
# Define UI for application that draws a histogram
|
# Define UI for application that draws a histogram
|
||||||
ui=dashboardPage(skin="purple",
|
ui=dashboardPage(skin="purple",
|
||||||
|
@ -32,9 +48,12 @@ ui=dashboardPage(skin="purple",
|
||||||
dashboardSidebar(
|
dashboardSidebar(
|
||||||
radioButtons("gene",
|
radioButtons("gene",
|
||||||
label="Gene",
|
label="Gene",
|
||||||
choices = genes,
|
choices = genes$Gene,
|
||||||
selected="Gene 1" # "none" is a value
|
selected="alr" # "alr" is a value
|
||||||
)
|
),
|
||||||
|
actionButton("clear_ngl",
|
||||||
|
"Clear Structures")
|
||||||
|
|
||||||
),
|
),
|
||||||
dashboardBody(
|
dashboardBody(
|
||||||
useShinyjs(),
|
useShinyjs(),
|
||||||
|
@ -80,47 +99,121 @@ server <- function(input, output) {
|
||||||
### NGLViewer ####
|
### NGLViewer ####
|
||||||
# Structure Viewer WebGL/NGLViewR window
|
# Structure Viewer WebGL/NGLViewR window
|
||||||
output$structure <- renderNGLVieweR({
|
output$structure <- renderNGLVieweR({
|
||||||
#ngl_gene=isolate(input$switch_target)
|
selected_gene=input$gene
|
||||||
#ngl_gene=input$switch_target
|
ngl_gene=as.character(genes[genes$Gene==selected_gene,"PDB"])
|
||||||
#ngl_drug=target_map[[ngl_gene]]
|
NGLVieweR(ngl_gene) %>%
|
||||||
#ngl_pdb_file=paste0(load_dir, "Data/", ngl_drug, '/output/depth/', ngl_gene, '_complex.pdb')
|
|
||||||
#print(ngl_pdb_file)
|
|
||||||
#NGLVieweR(ngl_pdb_file) %>%
|
|
||||||
NGLVieweR("3pl1") %>%
|
|
||||||
addRepresentation("cartoon",
|
addRepresentation("cartoon",
|
||||||
param = list(name = "cartoon",
|
param = list(name = "cartoon",
|
||||||
color="tan"
|
#color="tan"
|
||||||
#, colorScheme = "chainid"
|
colorScheme = "bfactor",
|
||||||
|
opacity = 1
|
||||||
)
|
)
|
||||||
) %>%
|
) %>%
|
||||||
stageParameters(backgroundColor = "lightgrey") %>%
|
stageParameters(backgroundColor = "white") %>%
|
||||||
setQuality("high") %>%
|
setQuality("high") %>%
|
||||||
setFocus(0) %>%
|
setFocus(0) %>%
|
||||||
setSpin(FALSE)
|
setSpin(FALSE)
|
||||||
})
|
})
|
||||||
output$af_structure <- renderNGLVieweR({
|
output$af_structure <- renderNGLVieweR({
|
||||||
#ngl_gene=isolate(input$switch_target)
|
selected_af_gene=input$gene
|
||||||
#ngl_gene=input$switch_target
|
ngl_af_gene=as.character(genes[genes$Gene==selected_af_gene,"AF_PDB"])
|
||||||
#ngl_drug=target_map[[ngl_gene]]
|
|
||||||
|
#af_pdb=cat(content(GET(paste0(alphafold_url,"AF-",ngl_af_gene,"-F1-model_v4.pdb")), as="text"), "\n")
|
||||||
|
af_pdb=content(GET(paste0(alphafold_url,"AF-",ngl_af_gene,"-F1-model_v4.pdb")), as="text")
|
||||||
|
#print(af_pdb)
|
||||||
#ngl_pdb_file=paste0(load_dir, "Data/", ngl_drug, '/output/depth/', ngl_gene, '_complex.pdb')
|
#ngl_pdb_file=paste0(load_dir, "Data/", ngl_drug, '/output/depth/', ngl_gene, '_complex.pdb')
|
||||||
#print(ngl_pdb_file)
|
NGLVieweR(af_pdb, format="pdb") %>%
|
||||||
#NGLVieweR(ngl_pdb_file) %>%
|
|
||||||
NGLVieweR("3pl1") %>%
|
|
||||||
addRepresentation("cartoon",
|
addRepresentation("cartoon",
|
||||||
param = list(name = "cartoon",
|
param = list(name = "cartoon",
|
||||||
color="tan"
|
#color="tan"
|
||||||
#, colorScheme = "chainid"
|
colorScheme = "bfactor",
|
||||||
|
opacity = 1
|
||||||
)
|
)
|
||||||
) %>%
|
) %>%
|
||||||
stageParameters(backgroundColor = "lightgrey") %>%
|
stageParameters(backgroundColor = "white") %>%
|
||||||
setQuality("high") %>%
|
setQuality("high") %>%
|
||||||
setFocus(0) %>%
|
setFocus(0) %>%
|
||||||
setSpin(FALSE)
|
setSpin(FALSE)
|
||||||
})
|
})
|
||||||
output$table = DT::renderDataTable(mtcars)
|
|
||||||
|
|
||||||
|
# output$table <- DT::renderDataTable({
|
||||||
|
# selected_gene=input$gene
|
||||||
|
# gene=as.character(genes[genes$Gene==selected_gene,"Gene"])
|
||||||
|
# #unique_missense_genes[unique_missense_genes$gene_name==gene,]
|
||||||
|
# unique_missense_genes
|
||||||
|
# },
|
||||||
|
# selection = "single",
|
||||||
|
# search = list(search="alr"))
|
||||||
|
output$table <- DT::renderDataTable(
|
||||||
|
unique_missense_genes,
|
||||||
|
selection = "single",
|
||||||
|
options=list(
|
||||||
|
search = list(search=as.character(genes[genes$Gene==input$gene,"Gene"]))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
observeEvent(input$table_rows_selected,{
|
||||||
|
#req(length(input$table_row_selected) > 0)
|
||||||
|
mutation = as.character(unique_missense_genes[input$table_rows_selected,"hgvd_p"])
|
||||||
|
# what the absolute FUCK is this mess? I JUST WANT THE MATCH ASDLASJASDASHFKLJASDFK
|
||||||
|
# coming down from the trees was a mistake, and abandoning Perl doubly so.
|
||||||
|
clicked_position = regmatches(mutation, regexpr("[0-9]+", mutation, perl=TRUE))
|
||||||
|
|
||||||
|
# Now update the 3D structure to highlight the clicked thing and then zoom in.
|
||||||
|
|
||||||
|
NGLVieweR_proxy("structure") %>%
|
||||||
|
#addSelection('ball+stick'
|
||||||
|
addSelection('ball+stick'
|
||||||
|
, param = list(
|
||||||
|
name = "Pos"
|
||||||
|
, sele = clicked_position
|
||||||
|
, color = "green"
|
||||||
|
#, colorValue="00ff00"
|
||||||
|
#, colorScheme="element"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
NGLVieweR_proxy("af_structure") %>%
|
||||||
|
#addSelection('ball+stick'
|
||||||
|
addSelection('ball+stick'
|
||||||
|
, param = list(
|
||||||
|
name = "Pos"
|
||||||
|
, sele = clicked_position
|
||||||
|
, color = "green"
|
||||||
|
#, colorValue="00ff00"
|
||||||
|
#, colorScheme="element"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
NGLVieweR_proxy("af_structure") %>% updateZoomMove(
|
||||||
|
center = clicked_position,
|
||||||
|
zoom = clicked_position,
|
||||||
|
duration = 1000, # animation time in ms
|
||||||
|
z_offSet = -1
|
||||||
|
)
|
||||||
|
NGLVieweR_proxy("structure") %>% updateZoomMove(
|
||||||
|
center = clicked_position,
|
||||||
|
zoom = clicked_position,
|
||||||
|
duration = 1000, # animation time in ms
|
||||||
|
z_offSet = -1
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# output$debug <- renderPrint({
|
||||||
|
# print(c(mutation, clicked_position))
|
||||||
|
# })
|
||||||
|
})
|
||||||
|
observeEvent(
|
||||||
|
{
|
||||||
|
input$clear_ngl
|
||||||
|
}, {
|
||||||
|
NGLVieweR_proxy("structure") %>%
|
||||||
|
removeSelection("Pos")
|
||||||
|
NGLVieweR_proxy("af_structure") %>%
|
||||||
|
removeSelection("Pos")
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run the application
|
# Run the application
|
||||||
shinyApp(ui = ui, server = server)
|
shinyApp(ui = ui, server = server)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue