前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >转换OTU表和序列文件为PICRUST2需要的格式

转换OTU表和序列文件为PICRUST2需要的格式

作者头像
Listenlii-生物信息知识分享
发布2022-07-30 14:02:47
9130
发布2022-07-30 14:02:47
举报

作者:需要鼓励的小昱

审核:Listenlii


Load data

代码语言:javascript
复制
library(phyloseq)
packageVersion("phyloseq")
## [1] '1.32.0'
data("GlobalPatterns")# phyloseq 自带文件
GlobalPatterns

1.准备biom格式的OTU表

Export otu_table.txt

代码语言:javascript
复制
write.table(otu_table(GlobalPatterns), "GlobalPatterns_otu_table.txt", sep="\t", row.names=TRUE, col.names=NA, quote=FALSE)

Change .txt file to .biom file

在服务器运行这部分代码

代码语言:javascript
复制
# 把文件放到工作文件夹中
echo -n "#OTU Table" | cat - GlobalPatterns_otu_table.txt > GlobalPatterns_otu_biom_table.txt

biom convert -i GlobalPatterns_otu_biom_table.txt -o GlobalPatterns_otu.biom --table-type="OTU table" --to-hdf5

2. 准备.fna格式的代表性序列

Phyloseq 提供的数据提取不出来序列文件。只能用自己的了

library

代码语言:javascript
复制
library("phyloseq") 
library("dplyr") 
library("biomformat")
library("Biostrings")
load(file = "ps_rs_rsingle_CK_AT.rda")#载入一个phyloseq文件

whole rep seq

代码语言:javascript
复制
whole_seq_fasta <- readDNAStringSet("../raw_data/RDP-Bacteria-sequences.fasta")# 代表性序列文件
whole_sequences_fasta_ASV <- names(whole_seq_fasta)
whole_sequences_fasta_sequences <- paste(whole_seq_fasta)
whole_sequences_fasta_df <- data.frame(whole_sequences_fasta_ASV,
                                       whole_sequences_fasta_sequences)

Abundant taxa data

filter subset repseq:

从整个数据的fastq文件,提取出来我们想要的丰富种序列。

代码语言:javascript
复制
AT_tax_picrust <- taxa_names(ps_rs_CK_AT)
AT_tax_seq_fasta_df <- whole_sequences_fasta_df[with
                                                (whole_sequences_fasta_df,whole_sequences_fasta_ASV %in% AT_tax_picrust),]
 

rename the dataframe columns

代码语言:javascript
复制
AT_tax_seq_fasta_df_names <- rename(AT_tax_seq_fasta_df, 
                                   c( "whole_sequences_fasta_ASV" = "abundance",
                                      "whole_sequences_fasta_sequences" = "sequence")
                                   )

Export using dada2

代码语言:javascript
复制

uniquesToFasta(AT_tax_seq_fasta_df_names , 
                fout = "../rsingle_data/R_output/PICRUST2_data/AT_tax_rep_seqs.fna", #路径
                ids = AT_tax_seq_fasta_df_names$abundance)

最后就得到了PICRUST2需要的OTU表和序列文件了!


PS:

一个问题,如果想分别分析稀有种和优势种得功能,是整个跑Picrust之后再挑出不同类型的物种,还是先挑出不同类型物种再做分析?

github上有人回答建议整个跑出来之后再挑不同类型物种的结果查看。

It would be best to generate the stratified output (mentioned in the tutorial), which you can then analyze based on the different sets of ASVs you're interested in. You might also just want to look at the output of hsp.py specifically, as it sounds like you just want to compare the predicted genome annotations for rare and abundant ASVs. https://github.com/picrust/picrust2/issues/258

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-06-24,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 Listenlii 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Load data
  • 1.准备biom格式的OTU表
    • Export otu_table.txt
      • Change .txt file to .biom file
      • 2. 准备.fna格式的代表性序列
        • library
          • whole rep seq
          • Abundant taxa data
            • filter subset repseq:
              • rename the dataframe columns
                • Export using dada2
                领券
                问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档