msa dashboard
This commit is contained in:
parent
88aaf56729
commit
3037d6e3ef
6 changed files with 643 additions and 0 deletions
301
msa/global.R
Normal file
301
msa/global.R
Normal file
|
@ -0,0 +1,301 @@
|
|||
library(shinycssloaders)
|
||||
library(DT)
|
||||
library(NGLVieweR)
|
||||
library(hash)
|
||||
|
||||
load_target_globals=function(target){
|
||||
cat(paste0("Reloading Target: ", target))
|
||||
source(paste0("/srv/shiny-server/git/LSHTM_analysis/config/", target, ".R")) # load per-target config file
|
||||
|
||||
invisible(assign(paste0(target, "_merged_df3"), read.csv(paste0("/srv/shiny-server/git/Misc/shiny_dashboard/data/",target,"-merged_df3.csv")), envir = .GlobalEnv))
|
||||
invisible(assign(paste0(target, "_merged_df2"), read.csv(paste0("/srv/shiny-server/git/Misc/shiny_dashboard/data/",target,"-merged_df2.csv")), envir = .GlobalEnv))
|
||||
invisible(assign(paste0(target, "_corr_df_m3_f"), read.csv(paste0("/srv/shiny-server/git/Misc/shiny_dashboard/data/",target,"-corr_df_m3_f.csv")), envir = .GlobalEnv))
|
||||
invisible(assign(paste0(target, "_lin_lf"), read.csv(paste0("/srv/shiny-server/git/Misc/shiny_dashboard/data/",target,"-lin_lf.csv")), envir = .GlobalEnv))
|
||||
invisible(assign(paste0(target, "_lin_wf"), read.csv(paste0("/srv/shiny-server/git/Misc/shiny_dashboard/data/",target,"-lin_wf.csv")), envir = .GlobalEnv))
|
||||
lapply(
|
||||
c(
|
||||
"duet",
|
||||
"mcsm_lig",
|
||||
"foldx",
|
||||
"deepddg",
|
||||
"dynamut2",
|
||||
"consurf",
|
||||
"snap2",
|
||||
"provean",
|
||||
"dist_gen",
|
||||
"mcsm_ppi2"#,
|
||||
#"mcsm_na"
|
||||
), function(x){
|
||||
wf_filename=paste0("/srv/shiny-server/git/Misc/shiny_dashboard/data/", tolower(gene), "-wf_", x ,".csv")
|
||||
wf_var=paste0("wf_",x)
|
||||
if (file.exists(wf_filename)){
|
||||
invisible(assign(wf_var,read.csv(wf_filename), envir = .GlobalEnv)) # FILTH
|
||||
}
|
||||
lf_filename=paste0("/srv/shiny-server/git/Misc/shiny_dashboard/data/", tolower(gene), "-lf_", x ,".csv")
|
||||
lf_var=paste0(target, "_lf_",x)
|
||||
if (file.exists(lf_filename)){
|
||||
invisible(assign(lf_var,read.csv(lf_filename), envir = .GlobalEnv)) # FILTH
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
# populate target-specific *_unified_msa vars
|
||||
load_msa_global=function(gene){
|
||||
drug=target_map[[gene]]
|
||||
in_filename_msa = paste0(tolower(gene), "_msa.csv")
|
||||
infile_msa = paste0("/srv/shiny-server/git/Data/", drug, "/output/", in_filename_msa)
|
||||
print(infile_msa)
|
||||
msa1 = read.csv(infile_msa, header = F)
|
||||
msa_seq = msa1$V1
|
||||
|
||||
infile_fasta = paste0("/srv/shiny-server/git/Data/", drug, "/input/", tolower(gene), "2_f2.fasta")
|
||||
print(infile_fasta)
|
||||
msa2 = read.csv(infile_fasta, header = F)
|
||||
wt_seq = msa2$V1
|
||||
|
||||
target_name=paste0(gene, '_unified_msa')
|
||||
#print(target_name)
|
||||
invisible(assign(target_name, list(msa_seq = msa_seq, wt_seq = wt_seq), envir = .GlobalEnv))
|
||||
}
|
||||
|
||||
#### Local Functions ####
|
||||
# Generate a conditionalPanel() for a given graph function and sidebar name combination
|
||||
generate_conditionalPanel = function(tab_name, plot_function, plot_df){
|
||||
# e.g.: list("lin_count_bp_diversity", "Lineage diversity count")
|
||||
cond=paste0("input.sidebar == '", tab_name, "'")
|
||||
conditionalPanel(condition=cond, box(
|
||||
title=tab_name
|
||||
, status = "info"
|
||||
, width=NULL
|
||||
, plotOutput(plot_function
|
||||
, click = "plot_click") %>% withSpinner(color="#0dc5c1")
|
||||
# , plotOutput(plot_function, click = "plot_click")
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
# FIXME: passing in the per-plot params is broken
|
||||
lin_sc=function(x, all_lineages = F, ...){
|
||||
lf_var = get(paste0(x,"_lin_lf"))
|
||||
wf_var = get(paste0(x,"_lin_wf"))
|
||||
cowplot::plot_grid(lin_count_bp_diversity(wf_var, all_lineages, ...), lin_count_bp(lf_var, all_lineages, ...))
|
||||
}
|
||||
|
||||
|
||||
options(shiny.port = 8000)
|
||||
options(shiny.host = '0.0.0.0') # This means "listen to all addresses on all interfaces"
|
||||
options(shiny.launch.browser = FALSE)
|
||||
options(width=120)
|
||||
options(DT.options = list(scrollX = TRUE))
|
||||
|
||||
|
||||
################ STATIC GLOBALS ONLY ##############
|
||||
# never quite sure where "outdir" gets set :-|
|
||||
|
||||
# using dataframes instead of lists lets us avoid use of map()
|
||||
plot_functions_df=data.frame(
|
||||
tab_name=c(
|
||||
"LogoP SNP",
|
||||
"Lineage Sample Count",
|
||||
"Site SNP count",
|
||||
"Stability SNP by site",
|
||||
"DM OM Plots",
|
||||
"Correlation",
|
||||
"Lineage Distribution",
|
||||
"Consurf",
|
||||
"LogoP OR",
|
||||
"LogoP ED"
|
||||
),
|
||||
plot_function=c(
|
||||
"LogoPlotSnps",
|
||||
"lin_sc",
|
||||
"site_snp_count_bp",
|
||||
"bp_stability_hmap",
|
||||
"lf_bp2",
|
||||
"my_corr_pairs",
|
||||
"lineage_distP",
|
||||
"wideP_consurf3",
|
||||
"LogoPlotCustomH",
|
||||
"LogoPlotMSA"
|
||||
),
|
||||
plot_df=c(
|
||||
"mutable_df3" ,
|
||||
"lin_lf",
|
||||
"mutable_df3",
|
||||
"merged_df3" ,
|
||||
"lf_duet" ,
|
||||
"corr_df_m3_f",
|
||||
"merged_df2",
|
||||
"merged_df3",
|
||||
"merged_df2",
|
||||
"unified_msa"
|
||||
)
|
||||
)
|
||||
|
||||
stability_boxes_df=data.frame(
|
||||
outcome_colname=c("duet_outcome",
|
||||
"foldx_outcome",
|
||||
"deepddg_outcome",
|
||||
"ddg_dynamut2_outcome",
|
||||
"mcsm_na_outcome",
|
||||
"mcsm_ppi2_outcome",
|
||||
"snap2_outcome",
|
||||
"consurf_outcome",
|
||||
"avg_stability_outcome"),
|
||||
stability_type=c(
|
||||
"DUET",
|
||||
"FoldX",
|
||||
"DeepDDG",
|
||||
"Dynamut2",
|
||||
"mCSM-NA",
|
||||
"mCSM-ppi2",
|
||||
"SNAP2",
|
||||
"Consurf",
|
||||
"Average"
|
||||
),
|
||||
stability_colname=c(
|
||||
"duet_scaled",
|
||||
"foldx_scaled",
|
||||
"deepddg_scaled",
|
||||
"ddg_dynamut2_scaled",
|
||||
"mcsm_na_scaled",
|
||||
"mcsm_ppi2_scaled",
|
||||
"snap2_scaled",
|
||||
"consurf_scaled",
|
||||
"avg_stability_scaled"
|
||||
)
|
||||
)
|
||||
|
||||
table_columns = c(
|
||||
"position",
|
||||
"mutationinformation",
|
||||
"sensitivity",
|
||||
"ligand_distance",
|
||||
"avg_lig_affinity",
|
||||
"avg_lig_affinity_outcome",
|
||||
"avg_stability",
|
||||
"avg_stability_outcome",
|
||||
"or_mychisq",
|
||||
"maf",
|
||||
"snap2_outcome",
|
||||
"consurf_outcome",
|
||||
"provean_outcome",
|
||||
"rsa",
|
||||
"kd_values" ,
|
||||
"rd_values"
|
||||
)
|
||||
|
||||
logoPlotSchemes <- list("chemistry"
|
||||
, "taylor"
|
||||
, "hydrophobicity"
|
||||
, "clustalx")
|
||||
dm_om_methods = c("DUET ΔΔG"
|
||||
, "Consurf"
|
||||
, "Deepddg ΔΔG"
|
||||
, "Dynamut2 ΔΔG"
|
||||
, "FoldX ΔΔG"
|
||||
, "Ligand affinity (log fold change)"
|
||||
, "mCSM-NA affinity ΔΔG"
|
||||
, "SNAP2")
|
||||
dm_om_map = hash(c(
|
||||
"DUET ΔΔG"
|
||||
, "Consurf"
|
||||
, "Deepddg ΔΔG"
|
||||
, "Dynamut2 ΔΔG"
|
||||
, "FoldX ΔΔG"
|
||||
, "Ligand affinity (log fold change)"
|
||||
, "mCSM-NA affinity ΔΔG"
|
||||
, "SNAP2"
|
||||
), c(
|
||||
"lf_duet"
|
||||
,"lf_consurf"
|
||||
,"lf_deepddg"
|
||||
,"lf_dynamut2"
|
||||
,"lf_foldx"
|
||||
,"lf_mcsm_lig"
|
||||
,"lf_mcsm_na"
|
||||
,"lf_snap2"
|
||||
)
|
||||
)
|
||||
#### target_map: handy gene/drug mapping hash ####
|
||||
target_map = hash(
|
||||
c(
|
||||
"alr",
|
||||
"gid",
|
||||
"embb",
|
||||
"pnca",
|
||||
"rpob",
|
||||
"katg"),
|
||||
c(
|
||||
"cycloserine",
|
||||
"streptomycin",
|
||||
"ethambutol",
|
||||
"pyrazinamide",
|
||||
"rifampicin",
|
||||
"isoniazid")
|
||||
)
|
||||
|
||||
# load E V E R Y T H I N G
|
||||
lapply(c(
|
||||
"alr",
|
||||
"embb",
|
||||
"gid",
|
||||
"katg",
|
||||
"pnca",
|
||||
"rpob"
|
||||
),function(x){
|
||||
invisible(load_target_globals(x))
|
||||
invisible(load_msa_global(x)) # turn off to speed up start time at the expense of "LogoP ED"
|
||||
}
|
||||
)
|
||||
|
||||
consurf_palette1 = c("0" = "yellow2"
|
||||
, "1" = "cyan1"
|
||||
, "2" = "steelblue2"
|
||||
, "3" = "cadetblue2"
|
||||
, "4" = "paleturquoise2"
|
||||
, "5" = "thistle3"
|
||||
, "6" = "thistle2"
|
||||
, "7" = "plum2"
|
||||
, "8" = "maroon"
|
||||
, "9" = "violetred2")
|
||||
|
||||
consurf_palette2 = c("0" = "yellow2"
|
||||
, "1" = "forestgreen"
|
||||
, "2" = "seagreen3"
|
||||
, "3" = "palegreen1"
|
||||
, "4" = "darkseagreen2"
|
||||
, "5" = "thistle3"
|
||||
, "6" = "lightpink1"
|
||||
, "7" = "orchid3"
|
||||
, "8" = "orchid4"
|
||||
, "9" = "darkorchid4")
|
||||
|
||||
# decreasing levels mess legend
|
||||
# consurf_colours_LEVEL = c(
|
||||
# "0" = rgb(1.00,1.00,0.59)
|
||||
# , "9" = rgb(0.63,0.16,0.37)
|
||||
# , "8" = rgb(0.94,0.49,0.67)
|
||||
# , "7" = rgb(0.98,0.78,0.86)
|
||||
# , "6" = rgb(0.98,0.92,0.96)
|
||||
# , "5" = rgb(1.00,1.00,1.00)
|
||||
# , "4" = rgb(0.84,0.94,0.94)
|
||||
# , "3" = rgb(0.65,0.86,0.90)
|
||||
# , "2" = rgb(0.29,0.69,0.75)
|
||||
# , "1" = rgb(0.04,0.49,0.51)
|
||||
# )
|
||||
|
||||
consurf_colours = c(
|
||||
"0" = rgb(1.00,1.00,0.59)
|
||||
, "1" = rgb(0.04,0.49,0.51)
|
||||
, "2" = rgb(0.29,0.69,0.75)
|
||||
, "3" = rgb(0.65,0.86,0.90)
|
||||
, "4" = rgb(0.84,0.94,0.94)
|
||||
, "5" = rgb(1.00,1.00,1.00)
|
||||
, "6" = rgb(0.98,0.92,0.96)
|
||||
, "7" = rgb(0.98,0.78,0.86)
|
||||
, "8" = rgb(0.94,0.49,0.67)
|
||||
, "9" = rgb(0.63,0.16,0.37)
|
||||
)
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue