服务热线
178 0020 3020
library(ggplot2)
my_plot<-ggplot(
mtcars,
aes(
x=factor(cyl),
fill=factor(gear)
)
)+
geom_bar(width = 0.5)+
labs(
title = "Here is title",
subtitle = "Here is subtitle",
caption = "R2-31",
x = "cyl"
)
theme_new <-function(){
theme_classic() +
theme(
panel.background=element_rect(fill='white'),
panel.grid = element_blank(),
legend.position = "",
axis.line = element_line(color = "black"),
)
}
my_plot+theme_new()
2:
library(ggplot2)
library(latex2exp)
theme_new <-function(){
theme_classic() +
theme(
panel.background=element_rect(fill='white'),
panel.grid = element_blank()
legend.position = "",
axis.line = element_line(color = "black")
)
}
myvolcano<-read.table("E:/nature23643-s4.csv",header = T,sep = ",")
myvolcano$significant<-ifelse(abs(log2(myvolcano$FC))<1,"not","yes")
head(myvolcano)
myvolcano$lables<-ifelse(abs(log2(myvolcano$FC))<1,NA,as.character(myvolcano$gene.ID))
head(myvolcano)
mysig<-subset(myvolcano,significant=="yes")
head(mysig)
ydrop = -0.6
textdrop=0.3
p1<-ggplot(
data = myvolcano,
aes(x=log2(FC),y=-log2(q_value), size=significant))+
geom_point(color="grey",alpha=0.4)+
xlim(c(-3,3))+ylim(c(-1,16))+
scale_size_manual(values = c(2,0))+
geom_vline(xintercept = c(0),lty=4,col="black",lwd=0.5)+
geom_hline(yintercept = -log2(1/32),lty=4,col="red",lwd=0.5)+
#overlap
geom_point(data = mysig,aes(x=log2(FC), y=-log2(q_value),color=lables ),
size=4
)+
geom_text(
aes(label=lables),
size=3,
hjust=0,
vjust=-1,
col="black",
fontface="italic"
)+
annotate(
"segment",
x = 1,
xend = 2.5,
y = ydrop,
yend = ydrop,
color = "black",
size = 1,
arrow = arrow(
angle = 18,
ends = "last",
type = "closed"
)
) +
annotate(
"segment",
x = -1,
xend = -2.5,
y = ydrop,
yend = ydrop,
color = "black",
size = 1,
arrow = arrow(
angle = 18,
ends = "last",
type = "closed"
)
) +
annotate(
"text",
x = 1.7,
y = textdrop,
label = "Upregulated",
size = 4.5
) +
annotate(
"text",
x = -1.7,
y = textdrop,
label = "Downregulated",
size = 4.5
)
p1+theme_new()+ggtitle("R2-31")
附件