GUniFrac {GUniFrac} | R Documentation |
A generalized version of commonly used UniFrac distances. It is defined as:
d^{(α)} = [∑_{i=1}^m b_i (p^A_{i} + p^B_{i})^α |p^A_{i} - p^B_{i}|/(p^A_{i} + p^B_{i})]/ [ ∑_{i=1}^m b_i (p^A_{i} + p^B_{i})^α],
where m is the number of branches, b_i is the length of ith branch, p^A_{i}, p^B_{i} are the branch proportion for community A and B.
Generalized UniFrac distance contains an extra parameter α controlling the weight on abundant lineages so the distance is not dominated by highly abundant lineages. α=0.5 is overall very robust.
The unweighted and weighted UniFrac, and variance-adjusted weighted UniFrac distances are also implemented.
GUniFrac(otu.tab, tree, alpha = c(0, 0.5, 1))
otu.tab |
OTU count table, row - n sample, column - q OTU |
tree |
Rooted phylogenetic tree of R class “phylo” |
alpha |
Parameter controlling weight on abundant lineages |
Return a LIST containing
unifracs |
A three dimensional array containing all the UniFrac distance matrices |
The function only accepts rooted tree. To root a tree, you may
consider using midpoint
from the package phangorn
.
Jun Chen <chen.jun2@mayo.edu>
Jun Chen et al. (2012). Associating microbiome composition with environmental covariates using generalized UniFrac distances. 28(16): 2106–2113.
data(throat.otu.tab) data(throat.tree) data(throat.meta) groups <- throat.meta$SmokingStatus # Rarefaction otu.tab.rff <- Rarefy(throat.otu.tab)$otu.tab.rff # Calculate the UniFracs unifracs <- GUniFrac(otu.tab.rff, throat.tree, alpha=c(0, 0.5, 1))$unifracs dw <- unifracs[, , "d_1"] # Weighted UniFrac du <- unifracs[, , "d_UW"] # Unweighted UniFrac dv <- unifracs[, , "d_VAW"] # Variance adjusted weighted UniFrac d0 <- unifracs[, , "d_0"] # GUniFrac with alpha 0 d5 <- unifracs[, , "d_0.5"] # GUniFrac with alpha 0.5 # Permanova - Distance based multivariate analysis of variance adonis3(as.dist(d5) ~ groups)