微生物多樣性qiime2分析流程(8) phyloseq整合已有OTU數(shù)據(jù)進行分析

前面一系列文章介紹了如何通過qiime2處理原始數(shù)據(jù),進行聚類注釋及可視化分析,但是現(xiàn)實中小伙伴們已經(jīng)得到了處理好的OTU表及注釋文件,那怎么基于此來進行后續(xù)分析呢?由于qiime2提供的是.qza的壓縮文件,而我們手中的是文本文件,那就需要進行格式轉(zhuǎn)換及整合,最終轉(zhuǎn)化成phyloseq對象.

這次我們通過phyloseq包來轉(zhuǎn)化格式

1.安裝phyloseq

注:目前所安裝包均基于R 4.0 (請及時更新R版本)

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("phyloseq")

2. 處理OTU表格式

le otu_taxa.table.xls|sed 's/ //g'| \
awk 'BEGIN{OFS=FS="\t"}{print $1,$NF}'|sed '1d'| \
sed '1i OTU,domain,phylum,class,order,family,genus,species'| \
sed 's/,/\t/g'|sed 's/;/\t/g' |sed 's/[a-z]__//g'> otu_taxa.xls

le otu_taxa_table.xls|awk 'BEGIN{OFS=FS="\t"};NF{NF-=1};1' > otu_table.xls

注:otu_taxa.table.xls 中包含OTU豐度信息及注釋信息
通過以上處理得到了OTU表及OTU注釋信息,接下來讓我們通過phyloseq包將其與樣本信息整合。

3. phyloseq整合數(shù)據(jù)

pacman::p_load(tidyverse,phyloseq,MicrobiotaProcess,ape)
otu_mat <- read.delim2("otu_table.xls",header=T,
                       sep="\t",check.names = F,row.names = 1) %>% as.matrix()
tax_mat <- read.delim("otu_taxa.xls",header=T,row.names = 1,
                      sep="\t",check.names = F) %>% as.matrix()
samples_df <- read.delim("group.txt",header = T,
                         sep="\t",check.names = F,row.names = 1)
tree <- read.tree("rep_set.tre")

OTU = otu_table(otu_mat, taxa_are_rows =T)
TAX = tax_table(tax_mat)
samples = sample_data(samples_df)

ps <- phyloseq(OTU, TAX, samples,tree)
ps
phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 3365 taxa and 41 samples ]
sample_data() Sample Data:       [ 41 samples by 2 sample variables ]
tax_table()   Taxonomy Table:    [ 3365 taxa by 7 taxonomic ranks ]
phy_tree()    Phylogenetic Tree: [ 3365 tips and 3363 internal nodes ]

經(jīng)過以上處理我們就得到了可直接用于可視化分析的數(shù)據(jù),之后參考可視化教程對其直接進行分析

4. 基礎(chǔ)可視化操作

phytax <- get_taxadf(obj=ps, taxlevel=2)
phybar <- ggbartax(obj=phytax,facetNames="Group", count=FALSE) +
  xlab(NULL) + ylab("relative abundance (%)")+
  theme(axis.text.x=element_text(face="plain",
                                 color="black",hjust=0.8,vjust=0.6,
                                 size=9, angle=90))+
  theme(strip.text.x = element_text(size=8, color="black",
                                    face="plain"))+
  theme(legend.position="right")
phybar

bar.jpeg

參考:https://vaulot.github.io/tutorials/Phyloseq_tutorial.html

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

友情鏈接更多精彩內(nèi)容