Skip to content

Instantly share code, notes, and snippets.

@lpantano
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpantano/9930881 to your computer and use it in GitHub Desktop.
Save lpantano/9930881 to your computer and use it in GitHub Desktop.
Plot expression values according to design data.frame using DEGReport object
#https://gist.github.com/jcheng5/4050398
library(ggplot2)
options(shiny.maxRequestSize = -1)
shinyServer(function(input, output,session) {
observe({
if (is.null(input$files)) {
# User has not uploaded a file yet
return(NULL)
}
inFile <- input$files
load(inFile$datapath)
updateSelectInput(session, "srcgen", choices = colnames(deg[[2]]), selected="condition")
updateSelectInput(session, "srccol", choices = colnames(deg[[2]]), selected="condition")
})
datasetInput <- reactive({
if (input$do==0) {
return(NULL)
}else{
data<-deg[[1]]
des<-deg[[2]]
exp<-(unlist(data[input$gene,]))
gen<-des[,input$srcgen]
col<-des[,input$srccol]
exp<-list(data.frame(exp=exp,gen=gen,col=col))
return(exp)
}
})
output$distPlot <- renderPlot({
if (input$do>0) {
d<-datasetInput()[[1]]
p <- ggplot(d, aes(factor(gen), exp)) +
geom_boxplot(outlier.size = 0) +
geom_jitter(position=position_jitter(width=0.2),aes(factor(gen), exp,colour=col)) +
stat_summary(fun.y=mean, geom="point",size=5)+
scale_color_brewer(palette="Set1")+
theme_bw(base_size = 16, base_family = "serif") +
theme(axis.text.x=element_text(angle = 90, hjust = 1))+
labs(list(title=input$gene,y="abundance",x=""))
print(p)
}
})
})
shinyUI(pageWithSidebar(
headerPanel("Plot Expression using DEGReport package output"),
sidebarPanel(
fileInput("files", "File data", multiple=TRUE),
selectInput("srcgen","Select genotype:", "Loading..."),
selectInput("srccol","Select colours:", "Loading..."),
textInput("gene", "Gene ID:", "ENSG00000000419"),
actionButton("do","Update View")
),
mainPanel(
plotOutput("distPlot")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment