GO 和 KEGG富集分析包,简单好用!
代码
#https://bioconductor.org/packages/release/bioc/vignettes/clusterProfiler/inst/doc/clusterProfiler.html
#source("https://bioconductor.org/biocLite.R")
#biocLite("org.Dr.eg.db")
#biocLite("clusterProfiler")
#biocLite("Rgraphviz")
#biocLite("DOSE")
library(clusterProfiler)
library(org.Hs.eg.db)
library(DOSE)
library(Rgraphviz)
setwd("F:/R/clusterprofile")
x=read.table("gene1.txt")
x=as.vector( x[,1] )
eg = bitr(x, fromType="SYMBOL", toType="ENTREZID", annoDb="org.Hs.eg.db")
cmd=function(entrezID,ont,wd){
ego= enrichGO(entrezID, organism = "human", ont = ont, pvalueCutoff = 0.05,
pAdjustMethod = "BH", qvalueCutoff = 0.2, minGSSize = 5,readable = T)
ekegg= enrichKEGG(eg[,2], organism = "human", pvalueCutoff = 0.05,
pAdjustMethod = "BH", qvalueCutoff = 0.2, minGSSize = 1,readable = T)
setwd(wd)
unlink(ont, recursive=TRUE)
if(!dir.exists(ont)){ dir.create(ont)}
setwd(ont)
write.csv(summary(ego),'GOenrich.csv', row.names = F)
write.csv(summary(ekegg),'KEGG.csv',row.names = F)
pdf(file='barplot.pdf')
myplot=barplot(ego)
print(myplot)
dev.off()
pdf(file='dotplot.pdf')
myplot=dotplot(ego)
print(myplot)
dev.off()
pdf(file='enrichMap.pdf')
myplot=enrichMap(ego)
print(myplot)
dev.off()
tryCatch({
pdf(file='GOgraph.pdf')
myplot=plotGOgraph(ego)
print(myplot)
dev.off()
}, #cc不存在
error=function(e){cat(conditionMessage(e),"\n\n")},
finally={print("error")})
tryCatch({
pdf(file="cnetplot.pdf")
myplot=cnetplot(ego, categorySize="pvalue", foldChange=geneList)
print(myplot)
dev.off()
}, #cc不存在
error=function(e){cat(conditionMessage(e),"\n\n")},
finally={print("error")})
setwd(wd)
}
wd=getwd()
cmd(eg[,2],'MF',wd)
cmd(eg[,2],'CC',wd)
cmd(eg[,2],'BP',wd)
例子: gene1.txt
ADAM32
ADCY2
ADD1
ADGRE2
ALDH1A2
ARIH1
ARRDC1
ATG16L2
AZIN1
BCL7C
C19orf33
C7orf43
CARD14
CARM1
CAST
CCS
CD99
CDK13
CEP192
CLPTM1L
CREBRF
DGKA
DNAH14
EEF1D
EGFL6
EIF4ENIF1
ENTPD6
EPN3
ETNK2
FAM156A
FAM200B
FAM71E1
FLYWCH1
FOXRED1
FRMD6
FUBP1
HLA-A
HMMR
HSPBP1
INTS9
KIAA0753
KYAT1
LUC7L
MAGI1
MAN2B1
MAP2K7
MAP7D3
MBD6
MOK
MTO1
MYL6
NCAM1
NME3
NOC2L
OSBPL8
PFDN5
PMF1-BGLAP
PON2
PPP1R12A
PRELID3B
PSMA4
PSME3
PTPRF
PTPRT
PTPRU
PUSL1
RAP1GAP2
RIPOR2
ROBO1
RPS3
SLC26A6
SLC30A5
SLC50A1
SLC6A15
SMTN
SNRPB
SORBS1
SPATA20
SRSF11
STX16
SYNE1
TARDBP
TARS
TECR
TEP1
TOP3B
TOPBP1
TOR1AIP1
TP53I13
TRA2A
TRMT112
UCHL5
UTP15
VIM
WASHC2C
WDR41
ZC3H11A
ZFYVE21
ZNF30
ZNF618
网友评论