ggplot2
1 导入包
# 帮助文档链接:http://docs.ggplot2.org/current/
library(ggplot2)
2.改变工作路径,将工作路径改变到数据存放的文件夹下
3.读取数据:isoforms.filter.tsv
isoforms.filter.tsv表格内容:
data =read.table("isoforms.filter.tsv",header=T,row.names=1)
4. 画图
r03 = ggplot(data,aes(log2FC,-1*log10(FDR)))
r03 + geom_point()
4.1 改变点的颜色
r03 + geom_point(color ="red")
r03 +geom_point(aes(color ="red"))
r03 + geom_point(aes(color =significant))
4.2 设置坐标轴范围和标题 # xlim(),ylim()函数,labs(title=“..”,x=“..”,y=“..”)函数
r03xy = r03 +geom_point(aes(color =significant)) + xlim(-4,4) + ylim(0,30)
r03xy + labs(title="Volcanoplot",x="log2(FC)")
r03xy + labs(title="Volcanoplot",x=expression_r(log[2](FC)), y=expression_r(-log[10](FDR)))
4.3 自定义颜色
r03xyp = r03xy + labs(title="Volcanoplot",x=expression_r(log[2](FC)), y=expression_r(-log[10](FDR)))
r03xyp + scale_color_manual(values =c("green","black", "red"))
volcano = r03xyp +scale_color_manual(values = c("#00ba38","#619cff","#f8766d"))
4.4 添加阈值线
volcano+geom_hline(yintercept=1.3)+geom_vline(xintercept=c(-1,1))
volcano+geom_hline(yintercept=1.3,linetype=4)+geom_vline(xintercept=c(-1,1),linetype=4)
ggsave("volcano.png")
ggsave("volcano8.png",volcano,width=8,height=8)