## This is a Shiny web application. You can run the application by clicking # the 'Run App' button above. # # Find out more about building applications with Shiny here: # # http://shiny.rstudio.com/ ## ################################### # load libraries and function #source("Header_TT.R") library(shiny) library(ggplot2) library(data.table) library(dplyr) #require("getopt", quietly = TRUE) # cmd parse arguments # load functions source("../plotting_globals.R") source("../plotting_data.R") ################################### # command line args : # INSERT HERE # hardcoded vars infile = "/home/tanu/git/Data/streptomycin/output/gid_comb_stab_struc_params.csv" drug = "streptomycin" gene = "gid" ################################### # call functions with relevant args #------------------------------------------ # import_dirs() # should return the follwoing variables: # datadir # indir # outdir # plotdir # dr_muts_col # other_muts_col # resistance_col #-------------------------------------------- import_dirs(drug, gene) #--------------------------------------------- # plotting_data() # should return the following dfs: # my_df # my_df_u # my_df_u_lig # dup_muts #---------------------------------------------- #if (!exists("infile") && exists("gene")){ if (!is.character(infile) && exists("gene")){ #in_filename_params = paste0(tolower(gene), "_all_params.csv") in_filename_params = paste0(tolower(gene), "_comb_stab_struc_params.csv") # part combined for gid infile = paste0(outdir, "/", in_filename_params) cat("\nInput file not specified, assuming filename: ", infile, "\n") } # Get the DFs out of plotting_data() pd_df = plotting_data(infile) my_df = pd_df[[1]] my_df_u = pd_df[[2]] my_df_u_lig = pd_df[[3]] dup_muts = pd_df[[4]] ######################################################### cat(paste0("Directories imported:" , "\ndatadir:", datadir , "\nindir:", indir , "\noutdir:", outdir , "\nplotdir:", plotdir)) cat(paste0("Variables imported:" , "\ndrug:", drug , "\ngene:", gene)) #========================================================== #================ # Data for plots #================ # REASSIGNMENT as necessary df = my_df_u # sanity checks str(df) #=========================================================== # Define UI for application that draws a histogram ui <- fluidPage( # Application title titlePanel("Mtb target: gid"), # Sidebar with a slider input for number of bins sidebarLayout( sidebarPanel(radioButtons("rb", "biophysical effect" , choiceNames = list( "mCSM" , "FoldX") , choiceValues = list( "mCSM" , "FoldX") )) # 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"} if (axisType == "FoldX") { y_value = "foldx_outcome" leg_name = "FoldX outcome"} 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")) }) #output$txt <- renderText({ # paste("You chose", input$rb)}) } stabiliyPlot <- function(input, output) { } # Run the application shinyApp(ui = ui, server = server)