Closed ixxmu closed 3 months ago
❝尝试一下这个富集分析图形,由两种条件下的富集结果组成,由两个半圆形表示两组数据:
先来个测试数据:
library(ggplot2)
library(org.Hs.eg.db)
library(gggibbous)
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
然后两波富集分析,注意一定要同时设置 qvalueCutoff = 1 pvalueCutoff = 1 才能获取所有富集结果:
# 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) %>%
mutate(type = "control")
# enrichment for treat
ego2 <- enrichGO(gene = names(geneList)[501:1000],
OrgDb = org.Hs.eg.db,
keyType = "ENTREZID",
ont = "ALL",
qvalueCutoff = 1,
pvalueCutoff = 1,
readable = T)
ego2_df <- data.frame(ego2) %>%
filter(Description %in% ego1_df$Description) %>%
mutate(type = "treat")
合并一下结果:
# combine data
cb <- rbind(ego1_df,ego2_df) %>%
rowwise() %>%
mutate(fc = eval(parse(text = GeneRatio))/eval(parse(text = BgRatio)),
side = ifelse(type == "control",TRUE,FALSE))
最后就是画图,学废了吗:
# PLOT
ggplot(cb) +
geom_moon(aes(x = fc,y = Description,
ratio = 0.5,
right = side,
size = Count,
fill = type)) +
facet_wrap(~ONTOLOGY,ncol = 1,
strip.position = "right") +
theme_bw() +
theme(panel.grid = element_blank(),
axis.text = element_text(color = "black"),
strip.text = element_text(face = "bold",size = rel(1))) +
scale_fill_manual(values = c("#FF0033","#0066CC")) +
ylab("") + xlab("Fold Enrichment")
❝路漫漫其修远兮,吾将上下而求索。
欢迎加入生信交流群。加我微信我也拉你进 微信群聊 老俊俊生信交流群 (微信交流群需收取 20 元入群费用,一旦交费,拒不退还!(防止骗子和便于管理)) 。QQ 群可免费加入, 记得进群按格式修改备注哦。
老俊俊微信:
知识星球:
❝enrichCluster 关于非模式物种富集分析的使用 tidyCoverage 计算 bigwig 文件在目标区域的信号 桑基图加富集图一行代码出图? GEO 上传数据最新教程 试试 bulkRNA 做拟时序分析? ClusterGVis 绘制 lineplot 的优化 RNAseqQC 给你的数据来个全面的 QC 检查 如何 Pull Request 到 github 贡献你的代码 ggplot 添加分类型数据双坐标轴 富集分析流星图?
https://mp.weixin.qq.com/s/zo6mIFmGA9nQcaKID0lrew