D2K: D2K

View source: R/D2K.R

D2KR Documentation

D2K

Description

Construct kernel matrix from distance matrix.

Usage

D2K(D)

Arguments

D

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

Details

Converts a distance matrix (matrix of pairwise distances) into a kernel matrix for microbiome data. 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 the identity matrix, and 1 is a vector of ones.

D^2 represents element-wise square.

To ensure that K is positive semi-definite, a positive semi-definiteness correction is conducted

Value

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

Author(s)

Ni Zhao

References

Zhao, Ni, et al. "Testing in microbiome-profiling studies with MiRKAT, the microbiome regression-based kernel association test

Examples

library(GUniFrac)

#Load in data and create a distance matrix
data(throat.tree)
data(throat.otu.tab)
unifracs <- GUniFrac(throat.otu.tab, throat.tree, alpha=c(1))$unifracs
D1 <- unifracs[,,"d_1"]

#Function call
K <- D2K(D1)


MiRKAT documentation built on March 7, 2023, 5:55 p.m.