用phyloseq甚至可以快速写出来微生物部分的结果

写在前面

这个功能我开发出来一年多了,一直都挺好用的,虽然重点在于数据统计,但是简单成文还是为我节省了不少时间。微生物组做到现在,连结果分析部分都有规律可循了,那这个领域就做的很成熟了,当然就需要更加深层次的研究要做。

实战

library(ggClusterNet)

#基于整体的测序文件我们需要制作测序数据的整体评估
# ps02准备好phyloseq对象并可以使用下面代码来书写群落分析的前四句话。data(ps)

ps

#step_1:where <- "where"
method <- "using 16S rRNA gene amplicon sequencing."
rep = 6
step_1 <- paste("We analyzed the composition of microbial communities in the",where,method)

#step_2 统计测序样本总量每个样品中的序列数量
a = sum(sample_sums(ps))
b = "high-quality sequences were obtained"
# 统计样本数量
b1 = paste("across the" ,length(sample_sums(ps)),"samples",sep = " ")
b1
#统计重复数量
repead <- paste("For this analysis, we collected",rep,"repeats for each samples.",sep = " ")
repead
#合并句子
each_count <- paste(repead,b1,a,b," and an average read count per sample of ",round(mean(sample_sums(ps)),0),"(standard deviation (SD)",round(sd(sample_sums(ps)),2),").",sep = " ")
each_count

# step3
aa = vegan_otu(ps)
otu_table = as.data.frame((aa))
otu_table = as.matrix(otu_table)
otu_table [otu_table > 0] <-1
OTU_sum <- colSums(otu_table)
d = length(OTU_sum [OTU_sum > 0])
c = paste("All sequences were clustered into", d, "operational taxonomic units (OTUs).",sep = " ")

sample_tax <- paste(c,"the numbers of OTU, generally ranged between ",
min(OTU_sum)," and ",max(OTU_sum)," per sample with an average of ",
round(mean(OTU_sum),0),"(SD ",round(sd(OTU_sum)),")",sep = "")
sample_tax

###step 4 统计门水平的总体丰度信息
library("tidyverse")
Taxonomies <- ps %>%
tax_glom(taxrank = "Phylum") %>%
transform_sample_counts(function(x) {x/sum(x)} )%>%
psmelt() %>%
#filter(Abundance > 0.05) %>%
arrange(Phylum)
iris_groups<- group_by(Taxonomies, Phylum)
ps0_sum <- dplyr::summarise(iris_groups, mean(Abundance), sd(Abundance))
ps0_sum[is.na(ps0_sum)] <- 0
colnames(ps0_sum) = c("ID","mean","sd")
ps0_sum <- dplyr::arrange(ps0_sum,desc(mean))
ps0_sum$mean <- ps0_sum$mean *100
ps0_sum <- as.data.frame(ps0_sum)
a = paste(ps0_sum[1,1],"(",round(ps0_sum[1,2],2),"%"," with sd ",round(ps0_sum[1,3],3),")",sep = " ")
b = paste(ps0_sum[2,1],"(",round(ps0_sum[2,2],2),"%"," with sd ",round(ps0_sum[2,3],3),")",sep = " ")
c = paste(ps0_sum[3,1],"(",round(ps0_sum[3,2],2),"%"," with sd ",round(ps0_sum[3,3],3),")",sep = " ")
d = paste(ps0_sum[4,1],"(",round(ps0_sum[4,2],2),"%"," with sd ",round(ps0_sum[4,3],3),")",sep = " ")
e = paste(ps0_sum[5,1],"(",round(ps0_sum[5,2],2),"%"," with sd ",round(ps0_sum[5,3],3),")",sep = " ")
f = paste(ps0_sum[6,1],"(",round(ps0_sum[6,2],2),"%"," with sd ",round(ps0_sum[6,3],3),")",sep = " ")
g = paste(ps0_sum[7,1],"(",round(ps0_sum[7,2],2),"%"," with sd ",round(ps0_sum[7,3],3),")",sep = " ")
h = paste(ps0_sum[8,1],"(",round(ps0_sum[8,2],2),"%"," with sd ",round(ps0_sum[8,3],3),")",sep = " ")
i = paste(ps0_sum[9,1],"(",round(ps0_sum[9,2],2),"%"," with sd ",round(ps0_sum[9,3],3),")",sep = " ")
j = paste(ps0_sum[10,1],"(",round(ps0_sum[10,2],2),"%"," with sd ",round(ps0_sum[10,3],3),")",sep = " ")

tax_sum = paste("The majority of OTU belonged to the phyla",a,b,c,d,e,f,g,h,i,"and",j,".",sep = " ")
tax_sum
##all_first
line = paste(step_1,each_count ,sample_tax ,tax_sum,sep = "")
line

代码窗口

根际互作生物学研究室 简介

根际互作生物学研究室是沈其荣教授土壤微生物与有机肥团队下的一个关注于根际互作的研究小组。本小组由袁军副教授带领,主要关注:1.植物和微生物互作在抗病过程中的作用;2 环境微生物大数据整合研究;3 环境代谢组及其与微生物过程研究体系开发和应用。团队在过去三年中在 isme J, Microbiome, PCE,SBB,Horticulture Research等期刊上发表了多篇文章。欢迎关注 微生信生物 公众号对本研究小组进行了解。

团队工作及其成果 (点击查看)

(0)

相关推荐