-
Notifications
You must be signed in to change notification settings - Fork 2
/
vol plot
58 lines (27 loc) · 1.45 KB
/
vol plot
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
######################################################################
################### vol_plot #####################
######################################################################
#install.packages("ggplot2")
#install.packages("ggrepel")
library(dplyr)
library(ggplot2)
library(ggrepel)
logFCfilter=1 #Fold Change调整
adj.P.Val.Filter=0.05 #FDR调整
inputFile="all.txt" #修改处;输入文件名称,具有Fold Change和adj.p.val的文件
rt = read.table(inputFile, header=T, sep="\t", check.names=F)
Sig=ifelse((rt$adj.P.Val<adj.P.Val.Filter) & (abs(rt$logFC)>logFCfilter), ifelse(rt$logFC>logFCfilter,"Up","Down"), "Not")
rt = mutate(rt, Sig=Sig)
rt = rt[!is.na(rt$adj.P.Val),]
p = ggplot(rt, aes(logFC, -log10(adj.P.Val)))+
geom_point(aes(col=Sig))+
scale_color_manual(values=c("green", "black","red"))+
labs(title = " ")+
theme(plot.title = element_text(size = 16, hjust = 0.5, face = "bold"))
p1=p+geom_label_repel(data=filter(rt, ((rt$adj.P.Val<adj.P.Val.Filter) & (abs(rt$logFC)>logFCfilter))),
box.padding=0.1, point.padding=0.1, min.segment.length=0.05,
size=1.8, aes(label=id)) + theme_bw()
pdf(file="vol.pdf", width=7, height=6.1)
print(p1)
dev.off()
write.table(rt,file="rt.csv",sep="\t",quote=F,row.names=F)