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/
586 stars 186 forks source link

Calculating weighted Unifrac Distance from CLR Data #1685

Open JLammons14 opened 1 year ago

JLammons14 commented 1 year ago

I have been trying to generate an ordination plot using weighted unifrac distances calculated from CLR transformed data. I initially had this working but after our local server crashed and I lost about a days worth of code, and had to redownload all related packages, I'm having a lot of trouble reproducing my results or even producing normal looking results. Unfortunately I don't know what package versions I was previously using.

Some trouble shooting I've done: I've successfully generated a normal ordination plot using wunifrac distance with relative abundance transformed data, and have been able to ordinate CLR transformed data when using euclidean distance. Let me know if there's anything I could be doing wrong, or if others have found success generating wunifrac disance from CLR in phyloseq.

I've attached an image of what the current plot looks like when I am calculating weighted unifrac distance using CLR transformed data. For reference there are over 200 samples in this analysis.

phyloseq version = 1.44.0 microbiome version = 1.23.1 vegan version = 2.6-4

Relevant Code:

##glommed phyloseq object with count abundance
ps_glom_genus
##transform to CLR
ps_glom_genus_clr <- microbiome::transform(ps_glom_genus, 'clr')

##distance matrix 
wuni_dist <- phyloseq::distance(ps_glom_genus_clr, method = "wunifrac")
##ordinate
ord <- phyloseq::ordinate(ps_glom_genus_clr, method = "MDS", distance = wuni_dist)
##plot
plot_ordination(ps_glom_genus_clr, ord)

` CLR_weighted_unifrac

samd1993 commented 1 year ago

not sure but there have been multiple posts showing that unifrac in phyloseq is unreliable see here. So I would use vegan in R to generate the unifrac plot. I would also try it on the raw data rather than transforming it and see if u get more tangible variation

slambrechts commented 8 months ago

This might not be related to weighted Unifrac Distance from CLR Data, because I am seeing the same with Bray distances from CLR Data. I think the CLR transformation might be causing this

I also got the following error message:

Warning: results may be meaningless because data have negative entries in method “bray”Warning: results may be meaningless because data have negative entries in method “bray”