大概又用shiny寫了個一鍵Gencode注釋的網(wǎng)頁

和上次 大概是用shiny寫了個批量轉(zhuǎn)換基因ID的網(wǎng)頁 如出一轍 相比,粗暴解決了 上傳文件 or 直接輸入 的矛盾
不過缺點(diǎn)是,依然需要把gtf下載到本地,然后讀入 Rstudio ,
(anyway 這個目前不造怎么解決


ui 長這樣:

library(shiny)

ui <- fluidPage(
  
  titlePanel("One Click Gencode 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(),
      
      h4("Or"),
      textInput("genesymbol", "Type a gene symbol/name",
                "TP53"),
      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("Gencode Annotation Info", tableOutput("annotationinfo"))
                  
      )
    )
  )
)

server 長這樣:

# url <- "ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_31/gencode.v31.annotation.gtf.gz"
# GRCh38p12 <- tempfile(fileext=".gtf.gz", tmpdir = ".")
# download.file(url, GRCh38p12)
# 
# gtf1 <- rtracklayer::import("file3a2017cb68c2.gtf.gz")
# gtf_df <- as.data.frame(gtf1)


server <- function(input, output) {
  
  output$genelist <- renderTable({
    if (is.null(input$file1))
      return(input$genesymbol)
    else {
      genelist <- read.csv(input$file1$datapath, 
                         header = FALSE, sep = "\t")
      colnames(genelist) <- "gene_name"
      genelist
    }
  })
  
   inputgene <- reactive({
     if (is.null(input$file1))
       return(input$genesymbol)
     else {
       genelist <- as.character(read.csv(input$file1$datapath, 
                                header = FALSE, sep = "\t")[,1])
       genelist
     }
  })
  
  
  output$annotationinfo <- renderTable({
    input$goButton
    annotable <- subset(gtf_df,gtf_df$gene_name==inputgene(), 
                        colnames(gtf_df))
    return(annotable)
  })
  
}

最后 RunApp 后就是這個亞子:


image

最后,向大家隆重推薦生信技能樹的一系列干貨!

  1. 生信技能樹全球公益巡講:https://mp.weixin.qq.com/s/E9ykuIbc-2Ja9HOY0bn_6g
  2. B站公益74小時生信工程師教學(xué)視頻合輯:https://mp.weixin.qq.com/s/IyFK7l_WBAiUgqQi8O7Hxw
  3. 招學(xué)徒:https://mp.weixin.qq.com/s/KgbilzXnFjbKKunuw7NVfw
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容