Jimmy老师今天发在群里的作业:

公众号文章地址:https://mp.weixin.qq.com/s/MnoT1zL8r0nr2ayBsBZgsQ
y叔为clusterprofile包写的书:https://yulab-smu.github.io/clusterProfiler-book/
所以作业就是复现富集分析的几个图。
rm(list = ls())
options(stringsAsFactors = F)
gene_up <- read.table("up_gene.txt",sep = '\n')
colnames(gene_up) <- "SYMBOL"
nrow(gene_up)
#[1] 120 ##上调基因数量
##基因多名情况取第1个名字
gene_up$SYMBOL <- apply(gene_up,1,function(x) {
trimws(strsplit(x,'///')[[1]][1])
})
library(clusterProfiler)
library(org.Hs.eg.db)
df <- bitr(gene_up$SYMBOL,
fromType = "SYMBOL",
toType = c("ENTREZID"),
OrgDb = org.Hs.eg.db)
gene_up <- df$ENTREZID ##KEGG分析需要使用ENTREZID
kk_up <- enrichKEGG(gene = gene_up,
organism = 'hsa',
pvalueCutoff = 0.1,
qvalueCutoff = 0.1)
head(kk_up)[,1:6]
# ID Description GeneRatio BgRatio pvalue p.adjust
#hsa04657 hsa04657 IL-17 signaling pathway 7/62 94/7923 7.633936e-06 0.001022947
#hsa04310 hsa04310 Wnt signaling pathway 8/62 160/7923 3.109488e-05 0.002083357
#hsa05210 hsa05210 Colorectal cancer 5/62 86/7923 5.334629e-04 0.023828009
#hsa05213 hsa05213 Endometrial cancer 4/62 58/7923 1.051629e-03 0.027373514
#hsa05146 hsa05146 Amoebiasis 5/62 102/7923 1.159510e-03 0.027373514
#hsa04390 hsa04390 Hippo signaling pathway 6/62 154/7923 1.225680e-03 0.027373514
dotplot(kk_up)
browseKEGG(kk_up, 'hsa04657')
enrichKK=DOSE::setReadable(kk_up, OrgDb='org.Hs.eg.db',keyType='ENTREZID')


条带图
(gg_barplot <- barplot(enrichKK,showCategory=20))

通路与基因之间的关系可视化
cnetplot(enrichKK, categorySize="pvalue", foldChange=gene_up,colorEdge = TRUE)
cnetplot(enrichKK, foldChange=gene_up, circular = TRUE, colorEdge = TRUE)


通路与通路之间的连接展示
emapplot(enrichKK)

热图展现通路与基因之间的关系
heatplot(enrichKK)

网友评论