应用案例:气泡图展示基因丰度
Fig.3.Relativenormalizedabundanceofmetabolicandfunctionalgenesinvolvedinenergygeneration,oxygentolerance,andbiogeochemicalcyclingfromBrothersvolcanometagenomeassemblies,includingthosediscussedinthetext.(A)BubblesrepresentsinglegenesorironmetabolismgenecategorieslistedinDatasetS2B.(Reysenbachetal.,;PNAS)
绘图代码
###bubbleplot
library(ggplot2)
library(reshape2)
pp-read.csv("D://RF_analysis.csv")#可后台获取
pp-pp[,1:8]
##构建数据框
io=melt(pp,id.vars=c("name"),value.name="Value",variable.name="Genes")####把宽数据变为长数据
head(io)
#io$sites=factor(io$sites,levels=unique(io$sites))####对样方排序
###转化数值型
io$Value-as.numeric(as.character(io$Value))
####转factor型
unique(io$name)
io$Phylum=factor(io$name)
####出图1
ggplot(io,aes(y=io$name,x=io$Genes))+
geom_point(aes(size=abs(Value),colour=Genes))+#,shape=1
scale_colour_manual(values=c("#B1A4C0","#E9B","#FDDC7B","#B2","#ACCDDC","#DD5F60","#F2B","#7CB6DB","pink2","skyblue","Gold2"))+
theme_bw(base_size=12)+
theme(axis.text.x=element_text(angle=45,hjust=1))+
#theme(legend.position="bottom",legend.direction="horizontal")+
#+labs(size="WindSpeed(mph)",fill="Months")#legendtitle
scale_size(range=c(0,9),breaks=c(0,10,20,40),limits=c(0,40))+
guides(colour=guide_legend(override.aes=list(size=5)))+
theme(axis.text=element_text(colour=black,size=9))
#####出图2
ggplot(io,aes(y=io$name,x=io$Genes))+
geom_point(aes(size=abs(Value),colour=Genes))+#,shape=1
scale_colour_manual(values=c("#B1A4C0","#E9B","#FDDC7B","#B2","#ACCDDC","#DD5F60","#F2B","#7CB6DB","pink2","skyblue","Gold2"))+
theme_bw(base_size=12)+
theme(axis.text.x=element_text(angle=45,hjust=1))+
#theme(legend.position="bottom",legend.direction="horizontal")+
#+labs(size="WindSpeed(mph)",fill="Months")#legendtitle
scale_size(range=c(0,9),breaks=c(0,10,20,40),limits=c(0,40))+
guides(colour=guide_legend(override.aes=list(size=5)))+
theme(axis.text=element_text(colour=black,size=9))+
theme(panel.background=element_rect(fill=white,colour=black),
panel.grid=element_blank(),
axis.title=element_text(color=black,size=9),
axis.ticks.length=unit(0.4,"lines"),axis.ticks=element_line(color=black),
axis.line=element_line(colour="black"),
axis.title.x=element_text(colour=black,size=9),
axis.title.y=element_text(colour=black,size=9),
axis.text=element_text(colour=black,size=9),
legend.title=element_blank(),
legend.text=element_text(size=9),
legend.key=element_blank(),
legend.background=element_rect(colour="white"))+
theme(axis.text.x=element_text(size=9,angle=45,hjust=1))
预览时标签不可点收录于话题#个上一篇下一篇