moved bp function script to function/

This commit is contained in:
Tanushree Tunstall 2021-06-09 17:08:56 +01:00
parent 826b8aa9d0
commit 912a439589
3 changed files with 28 additions and 261 deletions

View file

@ -17,6 +17,7 @@ library(dplyr)
# load functions
source("../plotting_globals.R")
source("../plotting_data.R")
source("my_stability_bp.R")
###################################
# command line args :
@ -81,7 +82,7 @@ cat(paste0("Variables imported:"
# Data for plots
#================
# REASSIGNMENT as necessary
df = my_df_u
#df = my_df_u
# sanity checks
str(df)
@ -94,56 +95,49 @@ ui <- fluidPage(
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(radioButtons("rb", "biophysical effect"
sidebarPanel(radioButtons("rb", "Biophysical effect"
, choiceNames = list(
"mCSM"
, "FoldX")
, "FoldX"
, "mCSM-lig")
, choiceValues = list(
"mCSM"
, "FoldX")
, "FoldX"
, "mCSM-lig")
))
# Show a plot of the generated distribution
, mainPanel(plotOutput("distPlot")
, textOutput("txt"))))
# Define server logic required to draw a histogram
my_ats = 25 # axis text size
my_als = 22 # axis label size
theme_set(theme_grey())
server <- function(input, output) {output$distPlot <- renderPlot({
axisType = input$rb
my_title = paste0("Barplots for biophyiscal effects ", axisType)
if (axisType == "mCSM") {
y_value = "duet_outcome"
leg_name = "DUET outcome"}
data_plot = my_df_u
stability_colname = "duet_outcome"
leg_name = "DUET outcome"
p_title = ""}
if (axisType == "FoldX") {
y_value = "foldx_outcome"
leg_name = "FoldX outcome"}
data_plot = my_df_u
stability_colname = "foldx_outcome"
leg_name = "FoldX outcome"
p_title = ""}
ggplot(df, aes(x = eval(parse(text = y_value)))) +
geom_bar(aes(fill = eval(parse(text = y_value))), show.legend = TRUE) +
geom_label(stat = "count"
, aes(label = ..count..)
, color = "black"
, show.legend = FALSE
, size = 10) +
theme(axis.text.x = element_blank()
, axis.title.x = element_blank()
, axis.title.y = element_text(size=my_als)
, axis.text.y = element_text(size = my_ats)
, legend.position = c(0.73,0.8)
, legend.text = element_text(size=my_als-2)
, legend.title = element_text(size=my_als)
, plot.title = element_blank()) +
labs(title = ""
, y = "Number of nsSNPs"
#, fill="DUET Outcome"
) +
scale_fill_discrete(name = leg_name
, labels = c("Destabilising", "Stabilising"))
if (axisType == "mCSM-lig") {
data_plot = my_df_u_lig
stability_colname = "ligand_outcome"
leg_name = "Ligand affinity outcome"
p_title = "Sites < 10 Ang of ligand"}
# plot the basic barplots
my_stability_count(plotdf = data_plot
, df_colname = stability_colname,
, leg_title = leg_name
, bp_plot_title = p_title)
})
#output$txt <- renderText({
# paste("You chose", input$rb)})