GUniFrac: Generalized UniFrac distances for comparing microbial...

GUniFracR Documentation

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 ith 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 ("d_0.5") is overall very robust.

The unweighted ("d_1") and weighted UniFrac ("d_UW") are also implemented.

Usage

GUniFrac(otu.tab, tree, size.factor = NULL, alpha = c(0, 0.5, 1), verbose = TRUE)

Arguments

otu.tab

a matrix, the OTU count table, row - n sample, column - q OTU

tree

a rooted phylogenetic tree of R class “phylo”

size.factor

a numeric vector of the normalizing factors to divide the counts. The length is the number of samples. This provides the flexibility to normalize data using the preferred normalization method (e.g. GMPR normalizing factor). If not supplied, the total sum will be used.

alpha

a numeric vector, parameters controlling the weight on abundant lineages

verbose

logical value, whether to print out the messages

Value

Return a list containing

unifracs

a three dimensional array containing all the UniFrac distance matrices

Note

The function only accepts rooted tree. To root a tree, you may consider using midpoint from the package phangorn.

Author(s)

Jun Chen <chen.jun2@mayo.edu>

References

Chen, J., Bittinger, K., Charlson, E.S., Hoffmann, C., Lewis, J., Wu, G.D., Collman, R.G., Bushman, F.D. and Li, H. (2012). Associating microbiome composition with environmental covariates using generalized UniFrac distances. 28(16): 2106–2113.

See Also

Rarefy, PermanovaG

Examples

## 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	
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)

## End(Not run)


GUniFrac documentation built on Sept. 14, 2023, 1:07 a.m.