送你一个环形富集分析图

引言


好久没用 circlize 了,都忘记怎么用了。今天画个环形富集分析图。网上教程也多,开动自己的脑筋和创意画一个。
富集分析

首先获得富集结果:
library(ggplot2)
library(org.Hs.eg.db)
library(clusterProfiler)
library(dplyr)

load test data

data(geneList, package=”DOSE”)

check

head(geneList)

4312 8318 10874 55143 55388 991

4.572613 4.514594 4.418218 4.144075 3.876258 3.677857

enrichment for control

ego1 <- enrichGO(gene = names(geneList)[1:500],
OrgDb = org.Hs.eg.db,
keyType = “ENTREZID”,
ont = “ALL”,
qvalueCutoff = 1,
pvalueCutoff = 1,
readable = T)

get top 6 terms for visualization

ego1_df <- data.frame(ego1) %>%
group_by(ONTOLOGY) %>%
arrange(pvalue) %>%
slice_head(n = 6) %>%
rowwise() %>%
mutate(fc = eval(parse(text = GeneRatio))/eval(parse(text = BgRatio)))

画图

就拿上面的结果来绘图:

plot

library(circlize)

colors for ONTOLOGY group

col <- rep(rand_color(n = length(unique(ego1_df$ONTOLOGY))),
table(ego1_df$ONTOLOGY))

circos.clear()
circos.initialize(sectors = ego1_df$ID,xlim = c(0,1))

first GO id

circos.track(sectors = ego1_df$ID,ylim = c(0,1),
bg.col = col,
panel.fun = function(x, y){
circos.text(x = CELL_META$xcenter,y = CELL_META$ycenter,
labels = CELL_META$sector.index,
cex = 0.75)
})

add count track

circos.track(sectors = ego1_df$ID,ylim = c(0,1),track.height = 0.1,
panel.fun = function(x, y){
# circos.axis(h = “bottom”)
})
for (i in 1:nrow(ego1_df)){
circos.rect(xleft = 0,xright = ego1_df$Count[i]/max(ego1_df$Count),
ybottom = 0.25,ytop = 0.75,
sector.index = ego1_df$ID[i],
# track.index = 1,
col = “#9933CC”)

# add xaxis
circos.axis(h = “bottom”,major.at = c(0,1),labels = c(0,max(ego1_df$Count)),
sector.index = ego1_df$ID[i])
}

foldchange enriment

circos.track(sectors = ego1_df$ID,ylim = c(0,1),track.height = 0.05)
for (i in 1:nrow(ego1_df)){
circos.text(x = 0.5,y = 0.5,
labels = paste(“FC:”,round(ego1_df$fc[i],digits = 1),sep = ” “),
sector.index = ego1_df$ID[i])
}

circos.track(sectors = ego1_df$ID,ylim = c(0,ceiling(max(ego1_df$fc))))
for (i in 1:nrow(ego1_df)){
circos.barplot(value = ego1_df$fc[i],pos = 0.5,
sector.index = ego1_df$ID[i],
# track.index = 4,
col = “#FF6666”)
}

-log10 pvalue

circos.track(sectors = ego1_df$ID,ylim = c(0,ceiling(max(-log10(ego1_df$pvalue)))))
for (i in 1:nrow(ego1_df)){
circos.barplot(value = -log10(ego1_df$pvalue)[i],pos = 0.5,
sector.index = ego1_df$ID[i],
# track.index = 2,
col = col[i])
}


包括了 count,富集倍数,p 值信息。当然你也可以继续添加其它信息上去。
结尾


路漫漫其修远兮,吾将上下而求索。
欢迎加入生信交流群。加我微信我也拉你进 微信群聊 老俊俊生信交流群 (微信交流群需收取 20 元入群费用,一旦交费,拒不退还!(防止骗子和便于管理)) 。QQ 群可免费加入, 记得进群按格式修改备注哦。

声明:文中观点不代表本站立场。本文传送门:https://eyangzhen.com/419643.html

(0)
联系我们
联系我们
分享本页
返回顶部