D2K: Construct kernel matrix from distance metric

Description Usage Arguments Details Value Author(s) References Examples

View source: R/D2K.R

Description

Construct kernel matrix from distance matrix (matrix of pairwise distances) for microbiome data.

Usage

1
D2K(D)

Arguments

D

An n by n matrix giving pairwise distances or dissimilarities, where n is the sample size.

Details

The kernel matrix is constructed as K = - (I - 11'/n)D^2 (I - 11'/n)/2, where D is the pairwise distance matrix, I is an identity matrix and 1 is a vector of 1. D^2 represents element wise square. To ensure that K to be positive semi-definite, a positive semi-definiteness correction is conducted.

Value

An n by n kernel or similarity matrix corresponding to the distance matrix.

Author(s)

Ni Zhao

References

Zhao, Ni, et al. "Testing in microbiome-profiling studies with MiRKAT, the microbiome regression-based kernel association test." The American Journal of Human Genetics 96.5 (2015): 797-807.

Examples

1
2
3
4
5
6
7
8
9
  #############################################################
 require(GUniFrac)
 # Load in data and create a distance metric
 data(throat.tree)
 data(throat.otu.tab)
 unifracs = GUniFrac(throat.otu.tab, throat.tree, alpha = c(1))$unifracs
 D1 = unifracs[,,"d_1"]
 # Function
 K = D2K(D1)

aplantin/MiRKATS documentation built on Feb. 16, 2021, 2:23 a.m.