# PCoA are different between qiime2 and physeq r package.

**URL:** https://forum.qiime2.org/t/pcoa-are-different-between-qiime2-and-physeq-r-package/17042
**Category:** General Discussion
**Tags:** pcoa
**Created:** [October 12, 2020, 9:59pm UTC](https://forum.qiime2.org/t/pcoa-are-different-between-qiime2-and-physeq-r-package/17042 "2020-10-12T21:59:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![11132](https://forum.qiime2.org/user_avatar/forum.qiime2.org/11132/32/8508_2.png) [@11132](https://forum.qiime2.org/u/11132)
#### Post date: [October 12, 2020, 9:59pm UTC](https://forum.qiime2.org/t/pcoa-are-different-between-qiime2-and-physeq-r-package/17042/1 "2020-10-12T21:59:04Z")

</div>

Hi friends in qiime2,

I used qiime2 and R to generate PCoA matrix on the same beta diversity matrix.  
PCoA matrix generated from two methods are different.  
Has anyone met the same issue before or does anyone have an opinion on it? Thanks.

Way1. The unweighted UniFrac pcoa was generated in qiime2 using codes below.

`qiime diversity pcoa \ --i-distance-matrix $diversity_dir/unweighted_unifrac.qza \ --o-pcoa $pcoa_dir/unweighted_unifrac_pcoa.qza`  
Then _unweighted\_unifrac\_pcoa.qza_ was loaded into R using codes below  
`uufp=read_qza('unweighted_unifrac_pcoa.qza')$data$Vectors`

Way2. The unweighted UniFrac pcoa was generated in phyloseq r package using codes below.  
`physeq\<-qza\_to\_phyloseq(features="asv\_table.qza",  
tree='tree.qza',  
taxonomy='taxa\_assignments.qza',  
metadata ="dat.tsv")

uufp\_phy= ordinate(physeq, "PCoA", "unifrac", weighted=FALSE)``

Then I compared the `uufp` and `uufp_phy`, these two objects are different.

best,  
Yun

---

<div class="post-metadata">

### Author: ![Nicholas\_Bokulich](https://forum.qiime2.org/user_avatar/forum.qiime2.org/nicholas_bokulich/32/19937_2.png) [@Nicholas\_Bokulich](https://forum.qiime2.org/u/Nicholas_Bokulich)
#### Post date: [October 13, 2020, 5:39am UTC](https://forum.qiime2.org/t/pcoa-are-different-between-qiime2-and-physeq-r-package/17042/2 "2020-10-13T05:39:53Z")

</div>

Hi @11132,  
This is a known **issue with phyloseq** : [very different weighted unifrac values for qiime2 versus phyloseq · Issue #956 · joey711/phyloseq · GitHub](https://github.com/joey711/phyloseq/issues/956)

See also these QIIME 2 forum topics for relevant discussion and description of testing and validation of the UniFrac implementation used in QIIME 2.

> [@Very different weighted unifrac results for qiime2 versus phyloseq](https://forum.qiime2.org/t/very-different-weighted-unifrac-results-for-qiime2-versus-phyloseq/4591/12):
>
> @nick-youngblut, I’m not sure of the source of the difference but thank you for flagging it. Weighted UniFrac is deterministic, and the implementations of UniFrac used by QIIME 2 are validated against the original implementation of UniFrac by Cathy Lozupone from PyCogent (unit tests for the version of UniFrac being used by QIIME 2 by default are [here](https://github.com/biocore/scikit-bio/blob/master/skbio/diversity/beta/tests/test_unifrac.py)). Has anyone in your team followed up with the phyloseq developers about the difference? Best, Daniel

> [@How to tell which UniFrac calculation is correct from different software](https://forum.qiime2.org/t/how-to-tell-which-unifrac-calculation-is-correct-from-different-software/11892/11):
>
> Hi @wallacelab, Thank you for joining the form, and for taking the time to perform this assessment and post the exploration! UniFrac is deterministic, and variation in results is unexpected. QIIME 2 uses an implementation of [Striped UniFrac](https://www.nature.com/articles/s41592-018-0187-8). The [unit tests](https://github.com/biocore/unifrac/blob/master/sucpp/test_su.cpp) for Striped UniFrac are derived from the [unit tests](https://github.com/biocore/scikit-bio/blob/master/skbio/diversity/beta/tests/test_unifrac.py) for the [Fast UniFrac](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2797552/) implementation in scikit-bio (which QIIME 2 used previously). These implementations exhibit identical results to the best of our knowledge. The unit tests for Fast UniF…

---

<div class="post-metadata">

### Author: ![11132](https://forum.qiime2.org/user_avatar/forum.qiime2.org/11132/32/8508_2.png) [@11132](https://forum.qiime2.org/u/11132)
#### Post date: [October 13, 2020, 8:57pm UTC](https://forum.qiime2.org/t/pcoa-are-different-between-qiime2-and-physeq-r-package/17042/3 "2020-10-13T20:57:32Z")

</div>

hi @ Nicholas\_Bokulich,

Thanks for your reply.  
Based on the discussion points, i think i'll use qiime2-generated matrix, rather than phyloseq r package since it doesn't check the assumptions.

Best,  
Yun
