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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
library(ggplot2)
library(ggthemes)
library(Cairo)
data <- read.delim("./data/g1_VS_g3.txt",header = T,sep="\t",na.strings = "")
datathreshold <- as.factor(ifelse(datapvalues < 0.05 & abs(log2(datafoldchange)) >=1.5,ifelse(log2(datafoldchange) > 1.5 ,'Up','Down'),'Not'))
# Construct the plot object
# with legend
Cairo(file="volcan_PNG_300_lengend_dpi.png",
type="png",
units="in",
bg="white",
width=5.5,
height=5,
pointsize=12,
dpi=300)
ggplot(data=data,
aes(x=log2(foldchange), y =-log10(pvalues),
colour=threshold,fill=threshold)) +
scale_color_manual(values=c("blue", "grey","red"))+
geom_point(alpha=0.4, size=1.2) +
xlim(c(-4, 4)) +
theme_bw(base_size = 12, base_family = "Times") +
geom_vline(xintercept=c(-1.5,1.5),lty=4,col="grey",lwd=0.6)+
geom_hline(yintercept = -log10(0.05),lty=4,col="grey",lwd=0.6)+
theme(legend.position="right",
panel.grid=element_blank(),
legend.title = element_blank(),
legend.text= element_text(face="bold", color="black",family = "Times", size=8),
plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(face="bold", color="black", size=12),
axis.text.y = element_text(face="bold", color="black", size=12),
axis.title.x = element_text(face="bold", color="black", size=12),
axis.title.y = element_text(face="bold",color="black", size=12))+
labs(x="log2 (fold change)",y="-log10 (p-value)",title="Volcano picture of DEG")
dev.off()
# without legend
Cairo(file="volcan_PNG_300_dpi.png",
type="png",
units="in",
bg="white",
width=6,
height=5,
pointsize=12,
dpi=300)
ggplot(data=data,
aes(x=log2(foldchange), y =-log10(pvalues),
colour=threshold,fill=threshold)) +
scale_color_manual(values=c("blue", "grey","red"))+
geom_point(alpha=0.4, size=1.2) +
xlim(c(-4, 4)) +
theme_bw(base_size = 12, base_family = "Times") +
geom_vline(xintercept=c(-1.5,1.5),lty=4,col="grey",lwd=0.6)+
geom_hline(yintercept = -log10(0.05),lty=4,col="grey",lwd=0.6)+
theme(legend.position="none",
panel.grid=element_blank(),
# legend.title = element_blank(),
# legend.text= element_text(face="bold", color="black",family = "Times", size=8),
plot.title = element_text(hjust = 0.5),
axis.text.x = element_text(face="bold", color="black", size=12),
axis.text.y = element_text(face="bold", color="black", size=12),
axis.title.x = element_text(face="bold", color="black", size=12),
axis.title.y = element_text(face="bold",color="black", size=12))+
labs(x="log2 (fold change)",y="-log10 (p-value)",title="Volcano picture of DEG")
dev.off()
|