R语言绘图包04--GOplot:富集分析结果可视化


R语言绘图包系列:

  • R语言绘图包01--优秀的拼图包patchwork
  • R语言绘图包02--热图pheatmap
  • R语言绘图包03--火山图EnhancedVolcano

GOplot是一个基因富集可视化的R包,提供了一些新的GO富集可视化思路。
GOplot使用了zscore概念,但其并不是指Z-score标准化,而是指每个GO term下上调(logFC>0)基因数和下调基因数的差与注释到GO term基因数平方根的商。用于表示参与某个GO Term下基因的上调或下调情况,公式:

zscore is an easy to calculate value to give you a hint if the biological process (/molecular function/cellular components) is more likely to be decreased (negative value) or increased (positive value)

1. 安装

# Installation of the latest released version
install.packages('GOplot')
# Installation of the latest development version
install_github('wencke/wencke.github.io')

2. GOplot 内置数据

来自已发表的文章: Dev Cell. 2013 Jul 29;26(2):204-19.
GEO号: GSE47067

3. GOplot用法演示

3.1 准备

加载R包,导入数据

library(GOplot)
data(EC) #内置数据集

查看基因富集结果

View(EC$david) 

查看选择的基因

View(EC$genelist) 

使用circle_dat()构建画图数据,生成circ对象。⚠️

circ <- circle_dat(EC$david, EC$genelist)
#   category         ID              term count  genes      logFC adj_pval     zscore
# 1       BP GO:0007507 heart development    54   DLC1 -0.9707875 2.17e-06 -0.8164966
# 2       BP GO:0007507 heart development    54   NRP2 -1.5153173 2.17e-06 -0.8164966
# 3       BP GO:0007507 heart development    54   NRP1 -1.1412315 2.17e-06 -0.8164966
# 4       BP GO:0007507 heart development    54   EDN1  1.3813006 2.17e-06 -0.8164966
# 5       BP GO:0007507 heart development    54 PDLIM3 -0.8876939 2.17e-06 -0.8164966
# 6       BP GO:0007507 heart development    54   GJA1 -0.8179480 2.17e-06 -0.8164966
3.2 绘图
3.2.1 条形图GOBar()
# 画一张简单的条形图
GOBar(subset(circ, category == 'BP'))

绘制分面图,添加标题,更改颜色

GOBar(circ, display = 'multiple', title = 'Z-score coloured barplot', zsc.col = c('yellow', 'black', 'cyan'))
3.2.2气泡图GOBubble()

气泡图是另外一种全局查看富集通路的方法

GOBubble(circ, labels = 3)
X轴是z-score; Y轴是多重矫正后p值的负对数,值越大padj值越小;圈大小展示GO Term下的基因数。

分面同时展示BP, CC, MF的气泡图

GOBubble(circ, title = 'Bubble plot', colour = c('orange', 'darkred', 'gold'), display = 'multiple', labels = 3) 

更改背景颜色

GOBubble(circ, title = 'Bubble plot with background colour', display = 'multiple', bg.col = T, labels = 3)  
3.2.3 圈图展示基因富集分析结果GOCircle()
GOCircle(circ)

GOCircle()默认展示circ 数据前10个GO Term,可以通过参数nsub参数调整需要展示的GO Term。

IDs <- c('GO:0007507', 'GO:0001568', 'GO:0001944', 'GO:0048729', 'GO:0048514', 'GO:0005886', 'GO:0008092', 'GO:0008047')
GOCircle(circ, nsub = IDs)
GOCircle(circ, nsub = 13)
3.2.4 展示基因与GO Terms关系的圈图 GOChord()

在绘制圈图 之前,首先需要使用chord_dat ()函数将绘图数据整理成GOChord() 要求的输入格式:一个二进制的关系矩阵,1表示基因属于该GO Term,0与之相反。

# 选择感兴趣的基因
head(EC$genes)
##      ID      logFC
## 1  PTK2 -0.6527904
## 2 GNA13  0.3711599
## 3  LEPR  2.6539788
## 4  APOE  0.8698346
## 5 CXCR4 -2.5647537
## 6  RECK  3.6926860

# 选择感兴趣的GO Term
EC$process
## [1] "heart development"        "phosphorylation"         
## [3] "vasculature development"  "blood vessel development"
## [5] "tissue morphogenesis"     "cell adhesion"           
## [7] "plasma membrane"

使用chord_dat ()构建画图数据

# chord_dat(data, genes, process)
# genes和process参数如果不指定,将默认使用对应的全部数据
chord <- chord_dat(circ, EC$genes, EC$process)
View(chord)

画图

GOChord(chord, space = 0.02, gene.order = 'logFC', gene.space = 0.25, gene.size = 5)

GOChord() 参数

GOChord(data, title, space, gene.order, gene.size, gene.space, nlfc = 1,
  lfc.col, lfc.min, lfc.max, ribbon.col, border.size, process.label, limit)
参数 含义
data 二进制矩阵
title 标题
space 基因对应方块之间的距离
gene.order 基因排列顺序
gene.size 基因标签大小
nlfc logFC 列的数目
lfc.col LFC颜色,定义模式:c(color for low values, color for the mid point, color for the high values)
lfc.min LFC最小值
lfc.max LFC最大值
ribbon.col 向量定义基因与GO Term间条带颜色
border.size 基因与GO Term间条带边框粗细
process.label GO Term 图例文字大小
limit c(3, 2),两个数字;第一个参数筛选基因(保留至少存在于3个GO Term的基因),第二个参数筛选GO Term(保留至少包含2个基因的GO Term )
3.2.5 基因与GO Term的热图GOHeat()
GOHeat(chord[,-8], nlfc = 0)

nlfc = 1:颜色对应logFC nlfc = 0:颜色对应每个基因注释了到了几个GO Term

GOHeat(chord, nlfc = 1, fill.col = c('red', 'yellow', 'green'))
GOCluster(circ, EC$process, clust.by = 'logFC', term.width = 2)
3.2.6 韦恩图GOVenn()
l1 <- subset(circ, term == 'heart development', c(genes,logFC))
l2 <- subset(circ, term == 'plasma membrane', c(genes,logFC))
l3 <- subset(circ, term == 'tissue morphogenesis', c(genes,logFC))
GOVenn(l1,l2,l3, label = c('heart development', 'plasma membrane', 'tissue morphogenesis'))

参考:http://wencke.github.io

你可能感兴趣的:(R语言绘图包04--GOplot:富集分析结果可视化)