Created
December 5, 2012 23:21
-
-
Save mtmorgan/4220434 to your computer and use it in GitHub Desktop.
shiny AnnotationTable
This file contains hidden or 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
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) |
This file contains hidden or 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
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) | |
}) | |
}) |
This file contains hidden or 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("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