msa dash
This commit is contained in:
parent
75ec1419d7
commit
904798bb60
2 changed files with 38 additions and 90 deletions
77
msa/global.R
77
msa/global.R
|
@ -42,8 +42,13 @@ source(paste0(load_dir,"LSHTM_analysis/scripts/Header_TT.R"))
|
||||||
load_target_globals=function(target){
|
load_target_globals=function(target){
|
||||||
cat(paste0("Reloading Target: ", target))
|
cat(paste0("Reloading Target: ", target))
|
||||||
source(paste0(load_dir, "LSHTM_analysis/config/", target, ".R")) # load per-target config file
|
source(paste0(load_dir, "LSHTM_analysis/config/", target, ".R")) # load per-target config file
|
||||||
|
invisible(assign(paste0(target, "_aa_pos_drug"), aa_pos_drug, envir = .GlobalEnv))
|
||||||
|
invisible(assign(paste0(target, "_active_aa_pos"), active_aa_pos, envir = .GlobalEnv))
|
||||||
|
invisible(assign(paste0(target, "_aa_pos_lig1"), aa_pos_lig1, envir = .GlobalEnv))
|
||||||
|
invisible(assign(paste0(target, "_aa_pos_lig2"), aa_pos_lig2, envir = .GlobalEnv))
|
||||||
|
invisible(assign(paste0(target, "_aa_pos_lig3"), aa_pos_lig3, envir = .GlobalEnv))
|
||||||
invisible(assign(paste0(target, "_merged_df3"), read.csv(paste0(load_dir, "Misc/shiny_dashboard/data/",target,"-merged_df3.csv")), envir = .GlobalEnv))
|
invisible(assign(paste0(target, "_merged_df3"), read.csv(paste0(load_dir, "Misc/shiny_dashboard/data/",target,"-merged_df3.csv")), envir = .GlobalEnv))
|
||||||
|
|
||||||
invisible(assign(paste0(target, "_merged_df2"), read.csv(paste0(load_dir, "Misc/shiny_dashboard/data/",target,"-merged_df2.csv")), envir = .GlobalEnv))
|
invisible(assign(paste0(target, "_merged_df2"), read.csv(paste0(load_dir, "Misc/shiny_dashboard/data/",target,"-merged_df2.csv")), envir = .GlobalEnv))
|
||||||
invisible(assign(paste0(target, "_corr_df_m3_f"), read.csv(paste0(load_dir, "Misc/shiny_dashboard/data/",target,"-corr_df_m3_f.csv")), envir = .GlobalEnv))
|
invisible(assign(paste0(target, "_corr_df_m3_f"), read.csv(paste0(load_dir, "Misc/shiny_dashboard/data/",target,"-corr_df_m3_f.csv")), envir = .GlobalEnv))
|
||||||
invisible(assign(paste0(target, "_lin_lf"), read.csv(paste0(load_dir, "Misc/shiny_dashboard/data/",target,"-lin_lf.csv")), envir = .GlobalEnv))
|
invisible(assign(paste0(target, "_lin_lf"), read.csv(paste0(load_dir, "Misc/shiny_dashboard/data/",target,"-lin_lf.csv")), envir = .GlobalEnv))
|
||||||
|
@ -96,24 +101,7 @@ load_msa_global=function(gene){
|
||||||
|
|
||||||
#### Local Functions ####
|
#### Local Functions ####
|
||||||
|
|
||||||
|
|
||||||
# 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 ##############
|
################ STATIC GLOBALS ONLY ##############
|
||||||
# never quite sure where "outdir" gets set :-|
|
|
||||||
|
|
||||||
# using dataframes instead of lists lets us avoid use of map()
|
# using dataframes instead of lists lets us avoid use of map()
|
||||||
plot_functions_df=data.frame(
|
plot_functions_df=data.frame(
|
||||||
|
@ -254,6 +242,13 @@ lapply(c(
|
||||||
|
|
||||||
#### Shiny UI #####
|
#### Shiny UI #####
|
||||||
if(interactive()){
|
if(interactive()){
|
||||||
|
|
||||||
|
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))
|
||||||
|
|
||||||
ui <- dashboardPage(
|
ui <- dashboardPage(
|
||||||
#dashboardHeader(title = paste0(gene, "/", drug)),
|
#dashboardHeader(title = paste0(gene, "/", drug)),
|
||||||
dashboardHeader(title = "Sequence Alignment"),
|
dashboardHeader(title = "Sequence Alignment"),
|
||||||
|
@ -328,6 +323,7 @@ if(interactive()){
|
||||||
# C O M P A T I B I L I T Y
|
# C O M P A T I B I L I T Y
|
||||||
#gene=input$switch_target
|
#gene=input$switch_target
|
||||||
#drug=target_map[[gene]]
|
#drug=target_map[[gene]]
|
||||||
|
target = input$switch_target
|
||||||
merged_df3=cbind(get(paste0(input$switch_target, '_merged_df3')))
|
merged_df3=cbind(get(paste0(input$switch_target, '_merged_df3')))
|
||||||
|
|
||||||
position_max=max(merged_df3[['position']])
|
position_max=max(merged_df3[['position']])
|
||||||
|
@ -341,7 +337,6 @@ if(interactive()){
|
||||||
# merged_df3$n=NULL
|
# merged_df3$n=NULL
|
||||||
#
|
#
|
||||||
mutable_df3 = cbind(merged_df3)
|
mutable_df3 = cbind(merged_df3)
|
||||||
unified_msa = get(paste0(input$switch_target, '_unified_msa'))
|
|
||||||
#
|
#
|
||||||
# # re-sort the dataframe according to position count
|
# # re-sort the dataframe according to position count
|
||||||
sorted_df = cbind(merged_df3)
|
sorted_df = cbind(merged_df3)
|
||||||
|
@ -366,13 +361,7 @@ if(interactive()){
|
||||||
|
|
||||||
#input$stability_snp_param
|
#input$stability_snp_param
|
||||||
|
|
||||||
updateSliderInput(
|
|
||||||
session,
|
|
||||||
"display_position_range",
|
|
||||||
min = position_min,
|
|
||||||
max = position_max
|
|
||||||
#, value = c(position_min, position_min+150)
|
|
||||||
)
|
|
||||||
updateSliderInput(
|
updateSliderInput(
|
||||||
session,
|
session,
|
||||||
"display_position_full_range",
|
"display_position_full_range",
|
||||||
|
@ -380,43 +369,23 @@ if(interactive()){
|
||||||
max = position_max #,
|
max = position_max #,
|
||||||
# value = c(position_min, position_min+150)
|
# value = c(position_min, position_min+150)
|
||||||
)
|
)
|
||||||
updateNumericInput(session, "selected_logop_snp_position", min = position_min, max = position_max, value = position_min)
|
|
||||||
updateNumericInput(session, "selected_logop_ed_position", min = position_min, max = position_max, value = position_min)
|
|
||||||
updateNumericInput(session, "corr_lig_dist", min = min_ligand_distance, max = max_ligand_distance, value = min_ligand_distance)
|
|
||||||
|
|
||||||
stability_colname = stability_boxes_df[stability_boxes_df$stability_type==input$stability_snp_param,"stability_colname"]
|
|
||||||
outcome_colname = stability_boxes_df[stability_boxes_df$stability_type==input$stability_snp_param,"outcome_colname"]
|
|
||||||
|
|
||||||
display_position_range = input$display_position_range
|
|
||||||
plot_min=display_position_range[1]
|
|
||||||
plot_max=display_position_range[2]
|
|
||||||
|
|
||||||
display_position_full_range = input$display_position_full_range
|
display_position_full_range = input$display_position_full_range
|
||||||
full_range_min=display_position_full_range[1]
|
full_range_min=display_position_full_range[1]
|
||||||
full_range_max=display_position_full_range[2]
|
full_range_max=display_position_full_range[2]
|
||||||
|
|
||||||
logoplot_colour_scheme = input$logoplot_colour_scheme
|
logoplot_colour_scheme = input$logoplot_colour_scheme
|
||||||
omit_snp_count = input$omit_snp_count
|
|
||||||
|
|
||||||
print(paste0('Plotting positions between: ', plot_min, ' and ', plot_max))
|
|
||||||
|
|
||||||
subset_mutable_df3=mutable_df3[(mutable_df3$position>=plot_min & mutable_df3$position <=plot_max),]
|
|
||||||
|
|
||||||
subset_mutable_df3=mutable_df3[(mutable_df3$position>=plot_min & mutable_df3$position <=plot_max),]
|
|
||||||
subset_sorted_df=sorted_df[(sorted_df$position>=plot_min & sorted_df$position <=plot_max),]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### LogoPlotMSA/Logo Plot ED ####
|
#### LogoPlotMSA/Logo Plot ED ####
|
||||||
output$LogoPlotMSA = renderPlot(
|
output$LogoPlotMSA = renderPlot(
|
||||||
LogoPlotMSA(target=input$switch_target,
|
LogoPlotMSA(target=target,
|
||||||
plot_positions=full_range_min:full_range_max,
|
plot_positions=full_range_min:full_range_max,
|
||||||
my_logo_col = logoplot_colour_scheme,
|
my_logo_col = logoplot_colour_scheme,
|
||||||
aa_pos_drug = aa_pos_drug,
|
aa_pos_drug = paste0(target,"_aa_pos_drug"),
|
||||||
active_aa_pos = active_aa_pos,
|
active_aa_pos = paste0(target,"_active_aa_pos"),
|
||||||
aa_pos_lig1 = aa_pos_lig1,
|
aa_pos_lig1 = paste0(target,"_aa_pos_lig1"),
|
||||||
aa_pos_lig2 = aa_pos_lig2,
|
aa_pos_lig2 = paste0(target,"_aa_pos_lig2"),
|
||||||
aa_pos_lig3 = aa_pos_lig3
|
aa_pos_lig3 = paste0(target,"_aa_pos_lig3")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
51
msa/server.R
51
msa/server.R
|
@ -9,6 +9,7 @@ function(input, output, session) {
|
||||||
# C O M P A T I B I L I T Y
|
# C O M P A T I B I L I T Y
|
||||||
#gene=input$switch_target
|
#gene=input$switch_target
|
||||||
#drug=target_map[[gene]]
|
#drug=target_map[[gene]]
|
||||||
|
target = input$switch_target
|
||||||
merged_df3=cbind(get(paste0(input$switch_target, '_merged_df3')))
|
merged_df3=cbind(get(paste0(input$switch_target, '_merged_df3')))
|
||||||
|
|
||||||
position_max=max(merged_df3[['position']])
|
position_max=max(merged_df3[['position']])
|
||||||
|
@ -22,15 +23,14 @@ function(input, output, session) {
|
||||||
# merged_df3$n=NULL
|
# merged_df3$n=NULL
|
||||||
#
|
#
|
||||||
mutable_df3 = cbind(merged_df3)
|
mutable_df3 = cbind(merged_df3)
|
||||||
unified_msa = get(paste0(input$switch_target, '_unified_msa'))
|
|
||||||
#
|
#
|
||||||
# # re-sort the dataframe according to position count
|
# # re-sort the dataframe according to position count
|
||||||
sorted_df = cbind(merged_df3)
|
sorted_df = cbind(merged_df3)
|
||||||
sorted_df = sorted_df %>% arrange(pos_count)
|
sorted_df = sorted_df %>% arrange(pos_count)
|
||||||
|
|
||||||
#
|
#
|
||||||
outdir = paste0("~/git/Data/", drug, '/output/')
|
outdir = paste0(load_dir, "Data/", drug, '/output/')
|
||||||
indir = paste0("~/git/Data/", drug , "/input/")
|
indir = paste0(load_dir, "Data/", drug , "/input/")
|
||||||
#
|
#
|
||||||
# source("~/git/LSHTM_analysis/scripts/plotting/logo_data_msa.R") # probably unnecessary...
|
# source("~/git/LSHTM_analysis/scripts/plotting/logo_data_msa.R") # probably unnecessary...
|
||||||
|
|
||||||
|
@ -47,13 +47,7 @@ function(input, output, session) {
|
||||||
|
|
||||||
#input$stability_snp_param
|
#input$stability_snp_param
|
||||||
|
|
||||||
updateSliderInput(
|
|
||||||
session,
|
|
||||||
"display_position_range",
|
|
||||||
min = position_min,
|
|
||||||
max = position_max
|
|
||||||
#, value = c(position_min, position_min+150)
|
|
||||||
)
|
|
||||||
updateSliderInput(
|
updateSliderInput(
|
||||||
session,
|
session,
|
||||||
"display_position_full_range",
|
"display_position_full_range",
|
||||||
|
@ -61,45 +55,30 @@ function(input, output, session) {
|
||||||
max = position_max #,
|
max = position_max #,
|
||||||
# value = c(position_min, position_min+150)
|
# value = c(position_min, position_min+150)
|
||||||
)
|
)
|
||||||
updateNumericInput(session, "selected_logop_snp_position", min = position_min, max = position_max, value = position_min)
|
|
||||||
updateNumericInput(session, "selected_logop_ed_position", min = position_min, max = position_max, value = position_min)
|
|
||||||
updateNumericInput(session, "corr_lig_dist", min = min_ligand_distance, max = max_ligand_distance, value = min_ligand_distance)
|
|
||||||
|
|
||||||
stability_colname = stability_boxes_df[stability_boxes_df$stability_type==input$stability_snp_param,"stability_colname"]
|
|
||||||
outcome_colname = stability_boxes_df[stability_boxes_df$stability_type==input$stability_snp_param,"outcome_colname"]
|
|
||||||
|
|
||||||
display_position_range = input$display_position_range
|
|
||||||
plot_min=display_position_range[1]
|
|
||||||
plot_max=display_position_range[2]
|
|
||||||
|
|
||||||
display_position_full_range = input$display_position_full_range
|
display_position_full_range = input$display_position_full_range
|
||||||
full_range_min=display_position_full_range[1]
|
full_range_min=display_position_full_range[1]
|
||||||
full_range_max=display_position_full_range[2]
|
full_range_max=display_position_full_range[2]
|
||||||
|
|
||||||
logoplot_colour_scheme = input$logoplot_colour_scheme
|
logoplot_colour_scheme = input$logoplot_colour_scheme
|
||||||
omit_snp_count = input$omit_snp_count
|
|
||||||
|
|
||||||
print(paste0('Plotting positions between: ', plot_min, ' and ', plot_max))
|
|
||||||
|
|
||||||
subset_mutable_df3=mutable_df3[(mutable_df3$position>=plot_min & mutable_df3$position <=plot_max),]
|
|
||||||
|
|
||||||
subset_mutable_df3=mutable_df3[(mutable_df3$position>=plot_min & mutable_df3$position <=plot_max),]
|
|
||||||
subset_sorted_df=sorted_df[(sorted_df$position>=plot_min & sorted_df$position <=plot_max),]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#### LogoPlotMSA/Logo Plot ED ####
|
#### LogoPlotMSA/Logo Plot ED ####
|
||||||
output$LogoPlotMSA = renderPlot(
|
output$LogoPlotMSA = renderPlot(
|
||||||
LogoPlotMSA(target=input$switch_target,
|
LogoPlotMSA(target=target,
|
||||||
plot_positions=full_range_min:full_range_max,
|
plot_positions=full_range_min:full_range_max,
|
||||||
my_logo_col = logoplot_colour_scheme,
|
my_logo_col = logoplot_colour_scheme,
|
||||||
aa_pos_drug = aa_pos_drug,
|
aa_pos_drug = paste0(target,"_aa_pos_drug"),
|
||||||
active_aa_pos = active_aa_pos,
|
active_aa_pos = paste0(target,"_active_aa_pos"),
|
||||||
aa_pos_lig1 = aa_pos_lig1,
|
aa_pos_lig1 = paste0(target,"_aa_pos_lig1"),
|
||||||
aa_pos_lig2 = aa_pos_lig2,
|
aa_pos_lig2 = paste0(target,"_aa_pos_lig2"),
|
||||||
aa_pos_lig3 = aa_pos_lig3
|
aa_pos_lig3 = paste0(target,"_aa_pos_lig3")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#### EOF Shiny Server ####
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue