library(GUniFrac)
if(requireNamespace("vegan")) { library(vegan) }
data(throat.tree)
data(throat.otu.tab)
data(throat.meta)
unifracs <- GUniFrac(throat.otu.tab, throat.tree, alpha=c(0, 0.5, 1))$unifracs
if(requireNamespace("vegan")) {
BC= as.matrix(vegdist(throat.otu.tab , method="bray"))
Ds = list(w = unifracs[,,"d_1"], u = unifracs[,,"d_UW"], BC = BC)
} else {
Ds = list(w = unifracs[,,"d_1"], u = unifracs[,,"d_UW"])
}
Ks = lapply(Ds, FUN = function(d) D2K(d))
n = nrow(throat.otu.tab)
Y = matrix(rnorm(n*3, 0, 1), n, 3)
covar = cbind(as.numeric(throat.meta$Sex == "Male"), as.numeric(throat.meta$PackYears))
MMiRKAT(Y = Y, X = covar, Ks = Ks)
Run the code above in your browser using DataLab