shuffle everything

This commit is contained in:
Tanushree Tunstall 2022-12-12 10:35:41 +00:00
parent 8c96f1a317
commit 48d9e88bc9
3 changed files with 60 additions and 16 deletions

29
global.R Normal file
View file

@ -0,0 +1,29 @@
library(dplyr)
library(DT)
library(ggplot2)
library(grid) # for the info box
library(plotly)
library(NGLVieweR)
library(httr)
library(readr)
library(RCurl)
# make shiny non-stupid
#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.host = '0.0.0.0') # This means "listen to all addresses on all interfaces"
#options(DT.options = list(scrollX = TRUE))
# 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/data_dashboard/list_unique_missense_genes.csv"
missense_gene_url = "https://git.tunstall.in/api/v1/repos/tanu/fellowship_dcdf/raw/tb_data_fc/data_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))

View file

@ -83,11 +83,13 @@ shinyServer(function(input, output) {
observeEvent(input$table_rows_selected,{
#req(length(input$table_row_selected) > 0)
mutation_pdb = as.character(unique_missense_genes[input$table_rows_selected,"position_pdb"])
mutation_af = as.character(unique_missense_genes[input$table_rows_selected,"position_af"])
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))
#clicked_position = regmatches(mutation, regexpr("[0-9]+", mutation, perl=TRUE))
# Now update the 3D structure to highlight the clicked thing and then zoom in.
@ -96,7 +98,7 @@ shinyServer(function(input, output) {
addSelection('spacefill'
, param = list(
name = "Pos"
, sele = trimws(paste0(clicked_position,':', chain))
, sele = trimws(paste0(mutation_pdb,':', chain))
, color = "red"
#, colorValue="00ff00"
#, colorScheme="element"
@ -107,7 +109,7 @@ shinyServer(function(input, output) {
addSelection('spacefill'
, param = list(
name = "Pos"
, sele = clicked_position
, sele = mutation_af
, color = "red"
#, colorValue="00ff00"
#, colorScheme="element"
@ -115,20 +117,20 @@ shinyServer(function(input, output) {
)
NGLVieweR_proxy("af_structure") %>% updateZoomMove(
center = clicked_position,
zoom = clicked_position,
center = mutation_af,
zoom = mutation_af,
duration = 1000, # animation time in ms
z_offSet = -1
)
NGLVieweR_proxy("structure") %>% updateZoomMove(
center = trimws(paste0(clicked_position,':', chain)),
zoom = trimws(paste0(clicked_position,':', chain)),
center = trimws(paste0(mutation_pdb,':', chain)),
zoom = trimws(paste0(mutation_pdb,':', chain)),
duration = 1000, # animation time in ms
z_offSet = -1
)
output$information <- renderUI({
selected_gene=input$gene
HTML(paste0("<strong>Mutation: </strong>", as.character(unique_missense_genes[input$table_rows_selected,"mutationinformation"]),"<br/>",
HTML(paste0("<strong>Mutation: </strong>", as.character(unique_missense_genes[input$table_rows_selected,"mutationinformation_pdb"]),"<br/>",
"<strong>PDB ID: </strong>", as.character(genes[genes$Gene==selected_gene,"PDB"]),"<br/>",
"<strong>AlphaFold ID: </strong>", as.character(genes[genes$Gene==selected_gene,"AF_PDB"]), "<br/>",
"<strong>Ligand Distance: </strong>", as.character(unique_missense_genes[input$table_rows_selected,"ligand_distance"]), "<br/>",
@ -186,7 +188,21 @@ shinyServer(function(input, output) {
" and (",
paste0(
apply(
unique_missense_genes[unique_missense_genes$gene_name == gene,c("position","chain")],
unique_missense_genes[unique_missense_genes$gene_name == gene,c("position_pdb","chain")],
1,
function(x){
paste0(trimws(x[1])
)}
),
collapse=", "
), ")"
)
mutations_af = paste0(":",
as.matrix(unique_missense_genes[unique_missense_genes$gene_name == gene,c("chain")])[1],
" and (",
paste0(
apply(
unique_missense_genes[unique_missense_genes$gene_name == gene,c("position_af","chain")],
1,
function(x){
paste0(trimws(x[1])
@ -207,7 +223,7 @@ shinyServer(function(input, output) {
opacity = 0.2
)
) %>%
addSelection(type="ball+stick", #spacefill
addSelection(type="spacefill", #spacefill
param = list(name = "all_mutations",
color="orange",
sele = mutations
@ -225,14 +241,14 @@ shinyServer(function(input, output) {
opacity = 0.2
)
) %>%
addSelection(type="ball+stick", #spacefill
addSelection(type="spacefill", #spacefill
param = list(name = "all_mutations",
color="orange",
sele = mutations
sele = mutations_af
#colorScheme = "bfactor",
#opacity = 1
)
)
})
}
)
})

1
ui.R
View file

@ -12,7 +12,6 @@ library(NGLVieweR)
library(httr)
library(readr)
library(RCurl)
dashboardPage(skin="purple",
dashboardHeader(title="Tuberculosis Host"),
dashboardSidebar(