CRAN Package Check Results for Package MiRKAT

Last updated on 2020-02-19 10:48:59 CET.

Flavor Version Tinstall Tcheck Ttotal Status Flags
r-devel-linux-x86_64-debian-clang 1.0.1 11.37 84.47 95.84 ERROR
r-devel-linux-x86_64-debian-gcc 1.0.1 8.81 66.43 75.24 ERROR
r-devel-linux-x86_64-fedora-clang 1.0.1 114.10 ERROR
r-devel-linux-x86_64-fedora-gcc 1.0.1 113.17 ERROR
r-devel-windows-ix86+x86_64 1.0.1 22.00 119.00 141.00 OK
r-devel-windows-ix86+x86_64-gcc8 1.0.1 30.00 173.00 203.00 OK
r-patched-linux-x86_64 1.0.1 8.84 76.52 85.36 OK
r-patched-solaris-x86 1.0.1 176.50 OK
r-release-linux-x86_64 1.0.1 8.52 76.01 84.53 OK
r-release-windows-ix86+x86_64 1.0.1 20.00 113.00 133.00 OK
r-release-osx-x86_64 1.0.1 OK
r-oldrel-windows-ix86+x86_64 1.0.1 15.00 119.00 134.00 OK
r-oldrel-osx-x86_64 1.0.1 OK

Check Details

Version: 1.0.1
Check: examples
Result: ERROR
    Running examples in 'MiRKAT-Ex.R' failed
    The error most likely occurred in:
    
    > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
    > ### Name: KRV
    > ### Title: Kernel RV Coefficient Test
    > ### Aliases: KRV
    >
    > ### ** Examples
    >
    > library(MASS)
    > library(GUniFrac)
    > data(throat.tree)
    > data(throat.otu.tab)
    > data(throat.meta)
    > attach(throat.meta)
    >
    > set.seed(123)
    > n = nrow(throat.otu.tab)
    > Male = (Sex == "Male")**2
    > Smoker =(SmokingStatus == "Smoker") **2
    > anti = (AntibioticUsePast3Months_TimeFromAntibioticUsage != "None")^2
    > cova = cbind(Male, anti)
    >
    > otu.tab.rff <- Rarefy(throat.otu.tab)$otu.tab.rff
    > unifracs <- GUniFrac(otu.tab.rff, throat.tree, alpha=c(0, 0.5, 1))$unifracs
    >
    > D.weighted = unifracs[,,"d_1"]
    > D.unweighted = unifracs[,,"d_UW"]
    > D.BC= as.matrix(vegdist(otu.tab.rff , method="bray"))
    >
    > K.weighted = D2K(D.weighted)
    > K.unweighted = D2K(D.unweighted)
    > K.BC = D2K(D.BC)
    >
    > rho = 0.2
    > Va = matrix(rep(rho, (2*n)^2), 2*n, 2*n)+diag(1-rho, 2*n)
    > G = mvrnorm(n, rep(0, 2*n), Va)
    >
    > #############################################################
    >
    > KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    MiRKAT
     --- call from context ---
    KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
     --- call from argument ---
    if ((class(kernel.otu) != "matrix")) {
     stop("Please provide a kernel matrix for microbiome data")
    }
     --- R stacktrace ---
    where 1: KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
    
     --- value of length: 2 type: logical ---
    [1] FALSE TRUE
     --- function from context ---
    function (kernel.otu, y = NULL, X = NULL, kernel.y)
    {
     if ((class(kernel.otu) != "matrix")) {
     stop("Please provide a kernel matrix for microbiome data")
     }
     if (is.matrix(kernel.y)) {
     n = nrow(kernel.otu)
     if (!is.null(X)) {
     warning("Covariates can't be adjusted for in this case, and hence argument \"X\" will be ignored.")
     }
     if (!is.null(y)) {
     warning("No need to provide phenotype matrix when a phenotype kernel is provided, and hence argument \"y\" will be ignored.")
     }
     if (ncol(kernel.otu) != n | nrow(kernel.y) != n | ncol(kernel.y) !=
     n) {
     stop("kernel matrices need to be n x n, where n is the sample size \n ")
     }
     }
     if (!is.matrix(kernel.y)) {
     if (!(kernel.y %in% c("Gaussian", "linear"))) {
     stop("Please choose kernel.y = \"Gaussian\" or \"linear\", or enter a kernel matrix for \"kernel.y\"")
     }
     if (is.null(y)) {
     stop("Please enter a phenotype matrix for argument \"y\" or enter a kernel matrix for argument \"kernel.y\" ")
     }
     n = NROW(y)
     if (nrow(kernel.otu) != n | ncol(kernel.otu) != n) {
     stop("kernel matrix needs to be n x n, where n is the sample size \n ")
     }
     if (any(is.na(y))) {
     ids = which(is.na(y))
     stop(paste("subjects", ids, "has missing response, please remove before proceed \n"))
     }
     if (!is.null(X)) {
     if (any(is.na(X))) {
     stop("NAs in covariates X, please impute or remove subjects which has missing covariates values")
     }
     if (NROW(X) != NROW(y))
     stop("Dimensions of X and y don't match.")
     }
     }
     K = kernel.otu
     kern_g = function(zz) {
     n = nrow(zz)
     D = matrix(NA, nrow = n, ncol = n)
     for (i in 1:n) {
     for (j in 1:n) {
     D[i, j] = sum((zz[i, ] - zz[j, ])^2)
     }
     }
     temp = c(D)
     D1 = temp[temp > 0]
     scl = median(D1)
     K = matrix(NA, nrow = n, ncol = n)
     for (i in 1:n) {
     for (j in 1:n) {
     K[i, j] = exp(-sum((zz[i, ] - zz[j, ])^2)/scl)
     }
     }
     return(K)
     }
     n = nrow(K)
     I.n = diag(1, n)
     I.1 = rep(1, n)
     if (is.matrix(kernel.y)) {
     L = kernel.y
     }
     else {
     if (!is.null(X)) {
     Px = X %*% solve(t(X) %*% X) %*% t(X)
     err.Y = (I.n - Px) %*% y
     }
     else {
     err.Y = y
     }
     if (kernel.y == "Gaussian") {
     L = kern_g(err.Y)
     }
     else {
     if (kernel.y == "linear") {
     L = err.Y %*% t(err.Y)
     }
     }
     }
     H = I.n - I.1 %*% t(I.1)/n
     K = H %*% K %*% H
     L = H %*% L %*% H
     A = K/tr(K %*% K)
     W = L/tr(L %*% L)
     Fstar = tr(A %*% W)
     mean.krv = tr(A) * tr(W)/(n - 1)
     T = tr(A)
     T2 = tr(A %*% A)
     S2 = sum(diag(A)^2)
     Ts = tr(W)
     T2s = tr(W %*% W)
     S2s = sum(diag(W)^2)
     temp1 = 2 * ((n - 1) * T2 - T^2) * ((n - 1) * T2s - Ts^2)/(n -
     1)^2/(n + 1)/(n - 2)
     temp21 = n * (n + 1) * S2 - (n - 1) * (T^2 + 2 * T2)
     temp22 = n * (n + 1) * S2s - (n - 1) * (Ts^2 + 2 * T2s)
     temp23 = (n + 1) * n * (n - 1) * (n - 2) * (n - 3)
     temp2 = temp21 * temp22/temp23
     variance.krv = temp1 + temp2
     T3 = tr(A %*% A %*% A)
     S3 = sum(diag(A)^3)
     U = sum(A^3)
     R = t(diag(A)) %*% diag(A %*% A)
     B = t(diag(A)) %*% A %*% diag(A)
     T3s = tr(W %*% W %*% W)
     S3s = sum(diag(W)^3)
     Us = sum(W^3)
     Rs = t(diag(W)) %*% diag(W %*% W)
     Bs = t(diag(W)) %*% W %*% diag(W)
     t1 = n^2 * (n + 1) * (n^2 + 15 * n - 4) * S3 * S3s
     t2 = 4 * (n^4 - 8 * n^3 + 19 * n^2 - 4 * n - 16) * U * Us
     t3 = 24 * (n^2 - n - 4) * (U * Bs + B * Us)
     t4 = 6 * (n^4 - 8 * n^3 + 21 * n^2 - 6 * n - 24) * B * Bs
     t5 = 12 * (n^4 - n^3 - 8 * n^2 + 36 * n - 48) * R * Rs
     t6 = 12 * (n^3 - 2 * n^2 + 9 * n - 12) * (T * S2 * Rs + R *
     Ts * S2s)
     t7 = 3 * (n^4 - 4 * n^3 - 2 * n^2 + 9 * n - 12) * T * Ts *
     S2 * S2s
     t81 = (n^3 - 3 * n^2 - 2 * n + 8) * (R * Us + U * Rs)
     t82 = (n^3 - 2 * n^2 - 3 * n + 12) * (R * Bs + B * Rs)
     t8 = 24 * (t81 + t82)
     t9 = 12 * (n^2 - n + 4) * (T * S2 * Us + U * Ts * S2s)
     t10 = 6 * (2 * n^3 - 7 * n^2 - 3 * n + 12) * (T * S2 * Bs +
     B * Ts * S2s)
     t11 = -2 * n * (n - 1) * (n^2 - n + 4) * ((2 * U + 3 * B) *
     S3s + (2 * Us + 3 * Bs) * S3)
     t12 = -3 * n * (n - 1)^2 * (n + 4) * ((T * S2 + 4 * R) *
     S3s + (Ts * S2s + 4 * Rs) * S3)
     t13 = 2 * n * (n - 1) * (n - 2) * ((T^3 + 6 * T * T2 + 8 *
     T3) * S3s + (Ts^3 + 6 * Ts * T2s + 8 * T3s) * S3)
     t14 = T^3 * ((n^3 - 9 * n^2 + 23 * n - 14) * Ts^3 + 6 * (n -
     4) * Ts * T2s + 8 * T3s)
     t15 = 6 * T * T2 * ((n - 4) * Ts^3 + (n^3 - 9 * n^2 + 24 *
     n - 14) * Ts * T2s + 4 * (n - 3) * T3s)
     t16 = 8 * T3 * (Ts^3 + 3 * (n - 3) * Ts * T2s + (n^3 - 9 *
     n^2 + 26 * n - 22) * T3s)
     t17 = -16 * (T^3 * Us + U * Ts^3) - 6 * (T * T2 * Us + U *
     Ts * T2s) * (2 * n^2 - 10 * n + 16)
     t18 = -8 * (T3 * Us + U * T3s) * (3 * n^2 - 15 * n + 16) -
     (T^3 * Bs + B * Ts^3) * (6 * n^2 - 30 * n + 24)
     t19 = -6 * (T * T2 * Bs + B * Ts * T2s) * (4 * n^2 - 20 *
     n + 24) - 8 * (T3 * Bs + B * T3s) * (3 * n^2 - 15 * n +
     24)
     t201 = 24 * (T^3 * Rs + R * Ts^3) + 6 * (T * T2 * Rs + R *
     Ts * T2s) * (2 * n^2 - 10 * n + 24)
     t202 = 8 * (T3 * Rs + R * T3s) * (3 * n^2 - 15 * n + 24) +
     (3 * n^2 - 15 * n + 6) * (T^3 * Ts * S2s + T * S2 * Ts^3)
     t203 = 6 * (T * T2 * Ts * S2s + Ts * T2s * T * S2) * (n^2 -
     5 * n + 6) + 48 * (T3 * Ts * S2s + T3s * T * S2)
     t20 = -(n - 2) * (t201 + t202 + t203)
     temp31 = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 +
     t11 + t12 + t13 + t14 + t15 + t16 + t17 + t18 + t19 +
     t20
     temp32 = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n -
     5)
     mom3 = temp31/temp32
     skewness.krv = (mom3 - 3 * mean.krv * variance.krv - mean.krv^3)/variance.krv^1.5
     m1 = mean.krv
     m2 = variance.krv
     m3 = skewness.krv
     shape = 4/m3^2
     scale = sqrt(m2) * m3/2
     location = m1 - 2 * sqrt(m2)/m3
     PIIIpars = list(shape, location, scale)
     pv = 1 - ppearsonIII(Fstar, params = PIIIpars)
     return(pv)
    }
    <bytecode: 0x6a37268>
    <environment: namespace:MiRKAT>
     --- function search by body ---
    Function KRV in namespace MiRKAT has this body.
     ----------- END OF FAILURE REPORT --------------
    Error in if ((class(kernel.otu) != "matrix")) { :
     the condition has length > 1
    Calls: KRV
    Execution halted
Flavor: r-devel-linux-x86_64-debian-clang

Version: 1.0.1
Check: re-building of vignette outputs
Result: WARN
    Error(s) in re-building vignettes:
     ...
    --- re-building 'MiRKAT.Rnw' using Sweave
    This is vegan 2.5-6
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    MiRKAT
     --- call from context ---
    MiRKAT(y = Smoker, Ks = K.weighted, X = cbind(Male, anti), out_type = "D",
     method = "davies")
     --- call from argument ---
    if (class(Ks) == "matrix") {
     Ks = list(Ks)
    }
     --- R stacktrace ---
    where 1: MiRKAT(y = Smoker, Ks = K.weighted, X = cbind(Male, anti), out_type = "D",
     method = "davies")
    where 2: eval(expr, .GlobalEnv)
    where 3: eval(expr, .GlobalEnv)
    where 4: withVisible(eval(expr, .GlobalEnv))
    where 5: doTryCatch(return(expr), name, parentenv, handler)
    where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 7: tryCatchList(expr, classes, parentenv, handlers)
    where 8: tryCatch(expr, error = function(e) {
     call <- conditionCall(e)
     if (!is.null(call)) {
     if (identical(call[[1L]], quote(doTryCatch)))
     call <- sys.call(-4L)
     dcall <- deparse(call)[1L]
     prefix <- paste("Error in", dcall, ": ")
     LONG <- 75L
     sm <- strsplit(conditionMessage(e), "\n")[[1L]]
     w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")
     if (is.na(w))
     w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
     type = "b")
     if (w > LONG)
     prefix <- paste0(prefix, "\n ")
     }
     else prefix <- "Error : "
     msg <- paste0(prefix, conditionMessage(e), "\n")
     .Internal(seterrmessage(msg[1L]))
     if (!silent && isTRUE(getOption("show.error.messages"))) {
     cat(msg, file = outFile)
     .Internal(printDeferredWarnings())
     }
     invisible(structure(msg, class = "try-error", condition = e))
    })
    where 9: try(withVisible(eval(expr, .GlobalEnv)), silent = TRUE)
    where 10: evalFunc(ce, options)
    where 11: tryCatchList(expr, classes, parentenv, handlers)
    where 12: tryCatch(evalFunc(ce, options), finally = {
     cat("\n")
     sink()
    })
    where 13: driver$runcode(drobj, chunk, chunkopts)
    where 14: utils::Sweave(...)
    where 15: engine$weave(file, quiet = quiet, encoding = enc)
    where 16: doTryCatch(return(expr), name, parentenv, handler)
    where 17: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 18: tryCatchList(expr, classes, parentenv, handlers)
    where 19: tryCatch({
     engine$weave(file, quiet = quiet, encoding = enc)
     setwd(startdir)
     output <- find_vignette_product(name, by = "weave", engine = engine)
     if (!have.makefile && vignette_is_tex(output)) {
     texi2pdf(file = output, clean = FALSE, quiet = quiet)
     output <- find_vignette_product(name, by = "texi2pdf",
     engine = engine)
     }
     outputs <- c(outputs, output)
    }, error = function(e) {
     thisOK <<- FALSE
     fails <<- c(fails, file)
     message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s",
     file, conditionMessage(e)))
    })
    where 20: tools:::buildVignettes(dir = "/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/MiRKAT.Rcheck/vign_test/MiRKAT",
     ser_elibs = "/tmp/RtmpSOT4TH/file2fda79e2c763.rds")
    
     --- value of length: 2 type: logical ---
    [1] TRUE FALSE
     --- function from context ---
    function (y, X = NULL, Ks, out_type = "C", nperm = 999, method = "davies")
    {
     n = length(y)
     if (any(is.na(y))) {
     ids = which(is.na(y))
     stop(paste("subjects", ids, "has missing response, please remove before proceed \n"))
     }
     if (is.null(X) == FALSE) {
     if (NROW(X) != length(y))
     stop("Dimensions of X and y don't match.")
     }
     if (class(Ks) == "matrix") {
     Ks = list(Ks)
     }
     if (class(Ks) == "list") {
     if ((any(lapply(Ks, "nrow") != n)) | (any(lapply(Ks,
     "ncol") != n))) {
     stop("distance matrix need to be n x n, where n is the sample size \n ")
     }
     if (class(Ks) != "list") {
     stop("Distance needs to be a list of n x n matrices or a single n x n matrix \n")
     }
     }
     if (!is.null(X)) {
     if (any(is.na(X))) {
     stop("NAs in covariates X, please impute or remove subjects which has missing covariates values")
     }
     }
     if (method == "moment" & n < 100 & out_type == "C") {
     warning("Continuous outcome: sample size < 100, p-value using moment matching can be inaccurate at tails, davies or permutation is recommended")
     }
     if (method == "moment" & n < 200 & out_type == "D") {
     warning("Continuous outcome: sample size < 200, p-value using moment matching can be inaccurate at tails, davies or permutation is recommended")
     }
     if (!(out_type %in% c("C", "D"))) {
     stop("Currently only continuous and Binary outcome are supported. Please choose out_type = \"C\" or \"D\" ")
     }
     if (out_type == "C") {
     re = MiRKAT_continuous(y, X = X, Ks = Ks, method = method,
     nperm = nperm)
     }
     if (out_type == "D") {
     re = MiRKAT_binary(y, X = X, Ks = Ks, method = method,
     nperm = nperm)
     }
     return(re)
    }
    <bytecode: 0x68e8400>
    <environment: namespace:MiRKAT>
     --- function search by body ---
    Function MiRKAT in namespace MiRKAT has this body.
     ----------- END OF FAILURE REPORT --------------
    
    Error: processing vignette 'MiRKAT.Rnw' failed with diagnostics:
     chunk 5 (label = data5)
    Error in if (class(Ks) == "matrix") { : the condition has length > 1
    
    --- failed re-building 'MiRKAT.Rnw'
    
    SUMMARY: processing the following file failed:
     'MiRKAT.Rnw'
    
    Error: Vignette re-building failed.
    Execution halted
Flavor: r-devel-linux-x86_64-debian-clang

Version: 1.0.1
Check: examples
Result: ERROR
    Running examples in ‘MiRKAT-Ex.R’ failed
    The error most likely occurred in:
    
    > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
    > ### Name: KRV
    > ### Title: Kernel RV Coefficient Test
    > ### Aliases: KRV
    >
    > ### ** Examples
    >
    > library(MASS)
    > library(GUniFrac)
    > data(throat.tree)
    > data(throat.otu.tab)
    > data(throat.meta)
    > attach(throat.meta)
    >
    > set.seed(123)
    > n = nrow(throat.otu.tab)
    > Male = (Sex == "Male")**2
    > Smoker =(SmokingStatus == "Smoker") **2
    > anti = (AntibioticUsePast3Months_TimeFromAntibioticUsage != "None")^2
    > cova = cbind(Male, anti)
    >
    > otu.tab.rff <- Rarefy(throat.otu.tab)$otu.tab.rff
    > unifracs <- GUniFrac(otu.tab.rff, throat.tree, alpha=c(0, 0.5, 1))$unifracs
    >
    > D.weighted = unifracs[,,"d_1"]
    > D.unweighted = unifracs[,,"d_UW"]
    > D.BC= as.matrix(vegdist(otu.tab.rff , method="bray"))
    >
    > K.weighted = D2K(D.weighted)
    > K.unweighted = D2K(D.unweighted)
    > K.BC = D2K(D.BC)
    >
    > rho = 0.2
    > Va = matrix(rep(rho, (2*n)^2), 2*n, 2*n)+diag(1-rho, 2*n)
    > G = mvrnorm(n, rep(0, 2*n), Va)
    >
    > #############################################################
    >
    > KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    MiRKAT
     --- call from context ---
    KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
     --- call from argument ---
    if ((class(kernel.otu) != "matrix")) {
     stop("Please provide a kernel matrix for microbiome data")
    }
     --- R stacktrace ---
    where 1: KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
    
     --- value of length: 2 type: logical ---
    [1] FALSE TRUE
     --- function from context ---
    function (kernel.otu, y = NULL, X = NULL, kernel.y)
    {
     if ((class(kernel.otu) != "matrix")) {
     stop("Please provide a kernel matrix for microbiome data")
     }
     if (is.matrix(kernel.y)) {
     n = nrow(kernel.otu)
     if (!is.null(X)) {
     warning("Covariates can't be adjusted for in this case, and hence argument \"X\" will be ignored.")
     }
     if (!is.null(y)) {
     warning("No need to provide phenotype matrix when a phenotype kernel is provided, and hence argument \"y\" will be ignored.")
     }
     if (ncol(kernel.otu) != n | nrow(kernel.y) != n | ncol(kernel.y) !=
     n) {
     stop("kernel matrices need to be n x n, where n is the sample size \n ")
     }
     }
     if (!is.matrix(kernel.y)) {
     if (!(kernel.y %in% c("Gaussian", "linear"))) {
     stop("Please choose kernel.y = \"Gaussian\" or \"linear\", or enter a kernel matrix for \"kernel.y\"")
     }
     if (is.null(y)) {
     stop("Please enter a phenotype matrix for argument \"y\" or enter a kernel matrix for argument \"kernel.y\" ")
     }
     n = NROW(y)
     if (nrow(kernel.otu) != n | ncol(kernel.otu) != n) {
     stop("kernel matrix needs to be n x n, where n is the sample size \n ")
     }
     if (any(is.na(y))) {
     ids = which(is.na(y))
     stop(paste("subjects", ids, "has missing response, please remove before proceed \n"))
     }
     if (!is.null(X)) {
     if (any(is.na(X))) {
     stop("NAs in covariates X, please impute or remove subjects which has missing covariates values")
     }
     if (NROW(X) != NROW(y))
     stop("Dimensions of X and y don't match.")
     }
     }
     K = kernel.otu
     kern_g = function(zz) {
     n = nrow(zz)
     D = matrix(NA, nrow = n, ncol = n)
     for (i in 1:n) {
     for (j in 1:n) {
     D[i, j] = sum((zz[i, ] - zz[j, ])^2)
     }
     }
     temp = c(D)
     D1 = temp[temp > 0]
     scl = median(D1)
     K = matrix(NA, nrow = n, ncol = n)
     for (i in 1:n) {
     for (j in 1:n) {
     K[i, j] = exp(-sum((zz[i, ] - zz[j, ])^2)/scl)
     }
     }
     return(K)
     }
     n = nrow(K)
     I.n = diag(1, n)
     I.1 = rep(1, n)
     if (is.matrix(kernel.y)) {
     L = kernel.y
     }
     else {
     if (!is.null(X)) {
     Px = X %*% solve(t(X) %*% X) %*% t(X)
     err.Y = (I.n - Px) %*% y
     }
     else {
     err.Y = y
     }
     if (kernel.y == "Gaussian") {
     L = kern_g(err.Y)
     }
     else {
     if (kernel.y == "linear") {
     L = err.Y %*% t(err.Y)
     }
     }
     }
     H = I.n - I.1 %*% t(I.1)/n
     K = H %*% K %*% H
     L = H %*% L %*% H
     A = K/tr(K %*% K)
     W = L/tr(L %*% L)
     Fstar = tr(A %*% W)
     mean.krv = tr(A) * tr(W)/(n - 1)
     T = tr(A)
     T2 = tr(A %*% A)
     S2 = sum(diag(A)^2)
     Ts = tr(W)
     T2s = tr(W %*% W)
     S2s = sum(diag(W)^2)
     temp1 = 2 * ((n - 1) * T2 - T^2) * ((n - 1) * T2s - Ts^2)/(n -
     1)^2/(n + 1)/(n - 2)
     temp21 = n * (n + 1) * S2 - (n - 1) * (T^2 + 2 * T2)
     temp22 = n * (n + 1) * S2s - (n - 1) * (Ts^2 + 2 * T2s)
     temp23 = (n + 1) * n * (n - 1) * (n - 2) * (n - 3)
     temp2 = temp21 * temp22/temp23
     variance.krv = temp1 + temp2
     T3 = tr(A %*% A %*% A)
     S3 = sum(diag(A)^3)
     U = sum(A^3)
     R = t(diag(A)) %*% diag(A %*% A)
     B = t(diag(A)) %*% A %*% diag(A)
     T3s = tr(W %*% W %*% W)
     S3s = sum(diag(W)^3)
     Us = sum(W^3)
     Rs = t(diag(W)) %*% diag(W %*% W)
     Bs = t(diag(W)) %*% W %*% diag(W)
     t1 = n^2 * (n + 1) * (n^2 + 15 * n - 4) * S3 * S3s
     t2 = 4 * (n^4 - 8 * n^3 + 19 * n^2 - 4 * n - 16) * U * Us
     t3 = 24 * (n^2 - n - 4) * (U * Bs + B * Us)
     t4 = 6 * (n^4 - 8 * n^3 + 21 * n^2 - 6 * n - 24) * B * Bs
     t5 = 12 * (n^4 - n^3 - 8 * n^2 + 36 * n - 48) * R * Rs
     t6 = 12 * (n^3 - 2 * n^2 + 9 * n - 12) * (T * S2 * Rs + R *
     Ts * S2s)
     t7 = 3 * (n^4 - 4 * n^3 - 2 * n^2 + 9 * n - 12) * T * Ts *
     S2 * S2s
     t81 = (n^3 - 3 * n^2 - 2 * n + 8) * (R * Us + U * Rs)
     t82 = (n^3 - 2 * n^2 - 3 * n + 12) * (R * Bs + B * Rs)
     t8 = 24 * (t81 + t82)
     t9 = 12 * (n^2 - n + 4) * (T * S2 * Us + U * Ts * S2s)
     t10 = 6 * (2 * n^3 - 7 * n^2 - 3 * n + 12) * (T * S2 * Bs +
     B * Ts * S2s)
     t11 = -2 * n * (n - 1) * (n^2 - n + 4) * ((2 * U + 3 * B) *
     S3s + (2 * Us + 3 * Bs) * S3)
     t12 = -3 * n * (n - 1)^2 * (n + 4) * ((T * S2 + 4 * R) *
     S3s + (Ts * S2s + 4 * Rs) * S3)
     t13 = 2 * n * (n - 1) * (n - 2) * ((T^3 + 6 * T * T2 + 8 *
     T3) * S3s + (Ts^3 + 6 * Ts * T2s + 8 * T3s) * S3)
     t14 = T^3 * ((n^3 - 9 * n^2 + 23 * n - 14) * Ts^3 + 6 * (n -
     4) * Ts * T2s + 8 * T3s)
     t15 = 6 * T * T2 * ((n - 4) * Ts^3 + (n^3 - 9 * n^2 + 24 *
     n - 14) * Ts * T2s + 4 * (n - 3) * T3s)
     t16 = 8 * T3 * (Ts^3 + 3 * (n - 3) * Ts * T2s + (n^3 - 9 *
     n^2 + 26 * n - 22) * T3s)
     t17 = -16 * (T^3 * Us + U * Ts^3) - 6 * (T * T2 * Us + U *
     Ts * T2s) * (2 * n^2 - 10 * n + 16)
     t18 = -8 * (T3 * Us + U * T3s) * (3 * n^2 - 15 * n + 16) -
     (T^3 * Bs + B * Ts^3) * (6 * n^2 - 30 * n + 24)
     t19 = -6 * (T * T2 * Bs + B * Ts * T2s) * (4 * n^2 - 20 *
     n + 24) - 8 * (T3 * Bs + B * T3s) * (3 * n^2 - 15 * n +
     24)
     t201 = 24 * (T^3 * Rs + R * Ts^3) + 6 * (T * T2 * Rs + R *
     Ts * T2s) * (2 * n^2 - 10 * n + 24)
     t202 = 8 * (T3 * Rs + R * T3s) * (3 * n^2 - 15 * n + 24) +
     (3 * n^2 - 15 * n + 6) * (T^3 * Ts * S2s + T * S2 * Ts^3)
     t203 = 6 * (T * T2 * Ts * S2s + Ts * T2s * T * S2) * (n^2 -
     5 * n + 6) + 48 * (T3 * Ts * S2s + T3s * T * S2)
     t20 = -(n - 2) * (t201 + t202 + t203)
     temp31 = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 +
     t11 + t12 + t13 + t14 + t15 + t16 + t17 + t18 + t19 +
     t20
     temp32 = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n -
     5)
     mom3 = temp31/temp32
     skewness.krv = (mom3 - 3 * mean.krv * variance.krv - mean.krv^3)/variance.krv^1.5
     m1 = mean.krv
     m2 = variance.krv
     m3 = skewness.krv
     shape = 4/m3^2
     scale = sqrt(m2) * m3/2
     location = m1 - 2 * sqrt(m2)/m3
     PIIIpars = list(shape, location, scale)
     pv = 1 - ppearsonIII(Fstar, params = PIIIpars)
     return(pv)
    }
    <bytecode: 0x563c4b3afdc0>
    <environment: namespace:MiRKAT>
     --- function search by body ---
    Function KRV in namespace MiRKAT has this body.
     ----------- END OF FAILURE REPORT --------------
    Error in if ((class(kernel.otu) != "matrix")) { :
     the condition has length > 1
    Calls: KRV
    Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc

Version: 1.0.1
Check: re-building of vignette outputs
Result: WARN
    Error(s) in re-building vignettes:
     ...
    --- re-building ‘MiRKAT.Rnw’ using Sweave
    This is vegan 2.5-6
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    MiRKAT
     --- call from context ---
    MiRKAT(y = Smoker, Ks = K.weighted, X = cbind(Male, anti), out_type = "D",
     method = "davies")
     --- call from argument ---
    if (class(Ks) == "matrix") {
     Ks = list(Ks)
    }
     --- R stacktrace ---
    where 1: MiRKAT(y = Smoker, Ks = K.weighted, X = cbind(Male, anti), out_type = "D",
     method = "davies")
    where 2: eval(expr, .GlobalEnv)
    where 3: eval(expr, .GlobalEnv)
    where 4: withVisible(eval(expr, .GlobalEnv))
    where 5: doTryCatch(return(expr), name, parentenv, handler)
    where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 7: tryCatchList(expr, classes, parentenv, handlers)
    where 8: tryCatch(expr, error = function(e) {
     call <- conditionCall(e)
     if (!is.null(call)) {
     if (identical(call[[1L]], quote(doTryCatch)))
     call <- sys.call(-4L)
     dcall <- deparse(call)[1L]
     prefix <- paste("Error in", dcall, ": ")
     LONG <- 75L
     sm <- strsplit(conditionMessage(e), "\n")[[1L]]
     w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")
     if (is.na(w))
     w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
     type = "b")
     if (w > LONG)
     prefix <- paste0(prefix, "\n ")
     }
     else prefix <- "Error : "
     msg <- paste0(prefix, conditionMessage(e), "\n")
     .Internal(seterrmessage(msg[1L]))
     if (!silent && isTRUE(getOption("show.error.messages"))) {
     cat(msg, file = outFile)
     .Internal(printDeferredWarnings())
     }
     invisible(structure(msg, class = "try-error", condition = e))
    })
    where 9: try(withVisible(eval(expr, .GlobalEnv)), silent = TRUE)
    where 10: evalFunc(ce, options)
    where 11: tryCatchList(expr, classes, parentenv, handlers)
    where 12: tryCatch(evalFunc(ce, options), finally = {
     cat("\n")
     sink()
    })
    where 13: driver$runcode(drobj, chunk, chunkopts)
    where 14: utils::Sweave(...)
    where 15: engine$weave(file, quiet = quiet, encoding = enc)
    where 16: doTryCatch(return(expr), name, parentenv, handler)
    where 17: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 18: tryCatchList(expr, classes, parentenv, handlers)
    where 19: tryCatch({
     engine$weave(file, quiet = quiet, encoding = enc)
     setwd(startdir)
     output <- find_vignette_product(name, by = "weave", engine = engine)
     if (!have.makefile && vignette_is_tex(output)) {
     texi2pdf(file = output, clean = FALSE, quiet = quiet)
     output <- find_vignette_product(name, by = "texi2pdf",
     engine = engine)
     }
     outputs <- c(outputs, output)
    }, error = function(e) {
     thisOK <<- FALSE
     fails <<- c(fails, file)
     message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s",
     file, conditionMessage(e)))
    })
    where 20: tools:::buildVignettes(dir = "/home/hornik/tmp/R.check/r-devel-gcc/Work/PKGS/MiRKAT.Rcheck/vign_test/MiRKAT",
     ser_elibs = "/home/hornik/tmp/scratch/RtmpskUzjb/filea6c33cd2524.rds")
    
     --- value of length: 2 type: logical ---
    [1] TRUE FALSE
     --- function from context ---
    function (y, X = NULL, Ks, out_type = "C", nperm = 999, method = "davies")
    {
     n = length(y)
     if (any(is.na(y))) {
     ids = which(is.na(y))
     stop(paste("subjects", ids, "has missing response, please remove before proceed \n"))
     }
     if (is.null(X) == FALSE) {
     if (NROW(X) != length(y))
     stop("Dimensions of X and y don't match.")
     }
     if (class(Ks) == "matrix") {
     Ks = list(Ks)
     }
     if (class(Ks) == "list") {
     if ((any(lapply(Ks, "nrow") != n)) | (any(lapply(Ks,
     "ncol") != n))) {
     stop("distance matrix need to be n x n, where n is the sample size \n ")
     }
     if (class(Ks) != "list") {
     stop("Distance needs to be a list of n x n matrices or a single n x n matrix \n")
     }
     }
     if (!is.null(X)) {
     if (any(is.na(X))) {
     stop("NAs in covariates X, please impute or remove subjects which has missing covariates values")
     }
     }
     if (method == "moment" & n < 100 & out_type == "C") {
     warning("Continuous outcome: sample size < 100, p-value using moment matching can be inaccurate at tails, davies or permutation is recommended")
     }
     if (method == "moment" & n < 200 & out_type == "D") {
     warning("Continuous outcome: sample size < 200, p-value using moment matching can be inaccurate at tails, davies or permutation is recommended")
     }
     if (!(out_type %in% c("C", "D"))) {
     stop("Currently only continuous and Binary outcome are supported. Please choose out_type = \"C\" or \"D\" ")
     }
     if (out_type == "C") {
     re = MiRKAT_continuous(y, X = X, Ks = Ks, method = method,
     nperm = nperm)
     }
     if (out_type == "D") {
     re = MiRKAT_binary(y, X = X, Ks = Ks, method = method,
     nperm = nperm)
     }
     return(re)
    }
    <bytecode: 0x55fc1e6e0e40>
    <environment: namespace:MiRKAT>
     --- function search by body ---
    Function MiRKAT in namespace MiRKAT has this body.
     ----------- END OF FAILURE REPORT --------------
    
    Error: processing vignette 'MiRKAT.Rnw' failed with diagnostics:
     chunk 5 (label = data5)
    Error in if (class(Ks) == "matrix") { : the condition has length > 1
    
    --- failed re-building ‘MiRKAT.Rnw’
    
    SUMMARY: processing the following file failed:
     ‘MiRKAT.Rnw’
    
    Error: Vignette re-building failed.
    Execution halted
Flavor: r-devel-linux-x86_64-debian-gcc

Version: 1.0.1
Check: examples
Result: ERROR
    Running examples in ‘MiRKAT-Ex.R’ failed
    The error most likely occurred in:
    
    > ### Name: KRV
    > ### Title: Kernel RV Coefficient Test
    > ### Aliases: KRV
    >
    > ### ** Examples
    >
    > library(MASS)
    > library(GUniFrac)
    > data(throat.tree)
    > data(throat.otu.tab)
    > data(throat.meta)
    > attach(throat.meta)
    >
    > set.seed(123)
    > n = nrow(throat.otu.tab)
    > Male = (Sex == "Male")**2
    > Smoker =(SmokingStatus == "Smoker") **2
    > anti = (AntibioticUsePast3Months_TimeFromAntibioticUsage != "None")^2
    > cova = cbind(Male, anti)
    >
    > otu.tab.rff <- Rarefy(throat.otu.tab)$otu.tab.rff
    > unifracs <- GUniFrac(otu.tab.rff, throat.tree, alpha=c(0, 0.5, 1))$unifracs
    >
    > D.weighted = unifracs[,,"d_1"]
    > D.unweighted = unifracs[,,"d_UW"]
    > D.BC= as.matrix(vegdist(otu.tab.rff , method="bray"))
    >
    > K.weighted = D2K(D.weighted)
    > K.unweighted = D2K(D.unweighted)
    > K.BC = D2K(D.BC)
    >
    > rho = 0.2
    > Va = matrix(rep(rho, (2*n)^2), 2*n, 2*n)+diag(1-rho, 2*n)
    > G = mvrnorm(n, rep(0, 2*n), Va)
    >
    > #############################################################
    >
    > KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    MiRKAT
     --- call from context ---
    KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
     --- call from argument ---
    if ((class(kernel.otu) != "matrix")) {
     stop("Please provide a kernel matrix for microbiome data")
    }
     --- R stacktrace ---
    where 1: KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
    
     --- value of length: 2 type: logical ---
    [1] FALSE TRUE
     --- function from context ---
    function (kernel.otu, y = NULL, X = NULL, kernel.y)
    {
     if ((class(kernel.otu) != "matrix")) {
     stop("Please provide a kernel matrix for microbiome data")
     }
     if (is.matrix(kernel.y)) {
     n = nrow(kernel.otu)
     if (!is.null(X)) {
     warning("Covariates can't be adjusted for in this case, and hence argument \"X\" will be ignored.")
     }
     if (!is.null(y)) {
     warning("No need to provide phenotype matrix when a phenotype kernel is provided, and hence argument \"y\" will be ignored.")
     }
     if (ncol(kernel.otu) != n | nrow(kernel.y) != n | ncol(kernel.y) !=
     n) {
     stop("kernel matrices need to be n x n, where n is the sample size \n ")
     }
     }
     if (!is.matrix(kernel.y)) {
     if (!(kernel.y %in% c("Gaussian", "linear"))) {
     stop("Please choose kernel.y = \"Gaussian\" or \"linear\", or enter a kernel matrix for \"kernel.y\"")
     }
     if (is.null(y)) {
     stop("Please enter a phenotype matrix for argument \"y\" or enter a kernel matrix for argument \"kernel.y\" ")
     }
     n = NROW(y)
     if (nrow(kernel.otu) != n | ncol(kernel.otu) != n) {
     stop("kernel matrix needs to be n x n, where n is the sample size \n ")
     }
     if (any(is.na(y))) {
     ids = which(is.na(y))
     stop(paste("subjects", ids, "has missing response, please remove before proceed \n"))
     }
     if (!is.null(X)) {
     if (any(is.na(X))) {
     stop("NAs in covariates X, please impute or remove subjects which has missing covariates values")
     }
     if (NROW(X) != NROW(y))
     stop("Dimensions of X and y don't match.")
     }
     }
     K = kernel.otu
     kern_g = function(zz) {
     n = nrow(zz)
     D = matrix(NA, nrow = n, ncol = n)
     for (i in 1:n) {
     for (j in 1:n) {
     D[i, j] = sum((zz[i, ] - zz[j, ])^2)
     }
     }
     temp = c(D)
     D1 = temp[temp > 0]
     scl = median(D1)
     K = matrix(NA, nrow = n, ncol = n)
     for (i in 1:n) {
     for (j in 1:n) {
     K[i, j] = exp(-sum((zz[i, ] - zz[j, ])^2)/scl)
     }
     }
     return(K)
     }
     n = nrow(K)
     I.n = diag(1, n)
     I.1 = rep(1, n)
     if (is.matrix(kernel.y)) {
     L = kernel.y
     }
     else {
     if (!is.null(X)) {
     Px = X %*% solve(t(X) %*% X) %*% t(X)
     err.Y = (I.n - Px) %*% y
     }
     else {
     err.Y = y
     }
     if (kernel.y == "Gaussian") {
     L = kern_g(err.Y)
     }
     else {
     if (kernel.y == "linear") {
     L = err.Y %*% t(err.Y)
     }
     }
     }
     H = I.n - I.1 %*% t(I.1)/n
     K = H %*% K %*% H
     L = H %*% L %*% H
     A = K/tr(K %*% K)
     W = L/tr(L %*% L)
     Fstar = tr(A %*% W)
     mean.krv = tr(A) * tr(W)/(n - 1)
     T = tr(A)
     T2 = tr(A %*% A)
     S2 = sum(diag(A)^2)
     Ts = tr(W)
     T2s = tr(W %*% W)
     S2s = sum(diag(W)^2)
     temp1 = 2 * ((n - 1) * T2 - T^2) * ((n - 1) * T2s - Ts^2)/(n -
     1)^2/(n + 1)/(n - 2)
     temp21 = n * (n + 1) * S2 - (n - 1) * (T^2 + 2 * T2)
     temp22 = n * (n + 1) * S2s - (n - 1) * (Ts^2 + 2 * T2s)
     temp23 = (n + 1) * n * (n - 1) * (n - 2) * (n - 3)
     temp2 = temp21 * temp22/temp23
     variance.krv = temp1 + temp2
     T3 = tr(A %*% A %*% A)
     S3 = sum(diag(A)^3)
     U = sum(A^3)
     R = t(diag(A)) %*% diag(A %*% A)
     B = t(diag(A)) %*% A %*% diag(A)
     T3s = tr(W %*% W %*% W)
     S3s = sum(diag(W)^3)
     Us = sum(W^3)
     Rs = t(diag(W)) %*% diag(W %*% W)
     Bs = t(diag(W)) %*% W %*% diag(W)
     t1 = n^2 * (n + 1) * (n^2 + 15 * n - 4) * S3 * S3s
     t2 = 4 * (n^4 - 8 * n^3 + 19 * n^2 - 4 * n - 16) * U * Us
     t3 = 24 * (n^2 - n - 4) * (U * Bs + B * Us)
     t4 = 6 * (n^4 - 8 * n^3 + 21 * n^2 - 6 * n - 24) * B * Bs
     t5 = 12 * (n^4 - n^3 - 8 * n^2 + 36 * n - 48) * R * Rs
     t6 = 12 * (n^3 - 2 * n^2 + 9 * n - 12) * (T * S2 * Rs + R *
     Ts * S2s)
     t7 = 3 * (n^4 - 4 * n^3 - 2 * n^2 + 9 * n - 12) * T * Ts *
     S2 * S2s
     t81 = (n^3 - 3 * n^2 - 2 * n + 8) * (R * Us + U * Rs)
     t82 = (n^3 - 2 * n^2 - 3 * n + 12) * (R * Bs + B * Rs)
     t8 = 24 * (t81 + t82)
     t9 = 12 * (n^2 - n + 4) * (T * S2 * Us + U * Ts * S2s)
     t10 = 6 * (2 * n^3 - 7 * n^2 - 3 * n + 12) * (T * S2 * Bs +
     B * Ts * S2s)
     t11 = -2 * n * (n - 1) * (n^2 - n + 4) * ((2 * U + 3 * B) *
     S3s + (2 * Us + 3 * Bs) * S3)
     t12 = -3 * n * (n - 1)^2 * (n + 4) * ((T * S2 + 4 * R) *
     S3s + (Ts * S2s + 4 * Rs) * S3)
     t13 = 2 * n * (n - 1) * (n - 2) * ((T^3 + 6 * T * T2 + 8 *
     T3) * S3s + (Ts^3 + 6 * Ts * T2s + 8 * T3s) * S3)
     t14 = T^3 * ((n^3 - 9 * n^2 + 23 * n - 14) * Ts^3 + 6 * (n -
     4) * Ts * T2s + 8 * T3s)
     t15 = 6 * T * T2 * ((n - 4) * Ts^3 + (n^3 - 9 * n^2 + 24 *
     n - 14) * Ts * T2s + 4 * (n - 3) * T3s)
     t16 = 8 * T3 * (Ts^3 + 3 * (n - 3) * Ts * T2s + (n^3 - 9 *
     n^2 + 26 * n - 22) * T3s)
     t17 = -16 * (T^3 * Us + U * Ts^3) - 6 * (T * T2 * Us + U *
     Ts * T2s) * (2 * n^2 - 10 * n + 16)
     t18 = -8 * (T3 * Us + U * T3s) * (3 * n^2 - 15 * n + 16) -
     (T^3 * Bs + B * Ts^3) * (6 * n^2 - 30 * n + 24)
     t19 = -6 * (T * T2 * Bs + B * Ts * T2s) * (4 * n^2 - 20 *
     n + 24) - 8 * (T3 * Bs + B * T3s) * (3 * n^2 - 15 * n +
     24)
     t201 = 24 * (T^3 * Rs + R * Ts^3) + 6 * (T * T2 * Rs + R *
     Ts * T2s) * (2 * n^2 - 10 * n + 24)
     t202 = 8 * (T3 * Rs + R * T3s) * (3 * n^2 - 15 * n + 24) +
     (3 * n^2 - 15 * n + 6) * (T^3 * Ts * S2s + T * S2 * Ts^3)
     t203 = 6 * (T * T2 * Ts * S2s + Ts * T2s * T * S2) * (n^2 -
     5 * n + 6) + 48 * (T3 * Ts * S2s + T3s * T * S2)
     t20 = -(n - 2) * (t201 + t202 + t203)
     temp31 = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 +
     t11 + t12 + t13 + t14 + t15 + t16 + t17 + t18 + t19 +
     t20
     temp32 = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n -
     5)
     mom3 = temp31/temp32
     skewness.krv = (mom3 - 3 * mean.krv * variance.krv - mean.krv^3)/variance.krv^1.5
     m1 = mean.krv
     m2 = variance.krv
     m3 = skewness.krv
     shape = 4/m3^2
     scale = sqrt(m2) * m3/2
     location = m1 - 2 * sqrt(m2)/m3
     PIIIpars = list(shape, location, scale)
     pv = 1 - ppearsonIII(Fstar, params = PIIIpars)
     return(pv)
    }
    <bytecode: 0x6b8a998>
    <environment: namespace:MiRKAT>
     --- function search by body ---
    Function KRV in namespace MiRKAT has this body.
     ----------- END OF FAILURE REPORT --------------
    Error in if ((class(kernel.otu) != "matrix")) { :
     the condition has length > 1
    Calls: KRV
    Execution halted
Flavor: r-devel-linux-x86_64-fedora-clang

Version: 1.0.1
Check: re-building of vignette outputs
Result: WARN
    Error(s) in re-building vignettes:
    --- re-building ‘MiRKAT.Rnw’ using Sweave
    This is vegan 2.5-6
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    MiRKAT
     --- call from context ---
    MiRKAT(y = Smoker, Ks = K.weighted, X = cbind(Male, anti), out_type = "D",
     method = "davies")
     --- call from argument ---
    if (class(Ks) == "matrix") {
     Ks = list(Ks)
    }
     --- R stacktrace ---
    where 1: MiRKAT(y = Smoker, Ks = K.weighted, X = cbind(Male, anti), out_type = "D",
     method = "davies")
    where 2: eval(expr, .GlobalEnv)
    where 3: eval(expr, .GlobalEnv)
    where 4: withVisible(eval(expr, .GlobalEnv))
    where 5: doTryCatch(return(expr), name, parentenv, handler)
    where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 7: tryCatchList(expr, classes, parentenv, handlers)
    where 8: tryCatch(expr, error = function(e) {
     call <- conditionCall(e)
     if (!is.null(call)) {
     if (identical(call[[1L]], quote(doTryCatch)))
     call <- sys.call(-4L)
     dcall <- deparse(call)[1L]
     prefix <- paste("Error in", dcall, ": ")
     LONG <- 75L
     sm <- strsplit(conditionMessage(e), "\n")[[1L]]
     w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")
     if (is.na(w))
     w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
     type = "b")
     if (w > LONG)
     prefix <- paste0(prefix, "\n ")
     }
     else prefix <- "Error : "
     msg <- paste0(prefix, conditionMessage(e), "\n")
     .Internal(seterrmessage(msg[1L]))
     if (!silent && isTRUE(getOption("show.error.messages"))) {
     cat(msg, file = outFile)
     .Internal(printDeferredWarnings())
     }
     invisible(structure(msg, class = "try-error", condition = e))
    })
    where 9: try(withVisible(eval(expr, .GlobalEnv)), silent = TRUE)
    where 10: evalFunc(ce, options)
    where 11: tryCatchList(expr, classes, parentenv, handlers)
    where 12: tryCatch(evalFunc(ce, options), finally = {
     cat("\n")
     sink()
    })
    where 13: driver$runcode(drobj, chunk, chunkopts)
    where 14: utils::Sweave(...)
    where 15: engine$weave(file, quiet = quiet, encoding = enc)
    where 16: doTryCatch(return(expr), name, parentenv, handler)
    where 17: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 18: tryCatchList(expr, classes, parentenv, handlers)
    where 19: tryCatch({
     engine$weave(file, quiet = quiet, encoding = enc)
     setwd(startdir)
     output <- find_vignette_product(name, by = "weave", engine = engine)
     if (!have.makefile && vignette_is_tex(output)) {
     texi2pdf(file = output, clean = FALSE, quiet = quiet)
     output <- find_vignette_product(name, by = "texi2pdf",
     engine = engine)
     }
     outputs <- c(outputs, output)
    }, error = function(e) {
     thisOK <<- FALSE
     fails <<- c(fails, file)
     message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s",
     file, conditionMessage(e)))
    })
    where 20: tools:::buildVignettes(dir = "/data/gannet/ripley/R/packages/tests-clang/MiRKAT.Rcheck/vign_test/MiRKAT",
     ser_elibs = "/tmp/RtmpgYUPve/filebcf83281160e.rds")
    
     --- value of length: 2 type: logical ---
    [1] TRUE FALSE
     --- function from context ---
    function (y, X = NULL, Ks, out_type = "C", nperm = 999, method = "davies")
    {
     n = length(y)
     if (any(is.na(y))) {
     ids = which(is.na(y))
     stop(paste("subjects", ids, "has missing response, please remove before proceed \n"))
     }
     if (is.null(X) == FALSE) {
     if (NROW(X) != length(y))
     stop("Dimensions of X and y don't match.")
     }
     if (class(Ks) == "matrix") {
     Ks = list(Ks)
     }
     if (class(Ks) == "list") {
     if ((any(lapply(Ks, "nrow") != n)) | (any(lapply(Ks,
     "ncol") != n))) {
     stop("distance matrix need to be n x n, where n is the sample size \n ")
     }
     if (class(Ks) != "list") {
     stop("Distance needs to be a list of n x n matrices or a single n x n matrix \n")
     }
     }
     if (!is.null(X)) {
     if (any(is.na(X))) {
     stop("NAs in covariates X, please impute or remove subjects which has missing covariates values")
     }
     }
     if (method == "moment" & n < 100 & out_type == "C") {
     warning("Continuous outcome: sample size < 100, p-value using moment matching can be inaccurate at tails, davies or permutation is recommended")
     }
     if (method == "moment" & n < 200 & out_type == "D") {
     warning("Continuous outcome: sample size < 200, p-value using moment matching can be inaccurate at tails, davies or permutation is recommended")
     }
     if (!(out_type %in% c("C", "D"))) {
     stop("Currently only continuous and Binary outcome are supported. Please choose out_type = \"C\" or \"D\" ")
     }
     if (out_type == "C") {
     re = MiRKAT_continuous(y, X = X, Ks = Ks, method = method,
     nperm = nperm)
     }
     if (out_type == "D") {
     re = MiRKAT_binary(y, X = X, Ks = Ks, method = method,
     nperm = nperm)
     }
     return(re)
    }
    <bytecode: 0x7df75e0>
    <environment: namespace:MiRKAT>
     --- function search by body ---
    Function MiRKAT in namespace MiRKAT has this body.
     ----------- END OF FAILURE REPORT --------------
    
    Error: processing vignette 'MiRKAT.Rnw' failed with diagnostics:
     chunk 5 (label = data5)
    Error in if (class(Ks) == "matrix") { : the condition has length > 1
    
    --- failed re-building ‘MiRKAT.Rnw’
    
    SUMMARY: processing the following file failed:
     ‘MiRKAT.Rnw’
    
    Error: Vignette re-building failed.
    Execution halted
Flavor: r-devel-linux-x86_64-fedora-clang

Version: 1.0.1
Check: examples
Result: ERROR
    Running examples in ‘MiRKAT-Ex.R’ failed
    The error most likely occurred in:
    
    > ### Name: KRV
    > ### Title: Kernel RV Coefficient Test
    > ### Aliases: KRV
    >
    > ### ** Examples
    >
    > library(MASS)
    > library(GUniFrac)
    > data(throat.tree)
    > data(throat.otu.tab)
    > data(throat.meta)
    > attach(throat.meta)
    >
    > set.seed(123)
    > n = nrow(throat.otu.tab)
    > Male = (Sex == "Male")**2
    > Smoker =(SmokingStatus == "Smoker") **2
    > anti = (AntibioticUsePast3Months_TimeFromAntibioticUsage != "None")^2
    > cova = cbind(Male, anti)
    >
    > otu.tab.rff <- Rarefy(throat.otu.tab)$otu.tab.rff
    > unifracs <- GUniFrac(otu.tab.rff, throat.tree, alpha=c(0, 0.5, 1))$unifracs
    >
    > D.weighted = unifracs[,,"d_1"]
    > D.unweighted = unifracs[,,"d_UW"]
    > D.BC= as.matrix(vegdist(otu.tab.rff , method="bray"))
    >
    > K.weighted = D2K(D.weighted)
    > K.unweighted = D2K(D.unweighted)
    > K.BC = D2K(D.BC)
    >
    > rho = 0.2
    > Va = matrix(rep(rho, (2*n)^2), 2*n, 2*n)+diag(1-rho, 2*n)
    > G = mvrnorm(n, rep(0, 2*n), Va)
    >
    > #############################################################
    >
    > KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    MiRKAT
     --- call from context ---
    KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
     --- call from argument ---
    if ((class(kernel.otu) != "matrix")) {
     stop("Please provide a kernel matrix for microbiome data")
    }
     --- R stacktrace ---
    where 1: KRV(kernel.otu = K.weighted, y = G, X = cova, kernel.y = "Gaussian")
    
     --- value of length: 2 type: logical ---
    [1] FALSE TRUE
     --- function from context ---
    function (kernel.otu, y = NULL, X = NULL, kernel.y)
    {
     if ((class(kernel.otu) != "matrix")) {
     stop("Please provide a kernel matrix for microbiome data")
     }
     if (is.matrix(kernel.y)) {
     n = nrow(kernel.otu)
     if (!is.null(X)) {
     warning("Covariates can't be adjusted for in this case, and hence argument \"X\" will be ignored.")
     }
     if (!is.null(y)) {
     warning("No need to provide phenotype matrix when a phenotype kernel is provided, and hence argument \"y\" will be ignored.")
     }
     if (ncol(kernel.otu) != n | nrow(kernel.y) != n | ncol(kernel.y) !=
     n) {
     stop("kernel matrices need to be n x n, where n is the sample size \n ")
     }
     }
     if (!is.matrix(kernel.y)) {
     if (!(kernel.y %in% c("Gaussian", "linear"))) {
     stop("Please choose kernel.y = \"Gaussian\" or \"linear\", or enter a kernel matrix for \"kernel.y\"")
     }
     if (is.null(y)) {
     stop("Please enter a phenotype matrix for argument \"y\" or enter a kernel matrix for argument \"kernel.y\" ")
     }
     n = NROW(y)
     if (nrow(kernel.otu) != n | ncol(kernel.otu) != n) {
     stop("kernel matrix needs to be n x n, where n is the sample size \n ")
     }
     if (any(is.na(y))) {
     ids = which(is.na(y))
     stop(paste("subjects", ids, "has missing response, please remove before proceed \n"))
     }
     if (!is.null(X)) {
     if (any(is.na(X))) {
     stop("NAs in covariates X, please impute or remove subjects which has missing covariates values")
     }
     if (NROW(X) != NROW(y))
     stop("Dimensions of X and y don't match.")
     }
     }
     K = kernel.otu
     kern_g = function(zz) {
     n = nrow(zz)
     D = matrix(NA, nrow = n, ncol = n)
     for (i in 1:n) {
     for (j in 1:n) {
     D[i, j] = sum((zz[i, ] - zz[j, ])^2)
     }
     }
     temp = c(D)
     D1 = temp[temp > 0]
     scl = median(D1)
     K = matrix(NA, nrow = n, ncol = n)
     for (i in 1:n) {
     for (j in 1:n) {
     K[i, j] = exp(-sum((zz[i, ] - zz[j, ])^2)/scl)
     }
     }
     return(K)
     }
     n = nrow(K)
     I.n = diag(1, n)
     I.1 = rep(1, n)
     if (is.matrix(kernel.y)) {
     L = kernel.y
     }
     else {
     if (!is.null(X)) {
     Px = X %*% solve(t(X) %*% X) %*% t(X)
     err.Y = (I.n - Px) %*% y
     }
     else {
     err.Y = y
     }
     if (kernel.y == "Gaussian") {
     L = kern_g(err.Y)
     }
     else {
     if (kernel.y == "linear") {
     L = err.Y %*% t(err.Y)
     }
     }
     }
     H = I.n - I.1 %*% t(I.1)/n
     K = H %*% K %*% H
     L = H %*% L %*% H
     A = K/tr(K %*% K)
     W = L/tr(L %*% L)
     Fstar = tr(A %*% W)
     mean.krv = tr(A) * tr(W)/(n - 1)
     T = tr(A)
     T2 = tr(A %*% A)
     S2 = sum(diag(A)^2)
     Ts = tr(W)
     T2s = tr(W %*% W)
     S2s = sum(diag(W)^2)
     temp1 = 2 * ((n - 1) * T2 - T^2) * ((n - 1) * T2s - Ts^2)/(n -
     1)^2/(n + 1)/(n - 2)
     temp21 = n * (n + 1) * S2 - (n - 1) * (T^2 + 2 * T2)
     temp22 = n * (n + 1) * S2s - (n - 1) * (Ts^2 + 2 * T2s)
     temp23 = (n + 1) * n * (n - 1) * (n - 2) * (n - 3)
     temp2 = temp21 * temp22/temp23
     variance.krv = temp1 + temp2
     T3 = tr(A %*% A %*% A)
     S3 = sum(diag(A)^3)
     U = sum(A^3)
     R = t(diag(A)) %*% diag(A %*% A)
     B = t(diag(A)) %*% A %*% diag(A)
     T3s = tr(W %*% W %*% W)
     S3s = sum(diag(W)^3)
     Us = sum(W^3)
     Rs = t(diag(W)) %*% diag(W %*% W)
     Bs = t(diag(W)) %*% W %*% diag(W)
     t1 = n^2 * (n + 1) * (n^2 + 15 * n - 4) * S3 * S3s
     t2 = 4 * (n^4 - 8 * n^3 + 19 * n^2 - 4 * n - 16) * U * Us
     t3 = 24 * (n^2 - n - 4) * (U * Bs + B * Us)
     t4 = 6 * (n^4 - 8 * n^3 + 21 * n^2 - 6 * n - 24) * B * Bs
     t5 = 12 * (n^4 - n^3 - 8 * n^2 + 36 * n - 48) * R * Rs
     t6 = 12 * (n^3 - 2 * n^2 + 9 * n - 12) * (T * S2 * Rs + R *
     Ts * S2s)
     t7 = 3 * (n^4 - 4 * n^3 - 2 * n^2 + 9 * n - 12) * T * Ts *
     S2 * S2s
     t81 = (n^3 - 3 * n^2 - 2 * n + 8) * (R * Us + U * Rs)
     t82 = (n^3 - 2 * n^2 - 3 * n + 12) * (R * Bs + B * Rs)
     t8 = 24 * (t81 + t82)
     t9 = 12 * (n^2 - n + 4) * (T * S2 * Us + U * Ts * S2s)
     t10 = 6 * (2 * n^3 - 7 * n^2 - 3 * n + 12) * (T * S2 * Bs +
     B * Ts * S2s)
     t11 = -2 * n * (n - 1) * (n^2 - n + 4) * ((2 * U + 3 * B) *
     S3s + (2 * Us + 3 * Bs) * S3)
     t12 = -3 * n * (n - 1)^2 * (n + 4) * ((T * S2 + 4 * R) *
     S3s + (Ts * S2s + 4 * Rs) * S3)
     t13 = 2 * n * (n - 1) * (n - 2) * ((T^3 + 6 * T * T2 + 8 *
     T3) * S3s + (Ts^3 + 6 * Ts * T2s + 8 * T3s) * S3)
     t14 = T^3 * ((n^3 - 9 * n^2 + 23 * n - 14) * Ts^3 + 6 * (n -
     4) * Ts * T2s + 8 * T3s)
     t15 = 6 * T * T2 * ((n - 4) * Ts^3 + (n^3 - 9 * n^2 + 24 *
     n - 14) * Ts * T2s + 4 * (n - 3) * T3s)
     t16 = 8 * T3 * (Ts^3 + 3 * (n - 3) * Ts * T2s + (n^3 - 9 *
     n^2 + 26 * n - 22) * T3s)
     t17 = -16 * (T^3 * Us + U * Ts^3) - 6 * (T * T2 * Us + U *
     Ts * T2s) * (2 * n^2 - 10 * n + 16)
     t18 = -8 * (T3 * Us + U * T3s) * (3 * n^2 - 15 * n + 16) -
     (T^3 * Bs + B * Ts^3) * (6 * n^2 - 30 * n + 24)
     t19 = -6 * (T * T2 * Bs + B * Ts * T2s) * (4 * n^2 - 20 *
     n + 24) - 8 * (T3 * Bs + B * T3s) * (3 * n^2 - 15 * n +
     24)
     t201 = 24 * (T^3 * Rs + R * Ts^3) + 6 * (T * T2 * Rs + R *
     Ts * T2s) * (2 * n^2 - 10 * n + 24)
     t202 = 8 * (T3 * Rs + R * T3s) * (3 * n^2 - 15 * n + 24) +
     (3 * n^2 - 15 * n + 6) * (T^3 * Ts * S2s + T * S2 * Ts^3)
     t203 = 6 * (T * T2 * Ts * S2s + Ts * T2s * T * S2) * (n^2 -
     5 * n + 6) + 48 * (T3 * Ts * S2s + T3s * T * S2)
     t20 = -(n - 2) * (t201 + t202 + t203)
     temp31 = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 +
     t11 + t12 + t13 + t14 + t15 + t16 + t17 + t18 + t19 +
     t20
     temp32 = n * (n - 1) * (n - 2) * (n - 3) * (n - 4) * (n -
     5)
     mom3 = temp31/temp32
     skewness.krv = (mom3 - 3 * mean.krv * variance.krv - mean.krv^3)/variance.krv^1.5
     m1 = mean.krv
     m2 = variance.krv
     m3 = skewness.krv
     shape = 4/m3^2
     scale = sqrt(m2) * m3/2
     location = m1 - 2 * sqrt(m2)/m3
     PIIIpars = list(shape, location, scale)
     pv = 1 - ppearsonIII(Fstar, params = PIIIpars)
     return(pv)
    }
    <bytecode: 0x6c33e78>
    <environment: namespace:MiRKAT>
     --- function search by body ---
    Function KRV in namespace MiRKAT has this body.
     ----------- END OF FAILURE REPORT --------------
    Error in if ((class(kernel.otu) != "matrix")) { :
     the condition has length > 1
    Calls: KRV
    Execution halted
Flavor: r-devel-linux-x86_64-fedora-gcc

Version: 1.0.1
Check: re-building of vignette outputs
Result: WARN
    Error(s) in re-building vignettes:
    --- re-building ‘MiRKAT.Rnw’ using Sweave
    This is vegan 2.5-6
     ----------- FAILURE REPORT --------------
     --- failure: the condition has length > 1 ---
     --- srcref ---
    :
     --- package (from environment) ---
    MiRKAT
     --- call from context ---
    MiRKAT(y = Smoker, Ks = K.weighted, X = cbind(Male, anti), out_type = "D",
     method = "davies")
     --- call from argument ---
    if (class(Ks) == "matrix") {
     Ks = list(Ks)
    }
     --- R stacktrace ---
    where 1: MiRKAT(y = Smoker, Ks = K.weighted, X = cbind(Male, anti), out_type = "D",
     method = "davies")
    where 2: eval(expr, .GlobalEnv)
    where 3: eval(expr, .GlobalEnv)
    where 4: withVisible(eval(expr, .GlobalEnv))
    where 5: doTryCatch(return(expr), name, parentenv, handler)
    where 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 7: tryCatchList(expr, classes, parentenv, handlers)
    where 8: tryCatch(expr, error = function(e) {
     call <- conditionCall(e)
     if (!is.null(call)) {
     if (identical(call[[1L]], quote(doTryCatch)))
     call <- sys.call(-4L)
     dcall <- deparse(call)[1L]
     prefix <- paste("Error in", dcall, ": ")
     LONG <- 75L
     sm <- strsplit(conditionMessage(e), "\n")[[1L]]
     w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")
     if (is.na(w))
     w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],
     type = "b")
     if (w > LONG)
     prefix <- paste0(prefix, "\n ")
     }
     else prefix <- "Error : "
     msg <- paste0(prefix, conditionMessage(e), "\n")
     .Internal(seterrmessage(msg[1L]))
     if (!silent && isTRUE(getOption("show.error.messages"))) {
     cat(msg, file = outFile)
     .Internal(printDeferredWarnings())
     }
     invisible(structure(msg, class = "try-error", condition = e))
    })
    where 9: try(withVisible(eval(expr, .GlobalEnv)), silent = TRUE)
    where 10: evalFunc(ce, options)
    where 11: tryCatchList(expr, classes, parentenv, handlers)
    where 12: tryCatch(evalFunc(ce, options), finally = {
     cat("\n")
     sink()
    })
    where 13: driver$runcode(drobj, chunk, chunkopts)
    where 14: utils::Sweave(...)
    where 15: engine$weave(file, quiet = quiet, encoding = enc)
    where 16: doTryCatch(return(expr), name, parentenv, handler)
    where 17: tryCatchOne(expr, names, parentenv, handlers[[1L]])
    where 18: tryCatchList(expr, classes, parentenv, handlers)
    where 19: tryCatch({
     engine$weave(file, quiet = quiet, encoding = enc)
     setwd(startdir)
     output <- find_vignette_product(name, by = "weave", engine = engine)
     if (!have.makefile && vignette_is_tex(output)) {
     texi2pdf(file = output, clean = FALSE, quiet = quiet)
     output <- find_vignette_product(name, by = "texi2pdf",
     engine = engine)
     }
     outputs <- c(outputs, output)
    }, error = function(e) {
     thisOK <<- FALSE
     fails <<- c(fails, file)
     message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s",
     file, conditionMessage(e)))
    })
    where 20: tools:::buildVignettes(dir = "/data/gannet/ripley/R/packages/tests-devel/MiRKAT.Rcheck/vign_test/MiRKAT",
     ser_elibs = "/tmp/RtmpnpUFDZ/file9bf21276aefc.rds")
    
     --- value of length: 2 type: logical ---
    [1] TRUE FALSE
     --- function from context ---
    function (y, X = NULL, Ks, out_type = "C", nperm = 999, method = "davies")
    {
     n = length(y)
     if (any(is.na(y))) {
     ids = which(is.na(y))
     stop(paste("subjects", ids, "has missing response, please remove before proceed \n"))
     }
     if (is.null(X) == FALSE) {
     if (NROW(X) != length(y))
     stop("Dimensions of X and y don't match.")
     }
     if (class(Ks) == "matrix") {
     Ks = list(Ks)
     }
     if (class(Ks) == "list") {
     if ((any(lapply(Ks, "nrow") != n)) | (any(lapply(Ks,
     "ncol") != n))) {
     stop("distance matrix need to be n x n, where n is the sample size \n ")
     }
     if (class(Ks) != "list") {
     stop("Distance needs to be a list of n x n matrices or a single n x n matrix \n")
     }
     }
     if (!is.null(X)) {
     if (any(is.na(X))) {
     stop("NAs in covariates X, please impute or remove subjects which has missing covariates values")
     }
     }
     if (method == "moment" & n < 100 & out_type == "C") {
     warning("Continuous outcome: sample size < 100, p-value using moment matching can be inaccurate at tails, davies or permutation is recommended")
     }
     if (method == "moment" & n < 200 & out_type == "D") {
     warning("Continuous outcome: sample size < 200, p-value using moment matching can be inaccurate at tails, davies or permutation is recommended")
     }
     if (!(out_type %in% c("C", "D"))) {
     stop("Currently only continuous and Binary outcome are supported. Please choose out_type = \"C\" or \"D\" ")
     }
     if (out_type == "C") {
     re = MiRKAT_continuous(y, X = X, Ks = Ks, method = method,
     nperm = nperm)
     }
     if (out_type == "D") {
     re = MiRKAT_binary(y, X = X, Ks = Ks, method = method,
     nperm = nperm)
     }
     return(re)
    }
    <bytecode: 0x6f8ea28>
    <environment: namespace:MiRKAT>
     --- function search by body ---
    Function MiRKAT in namespace MiRKAT has this body.
     ----------- END OF FAILURE REPORT --------------
    
    Error: processing vignette 'MiRKAT.Rnw' failed with diagnostics:
     chunk 5 (label = data5)
    Error in if (class(Ks) == "matrix") { : the condition has length > 1
    
    --- failed re-building ‘MiRKAT.Rnw’
    
    SUMMARY: processing the following file failed:
     ‘MiRKAT.Rnw’
    
    Error: Vignette re-building failed.
    Execution halted
Flavor: r-devel-linux-x86_64-fedora-gcc