R EnhancedVolcano 绘制火山图

火山图是用于差异表达分析结果可视化的一种有效方法。今天,我们来介绍一个用于增强火山图绘制的强大 R 包:EnhancedVolcano ,该包拥有强大的绘图功能,用户可以简单的通过设置颜色、形状、大小和阴影等参数定义不同的绘图属性,此外通过可以通过添加连线的方式有效避免数据点之间的重叠现象。使用 EnhancedVocalno 包绘制的火山图基本可以直接用于文献发表,可以说非常简单又实用的一款神器了。

1. 下载与安装

R 版本:3.6.1。从 Bioconductor 中下载包:

if (!requireNamespace('BiocManager', quietly = TRUE))    install.packages('BiocManager')    BiocManager::install('EnhancedVolcano')

2. 简单使用

2.1 输入数据格式

首先,我们先来介绍一下 EnhancedVolcan o 输入数据格式。EnhancedVolcano 包可以使用多种差异算法(例如 DESeq2 等)的结果作为输入,数据中需包含 log2FCPvalue 或(和) qvalue 结果,示例数据如下:

2.2 基础绘图

library(EnhancedVolcano)res <- read.table(diffexpress,                  sep="\t",                  head=T,                  row.names=1,                  check.names=F,                  quote="")  EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4))

3、进阶功能

3.1 调整阈值,设置点及标签大小

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    transcriptPointSize = 3.0,    transcriptLabSize = 3.0)

3.2 调整颜色及点透明度

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    col = c('black', 'black', 'black', 'red3'),    colAlpha = 1)

3.3 调整绘图点形状

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    #shape = 8,   #点形状    shape = c(1, 4, 23, 25), #形状列表    colAlpha = 1)

3.4 改变截止线及添加阈值线

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    colAlpha = 1,    cutoffLineType = 'blank',    cutoffLineCol = 'black',    cutoffLineWidth = 0.8,    hline = c(10e-4, 10e-8, 10e-12, 10e-15),    hlineCol = c('grey0', 'grey25','grey50','grey75'),    hlineType = 'longdash',    hlineWidth = 0.8,    gridlines.major = FALSE,    gridlines.minor = FALSE)

3.5 调整标注位置、大小及文字

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    colAlpha = 1,    cutoffLineType = 'twodash',    cutoffLineWidth = 0.8,    legend=c('NS','Log (base 2) fold-change','P value',      'P value & Log (base 2) fold-change'),    legendPosition = 'right',    legendLabSize = 16,    legendIconSize = 5.0)

legendVisible = FALSE 可以不展示图注

3.6 校正后的 p 值作图

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,     xlab = bquote(~Log[2]~ 'fold change'),    ylab = bquote(~-Log[10]~adjusted~italic(P)),    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    colAlpha = 1,    cutoffLineType = 'twodash',    cutoffLineWidth = 0.8,    legend=c('NS','Log (base 2) fold-change','P value',      'P value & Log (base 2) fold-change'),    legendPosition = 'right',    legendLabSize = 16,    legendIconSize = 5.0)

3.7 添加连线用于展示更多标注

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    xlab = bquote(~Log[2]~ 'fold change'),    ylab = bquote(~-Log[10]~adjusted~italic(P)),    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    colAlpha = 1,    cutoffLineType = 'twodash',    cutoffLineWidth = 0.8,    legend=c('NS','Log (base 2) fold-change','P value',      'P value & Log (base 2) fold-change'),    legendPosition = 'right',    drawConnectors = TRUE,    legendLabSize = 16,    legendIconSize = 5.0)

3.8 只标注重要变量

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    xlab = bquote(~Log[2]~ 'fold change'),    ylab = bquote(~-Log[10]~adjusted~italic(P)),    selectLab = c('Spp1','S100a11','Mgp','LOC498555','Sh3bgrl',                  'Ring1','Apoe','Tcn2','Ager','Mc1r'),    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    colAlpha = 1,    cutoffLineType = 'twodash',    cutoffLineWidth = 0.8,    legend=c('NS','Log (base 2) fold-change','P value',      'P value & Log (base 2) fold-change'),    legendPosition = 'right',    drawConnectors = TRUE,    legendLabSize = 16,    legendIconSize = 5.0)

3.9 加框展示变量

EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    xlab = bquote(~Log[2]~ 'fold change'),    ylab = bquote(~-Log[10]~adjusted~italic(P)),    selectLab = c('Spp1','S100a11','Mgp','LOC498555','Sh3bgrl',                  'Ring1','Apoe','Tcn2','Ager','Mc1r'),    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    colAlpha = 1,    cutoffLineType = 'twodash',    cutoffLineWidth = 0.8,    legend=c('NS','Log (base 2) fold-change','P value',      'P value & Log (base 2) fold-change'),    legendPosition = 'right',    drawConnectors = TRUE,    boxedlabels = TRUE,    legendLabSize = 16,    legendIconSize = 5.0)

3.10 针对特殊点设置颜色

colCustom 功能可针对特定位点设置颜色,例如上下调基因设置不同颜色,参考代码如下:

keyvals <- rep('black', nrow(res)) # set the base name/label as 'Mid' names(keyvals) <- rep('Mid', nrow(res)) # fold change > 1.5 & p-value < 0.0001 为高表达 keyvals[which(res$"log2(Fold_change)" > 1.5 & res$"p-value"<0.0001)] <- 'gold' names(keyvals)[which(res$"log2(Fold_change)" > 1.5 & res$"p-value"<0.0001)] <- 'high' # fold change < -1.5 & p-value < 0.0001为低表达 keyvals[which(res$"log2(Fold_change)" < -1.5 & res$"p-value"<0.0001)] <- 'royalblue' names(keyvals)[which(res$"log2(Fold_change)" < -1.5 & res$"p-value"<0.0001)] <- 'low'EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = 'A versus B',    pCutoff = 10e-3,    FCcutoff = 1.5,    xlab = bquote(~Log[2]~ 'fold change'),    ylab = bquote(~-Log[10]~adjusted~italic(P)),    selectLab = rownames(res)[which(names(keyvals) %in% c('high', 'low'))],    transcriptPointSize = 3.0,    transcriptLabSize = 3.0,    colAlpha = 1,    cutoffLineType = 'twodash',    cutoffLineWidth = 0.8,    colCustom = keyvals,    border = 'full',    legend=c('NS','Log (base 2) fold-change','P value',      'P value & Log (base 2) fold-change'),    legendPosition = 'right',    drawConnectors = FALSE,    boxedlabels = FALSE,    legendLabSize = 16,    legendIconSize = 5.0)

3.11 设置特定点的大小

p <- EnhancedVolcano(res,    lab = rownames(res),    x = 'log2(Fold_change)',    y = 'p-value',    xlim = c(-4, 4),    ylim = c(0,15),    title = '',    subtitle = '',    pCutoff = 10e-3,    FCcutoff = 1.5,    xlab = bquote(~Log[2]~ 'fold change'),    ylab = bquote(~-Log[10]~adjusted~italic(P)),    selectLab = rownames(res)[which(names(keyvals) %in% c('high', 'low'))],    transcriptLabSize = 3.0,    transcriptPointSize = c(ifelse((res$"log2(Fold_change)">2 |res$"log2(Fold_change)"< -2) & res$"p-value"<0.0001 , 3, 1)),    colAlpha = 1,    cutoffLineType = 'twodash',    cutoffLineWidth = 0.8,    colCustom = keyvals,    border = 'full',    legend=c('NS','Log (base 2) fold-change','P value',      'P value & Log (base 2) fold-change'),    legendPosition = 'right',    drawConnectors = FALSE,    boxedlabels = FALSE,    legendLabSize = 16,    legendIconSize = 5.0,    caption = "")p

3.12 自定义刻度

p +    ggplot2::coord_cartesian(xlim=c(-6, 6)) +    ggplot2::scale_x_continuous(      breaks=seq(-6,6, 1))

EnhancedVolcano 包绘制火山图就先介绍到这里。

(0)

相关推荐

  • 小程序背景音乐

    onLaunch: function () { console.log( this) this.AppMusic = wx.createInnerAudioContext(); this.AppMus ...

  • 微信小程序云开发删除数据学习心得

    根据要删除的ID定位到那条数据,然后用remove方法删除数据. 微信小程序中代码如下 Index.xwml <!-- 删除数据 --> <input placeholder=&qu ...

  • 微信小程序云开发修改数据学习心得

    根据要修改的ID定位到那条数据,然后用update方法修改数据. 微信小程序中代码如下 Index.xwml <!-- 修改数据 --> <input placeholder=&qu ...

  • ES6语法之异步编程-Promise

    Promise 分解异步操作,避免回调地狱 //1.promise //分解异步操作,避免回调地狱 function testMise(value) { //resolve成功后回调 //reject ...

  • 微信小程序云开发查询数据学习心得

    点击查询出所有数据 微信小程序中代码如下 Index.xwml <button bindtap="getData" type="primary">查 ...

  • R语言GEO数据处理(七)

    # 6. 可视化展示 ---------------------------------------------------------------- ##6.1 火山图 library(ggplot ...

  • R绘图笔记 | 火山图的绘制

    关于绘图,前面介绍了一些: R绘图笔记 | 一般的散点图绘制 R绘图笔记 | 柱状图绘制 R绘图笔记 | 直方图和核密度估计图的绘制 R绘图笔记 | 二维散点图与统计直方图组合 R绘图笔记 | 散点分 ...

  • 几行R语言代码即可绘制火山图?

    火山图 火山图(volcano plot)常用于显著差异基因表达的展示,包含显著和差异两个重要信息.显著性指P值小于0.05,差异性常用FoldChange值>=2作为筛选标准. 那么如何看懂一 ...

  • 手把手教你使用R语言绘制交互效应的森林图

    交互效应分析在SCI中是一个重要的组成,可以表示特殊的人群(也就是亚组)中自变量和因变量的结果关系,可以说是高分SCI必做的项目,在SCI中,这一部分结果很多都是以森林图来展示,这样结果又直观有方便分 ...

  • R语言绘制带有散点的盒形图

    原始数据为1. HM_39mappingfile.csv,即分组信息 2. adiv_all_sorted.txt,作图所需的值.如图所示: 程序如下: library("ggplot2&q ...

  • R语言简单绘制小提琴图

    原始数据: R语言脚本: install.packages("vioplot")#安装vioplot包 library("vioplot") #安装和载入vio ...

  • 练习R:用ggpubr包ggline绘制线图

    案例数据 雇员数据,employee 加载R包 library(ggpubr) 主要目的:不同岗位的平均工资水平,不同性别的平均工资分布. #简单均值折线图 ggline(employee,x=&qu ...

  • R绘图笔记 | 箱形图的绘制

    关于绘图图,前面介绍了一些: 这里介绍箱形图的绘制,这些图形在文章中是很常见的,也是必须要掌握的.比如下图中的E图(来自文献:DOI: 10.1002/jcp.30015 ) 一.读入数据 如果你想获 ...

  • R绘图笔记 | 小提琴图与漂亮的云雨图绘制

    关于绘图图,前面介绍了一些: R绘图笔记 | 一般的散点图绘制 R绘图笔记 | 柱状图绘制 R绘图笔记 | 直方图和核密度估计图的绘制 R绘图笔记 | 二维散点图与统计直方图组合 R绘图笔记 | 散点 ...

  • R绘图笔记 | 热图绘制

    关于绘图,前面介绍了一些: R绘图笔记 | 一般的散点图绘制 R绘图笔记 | 柱状图绘制 R绘图笔记 | 直方图和核密度估计图的绘制 R绘图笔记 | 二维散点图与统计直方图组合 R绘图笔记 | 散点分 ...