温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

R语言shiny如何实现简单的GO富集分析

发布时间:2021-07-10 14:38:37 阅读:449 作者:chen 栏目:大数据
GO开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

这篇文章主要介绍“R语言shiny如何实现简单的GO富集分析”,在日常操作中,相信很多人在R语言shiny如何实现简单的GO富集分析问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”R语言shiny如何实现简单的GO富集分析”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

模仿的是 https://github.com/sk-sahu/sig-bio-shiny

基本功能是用户输入

  • gene id
  • pvalue
  • qvalue

然后分别把

  • BP
  • CC
  • MF

以表格输出,

  • 汇总结果下载(压缩文件)
  • go富集结果的dotplot
 代码

代码中 cc和mf结果表格输出的逻辑没有写,和bp是完全一样的

library(shiny)ui<-navbarPage("Pomegranate",               tabPanel("Gene Ontology",                        sidebarLayout(sidebarPanel(width=2,                                                   textAreaInput("text_area_list",                                                                 label = "Please input protein id, one per line",                                                                 height = "200px",                                                                 width="180px",                                                                 value="Pg00001\nPg00002"),                                      selectInput("id_type",label = "Input gene-id Type",                                                  selected = "ensembl",                                                  choices = c('ensembl','refseq','entrezid')),                                      helpText("Please"),                                      numericInput('pval_cutoff',label="pvalue-Cutoff",                                                   value = 1,min=0.001,max=1,step=0.001),                                      numericInput("qval_cutoff",label="qvalue-Cutoff",                                                   value=1,min=0.001,max=1,step=0.001),                                      actionButton('submit',label = 'Submit',                                                   icon=icon('angle-double-right')),                                      tags$hr()),                                      mainPanel(helpText("ABC"),                                                downloadButton('download_plot',label = "Download results plot"),                                                downloadButton('download_table',label="Download result table"),                                                textOutput("gene_number_info"),                                                tags$br(),                                                tags$br(),                                                tabsetPanel(                                                  tabPanel("Biological Process",DT::dataTableOutput(outputId="table_go_bp")),                                                  tabPanel("Cellular Component",DT::dataTableOutput(outputId = "table_go_cc")),                                                  tabPanel("Molecular Functions",DT::dataTableOutput(outputId = 'table_go_mf')),                                                  tabPanel("dotplot",plotOutput('dot_plot_go'))                                                )))))server<-function(input,output){  observeEvent(input$submit,{    withProgress(message = 'Steps:',value=0,{      incProgress(1/7,detail = "A")      text_area_input<-input$text_area_list      print(text_area_input)      df<-as.data.frame(matrix(unlist(stringr::str_split(text_area_input,"\n")),ncol=1))      colnames(df)<-"protein_id"      print(dim(df))      input_gene_number<-dim(df)[1]      output$gene_number_info<-renderText({        paste("Done!","Total Number of Input genes:",input_gene_number,sep="\n")      })      incProgress(2/7,detail = "B")      library(clusterProfiler)      enrichGO_res<-enrichGO(gene=df$protein_id,                             OrgDb = 'org.Hs.eg.db',                             ont="all",                             pvalueCutoff = input$pval_cutoff,                             qvalueCutoff = input$qval_cutoff)      go_enricher_res<-enrichGO_res@result      go_bp<-go_enricher_res[go_enricher_res$ONTOLOGY == "BP",]      output$table_go_bp<-DT::renderDataTable({        go_bp      })      incProgress(3/7,detail="plot")      output$dot_plot_go<-renderPlot({        p1<-dotplot(enrichGO_res)        print(p1)      })      incProgress(4/7,detail = "OK")      go_plot_download<-reactive({        dotplot(enrichGO_res)      }      )      output$download_plot<-downloadHandler(        filename = function(){          paste("go_dot_plot.png",sep='')        },        content = function(file){          ggplot2::ggsave(file,plot=go_plot_download(),device = 'png',width=12,height = 10)        }      )      output$download_table<-downloadHandler(        filename = function(){          paste0("ABC.zip")        },        content = function(file){          fs<-c('go_results.tsv')          write.table(go_enricher_res,file="go_results.tsv",sep="\t",row.names = F)          zip(zipfile = file,files=fs)        },        contentType = "application/zip"      )    })  })  }shinyApp(ui,server)
   界面是这样子的
R语言shiny如何实现简单的GO富集分析  
image.png
 用于做测试的 id (人)
4312831810874551435538899162802305949310623868460598339133627910403868559771532339762787973325926613813627270746241551659787736811065553559582220134558725120336698346122974104601056347516373814079019820106351844428327299
   结果
R语言shiny如何实现简单的GO富集分析  
image.png
R语言shiny如何实现简单的GO富集分析  
image.png

到此,关于“R语言shiny如何实现简单的GO富集分析”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

原文链接:https://my.oschina.net/u/4579431/blog/4347462

AI

开发者交流群×