R2-33 火山图

R48-小之 2017-12-19 22:11:58 阅读: 1109

作业一

library(ggplot2)

b<-ggplot(mtcars,aes(x=cyl,fill=factor(gear)))+geom_bar()+labs(title = "Here is title", subtitle = "Here is subtitle", caption="R2-33")

mytheme<-theme_classic()+theme(panel.background=element_rect(fill='white',color="black"), panel.grid=element_blank(),legend.position = "none", plot.caption = element_text(face = "bold.italic") )

#fill=factor(gear) 要定义为因子,不然会认为是gear连续变量,bar会成为渐变色

#theme_classic() 代表什么?为什么加与不加,都对做图没有影响

#plot.caption = element_text(face = "bold.italic") 字体改变

#panel.background=element_rect(fill='white',color="black") 其中color=black使四周图片有黑色边框,如果删去则没有横纵坐标轴,那么横纵坐标轴又要如何做出了?

1.png 

作业二

library(ggplot2)

library(latex2exp)

mydata<-read.csv("nature23643-s4.csv")

head(mydata)

mydata$significant <- ifelse(abs(log2(mydata$FC)) > 1 & mydata$q_value < 0.05,"yes","no" )

mydata$mylabels <- ifelse(abs(log2(mydata$FC)) > 1 & mydata$q_value < 0.05, as.character(mydata$锘縂ene.ID),NA)

mysig<- subset(mydata,significant=="yes")

mysig

ydrop=-0.6

textdrop=0.3

myplot<- ggplot(mydata,aes(x=log2(FC),y=-log2(q_value),size=significant))+

geom_point(col="grey70",alpha=1)+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),color=锘縂ene.ID),size=4,position=position_jitter(height=0.1,width=0))+

geom_text(aes(label=mylabels),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)+

labs(title="CMTM6 sgRNA2 vs Control",caption="R2-33")+labs(x=expression(log[2]))+

labs(x=expression(paste(log[2],"(fold change)")),y=expression(paste(-log[2],"(Q value)")))

myplot

mytheme<-theme_classic()+theme(panel.background=element_rect(fill='white',color="black"), panel.grid=element_blank(),legend.position = "none", plot.caption = element_text(face = "bold.italic") )

myplot + geom_vline(xintercept = 0,linetype = 2 ,size= rel(0.8)) + mytheme


3.png


#点上未有标签的解决方法,代码中Gene.ID全部更换为锘縂ene.ID

2.png

 

 

 
邀请讨论

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
{{item.nick_name}} 受邀请回答 {{item.create_time}}
{{item.refer_comment.nick_name}} {{item.refer_comment.create_time}}

附件

{{f.title}} 大小 {{f.file_size}} 下载 {{f.count_download}} 金币 {{f.count_gold}}
切换到完整回复 发送回复
赞({{item.count_zan}}) 踩({{item.count_cai}}) 删除 回复 关闭
科研狗©2015-2024 科研好助手,京ICP备20005780号-1 建议意见

服务热线

178 0020 3020

微信服务号