标签:RNA-seq;基因表达
一个非常常见的图种,用于表示两组数据基因表达差异的图,通常横纵坐标分别为 Log2FC 和 P-value。
画出来并不难
美化稍微有点难度:标注重要的点,点的颜色、形状、图层顺序。
基本数据准备:
- 带log2FC和P-value的dataframe
- 需要标注的数据点
代码:
# prepare main dataset data.df <- c1.markers.DESeq2 ## API data.df$log2FC <- data.df$avg_logFC data.df$p_value <- data.df$p_val data.df$gene <- rownames(data.df) ## color data.df$color <- "black" data.df[data.df$gene %in% oxidation.go.genes,]$color <- "red" # prepare annotation data point mark.df <- subset(data.df, gene %in% oxidation.go.genes) library("ggrepel") options(repr.plot.width=6, repr.plot.height=6) ggplot(data.df, aes(x=log2FC, y=-log10(p_value))) + geom_hline(aes(yintercept=1), colour="grey50", linetype="dashed", size=0.2) + #geom_vline(aes(xintercept=0.5), colour="red", linetype="dashed", size=0.2) + geom_vline(aes(xintercept=0), colour="grey50", linetype="dashed", size=0.2) + geom_point(aes(color=color), stroke = 0.3, size=1) + # scale_color_manual(values=c("black", "red")) + labs(x = "Log2 fold change ",y = "-Log10(P-value)", title = "") + theme_bw() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), panel.border = element_rect(size=0.8, colour = "black")) + theme(axis.title =element_text(size = 16),axis.text =element_text(size = 10, color = "black"), plot.title =element_text(hjust = 0.5, size = 16)) + #scale_x_continuous(position="bottom", breaks = seq(-10, 10, by = 2), limits=c(-10, 10)) + #scale_y_continuous(position="left", breaks = seq(-10, 10, by = 2), limits=c(-10, 10)) + theme(legend.title=element_blank(), legend.position = "none") + # theme(legend.title=element_blank(), legend.key.size = unit(0.8, 'lines')) + geom_text_repel(data=mark.df, aes(label=gene), color="red", size=3.8, fontface="italic", arrow = arrow(ends="first", length = unit(0.01, "npc")), box.padding = 0.2, point.padding = 0.3, segment.color = 'black', segment.size = 0.3, force = 1, max.iter = 3e3) #+ #scale_fill_manual(values=c("blue", "red"))
成图:
不是很美观,以后多看看发在CNS上的火山图,模仿一下。
参考:
Ezh2项目文章的图:mouse/singleCell/case/Kif7_ENCC/Kif7-integration/Ezh2_analysis.ipynb