Skip to content

Instantly share code, notes, and snippets.

@mtmorgan
Created December 5, 2012 23:21
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 mtmorgan/4220434 to your computer and use it in GitHub Desktop.
Save mtmorgan/4220434 to your computer and use it in GitHub Desktop.
shiny AnnotationTable
library(shiny)
library(org.Hs.eg.db)
library(org.Mm.eg.db)
library(org.Dm.eg.db)
db <- c(Human="org.Hs.eg.db", Mouse="org.Mm.eg.db",
Drosophila="org.Dm.eg.db")
map <- lapply(db, function(elt) tryCatch({
library(elt, quietly=TRUE, character.only=TRUE)
get(elt)
}, error=function(err) {
NULL
}))
map <- Filter(Negate(is.null), map)
shinyServer(function(input, output) {
output$view <- reactiveTable(function() {
org <- input$organism
keys0 <- input$keys
keys <- strsplit(gsub(" +", "", keys0), ",")[[1]]
if (!length(keys))
keys <- head(keys(map[[org]]), 100)
cols <- input$columns
if (!length(cols))
cols <- head(cols(map[[org]]), 1L)
select(map[[org]], keys, cols)
})
})
shinyUI(pageWithSidebar(
headerPanel("Annotations"),
sidebarPanel(
textInput("keys", "ENTREZ identifiers"),
selectInput("organism", "Organism",
choices=names(map)),
selectInput("columns", "Annotations",
choices = cols(map[["Human"]]),
selected = c("SYMBOL", "GENENAME"),
multiple=TRUE),
submitButton("Update"),
helpText(HTML('Source available on
<a href="https://gist.github.com/4220434">github</a>'))
),
mainPanel(
h4("Results (maximum 100)"),
tableOutput("view")
)
))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment