clr_LUniFrac: clr_LUniFrac

Description Usage Arguments Details Value Examples

View source: R/pl_clr_unifrac.R

Description

Longitudinal UniFrac distances for comparing changes in microbial communities across 2 time points, using CLR-transformed data.

Usage

1
2
3
4
5
6
7
8
clr_LUniFrac(
  otu.tab,
  metadata,
  tree,
  gam = c(0, 0.5, 1),
  paired,
  pseudocount = NULL
)

Arguments

otu.tab

OTU count table, containing 2*n rows (samples) and q columns (OTUs)

metadata

Data frame with three columns: subject identifiers (n unique values), sample identifiers (must match row names of otu.tab), and time or group indicator (numeric variable, or factor with levels such that as.numeric returns the desired ordering). Column names should be subjID, sampID, time.

tree

Rooted phylogenetic tree of R class "phylo"

gam

Parameter controlling weighting factor for average taxon abundance.

paired

Logical indicating whether to use the paired (TRUE) or longitudinal (FALSE) transformation.

pseudocount

Pseudocount to be added to all values in OTU matrix prior to CLR transformation. Default NULL. If NULL, then 0.5 is added if entries are counts, or min(1e-06, 0.5*min(nonzero p)) if entries are proportions. If all entries are nonzero, nothing is added.

Details

Based in large part on Jun Chen & Hongzhe Li (2012), GUniFrac. With reference to the GitHub account of user ruthgrace, repository CLRUniFrac (this method is not associated with a publication).

Computes difference between time points and then calculates difference of these differences, resulting in a dissimilarity matrix that can be used in a variety of downstream distance-based analyses.

Value

Returns a (K+1) dimensional array containing the longitudinal UniFrac dissimilarities with the K specified gamma values plus the unweighted distance. The unweighted dissimilarity matrix may be accessed by result[,,"d_UW"], and the generalized dissimilarities by result[,,"d_G"] where G is the particular choice of gamma.

Examples

1
2
3
4
5
6
7
data("bal.long.otus")
data("bal.long.meta")
data("sim.tree")
D2.unifrac <- clr_LUniFrac(otu.tab = bal.long.otus, metadata = bal.long.meta, 
    tree = sim.tree, gam = c(0, 0.5, 1), paired = FALSE)
D2.unifrac[, , "d_1"]   # gamma = 1 (quantitative longitudinal transformation)
D2.unifrac[, , "d_UW"]  # unweighted LUniFrac (qualitative/binary longitudinal transf.)

aplantin/pldist documentation built on Feb. 26, 2021, 2:19 p.m.