MiRKAT.R: Robust MiRKAT (robust regression)

View source: R/MiRKAT_R.R

MiRKAT.RR Documentation

Robust MiRKAT (robust regression)

Description

A more robust version of MiRKAT utilizing a linear model by robust regression using an M estimator.

Usage

MiRKAT.R(y, X, Ks, omnibus = "kernel_om", returnKRV = FALSE, returnR2 = FALSE)

Arguments

y

A numeric vector of the a continuous or dichotomous outcome variable.

X

A numerical matrix or data frame, containing additional covariates that you want to adjust for Mustn't be NULL

Ks

list of n by n kernel matrices (or a single n by n kernel matrix), where n is the sample size. It can be constructed from microbiome data through distance metric or other approaches, such as linear kernels or Gaussian kernels.

omnibus

A string equal to either "Cauchy" or "kernel_om" (or nonambiguous abbreviations thereof), specifying whether to use the Cauchy combination test or an omnibus kernel to generate the omnibus p-value.

returnKRV

A logical indicating whether to return the KRV statistic. Defaults to FALSE.

returnR2

A logical indicating whether to return the R-squared coefficient. Defaults to FALSE.

Details

MiRKAT.R creates a kernel matrix using the linear model created with the function rlm, a robust regression function, then does the KRV analysis on Ks and the newly formed kernel matrix representing the outome traits.

y and X should all be numerical matrices or vectors with the same number of rows, and mustn't be NULL.

Ks should be a list of n by n matrices or a single matrix. If you have distance metric from metagenomic data, each kernel can be constructed through function D2K. Each kernel may also be constructed through other mathematical approaches.

Missing data is not permitted. Please remove all individuals with missing y, X, Ks prior to analysis

Value

Returns p-values for each individual kernel matrix, an omnibus p-value if multiple kernels were provided, and measures of effect size KRV and R2.

p_values

labeled individual p-values for each kernel

omnibus_p

omnibus p_value, calculated as for the KRV test

KRV

A vector of kernel RV statistics (a measure of effect size), one for each candidate kernel matrix. Only returned if returnKRV = TRUE

R2

A vector of R-squared statistics, one for each candidate kernel matrix. Only returned if returnR2 = TRUE

Author(s)

Weijia Fu

Examples

    


# Generate data
library(GUniFrac)

data(throat.tree)
data(throat.otu.tab)
data(throat.meta)

unifracs = GUniFrac(throat.otu.tab, throat.tree, alpha = c(1))$unifracs
if (requireNamespace("vegan")) {
 library(vegan)
 BC= as.matrix(vegdist(throat.otu.tab, method="bray"))
 Ds = list(w = unifracs[,,"d_1"], uw = unifracs[,,"d_UW"], BC = BC)
} else {
 Ds = list(w = unifracs[,,"d_1"], uw = unifracs[,,"d_UW"])
}
Ks = lapply(Ds, FUN = function(d) D2K(d))

covar = cbind(throat.meta$Age, as.numeric(throat.meta$Sex == "Male"))

# Continuous phenotype
n = nrow(throat.meta)
y = rchisq(n, 2)
MiRKAT.R(y, X = covar, Ks = Ks)


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