Skip to content

Commit

Permalink
Stripped out some annoying whitespace on empty lines.
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Dec 11, 2024
1 parent 8abb0c7 commit 45fdd30
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion R/aggregateReference.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/combineRecomputedResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion R/getClassicMarkers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions R/plotScoreDistribution.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion R/pruneScores.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/find_classic_markers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Rcpp::List find_classic_markers(int nlabels, int ngenes, Rcpp::List labels, Rcpp
}
lab_ptrs.push_back(static_cast<const int*>(lab_vec.back().begin()));
}

singlepp::ChooseClassicMarkersOptions opts;
opts.number = de_n;
opts.num_threads = nthreads;
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-SingleR.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-markers.R
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-prune.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-recomputed.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-train.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion vignettes/SingleR.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 45fdd30

Please sign in to comment.