服务热线
178 0020 3020
library(ggplot2)
R2_04_1 <- ggplot(mtcars, aes(factor(cyl))) +
geom_bar(aes(fill = factor(gear)), width = 0.6) +
labs(title = "Here is title", subtitle = "Here is subtitle", caption = "R2-04", x = "cyl", fill = "gear") # 更改图例名p1
mytheme <- theme_classic() +
theme(panel.grid.major = element_blank(),
legend.position = "none",
plot.caption = element_text(face = "bold.italic"))
R2_04_1 + mytheme
library("ggplot2")
library("latex2exp")
library(ggrepel)
volcano_data <- read.csv(file.choose())
volcano_data$significant <- ifelse(abs(log2(volcano_data$FC)) < 1 | volcano_data$q_value > 0.05 ,"not","yes" )
volcano_data$mylabels <- ifelse(abs(log2(volcano_data$FC)) < 1| volcano_data$q_value > 0.05,NA,as.character(volcano_data$Gene.ID))
sig <- subset(volcano_data,significant == "yes")
R2_04_2 <- ggplot(volcano_data,aes(x = log2(FC) , y = -log2(q_value),size = significant)) +
geom_point(col = "grey") +
xlim(-2.5,2.7) +
ylim(-0.4,15) +
scale_size_manual(values = c(2,0)) +
geom_point(data = sig,aes(x = log2(FC),y = -log2(q_value),col = mylabels),size = 4) +
geom_text_repel(aes(label = mylabels),size =3,col = "black",fontface = "italic") +
annotate("segment", x = 1 , xend = 2.5, y = 1,yend = 1 ,color = "black",
size = 1,arrow = arrow(angle = 18,ends = "last",type = "closed")) +
annotate("segment", x = -1 , xend = -2.5, y = 1,yend = 1 ,color = "black",
size = 1,arrow = arrow(angle = 18,ends = "last",type = "closed")) +
annotate("text",x = 1.7,y = 1.9,label = "Upregulated",size = 4.5) +
annotate("text",x = -1.7,y = 1.9,label = "Downregulated",size = 4.5) +
labs(title = "CMTM6 sgRNA2 vs Control",
caption = "create by R2-04") +
labs(x = expression(log[2])) +
labs(x = expression(paste(log[2],"(fold change)")),
y = expression(paste(-log[2],"(Q value)")))
R2_04_2 +
theme(plot.title = element_text(hjust = mean(range(log2(volcano_data$FC)))+ 0.1)) +
geom_vline(xintercept = 0,linetype = 2 ,size= rel(0.8)) +
mytheme
我觉得群主新建一个数据框,来放置标注的六个基因是正解。但是,鉴于我好不容易才找到ggrepel包,给大家推荐一下
附件