Skip to content
Snippets Groups Projects
Commit 5865aedc authored by Cosmin  SAVEANU's avatar Cosmin SAVEANU
Browse files

Upload New File

parent 93ee0d5a
No related branches found
No related tags found
No related merge requests found
app.R 0 → 100644
library(shiny)
library(ggplot2)
library(dplyr)
library(magrittr)
library(ggrepel)
# this is a global part, ran probably only once.
enrichment <- readRDS("data/enrichment.rds")
intensity <- readRDS("data/intensity.rds")
# UI
ui <- fluidPage(
title = "Yeast NMD data",
sidebarLayout(
sidebarPanel(
selectInput("cole_x", "x column ENRICHMENT",
names(enrichment)[c(-1, -2)], multiple=FALSE, selectize=TRUE),
selectInput("cole_y", "y column ENRICHMENT",
names(enrichment)[c(-1, -2)], multiple=FALSE, selectize=TRUE),
textOutput("info_text"),
plotOutput("plot_e", brush = brushOpts(id = "plot_e_brush")),
sliderInput("lab_threshold", label="Labeling threshold value",
value=4, min=0, max=10, step = 0.5),
downloadButton("save_plot", label="Download plot"),
textOutput("control_text"),
plotOutput("plot_i"),
width=4),
mainPanel(
tabsetPanel(
tabPanel("Data table",
textOutput("info_scrolltable"),
DT::dataTableOutput("mytable1"), width=8),
tabPanel("Documentation",
includeHTML("Documentation.html"))
)
)
)
)
# SERVER
server <- function(input, output) {
#Reactive that returns the whole dataset if there is no brush
selectedDataE <- reactive({
datae <- brushedPoints(enrichment,
input$plot_e_brush)
if (nrow(datae) == 0)
datae <- enrichment
datae
})
labelThreshold <- reactive({
labthreshold <- input$lab_threshold
labthreshold
})
output$mytable1 <- DT::renderDataTable({
DT::datatable(selectedDataE(),
filter='top',
extensions = 'Buttons',
options = list(lengthMenu = c(25, 100, 1000),
pageLength=25,
dom='Bfrtip',
buttons=c('copy', 'colvis'),
scrollX=TRUE),
colnames = gsub(names(enrichment), pattern="([_\\.])", replacement = " "))
})
plotXY = function()
{
thr <- labelThreshold()
overN <- which((enrichment[, input$cole_x] > thr) | (enrichment[, input$cole_y] > thr))
ggplot(data = enrichment, aes_string(x=input$cole_x, y=input$cole_y))+
geom_point()+
geom_text_repel(data=enrichment[overN, ], aes(label=Gene))+
ggtitle("Enrichment (fold, log2 axes)")
}
plotXY_intensity = function()
{
thr <- labelThreshold()
overN <- which((enrichment[, input$cole_x] > thr) | (enrichment[, input$cole_y] > thr))
ggplot(data = intensity, aes_string(x=input$cole_x, y=input$cole_y))+
geom_point()+
geom_text_repel(data=intensity[overN, ], aes(label=Gene))+
ggtitle("LTOP2 values (log2 axes)")
}
saveplotFilename <- reactive({
fname <- paste("plot", input$cole_x, '_', input$cole_y, '.pdf', sep='')
fname
})
output$plot_e <- renderPlot({
plotXY()
})
output$plot_i <- renderPlot({
plotXY_intensity()
})
output$info_text <- renderText({
"(i) Click-drag selects region of the plot."
})
output$info_scrolltable <- renderText({
"(i) Scroll right to see more columns --->"
})
output$control_text <- renderText({
saveplotFilename()
})
output$save_plot <- downloadHandler(
filename = function(){saveplotFilename()},
content = function(file) {
ggsave(file, plot = plotXY(), device = "pdf")
}
)
}
shinyApp(ui, server)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment