应用案例
Fig.4PhylumdistributionoftheOTUs.Relativesequenceabundanceofbacterialphylaassociatedwiththerhizospheresoilandtheroot,stemandleafendosphere.ProteobacteriaOTUhasbeenreplacedby5OTUsatthesubclasslevel(alpha,beta,delta,epsilon,gamma).(Beckerseta.,,Microbiome)
分析代码
######物种组成图
otu-read.csv("D://PJJ/test_otu.csv",row.names=1)#(测试数据可后台获取)
design-read.csv("D://PJJ/test_design.csv")
library(car)
library(ggplot2)
library(reshape2)
otu-otu[1:,]
#主要phylum统计
data-aggregate(otu[,1:32],by=list(otu$Tax),FUN=sum)
rownames(data)-data[,1]
mean-data[,-1]
#排序
mean-mean[order(rowSums(mean),decreasing=T),]
aa-cbind(t(mean),design)
##不同处理丰度统计
data-aggregate(aa[,1:6],by=list(aa$Treatment),FUN=mean)
rownames(data)-data[,1]
#去掉名字列
pp-t(data[,2:7])
pp-cbind(rownames(pp),pp)
#构建数据框
df=melt(pp,id.vars="V1",value.name="Relativeabundance",variable.name="sps")####把宽数据变为长数据
head(df)
#去掉多余因子
df-df[7:30,]
#转化为数值型
df$`Relativeabundance`-as.numeric(as.character(df$`Relativeabundance`))
##出图
ggplot(data=df,aes(x=df$Var2,y=df$`Relativeabundance`,fill=df$Var1))+
geom_bar(position="fill",stat="identity",width=0.7)+##设置为相对比例%,真实数据需根据数据调整
ylab("Relativeabundance")+#y轴设置
scale_fill_manual(values=c("#BC8F8F","#B","#AFF","#F","#B4EEB4","#CD69C9"))+
scale_y_reverse(expand=c(0,0),labels=c("1","0.75","0.50","0.25","0"))+##x轴单位设置,如非%,需根据数据调整
scale_x_discrete(name=Treatment)+
guides(fill=guide_legend(title="Phylum",color="black",reverse=TRUE))+theme_classic()#设置主题
分析结果
参考文献
Beckers,B.,OpDeBeeck,M.,Weyens,N.,Boerjan,W.,Vangronsveld,J.,.Structuralvariabilityandnichedifferentiationintherhizosphereandendospherebacterialmicrobiomeoffield-grownpoplartrees.Microbiome5.
欢迎投稿!将您最新的科研进展分享给大家!
欢迎同行加入土壤微生物组学术交流群!(识别下方