R语言做生信绘图R

火山图-“高下立判”

2019-04-06  本文已影响159人  Juan_NF
  • 这些东西,换成是高中的我们来做,应该会笑吧,原来长大后的考验也不过如此;
  • 其实就是把差异分析结果中的logFC(fold change,limma中给出的结果经由log2处理)和p.value拎出来 ,以log2FC为x轴,-log10(p.value)为y轴对数据进行展示而已;
  • 理解,stable、up-regulated、down-regulated的界定,都是未成文的cutoff(|log2FC|>1,p.value<0.05或p.value<0.01)而已;
#####从limma中得到p.value,logFC等值;
dff<-topTable(fit2,number=nrow(fit2))
dff <- subset(dff, select=c("P.Value","logFC"))
dff$'log10_P.Value'= -log10(dff$P.Value)
dff$total=ifelse(dff$P.Val>0.05,'stable',
                 ifelse( dff$logFC >1,'up',
                         ifelse( dff$logFC < -1,'down','stable') )
)
dff$name=rownames(dff)
####火山图
library(ggpubr)
ggscatter(dff, x = "logFC", y = "log10_P.Value", color = "total",size = 0.75)
total=dff$total
library(ggplot2)
qplot(x=dff$logFC, y=-log10(dff$P.Value),color= total)+xlab("log2 fold change") + ylab("-log10 p-value")+theme_bw()+scale_colour_manual(values = c('up'="blue",'stable'='grey','down'='red'))
with(subset(dff, adj.P.Val<.05 ),plot(logFC, log10_P.Value,pch=20, col="red"))
with(subset(dff, abs(logFC)>1), points(logFC, log10_P.Value, pch=20, col="orange"))
with(subset(dff, adj.P.Val<.05 & abs(logFC)>1),  points(logFC, log10_P.Value, pch=20, col="green"))

# Label points with the textxy function from the calibrate plot
library(calibrate)
TF_gene<-c('ONECUT2','RAPGEF5','SIX2','MYT1L','ASCL1','PROX1','INSM1','ZNF711','MYT1')
with(subset(dff, adj.P.Val<.05 & abs(logFC)>1), textxy(logFC, log10_P.Value, labs=dff$SYMBOL[dff$SYMBOL%in%TF_gene], cex=.8))

课程分享
生信技能树全球公益巡讲
https://mp.weixin.qq.com/s/E9ykuIbc-2Ja9HOY0bn_6g
B站公益74小时生信工程师教学视频合辑
https://mp.weixin.qq.com/s/IyFK7l_WBAiUgqQi8O7Hxw
招学徒:
https://mp.weixin.qq.com/s/KgbilzXnFjbKKunuw7NVfw

上一篇下一篇

猜你喜欢

热点阅读