Learn R Programming

MiRKAT (version 1.2.3)

D2K: D2K

Description

Construct kernel matrix from distance matrix.

Usage

D2K(D)

Value

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

Arguments

D

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

Author

Ni Zhao

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

References

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

Examples

Run this code
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)

Run the code above in your browser using DataLab