大概是用shiny写了个批量转换基因ID的网页
2019-06-28 本文已影响6人
美式永不加糖
成功的那一刻:
cry babe cry
一开始设想得很宏大,最后.....就先杰样吧。
ui 长这样:
library(shiny)
ui <- fluidPage(
titlePanel("One Click Gene Annotation"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose file to upload",
multiple = FALSE,
accept = c('text/csv',
'text/comma-separated-values',
'text/tab-separated-values',
'text/plain',
'.csv')),
helpText(strong("Please upload a gene list.")),
helpText("Accepted formats: .txt, .csv"),
hr(),
radioButtons("reference", "Select a reference genome:",
c("Human (Homo sapiens)" = "hs",
"Mouse (Mus Musculus)" = "mm"),
selected = 'hs'),
hr(),
actionButton("goButton", "GO!", icon("paper-plane"),
style="color: #fff; background-color: #337ab7;
border-color: #2e6da4")
),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Your Genes", tableOutput("genelist")),
tabPanel("Converted IDs", tableOutput("annotationinfo"))
)
)
)
)
server 长这样:
suppressPackageStartupMessages(library(org.Hs.eg.db))
suppressPackageStartupMessages(library(org.Mm.eg.db))
suppressPackageStartupMessages(library(AnnotationDbi))
server <- function(input, output) {
output$genelist <- renderTable({
if (is.null(input$file1))
return(NULL)
urgene <- read.csv(input$file1$datapath,
header = FALSE, sep = "\t")
colnames(urgene) <- "SYMBOL"
urgene
})
annodb <- reactive({
if(input$reference == "hs"){
require(org.Hs.eg.db)
annodb <- org.Hs.eg.db
} else {
(input$reference == "mm")
require(org.Mm.eg.db)
annodb <- org.Mm.eg.db
}
})
mykey <- reactive({
req(input$file1)
ks <- as.character(read.csv(input$file1$datapath,
header = FALSE, sep = "\t")[,1])
return(ks)
})
output$annotationinfo <- renderTable({
input$goButton
AnnotationDbi::select(
annodb(),
keys = mykey(),
column = c("ENTREZID", "ENSEMBL",
"UNIGENE", "UNIPROT", "GENENAME"),
keytype = "SYMBOL")
})
}
Run APP 就会是这样:
最后,向大家隆重推荐生信技能树的一系列干货!
- 生信技能树全球公益巡讲:https://mp.weixin.qq.com/s/E9ykuIbc-2Ja9HOY0bn_6g
- B站公益74小时生信工程师教学视频合辑:https://mp.weixin.qq.com/s/IyFK7l_WBAiUgqQi8O7Hxw
- 招学徒:https://mp.weixin.qq.com/s/KgbilzXnFjbKKunuw7NVfw