Search code examples
rphyloseq

tax_glom() or merge_samples() inhibits downstream calls for sam_table() categories


I have data with OTUs representing fungal taxa I have discovered through metabarcoding of moths with ITS2 primers. I have a phyloseq object with an otu_table, tax_table, and sam_data. In sam_data I have categories with all taxonomic levels of the sample (buttterfly). I have merged the individual samples by a category in my sam_data called species. This means that instead of having a bunch of samples where some samples are belonging to the same species, I now have a phyloseq object with much fewer samples, since the once who share species now are grouped together.

Code for merging:

physeq <- phyloseq(OTU, TAX, META)

mergesamp_physeq <- merge_samples(physeq, "species")

I have also merged the OTU table so that OTUs identified to be the same species are merged into one OTU:

merge_physeq <- tax_glom(mergesam_physeq, "species")

I now want to do a PCoA on this data using genus to colour the samples in my ordination, but the return shows me a PCoA without colour. I get no errors. See immage of PcoA plot, script below:

pcoa_bc = ordinate(merge_physeq, "PCoA", "bray") plot_ordination(merge_physeq, pcoa_bc, color = "genus") + geom_point(size = 3) + ggtitle("PCoA")

Does someone might now what has happened? It works fine before merging of samples and taxa.

EDIT: My sam_data() does indeed get a lot of NAs after merging. Identical column names is adressed as R by a warning, but it automatically renames my sample data headers with a "sam_" prefix, so that should be no issue. I have solved this by phrasing my question differently in another post the whole issue with merging samples is resolved here: Solution


Solution

  • The problem is resolved here: Solution The issue is with merging and the issue is more clearly stated in this post.