Commit 2cc8374d authored by Cosmin  SAVEANU's avatar Cosmin SAVEANU
Browse files

Upload New File

parent 4ea37f04
library(shiny)
library(ggplot2)
library(ggrepel)
library(DT)
# this is a global part, ran probably only once.
indata <- readRDS("data/gimdata2019.rds")
indata.t <- data.frame(t(indata[, c(-1, -2)]), stringsAsFactors = F)
names(indata.t) <- paste(indata$Name, indata$ORF)
indata.t$Screen <- rownames(indata.t)
complexnames <- names(indata.t)
colnamesspace = gsub(names(indata), pattern="([_\\.])", replacement = " ")
cors <- readRDS("data/top100_correlated.rds")
# UI
ui <- navbarPage("Yeast GIM data",
tabPanel("Screens comparison",
sidebarLayout(
sidebarPanel(
selectInput("cole_x", "x column log2(Q/R)",
names(indata)[c(-1, -2)], multiple=FALSE, selectize=TRUE,
selected = "YDR283C_GCN2_DEL"),
selectInput("cole_y", "y column log2(Q/R)",
names(indata)[c(-1, -2)], multiple=FALSE, selectize=TRUE,
selected = "YEL009C_GCN4_DEL"),
sliderInput("lab_threshold", label="Labeling threshold value",
value=2, min=1, max=5, step = 0.5),
htmlOutput("control_text"),
downloadButton("save_plot", label="Download plot")),
mainPanel(htmlOutput("info_text"),
plotOutput("plot_e",
brush = brushOpts(id = "plot_e_brush"),
height=600,
width=600))
),
hr(),
fluidRow(h4('Data Table'), icon=shiny::icon("info-circle"), htmlOutput("info_scrolltable"),
div(DT::dataTableOutput("alldatatable"), style="width:90%;margin:auto;"))),
tabPanel("Mutant profiles",
sidebarLayout(
sidebarPanel(
selectInput("gene_name", label=h4("Find mutant"),
choices=complexnames, selectize=T,
selected="AIR1 YIL079C"),
div(DT::dataTableOutput("screenstable")),
width = 3),
mainPanel(
div(DT::dataTableOutput("correlationstable"), style="width:600px;"), width = 8
))),
tabPanel("Description and help", includeHTML("Documentation.html"))
)
# SERVER
server <- function(input, output) {
#Reactive that returns the whole dataset if there is no brush
selectedDataE <- reactive({
datae <- brushedPoints(indata,
input$plot_e_brush,
xvar=input$cole_x,
yvar=input$cole_y)
if (nrow(datae) == 0)
datae <- indata
datae
})
selectedMutant <- reactive({
mutantrow <- input$gene_name
seldata <- indata.t[, c("Screen", mutantrow)]
if (nrow(seldata) == 0)
seldata <- indata.t[, c("Screen", 1)]
seldata
})
selectedMutantCorr <- reactive({
mutantrow <- strsplit(input$gene_name, " ")[[1]][[1]]
selidx <- which(cors$Mutant_1 == mutantrow)
seldata <- cors[selidx,]
if (nrow(seldata) == 0)
seldata <- cors[1:10, ]
seldata
})
labelThreshold <- reactive({
labthreshold <- input$lab_threshold
labthreshold
})
output$alldatatable <- DT::renderDataTable({
DT::datatable(selectedDataE(),
filter='top',
extensions = 'Buttons',
options = list(lengthMenu = c(25, 50, 100, 200),
pageLength=25,
buttons=c("copy", "csv"),
dom='ltBip',
scrollX = TRUE,
order=list(list(1, "asc"))
),
colnames = colnamesspace,
rownames = F
)
})
output$screenstable <- DT::renderDataTable({
DT::datatable(selectedMutant(),
filter='top',
extensions = 'Buttons',
options = list(lengthMenu = c(25, 50, 100, 200),
pageLength=25,
buttons=c('copy', 'csv'),
dom='ltBip',
scrollX = TRUE,
order=list(list(1, "asc"))
),
rownames = F)
})
output$correlationstable <- DT::renderDataTable({
DT::datatable(selectedMutantCorr(),
filter='top',
extensions = 'Buttons',
options = list(lengthMenu = c(25, 50, 100),
pageLength=25,
buttons=c('copy', 'csv'),
dom='ltBip',
scrollX = TRUE),
rownames = F)
})
plotXY = function()
{
thr <- labelThreshold()
overN <- which((abs(indata[, input$cole_x]) > thr) | (abs(indata[, input$cole_y]) > thr))
ggplot(data = indata, aes_string(x=input$cole_x, y=input$cole_y))+
geom_point()+
geom_text_repel(data=indata[overN, ], aes(label=Name))+
ggtitle("Growth defect score (log2[Q/R])")
}
saveplotFilename <- reactive({
fname <- paste("plot", input$cole_x, '_', input$cole_y, '.pdf', sep='')
fname
})
output$plot_e <- renderPlot({
plotXY()
})
output$info_text <- renderUI(
{
str1 <- paste(icon("info-circle"), "Click-drag selects region of the plot.")
HTML(str1)
})
output$info_scrolltable <- renderUI(
{
str1 <- paste(icon("info-circle"), "Scroll right to see more columns --->")
HTML(str1)
})
output$control_text <- renderUI({
str1 <- paste(icon("file-pdf"), saveplotFilename())
HTML(str1)
})
output$save_plot <- downloadHandler(
filename = function(){saveplotFilename()},
content = function(file) {
ggsave(file, plot = plotXY(), device = "pdf")
}
)
}
shinyApp(ui, server)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment