ggplot2: 火山图
2023-05-05 本文已影响0人
LET149
https://zhuanlan.zhihu.com/p/140535783
https://blog.csdn.net/weifanbio/article/details/116739296
火山图是点图和辅助线的组合图
1. 火山图绘制示例一
kk <- read.table(file="/home/zhiyong/Desktop/BBBBBBBB/Figure_2/Other/D/Bulk/DeSeq2/result_all.txt")
fc_cutoff_up <- 5 '#指定fold change的up阈值
fc_cutoff_down <- -5 #指定fold change的down阈值
padj_cutoff <- 30 #指定adjust p-value的阈值
kk <- subset(kk, subset = padj!="NA") #去除adjust p-value中为NA的行
kk[["minus_log10_padj"]] <- -log10(kk[,6]) #添加minus_log10_padj一列
kk[["type"]] <- "NS" #添加type一列
kk$type[kk$log2FoldChange >= fc_cutoff_up & kk$minus_log10_padj >=padj_cutoff] <- "UP" #把其中一些定义为UP
kk$type[kk$log2FoldChange <= fc_cutoff_down & kk$minus_log10_padj>=padj_cutoff] <- "down" #把其中一些定义为down
ggplot()+geom_point(data=kk, aes(x=log2FoldChange, y=minus_log10_padj, color=type), alpha=0.7, size=2.5)+theme_cowplot()+
scale_color_manual(values = c("red","darkgray","blue"))+ #配置颜色
geom_hline(aes(yintercept = padj_cutoff), colour="black", linetype="dashed", lwd=0.8)+ #添加横向辅助线
geom_vline(aes(xintercept = fc_cutoff_down), colour="black", linetype="dashed", lwd=0.8)+ #添加纵向辅助线一
geom_vline(aes(xintercept = fc_cutoff_up), colour="black", linetype="dashed", lwd=0.8) #添加纵向辅助线二
示例一