joey711 / phyloseq

phyloseq is a set of classes, wrappers, and tools (in R) to make it easier to import, store, and analyze phylogenetic sequencing data; and to reproducibly share that data and analysis with others. See the phyloseq front page:
http://joey711.github.io/phyloseq/
582 stars 187 forks source link

UniFrac distances not working after merging samples #1611

Closed ibrila closed 2 years ago

ibrila commented 2 years ago

I am trying to merge samples as in the tutorial to see what is the group-level response to the explanatory variable.

The command works fine, and I am able to calculate the Bray-Curtis and Jaccard distances but trying to run UniFrac :

rbiom::unifrac(biom=as.matrix(phyloseq::otu_table(ps_merged)), weighted=FALSE, tree=phy_tree(ps_merged))

gives this error:

Error: OTUs missing from reference tree.

The command works fine with the unmerged file, and the trees and taxonomy tables are identical.

Is there a fix for this?

ibrila commented 2 years ago

For whatever reason, after merging samples, the new OTU table had group names as rows instead of OTU IDs! So once I transposed the new OTU table the UniFracs work.