超详细ggmaplot绘制差异基因火山图

作者: 灵活胖子的进步之路 | 来源:发表于2020-12-28 15:46 被阅读0次

这次和大家分享下利用ggmaplot绘制差异基因筛选后的火山图,用到的基因集是ggpubr里面自带的数据集diff_express数据集

数据集结构及定义

可以看到basemean为所有样本数中特定基因的表达量的平均值,detection_all为一个数字型向量,用以确定特定基因集(笔者理解类似GSEA里面的基因集,可以指定特定基因集绘制其火山图)

以下是ggmaplot主要参数的用法

主要参数
主要参数续
主要参数续2

以下代码实战

library(ggpubr)

data(diff_express)
View(diff_express)
数据集结构

后面的代码中没有指定映射,所以笔者认为防止报错,需要检查并把列名改为模拟数据集中的同样的名称

colnames(diff_express)
列名
ggmaplot(diff_express,#数据集 
         main = expression("Group 1" %->% "Group 2"),#定义比较组及标题
         fdr = 0.05, #校验P值水平
         fc = 2, #foldchange
         size = 0.4,#点大小
         palette = c("#B31B21", "#1465AC", "darkgray"),#色板
         genenames = as.vector(diff_express$name),#指定特定行为基因名
         legend = "top", #图例位置
         top = 20,#显示上下调前20位基因
         font.label = c("bold", 11),#显示基因标签字号大小及加粗
         font.legend = "plain",#图例的设置,这里设置为不加粗
         font.main = "bold",#主要主题设置为加粗(就是那个Group图例加粗)
         ggtheme = ggplot2::theme_minimal())#设置色板主题
火山图

以下 给选出的基因绘制方框

ggmaplot(diff_express, 
         main = expression("Group 1" %->% "Group 2"),
         fdr = 0.05, 
         fc = 2, 
         size = 0.4,
         palette = c("#B31B21", "#1465AC", "darkgray"),
         genenames = as.vector(diff_express$name),
         legend = "top", 
         top = 20,
         font.label = c("bold", 11), 
         label.rectangle = T,#给选出的基因绘制方框
         font.legend = "bold",
         font.main = "bold",
         ggtheme = ggplot2::theme_minimal())
带方框图

指定特定基因以显示

ggmaplot(diff_express, 
         main = expression("Group 1" %->% "Group 2"),
         fdr = 0.05, 
         fc = 2, 
         size = 0.4,
         genenames = as.vector(diff_express$name),
         ggtheme = ggplot2::theme_minimal(),
         top = 0, 
         label.rectangle = T,
         label.select = c("BUB1", "CD83","TP53")#指定基因集
)
指定3个基因显示

相关文章

网友评论

    本文标题:超详细ggmaplot绘制差异基因火山图

    本文链接:https://www.haomeiwen.com/subject/pjlanktx.html