Bray-Curtis calculation

235 views
Skip to first unread message

plasti...@gmail.com

unread,
Aug 20, 2014, 11:42:10 AM8/20/14
to qiime...@googlegroups.com
My apologies if this is a rather elementary question.  I've searched the Qiime documentation, tutorial, and forum but can't seem to find the precise calculation used by beta_diversity.py for creating the Bray-Curtis distance matrix. 

I've been getting different results using the same OTU table using Qiime and vegan (vegdist, method set to bray) and am trying to track down why.

Thanks in advance!

Will Van Treuren

unread,
Aug 20, 2014, 12:01:48 PM8/20/14
to qiime...@googlegroups.com
Hi,

The development version of QIIME uses Scipy to calcuate the Bray Curtis dissimilarity measure (scipy.spatial.distance.pdist function specifically). 
QIIME 1.8 uses PyCogent to calculate the Bray Curtis distance apparently using the normalized Manhattan distance (cogent.maths.distance_transform dist_bray_curtis function, code located here).

Can you provide a small example that shows the differences in the outputs you are getting? That will help us diagnose any problems.

Hope this helps,
Will 


--

---
You received this message because you are subscribed to the Google Groups "Qiime Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qiime-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

jay bee

unread,
Aug 21, 2014, 4:00:18 PM8/21/14
to qiime...@googlegroups.com
Hi Will,

Thanks for responding!  This is a sample distance matrix from vegdist:
A B C D
A 0 1.531274835 1.649860898 1.451182992
B 1.531274835 0 1.877257876 1.499588695
C 1.649860898 1.877257876 0 1.398265611
D 1.451182992 1.499588695 1.398265611 0

and here is the distance matrix for the same samples from QIIME:
A B C D
A 0 0.860465116 0.961165049 0.904761905
B 0.860465116 0 1 0.866666667
C 0.961165049 1 0 0.882352941
D 0.904761905 0.866666667 0.882352941 0


--

---
You received this message because you are subscribed to a topic in the Google Groups "Qiime Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/qiime-forum/tx74w-fwyHA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to qiime-forum...@googlegroups.com.

Will Van Treuren

unread,
Aug 21, 2014, 4:08:06 PM8/21/14
to qiime...@googlegroups.com
HI Jay,

I need the commands you used and the input matrices. 

Thanks
Will 

jay bee

unread,
Aug 22, 2014, 3:13:02 PM8/22/14
to qiime...@googlegroups.com
Hi Will,

Sorry, I didn't think of that.  Here are the files and commands below:

QIIME
# convert sample back to biom format
biom convert -i otu_table.txt -o new_otu_table.biom --table-type "otu table" 

# make distance matrix
echo beta_diversity:metrics bray_curtis,binary_sorensen_dice >beta_params.txt

beta_diversity_through_plots.py -i new_otu_table.biom -o bdiv/ -m mapping_plot_qiime.txt -p beta_params.txt -f

Vegan

# manually deleted first line of OTU table with hashtag, then removed #otu id from the header line

comm.data <- read.table("otu_tableR.txt", header=TRUE, sep="\t")

comm.matrix<-t(comm.data) #transpose

## make Bray-Curtis distance matrix

dist.matrix<-vegdist(comm.matrix,method="bray")


Thanks!

otu_table.txt
mapping_plot_qiime.txt
otu_tableR.txt
Reply all
Reply to author
Forward
0 new messages