>fpkm <- read.csv(file = "clipboard", header = T, sep = "\t") # 读取分析好的差异表达数据
>head(fpkm)
>fpkm$type <- ifelse(fpkm$regulation == "up" & fpkm$significant == "yes","up",
ifelse(fpkm$regulation == "down" & fpkm$significant == "yes","down","no"))
>data2 <- fpkm[ , c(1,2,4,6)]
>head(data2)
>data2$pval <- -log10(data2$pval)
>data2$type <- as.factor(data2$type)
>ggplot(data2)+
geom_point(mapping = aes(x = log2FC, y = pval, color = type), size = 3, alpha = 0.8)+
scale_color_manual(values = c("skyblue","grey","pink"))+ # 自定义设置颜色
labs(title = "LPF vs LPE", x = "log2(fold change)", y = "log10(p-value)")+
#geom_hline(yintercept = -log10(0.05), linetype = "dashed", size = 1, color = "grey")+ #在图中画横线
#geom_vline(xintercept = c(-1,1), linetype = "dashed", size = 1, color = "grey", intercept = 0)+ #在图中画垂线
geom_segment(mapping = aes(x = -1, y = 0, xend = -1, yend = 22), linetype = "dashed", size = 1, color = "grey")+ #在图中任意位置画线
geom_segment(mapping = aes(x = 1, y = 0, xend = 1, yend = 22), linetype = "dashed",size = 1, color = "grey")+
geom_segment(mapping = aes(x = -12, y = -log10(0.05), xend = 16, yend = -log10(0.05)), linetype = "dashed", size = 1, color = "grey")+
coord_cartesian(expand = T)+ #调整坐标轴,可以设置图像是否挨着坐标轴
theme(axis.text = element_text(size = rel(1.5)),
axis.line = element_line(size = rel(1.5)),
axis.title = element_text(size = rel(1.5)),
panel.background = element_blank())
绘制图片结果: