david-barnett / microViz

R package for microbiome data visualization and statistics. Uses phyloseq, vegan and the tidyverse. Docker image available.
https://david-barnett.github.io/microViz/
GNU General Public License v3.0
106 stars 11 forks source link

dist_calc() Error #53

Closed Leran10 closed 2 years ago

Leran10 commented 2 years ago

Hi,

I was trying to run below command:

ps0.UC.CD.HHC.fix %>% 
  tax_transform(trans = "clr", rank = "Genus") %>% 
  dist_calc("wunifrac")

And I got this error message:

unifrac distances require un-aggregated taxa and a phylogenetic tree.
 Show Traceback
Error in access(physeq, "phy_tree", errorIfNULL) : phy_tree slot is empty.

I'm sure I have a tree in the phyloseq object:

ps0.UC.CD.HHC.fix
phyloseq-class experiment-level object
otu_table()   OTU Table:         [ 5284 taxa and 518 samples ]
sample_data() Sample Data:       [ 518 samples by 10 sample variables ]
tax_table()   Taxonomy Table:    [ 5284 taxa by 7 taxonomic ranks ]
phy_tree()    Phylogenetic Tree: [ 5284 tips and 5282 internal nodes ]

Could you let me know how to fix this issue?

Thanks so much! Leran

david-barnett commented 2 years ago

Hi Leran, tax_transform with a rank of "Genus" is aggregating the taxa, and so removing the phylogenetic tree, hence the error message. So don't use tax_transform or use it with "identity" transform with "unique" or NA rank before any unifrac distance

Leran10 commented 2 years ago

Thanks so much!!