千家信息网

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

发表于:2026-11-03 作者:千家信息网编辑
千家信息网最后更新 2026年11月03日,这篇文章主要介绍"R语言shiny如何实现简单的GO富集分析",在日常操作中,相信很多人在R语言shiny如何实现简单的GO富集分析问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对
千家信息网最后更新 2026年11月03日R语言shiny如何实现简单的GO富集分析

这篇文章主要介绍"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)
界面是这样子的
image.png
用于做测试的 id (人)
4312
8318
10874
55143
55388
991
6280
2305
9493
1062
3868
4605
9833
9133
6279
10403
8685
597
7153
23397
6278
79733
259266
1381
3627
27074
6241
55165
9787
7368
11065
55355
9582
220134
55872
51203
3669
83461
22974
10460
10563
4751
6373
8140
79019
820
10635
1844
4283
27299
结果
image.png
image.png


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

富集 语言 分析 结果 学习 代码 更多 表格 帮助 输出 实用 接下来 功能 文件 文章 方法 样子 理论 用户 界面 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 有格互联网科技 保险科技 互联网保险 百单网互联网科技有限公司 广州为想互联网科技有限公司 互联网和科技创新 互联网科技垄断 互联网 视角下的科技创新 盛创互联网科技有限公司 互联网科技生活的内容 成都铂石互联网科技做什么的 宜昌元轩互联网科技有限公司 哈尔滨屹滨互联网科技有限公司 米聚互联网科技南京有限公司排面 怎样加入科技互联网 互联网科技接地气 现代互联网科技公司 北京品多多互联网科技有限公司 互联网科技大佬云集 华人运通互联网科技公司 互联网科技自媒体灵感 互联网科技公司华为 中资互联网科技 互联网科技公司怎么样 易通互联网络科技有限公司 高科技互联网发展前景如何 朱啸虎曾投资哪些互联网科技企业 南博望互联网科技有限公司 长沙互联网科技 山东大美朱楼互联网科技有限公司 悟空问答互联网科技
0