library(GUniFrac)
library(quantreg)
# Generate data
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 = scale(cbind(throat.meta$Age, as.numeric(throat.meta$Sex == "Male")))
# Continuous phenotype
n = nrow(throat.meta)
y = rchisq(n, 2) + apply(covar, 1, sum)
MiRKAT.Q(y, X = covar, Ks = Ks)
Run the code above in your browser using DataLab