I'd like to ask how to calculate distances between groups using weighted UniFrac or Bray-Curtis method in R. I already got distances between each sample using UniFrac method.
library("phyloseq")
require(GUniFrac)
require(vegan)
require(ade4)
otu.tab <- t(otu_table(phy))
treefile <- phy_tree(phy)
# calculate the UniFracs
unifracs <- GUniFrac(otu.tab, treefile, alpha = c(0, 0.5, 1))$unifracs
# create
d5 <- unifracs[, , "d_0.5"] # GUniFrac with alpha 0.5
The distance result table is:
> d5
SamA_1 SamA_2 SamB_1 SamB_2 SamC_1 SamC_2
SamA_1 0.0000000 0.3939102 0.3972185 0.3846277 0.4052247 0.4187168
SamA_2 0.3939102 0.0000000 0.2986860 0.3003682 0.3384096 0.3475723
SamB_1 0.3972185 0.2986860 0.0000000 0.3549342 0.2997557 0.3457747
SamB_2 0.3846277 0.3003682 0.3549342 0.0000000 0.3378881 0.3529470
SamC_1 0.4052247 0.3384096 0.2997557 0.3378881 0.0000000 0.3828705
SamC_2 0.4187168 0.3475723 0.3457747 0.3529470 0.3828705 0.0000000
> sample_data(phy)
Treat Groups
SamA_1 CON A
SamA_2 CON A
SamB_1 Treat B
SamB_2 Treat B
SamC_1 Treat C
SamC_2 Treat C
I'd like to calculate distances between groups A, B, and C, eventually I want a distances table such as "d5".
Which function is proper to get a calculated distances table between groups in R?