2021年4月7日星期三

Phyloseq: relative abundance otu-table and metadata do not match

I am relatively new to phyloseq and I struggle to obtain a relative abundance otu-table acceptable for input to siamcat R code for meta-analysis.

# this works: from qza to phyloseq object  ps<-qza_to_phyloseq(    features="all-table.qza",    tree="rooted-tree.qza",    taxonomy = "all-taxonomy.qza",    metadata = "metafinal.tsv"  )    # import metadata  metadata <- read_tsv("metafinal.tsv")    # 100% overlap of the metadata-sample_id with relative-abundance-table rows  gplots::venn(list(metadata=metadata$sample_id, features=colnames(feat)))    # works: from phyloseq object to relative abundance otu table  table(tax_table(ps)[, "Phylum"])  ps_rel_abund <- transform_sample_counts(ps, function(x){x / sum(x)})  ps_phylum_rel <- tax_glom(ps_rel_abund, "Phylum")  taxa_names(ps_phylum_rel) <- tax_table(ps_phylum_rel)[, "Phylum"]  rel_table <- as(otu_table(ps_phylum_rel), "matrix")    # column names and sample_id are 100% the same  colnames(rel_table)  metadata$sample_id    # check that metadata and feature agree  stopifnot(all(colnames(rel_table) == metadata$sample_id))  

and here I get an error message: all(colnames(rel_table) == metadata$sample_id) is not TRUE and the following siamcat code is not working at all.

my metadata[1:5, 1:5]: sample_id absolute_filepath study experiment_acce… study_title

1 SRR8547628 $PWD/Chen_2020_da… Chen… SRX5349649 Dissection of c… 2 SRR8547629 $PWD/Chen_2020_da… Chen… SRX5349648 Dissection of c… 3 SRR8547630 $PWD/Chen_2020_da… Chen… SRX5349647 Dissection of c… 4 SRR8547631 $PWD/Chen_2020_da… Chen… SRX5349646 Dissection of c… 5 SRR8547632 $PWD/Chen_2020_da… Chen… SRX5349645 Dissection of c…

my rel-table[1:5, 1:5]: SRR5092146 SRR5092147 SRR5092148 SRR5092149 Phragmoplastophyta 0 0.0000000 0.00000000 0.000000000 Vertebrata 0 0.0000000 0.00000000 0.000000000 Apicomplexa 0 0.0000000 0.00000000 0.000000000 Ascomycota 0 0.0000000 0.00000000 0.000000000 Campilobacterota 0 0.2465222 0.01166882 0.004337051 SRR5092150 Phragmoplastophyta 0.00000000 Vertebrata 0.00000000 Apicomplexa 0.00000000 Ascomycota 0.00000000 Campilobacterota 0.02106281

nrow(metadata)= 154 ncol(rel_table)= 154

Please, why is it not working? I tried for weeks now and I can't make the code run properly ...

Thank you for your time and help.

https://stackoverflow.com/questions/66991209/phyloseq-relative-abundance-otu-table-and-metadata-do-not-match April 08, 2021 at 01:32AM

没有评论:

发表评论