Learn R Programming

GUniFrac (version 1.2)

GUniFrac: Generalized UniFrac distances for comparing microbial communities.

Description

A generalized version of commonly used UniFrac distances. It is defined as: $$d^{(\alpha)} = \frac{\sum_{i=1}^m b_i (p^A_{i} + p^B_{i})^\alpha \left\vert \frac{ p^A_{i} - p^B_{i} }{p^A_{i} + p^B_{i}} \right\vert } { \sum_{i=1}^m b_i (p^A_{i} + p^B_{i})^\alpha},$$

where \(m\) is the number of branches, \(b_i\) is the length of \(i\)th branch, \(p^A_{i}, p^B_{i}\) are the branch proportion for community A and B.

Generalized UniFrac distance contains an extra parameter \(\alpha\) controlling the weight on abundant lineages so the distance is not dominated by highly abundant lineages. \(\alpha=0.5\) is overall very robust.

The unweighted and weighted UniFrac, and variance-adjusted weighted UniFrac distances are also implemented.

Usage

GUniFrac(otu.tab, tree, alpha = c(0, 0.5, 1))

Arguments

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

Value

Return a LIST containing

unifracs

A three dimensional array containing all the UniFrac distance matrices

References

Jun Chen et al. (2012). Associating microbiome composition with environmental covariates using generalized UniFrac distances. 28(16): 2106<U+2013>2113.

See Also

Rarefy, PermanovaG

Examples

Run this code
# NOT RUN {
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)


# }

Run the code above in your browser using DataLab