Skip to content

Instantly share code, notes, and snippets.

@davemcg
Created March 18, 2017 16:43
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 davemcg/20887bfa82a28a9959adfa0f463f8bb5 to your computer and use it in GitHub Desktop.
Save davemcg/20887bfa82a28a9959adfa0f463f8bb5 to your computer and use it in GitHub Desktop.
library(shiny)
library(tidyverse)
genes <- c('A','B','C')
expression <- cbind(rbind(10,100,50),genes) %>% data.frame()
colnames(expression) <- c('Expression','Gene')
shinyServer(function(input, output, session) {
updateSelectizeInput(session, 'Gene', choices = genes, selected=c('A','C'), server = TRUE)
output$boxPlot <- renderPlot({
input$pan_button
isolate({
input.gene <- input$Gene
plot_data <- expression %>% filter(Gene %in% input.gene)
ggplot(plot_data, aes(x=Gene,y=as.numeric(as.character(Expression)))) + geom_bar(stat='identity') + ylim(0,100)
})
})
})
library(shiny)
fluidPage( actionButton('pan_button','Re-draw Plot!'),
selectizeInput('Gene',strong('Gene:'), choices = NULL, selected='ABCA4'),
plotOutput('boxPlot'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment