From 568fef38ae98a941794dffaf705befa3587300f7 Mon Sep 17 00:00:00 2001 From: Tanushree Tunstall Date: Sun, 11 Dec 2022 19:26:29 +0000 Subject: [PATCH] aaaaaaa --- tb_host/app.R | 131 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 115 insertions(+), 16 deletions(-) diff --git a/tb_host/app.R b/tb_host/app.R index 05d98b8..b114665 100644 --- a/tb_host/app.R +++ b/tb_host/app.R @@ -52,23 +52,34 @@ ui=dashboardPage(skin="purple", selected="alr" # "alr" is a value ), actionButton("clear_ngl", - "Clear Structures") - + "Reset Structures"), + actionButton("all_mutations", + "All Mutations") ), dashboardBody( useShinyjs(), fluidRow( box( title="Crystallised Structure", + width=5, column( NGLVieweROutput("structure"), width=12 + ) + ), + box( + title="AlphaFold Structure", + width=5, + column( + NGLVieweROutput("af_structure"), + width=12 ) ), box( - title="AlphaFold Structure", + title="Mutation Information", + width=2, column( - NGLVieweROutput("af_structure"), + htmlOutput("information"), width=12 ) ) @@ -104,8 +115,8 @@ server <- function(input, output) { NGLVieweR(ngl_gene) %>% addRepresentation("cartoon", param = list(name = "cartoon", - #color="tan" - colorScheme = "bfactor", + color="tan", + #colorScheme = "bfactor", opacity = 1 ) ) %>% @@ -155,6 +166,7 @@ server <- function(input, output) { observeEvent(input$table_rows_selected,{ #req(length(input$table_row_selected) > 0) mutation = as.character(unique_missense_genes[input$table_rows_selected,"hgvd_p"]) + chain = as.character(unique_missense_genes[input$table_rows_selected,"chain"]) # 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)) @@ -163,22 +175,22 @@ server <- function(input, output) { NGLVieweR_proxy("structure") %>% #addSelection('ball+stick' - addSelection('ball+stick' + addSelection('spacefill' , param = list( name = "Pos" - , sele = clicked_position - , color = "green" + , sele = trimws(paste0(clicked_position,':', chain)) + , color = "red" #, colorValue="00ff00" #, colorScheme="element" ) ) NGLVieweR_proxy("af_structure") %>% #addSelection('ball+stick' - addSelection('ball+stick' + addSelection('spacefill' , param = list( name = "Pos" , sele = clicked_position - , color = "green" + , color = "red" #, colorValue="00ff00" #, colorScheme="element" ) @@ -191,12 +203,37 @@ server <- function(input, output) { z_offSet = -1 ) NGLVieweR_proxy("structure") %>% updateZoomMove( - center = clicked_position, - zoom = clicked_position, + center = trimws(paste0(clicked_position,':', chain)), + zoom = trimws(paste0(clicked_position,':', chain)), duration = 1000, # animation time in ms z_offSet = -1 ) - + output$information <- renderUI({ + selected_gene=input$gene + HTML(paste0("Mutation: ", as.character(unique_missense_genes[input$table_rows_selected,"mutationinformation"]),"
", + "PDB ID: ", as.character(genes[genes$Gene==selected_gene,"PDB"]),"
", + "AlphaFold ID: ", as.character(genes[genes$Gene==selected_gene,"AF_PDB"]), "
", + "Ligand Distance: ", as.character(unique_missense_genes[input$table_rows_selected,"ligand_distance"]), "
", + "mCSM Lig: ", as.character(unique_missense_genes[input$table_rows_selected,"mcsm_lig"]), "
", + "mmCSM Lig: ", as.character(unique_missense_genes[input$table_rows_selected,"mmcsm_lig"]), "
", + "mCSM DUET: ", as.character(unique_missense_genes[input$table_rows_selected,"ddg_duet"]), "
", + "FoldX: ", as.character(unique_missense_genes[input$table_rows_selected,"ddg_foldx"]), "
", + "DeepDDG: ", as.character(unique_missense_genes[input$table_rows_selected,"ddg_deepddg"]), "
", + "Dynamut2: ", as.character(unique_missense_genes[input$table_rows_selected,"ddg_dynamut2"]), "
", + "mCSM PPI2: ", as.character(unique_missense_genes[input$table_rows_selected,"mcsm_ppi2_affinity"]), "
", + "Interface Distance: ", as.character(unique_missense_genes[input$table_rows_selected,"interface_dist"]), "
", + "mCSM NA: ", as.character(unique_missense_genes[input$table_rows_selected,"mcsm_na_affinity"]), "
", + "Consurf: ", as.character(unique_missense_genes[input$table_rows_selected,"consurf_score"]), "
", + #"SNAP2: ", as.character(unique_missense_genes[input$table_rows_selected,"snap2_score"]), "
", + "SNAP2 Outcome: ", as.character(unique_missense_genes[input$table_rows_selected,"snap2_outcome"]), "
", + #"PROVEAN: ", as.character(unique_missense_genes[input$table_rows_selected,"provean_score"]), "
", + "PROVEAN Outcome: ", as.character(unique_missense_genes[input$table_rows_selected,"provean_outcome"]), "
", + "RSA: ", as.character(unique_missense_genes[input$table_rows_selected,"rsa"]), "
", + "Residue Depth: ", as.character(unique_missense_genes[input$table_rows_selected,"rd_values"]), "
" + ) + ) + + }) # output$debug <- renderPrint({ # print(c(mutation, clicked_position)) @@ -207,9 +244,71 @@ server <- function(input, output) { input$clear_ngl }, { NGLVieweR_proxy("structure") %>% - removeSelection("Pos") + removeSelection("Pos") %>% + removeSelection("all_mutations_surface") %>% + updateVisibility("cartoon", TRUE) %>% + removeSelection("all_mutations") NGLVieweR_proxy("af_structure") %>% - removeSelection("Pos") + removeSelection("Pos") %>% + removeSelection("all_mutations_surface") %>% + updateVisibility("cartoon", TRUE) %>% + removeSelection("all_mutations") + }) + # add a surface representation and highlight all mutations on it + observeEvent( + { + input$all_mutations + }, { + gene = input$gene + mutations = paste0( + apply( + unique_missense_genes[unique_missense_genes$gene_name == gene,c("position","chain")], + 1, + function(x){ + paste0(trimws(x[1]), + ":", + trimws(x[2]) + )} + ), + collapse="," + ) + print(mutations) + + + NGLVieweR_proxy("structure") %>% + updateVisibility("cartoon", FALSE) %>% + addSelection(type="surface", + param = list(name = "all_mutations_surface", + sele = "all", + color="tan", + opacity = 0.2 + ) + ) %>% + addSelection(type="surface", + param = list(name = "all_mutations", + color="green", + sele = "20:A, 22:A, 157:A" + #colorScheme = "bfactor", + #opacity = 1 + ) + ) + # addSelection('spacefill', + # param = list( + # name = "Pos", + # sele = "4:A,20:A,22:A,157:A,344:A", + # color = "red", + # opacity=0.1 + # ) + # ) + # NGLVieweR_proxy("af_structure") %>% + # addSelection('ball+stick', + # param = list( + # name = "Pos", + # sele = mutations, + # color = "red", + # opacity=0.1 + # ) + # ) }) }