Error(s) in re-building vignettes:
--- re-building 'simExperiment.Rnw' using knitr
  ordinary text without R code

label: unnamed-chunk-2 (with options) 
List of 1
 $ warning: logi FALSE

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   pkgLoaded <- suppressPackageStartupMessages({
     c(require(bcTSNE),
       require(data.table),
       require(batchelor),
       require(kBET),
       require(splatter),
       require(scater),
       require(Rtsne),
       require(lisi),
       require(harmony),
       require(dlfUtils),
       require(xtable))
   })
   pkgLoaded <- all(pkgLoaded)
   ## Uncomment to install kBet & lisi
   ## Note: the packages will require compilation
   # if (!require(drat)) {install.packages("drat"); library(drat)}
   # drat::addRepo("daynefiler")
   # install.packages(c("lisi", "kBET", "harmony", "dlfUtils")) 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:27 2021 ------##

Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'kBET'
Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'lisi'
Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'harmony'
Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE,  :
  there is no package called 'dlfUtils'
  ordinary text without R code

label: unnamed-chunk-3 (with options) 
List of 1
 $ eval: logi TRUE

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     p <- newSplatParams(seed = 1234,
                         batchCells = rep(200, 4), 
                         batch.facLoc = 0.2, 
                         batch.facScale = 0.1,
                         group.prob = c(0.1, 0.2, 0.3, 0.4),
                         de.facLoc = 0.1,
                         de.facScale = 0.4)
     sim <- splatSimulate(p, method = "groups", verbose = FALSE)
     sizeFactors(sim) <- librarySizeFactors(sim)
     sim <- normalize(sim)
     sim <- normalize(sim, return_log = FALSE)
     assay(sim, "centered") <- t(scale(t(normcounts(sim)), 
                                       center = TRUE, 
                                       scale = FALSE))
     Z <- model.matrix( ~ -1 + factor(colData(sim)$Batch))
     grp <- factor(sim$Group)
     bch <- as.integer(factor(sim$Batch))
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:39 2021 ------##

  ordinary text without R code

label: calcMet (with options) 
List of 1
 $ echo: logi FALSE

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     calcMetrics <- function(Y, bchLst) {
     calcSil <- function(x) {
       s <- batch_sil(pca.data = list(x = Y), batch = x, nPCs = 2)
       1 - abs(s)
     }
     calcKBET <- function(x) {
       kBET(Y, batch = x, do.pca = FALSE, plot = FALSE)$average
     }
     calcPCA <- function(x) {
       pcRegression(pca.data = prcomp(Y), batch = x, n_top = 2)$pcReg
     }
     sil  <- sapply(bchLst, calcSil)
     kbet <- sapply(bchLst, calcKBET)
     lisi <- compute_lisi(Y, 
                          meta_data = as.data.frame(bchLst),
                          label_colnames = names(bchLst))
     lisi <- colMeans(lisi)
     sizes <- sapply(bchLst, function(x) length(unique(x)))
     lisi <- (lisi - 1)/(sizes - 1)
     pca  <- sapply(bchLst, calcPCA)
     res <- list(sil = sil, kbet = kbet, lisi = lisi, pca = pca)
     do.call(cbind, res)
   }
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:39 2021 ------##

  ordinary text without R code

label: pltFunc (with options) 
List of 1
 $ echo: logi FALSE

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     pltSimRes <- function(Y, lbl) {
     par(mar = c(4, 1, 2, 1) + 0.1)
     plot(Y, 
          ann = FALSE, 
          axes = FALSE, 
          bty = "n", 
          col = grp, 
          pch = bch)
     title(main = lbl)
     legend(x = grconvertX(0.2, "nfc"),
            y = line2user(2, 1),
            legend = rep(" ", 4),
            pch = 1:4,
            xpd = NA,
            bty = "n",
            horiz = TRUE,
            xjust = 0,
            yjust = 0.5)
     legend(x = grconvertX(0.2, "nfc"),
            y = line2user(3, 1),
            legend = rep(" ", 4),
            pch = 16,
            col = 1:4,
            xpd = NA,
            bty = "n",
            horiz = TRUE,
            xjust = 0,
            yjust = 0.5)
     text(x = grconvertX(0.2, "nfc"), 
          y = line2user(2:3, 1), 
          labels = c("Batch:", "Cell-type:"),
          xpd = NA,
          adj = c(1, 0.5))
   }
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: unnamed-chunk-4
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   res <- vector(mode = "list", length = 6)
   names(res) <- c("btcc", "btlc", "hmlc", "hmcc", "mnn", "tsne") 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: tsne
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     set.seed(1234)
     res$tsne <- Rtsne(t(assay(sim, "centered")), inital_dims = 50)$Y
     pltSimRes(res$tsne, "t-SNE")
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: bctsne-cc
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     set.seed(1234)
     res$btcc <- bctsne(t(assay(sim, "centered")), Z, k = 50)$Y
     pltSimRes(res$btcc, "bcTSNE-centered")
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: bctsne-lc
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     set.seed(1234)
     res$btlc <- bctsne(t(logcounts(sim)), Z, k = 50)$Y
     pltSimRes(res$btlc, "bcTSNE-logcounts")
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: harmony (with options) 
List of 1
 $ message: logi FALSE

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     set.seed(1234)
     sim <- runPCA(sim, 50, exprs_values = "logcounts")
     sim <- RunHarmony(sim, group.by.vars = "Batch")
     res$hmlc = Rtsne(reducedDim(sim, "HARMONY"), pca = FALSE)$Y
     pltSimRes(res$hmlc, "Harmony-logcounts")
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: harmony-centered (with options) 
List of 1
 $ message: logi FALSE

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     set.seed(1234)
     sim <- runPCA(sim, 50, exprs_values = "centered")
     sim <- RunHarmony(sim, group.by.vars = "Batch")
     res$hmcc = Rtsne(reducedDim(sim, "HARMONY"), pca = FALSE)$Y
     pltSimRes(res$hmcc, "Harmony-centered")
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: mnn
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     set.seed(1234)
     tmp <- mnnCorrect(sim, batch = factor(sim$Batch))
     res$mnn <- Rtsne(t(assay(tmp, "corrected")), initial_dims = 50)$Y
     rm(tmp)
     pltSimRes(res$mnn, "mnnRes")
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: comp
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     batchList <- list(batch = factor(sim$Batch), 
                       cellType = factor(sim$Group))
     met <- lapply(res, calcMetrics, bchLst = batchList)
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: figs (with options) 
List of 2
 $ echo   : logi FALSE
 $ results: chr "hide"

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     met <- lapply(met, round, 4)
     met <- lapply(met, as.data.table, keep.rownames = TRUE)
     for (i in seq_along(met)) met[[i]][ , alg := names(met)[i]]
     met <- rbindlist(met)
     met <- met[ , .(rn, alg, sil, kbet, lisi, pca)][order(rn, alg)]
     met[alg == "btcc", alg := "bcTSNE-centered"]
     met[alg == "btlc", alg := "bcTSNE-logcounts"]
     met[alg == "hmlc", alg := "Harmony-logcounts"]
     met[alg == "hmcc", alg := "Harmony-centered"]
     met[alg == "mnn", alg  := "MNN"]
     met[alg == "tsne", alg := "\\textit{t}-SNE"]
     met[rn == "batch", rn := "Batch"]
     met[rn == "cellType", rn := "Cell type"]
     met[ , tmp := seq_along(alg), by = rn]
     met[tmp != 1, rn := ""]
     met[ , tmp := NULL]
     setnames(met, c("", "", "SIL", "kBET", "iLSIS", "PcR"))
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: unnamed-chunk-5 (with options) 
List of 2
 $ echo   : logi FALSE
 $ results: chr "asis"

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   if (pkgLoaded) {
     print(xtable(met, digits = 4),hline.after = c(-1, 0, 6, nrow(met)), 
           include.rownames = FALSE, 
           sanitize.text.function = I)
   } 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: unnamed-chunk-6
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   <<calcMet>> 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

label: unnamed-chunk-7 (with options) 
List of 3
 $ eval  : logi FALSE
 $ echo  : logi FALSE
 $ resuls: chr "hide"

   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ R code chunk ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
   ## For internal use, save the sim results to the untracked inst/notrack folder
   # saveRDS(res, "../inst/notrack/sim.res")
   # saveRDS(met, "../inst/notrack/sim.metrics")
   # saveRDS(sim, "../inst/notrack/sim.sce")
   # saveRDS(as.data.table(colData(sim)), "../inst/notrack/sim.cellMeta") 
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
##------ Fri May 14 04:32:40 2021 ------##

  ordinary text without R code

--- finished re-building 'simExperiment.Rnw'


runtime error R6031
- Attempt to initialize the CRT more than once.
This indicates a bug in your application.