Last active
August 29, 2015 13:58
-
-
Save lpantano/9930881 to your computer and use it in GitHub Desktop.
Plot expression values according to design data.frame using DEGReport object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) | |
} | |
}) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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