服务热线
178 0020 3020
library(ggplot2) head(mtcars) R2_30<-ggplot(mtcars,aes(factor(cyl)))+geom_bar(aes(fill=factor(gear)),width = 0.5)+labs(title="Here is title",subtitle="Here is subtitle",caption="Here is caption",x="cyl",fill="gear") mytheme<-theme_classic()+theme(panel.grid = element_blank(),legend.position = "none",plot.caption = element_text(face = "bold.italic")) R2_30+mytheme
library("latex2exp")
library(ggrepel)
myvolcano<-read.csv("C:/Documents and Settings/Administrator/桌面/s/r/第七次作业/nature23643-s4.csv")
head(myvolcano)
myvolcano$significant<-ifelse(abs(log2(myvolcano$FC))>1 &myvolcano$q_value<0.05,"yes","no")
myvolcano$mylabels<-ifelse(abs(log2(myvolcano$FC))>1 & myvolcano$q_value<0.05,as.character(myvolcano$Gene.ID),NA)
head(myvolcano)
mysig<-subset(myvolcano,significant=="yes")
ydrop=-0.6
textdrop=0.3
myplot<-ggplot(myvolcano,aes(x=log2(FC),y=-log2(q_value),size=significant))+geom_point(col="grey70",alpha=0.8)+xlim(-2.5,2.7)+ylim(-0.8,15)+scale_size_manual(values = c(2,0))+geom_point(data =mysig,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=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)+ggtitle("R2-30")
R2_30<-myplot+mytheme+theme(plot.title = element_text(hjust = mean(range(log2(myvolcano$FC)))+0.1))+geom_vline(xintercept = 0,linetype=2,size=rel(0.8))
R2_30
附件