0%

RNA-seq分析(5)之GO富集分析

接上一篇KEGG富集分析,使用clusterProfiler包进行GO通路富集分析。

1. 上调基因通路富集

enrichGO进行上调基因的通路富集,并提取富集结果。

1
2
3
4
5
6
7
8
9
10
11
12
ego_up <- enrichGO(gene          = gene_up,
OrgDb = org.Dm.eg.db,
keytype = "ENTREZID",
ont = "ALL" ,
universe = gene_all,
pAdjustMethod = "BH",
pvalueCutoff = 0.99,
qvalueCutoff = 0.99,
readable = TRUE)

head(ego_up[,1:6])
ego_up_result <- ego_up@result[order(ego_up@result$pvalue),]

选择前10个BP、CC、MF合并到一个dataset中并绘图。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
ego_up_sig <- rbind(head(subset(ego_up_result, ONTOLOGY == "BP"), 10),
head(subset(ego_up_result, ONTOLOGY == "CC"), 10),
head(subset(ego_up_result, ONTOLOGY == "MF"), 10))
ego_up_sig$pvalue <- -log10(ego_up_sig$pvalue)
ego_up_sig$Description <- factor(ego_up_sig$Description,
levels = as.character(rev(ego_up_sig$Description)))

# GO富集分析柱状图,柱子颜色根据BP、CC、MF区分
ggplot(ego_up_sig, aes(x = Description, y = pvalue, fill = ONTOLOGY)) +
geom_col() +
coord_flip() +
theme_classic() +
facet_grid(ONTOLOGY~., scales = "free") +
xlab("Up regulated") +
ylab("-log10 pvalue")

# GO富集分析柱状图,柱子颜色变化依据p.adjust值
ggplot(ego_up_sig,
aes(x = Description, y = pvalue, fill = p.adjust)) +
scale_fill_gradient(low = "red",high = "blue")+
geom_col() +
coord_flip() +
theme_classic() +
facet_grid(ONTOLOGY~., scales = "free") +
xlab("Down regulated")+
ylab("-log10 pvalue")

# GO富集分析气泡图
ggplot(ego_up_sig,
aes(x = GeneRatio, y = Description, color =p.adjust, size = Count)) +
geom_point()+
scale_size(range = c(2,8))+
scale_color_gradient(low = "red",high = "blue")+
theme_classic() +
facet_grid(ONTOLOGY~., scales = "free") +
xlab("Gene ratio")

2. 下调基因通路富集

下调基因同理。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
ego_down <- enrichGO(gene          = gene_down,
OrgDb = org.Dm.eg.db,
ont = "ALL" ,
universe = gene_all,
pAdjustMethod = "BH",
pvalueCutoff = 0.99,
qvalueCutoff = 0.99,
readable = TRUE)

head(ego_down[,1:6])
ego_down_result <- ego_down@result[order(ego_down@result$pvalue),]
ego_down_sig <- rbind(head(subset(ego_down_result, ONTOLOGY == "BP"), 10),
head(subset(ego_down_result, ONTOLOGY == "CC"), 10),
head(subset(ego_down_result, ONTOLOGY == "MF"), 10))
ego_down_sig$pvalue <- -log10(ego_down_sig$pvalue)
ego_down_sig$Description <- factor(ego_down_sig$Description,
levels = as.character(rev(ego_down_sig$Description)))

ggplot(ego_down_sig, aes(x = Description, y = pvalue, fill = ONTOLOGY)) +
geom_col() +
coord_flip() +
theme_classic() +
facet_grid(ONTOLOGY~., scales = "free") +
xlab("Down regulated") +
ylab("-log10 pvalue")

# GO富集分析柱状图,柱子颜色变化依据p.adjust值
ggplot(ego_down_sig,
aes(x = Description, y = pvalue, fill = p.adjust)) +
scale_fill_gradient(low = "red",high = "blue")+
geom_col() +
coord_flip() +
theme_classic() +
facet_grid(ONTOLOGY~., scales = "free") +
xlab("Down regulated")+
ylab("-log10 pvalue")

# GO富集分析气泡图
ggplot(ego_down_sig,
aes(x = GeneRatio, y = Description, color =p.adjust, size = Count)) +
geom_point()+
scale_size(range = c(2,8))+
scale_color_gradient(low = "red",high = "blue")+
theme_classic() +
facet_grid(ONTOLOGY~., scales = "free") +
xlab("Gene ratio")