R2-24 第七次作业-火山图

fenglashoubuli 2017-12-19 23:10:18 阅读: 1229

library(ggplot2)

T1<-ggplot(mtcars,aes(factor(cyl)))+geom_bar(aes(fill=factor(gear)),width=0.8)+labs(title='The barplot of cyl',subtitle='stack barplot',caption='R2-24',x='cyl',fill='gear')

print(T1)

R7-1_0.jpg


T1+mytheme

mytheme<-theme_classic()+theme(panel.grid.minor=element_blank(),legend.position='none',plot.caption=element_text(face='bold.italic'))


R7-1_1.jpg


install.packages('latex2exp')
library(ggplot2)
library(latex2exp)
myvolcano<-read.csv('D:/R-LMT/7/nature23643-s4.csv');
head(myvolcano,5)
myvolcano$significant<-as.factor(ifelse(-log2(myvolcano$q_value)>5,ifelse(abs(log2(myvolcano$FC))>1,'yes' ,'no'),'no'))
mysig<-subset(myvolcano,significant=='yes')
ydrop=0.6
textdrop=1.2

p=ggplot(myvolcano,aes(x=log2(FC),y=-log2(q_value),size=significant))+geom_point(col='grey',alpha=1)+scale_size_manual(values=c(2,0))+geom_point(data=mysig,aes(x=log2(FC),y=-log2(q_value),color=锘縂ene.ID),size=4)+geom_text(data=mysig,aes(label=锘縂ene.ID),size=3,hjust=0.5,vjust=1.5,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)+geom_vline(xintercept=0,lty=2,lwd=0.5)+xlim(c(-3,3))+ylim(c(-1,15))+labs(x=expression(paste(log[2],'(fold change)')),y=expression(paste(-log[2],'(Q value)')))+labs(title='CMTM6 sgRNA2 vs Control',caption='R2-24')+theme(plot.title=element_text(hjust=mean(range(log2(myvolcano$FC)))+0.1))
p
p+mytheme


R7-2_1_.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

微信服务号