文章代码来自:https://zhuanlan.zhihu.com/p/518145829
degs$significance <- as.factor(ifelse(degs$adj.P.Val < padj_cutoff & abs(degs$logFC) > log2FC_cutoff,
ifelse(degs$logFC > log2FC_cutoff ,'UP','DOWN'),'NOT'))
this_title <- paste0(' Up : ',nrow(degs[degs$significance =='UP',]) ,
'\n Down : ',nrow(degs[degs$significance =='DOWN',]),
'\n adj.P.Val <= ',padj_cutoff,
'\n FoldChange >= ',round(2^log2FC_cutoff,3))
g <- ggplot(data=degs,
aes(x=logFC, y=-log10(adj.P.Val),
color=significance)) +
#点和背景
geom_point(alpha=0.4, size=1) +
theme_classic()+ #无网格线
#坐标轴
xlab("log2 ( FoldChange )") +
ylab("-log10 ( adj.P.Val )") +
#标题文本
ggtitle( this_title ) +
#分区颜色
scale_colour_manual(values = c('blue','grey','red'))+
#辅助线
geom_vline(xintercept = c(-log2FC_cutoff,log2FC_cutoff),lty=4,col="grey",lwd=0.8) +
geom_hline(yintercept = -log10(padj_cutoff),lty=4,col="grey",lwd=0.8) +
#图例标题间距等设置
theme(plot.title = element_text(hjust = 0.5),
plot.margin=unit(c(2,2,2,2),'lines'), #上右下左
legend.title = element_blank(),
legend.position="right")
ggsave(g,filename = 'GSVA_go_volcano_padj.pdf',width =8,height =7.5)