diff --git a/R/aggregateReference.R b/R/aggregateReference.R index 729b2fc..982d308 100644 --- a/R/aggregateReference.R +++ b/R/aggregateReference.R @@ -140,7 +140,7 @@ aggregateReference <- function( first <- labels[vapply(by.label, function(i) i[1], 0L)] num <- vapply(output.vals, ncol, 0L) output.labels <- rep(first, num) - + output <- SummarizedExperiment(list(logcounts=do.call(cbind, output.vals)), colData=DataFrame(label=output.labels)) colnames(output) <- sprintf("%s.%s", output.labels, sequence(num)) output diff --git a/R/combineRecomputedResults.R b/R/combineRecomputedResults.R index 983a2ad..02191d3 100644 --- a/R/combineRecomputedResults.R +++ b/R/combineRecomputedResults.R @@ -186,7 +186,7 @@ combineRecomputedResults <- function( # Organizing the outputs. base.scores <- vector("list", length(results)) for (r in seq_along(base.scores)) { - mat <- results[[r]]$scores + mat <- results[[r]]$scores mat[] <- NA_real_ idx <- cbind(seq_len(nrow(mat)), collated[[r]] + 1L) mat[idx] <- irun$scores[,r] diff --git a/R/getClassicMarkers.R b/R/getClassicMarkers.R index 4a95dee..55c05b3 100644 --- a/R/getClassicMarkers.R +++ b/R/getClassicMarkers.R @@ -83,7 +83,7 @@ getClassicMarkers <- function(ref, labels, assay.type="logcounts", check.missing colnames(gm) <- levels(flabels) ref[[i]] <- gm } - + ulabels <- .get_levels(unlist(lapply(ref, colnames))) labels <- list() for (i in seq_along(ref)) { diff --git a/R/plotScoreDistribution.R b/R/plotScoreDistribution.R index b47d087..11d5b3f 100644 --- a/R/plotScoreDistribution.R +++ b/R/plotScoreDistribution.R @@ -211,7 +211,7 @@ plotScoreDistribution <- function( name = labels.title, breaks = c("assigned", "pruned", "other"), values = c(this.color, pruned.color, other.color)) - + jit <- ggplot2::geom_jitter(height = 0, width = 0.3, color = "black", shape = 16, size = size, na.rm = TRUE) @@ -223,7 +223,7 @@ plotScoreDistribution <- function( p <- p + ggplot2::theme_classic() + ggplot2::facet_wrap(facets = ~label, ncol = ncol) + ggplot2::ylab(scores.title) - + if (nlevels(as.factor(df$label)) == 1) { p <- p + ggplot2::scale_x_discrete(name = NULL, labels = NULL) } else { diff --git a/R/pruneScores.R b/R/pruneScores.R index c26b0e5..3459130 100644 --- a/R/pruneScores.R +++ b/R/pruneScores.R @@ -90,7 +90,7 @@ pruneScores <- function(results, nmads=3, min.diff.med=-Inf, min.diff.next=0, get.thresholds=FALSE) { delta <- getDeltaFromMedian(results) keep <- delta >= min.diff.med - + dn <- results$delta.next if (!is.null(dn)) { keep <- keep & dn >= min.diff.next diff --git a/src/find_classic_markers.cpp b/src/find_classic_markers.cpp index 9e0aca4..90fd1b9 100644 --- a/src/find_classic_markers.cpp +++ b/src/find_classic_markers.cpp @@ -33,7 +33,7 @@ Rcpp::List find_classic_markers(int nlabels, int ngenes, Rcpp::List labels, Rcpp } lab_ptrs.push_back(static_cast(lab_vec.back().begin())); } - + singlepp::ChooseClassicMarkersOptions opts; opts.number = de_n; opts.num_threads = nthreads; diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R index a9c368c..ea6e97e 100644 --- a/tests/testthat/setup.R +++ b/tests/testthat/setup.R @@ -4,13 +4,13 @@ set.seed(100) ########################################### ## Mocking up some example training data ## ########################################### - + Ngroups <- 5 Ngenes <- 1000 means <- matrix(rnorm(Ngenes*Ngroups), nrow=Ngenes) means[1:900,] <- 0 colnames(means) <- LETTERS[1:5] - + N <- 100 g <- sample(LETTERS[1:5], N, replace=TRUE) training <- SingleCellExperiment( @@ -24,7 +24,7 @@ training <- scuttle::logNormCounts(training) ################################################## ## Mocking up some test data for classification ## ################################################## - + N <- 100 g <- sample(LETTERS[1:5], N, replace=TRUE) test <- SingleCellExperiment( diff --git a/tests/testthat/test-SingleR.R b/tests/testthat/test-SingleR.R index 37f6e43..7a1e88e 100644 --- a/tests/testthat/test-SingleR.R +++ b/tests/testthat/test-SingleR.R @@ -18,7 +18,7 @@ test_that("SingleR works with custom gene selection", { out <- SingleR(test=test, ref=training, labels=training$label, genes=more.collected) tab <- table(out$labels, test$label) expect_true(sum(diag(tab))/sum(tab) > 0.95) - + # We should get, in this case, the same result with a list of vectors. out2 <- SingleR(test=test, ref=training, labels=training$label, genes=collected) expect_identical(collected, lapply(metadata(out2)$de.genes, unlist, use.names=FALSE)) @@ -92,7 +92,7 @@ test_that("SingleR handles data.frame inputs", { ref1 <- SingleR(test=test, ref=training, labels=training$label) set.seed(10) ref2 <- SingleR(test=data.frame(logcounts(test)), ref=data.frame(logcounts(training)), labels=training$label) - + rownames(ref2) <- NULL # as the data.frame coercion changes the cell's names. expect_identical(ref1, ref2) diff --git a/tests/testthat/test-markers.R b/tests/testthat/test-markers.R index c7d4bdc..7ec5c18 100644 --- a/tests/testthat/test-markers.R +++ b/tests/testthat/test-markers.R @@ -38,7 +38,7 @@ REF <- function(ref, labels, de.n=NULL) { collected <- list() for (i in ulabels) { subcollected <- list() - + for (j in ulabels) { s <- sort(mat[,i] - mat[,j], decreasing=TRUE) s <- s[s>0] @@ -81,7 +81,7 @@ test_that("getClassicMarkers works with blocking", { out2 <- getClassicMarkers(list(logcounts(training), logcounts(training)), list(training$label, training$label)) expect_identical(out, out2) - + # Blocking is robust to training sets that don't have the labels. out3 <- getClassicMarkers(list(logcounts(training), logcounts(training)[,0]), list(training$label, training$label[0])) diff --git a/tests/testthat/test-prune.R b/tests/testthat/test-prune.R index 49f8dab..7225941 100644 --- a/tests/testthat/test-prune.R +++ b/tests/testthat/test-prune.R @@ -10,7 +10,7 @@ test_that("validating per-cell check without finetuning", { c(1,1,1,1,1) ) colnames(scores) <- LETTERS[1:5] - + results <- DataFrame(scores=I(scores), labels=colnames(scores)[max.col(scores)]) expect_identical(pruneScores(results, min.diff.med=0.05), c(FALSE, FALSE, TRUE, TRUE, TRUE)) diff --git a/tests/testthat/test-recomputed.R b/tests/testthat/test-recomputed.R index 59e880e..7c45d05 100644 --- a/tests/testthat/test-recomputed.R +++ b/tests/testthat/test-recomputed.R @@ -57,7 +57,7 @@ test_that("combineRecomputedResults matrix fragmentation works as expected", { test=test, trained=list(train1, train2)) - # Testing that it works upon parallelization. + # Testing that it works upon parallelization. combined1x <- combineRecomputedResults( results=list(pred1, pred2), test=test, diff --git a/tests/testthat/test-train.R b/tests/testthat/test-train.R index a9bef02..1b393c5 100644 --- a/tests/testthat/test-train.R +++ b/tests/testthat/test-train.R @@ -176,7 +176,7 @@ test_that("trainSingleR behaves with multiple references, plus recomputation", { training1 <- training2 <- training training1 <- training1[sample(nrow(training1)),] rownames(training1) <- rownames(training) - + ref1 <- trainSingleR(training1, training1$label) ref2 <- trainSingleR(training2, training2$label) out <- trainSingleR(list(training1, training2), list(training1$label, training2$label)) @@ -213,7 +213,7 @@ test_that("trainSingleR works when 'genes' contains markers outside of the refer train.sub <- head(training, 90) collected <- SingleR:::.get_genes_by_de(logcounts(training), training$label) genes <- unique(unlist(collected)) - + # Make sure more genes than ref expect_false(all(genes %in% row.names(train.sub))) expect_error(out <- SingleR::trainSingleR(train.sub, training$label, genes = collected), NA) diff --git a/vignettes/SingleR.Rmd b/vignettes/SingleR.Rmd index 9a6be3b..50698b2 100644 --- a/vignettes/SingleR.Rmd +++ b/vignettes/SingleR.Rmd @@ -18,7 +18,7 @@ bibliography: ref.bib vignette: > %\VignetteIndexEntry{Annotating scRNA-seq data} %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} + %\VignetteEncoding{UTF-8} --- ```{r, echo=FALSE, results="hide", message=FALSE}