... | ... |
@@ -165,9 +165,9 @@ recodeClusterZ <- function(sce, from, to, altExpName = "featureSubset") { |
165 | 165 |
new.clusters <- plyr::mapvalues(celdaClusters(sce, |
166 | 166 |
altExpName = altExpName), |
167 | 167 |
from, to) |
168 |
- new.clusters <- factor(new.clusters, levels = |
|
168 |
+ new.clusters <- factor(new.clusters, levels = |
|
169 | 169 |
sort(as.numeric(unique(new.clusters)))) |
170 |
- |
|
170 |
+ |
|
171 | 171 |
celdaClusters(sce, altExpName = altExpName) <- new.clusters |
172 | 172 |
return(sce) |
173 | 173 |
} |
... | ... |
@@ -218,9 +218,9 @@ recodeClusterY <- function(sce, from, to, altExpName = "featureSubset") { |
218 | 218 |
new.clusters <- plyr::mapvalues(celdaModules(sce, |
219 | 219 |
altExpName = altExpName), |
220 | 220 |
from, to) |
221 |
- new.clusters <- factor(new.clusters, levels = |
|
221 |
+ new.clusters <- factor(new.clusters, levels = |
|
222 | 222 |
sort(as.numeric(unique(new.clusters)))) |
223 |
- |
|
223 |
+ |
|
224 | 224 |
celdaModules(sce, altExpName = altExpName) <- plyr::mapvalues( |
225 | 225 |
celdaModules(sce, altExpName = altExpName), from, to) |
226 | 226 |
return(sce) |
... | ... |
@@ -27,13 +27,13 @@ |
27 | 27 |
#' @param background A numeric matrix of counts or a |
28 | 28 |
#' \linkS4class{SingleCellExperiment} with the matrix located in the assay |
29 | 29 |
#' slot under \code{assayName}. It should have the same data format as \code{x} |
30 |
-#' except it contains the empty droplets instead of cells. When supplied, |
|
30 |
+#' except it contains the empty droplets instead of cells. When supplied, |
|
31 | 31 |
#' empirical distribution of transcripts from these empty droplets |
32 | 32 |
#' will be used as the contamination distribution. Default NULL. |
33 | 33 |
#' @param bgAssayName Character. Name of the assay to use if \code{background} |
34 | 34 |
#' is a \linkS4class{SingleCellExperiment}. Default to same as |
35 | 35 |
#' \code{assayName}. |
36 |
-#' @param bgBatch Numeric or character vector. Batch labels for |
|
36 |
+#' @param bgBatch Numeric or character vector. Batch labels for |
|
37 | 37 |
#' \code{background}. Its unique values should be the same as those in |
38 | 38 |
#' \code{batch}, such that each batch of cells have their corresponding batch |
39 | 39 |
#' of empty droplets as background, pointed by this parameter. Default to NULL. |
... | ... |
@@ -174,10 +174,10 @@ setMethod("decontX", "SingleCellExperiment", function(x, |
174 | 174 |
bgBatch = bgBatch, |
175 | 175 |
logfile = logfile, |
176 | 176 |
verbose = verbose) |
177 |
- |
|
177 |
+ |
|
178 | 178 |
background <- temp$background |
179 | 179 |
bgBatch <- temp$bgBatch |
180 |
- |
|
180 |
+ |
|
181 | 181 |
if (is.null(bgAssayName)) { |
182 | 182 |
bgAssayName <- assayName |
183 | 183 |
} |
... | ... |
@@ -265,10 +265,10 @@ setMethod("decontX", "ANY", function(x, |
265 | 265 |
bgBatch = bgBatch, |
266 | 266 |
logfile = logfile, |
267 | 267 |
verbose = verbose) |
268 |
- |
|
268 |
+ |
|
269 | 269 |
background <- temp$background |
270 | 270 |
bgBatch <- temp$bgBatch |
271 |
- |
|
271 |
+ |
|
272 | 272 |
} |
273 | 273 |
|
274 | 274 |
.decontX( |
... | ... |
@@ -420,9 +420,9 @@ setMethod( |
420 | 420 |
## Generate batch labels if none were supplied |
421 | 421 |
if (is.null(batch)) { |
422 | 422 |
batch <- rep("all_cells", nC) |
423 |
- |
|
423 |
+ |
|
424 | 424 |
# If batch null, bgBatch has to be null |
425 |
- if (!is.null(batchBackground)){ |
|
425 |
+ if (!is.null(batchBackground)) { |
|
426 | 426 |
stop( |
427 | 427 |
"When experiment default to no bacth, background should ", |
428 | 428 |
"also default to no batch." |
... | ... |
@@ -436,7 +436,7 @@ setMethod( |
436 | 436 |
|
437 | 437 |
# If batch not null and countsBackground supplied, |
438 | 438 |
# user has to supply batchBackground as well |
439 |
- if (!is.null(countsBackground) & is.null(batchBackground)){ |
|
439 |
+ if (!is.null(countsBackground) & is.null(batchBackground)) { |
|
440 | 440 |
stop( |
441 | 441 |
"Cell batch, and background are supplied. Please also ", |
442 | 442 |
"supply background batch." |
... | ... |
@@ -540,7 +540,7 @@ setMethod( |
540 | 540 |
} |
541 | 541 |
|
542 | 542 |
## Try to convert class of new matrix to class of original matrix |
543 |
- |
|
543 |
+ |
|
544 | 544 |
.logMessages( |
545 | 545 |
date(), |
546 | 546 |
".. Calculating final decontaminated matrix", |
... | ... |
@@ -612,7 +612,7 @@ setMethod( |
612 | 612 |
append = TRUE, |
613 | 613 |
verbose = verbose |
614 | 614 |
) |
615 |
- |
|
615 |
+ |
|
616 | 616 |
## Determine class of seed in DelayedArray |
617 | 617 |
seed.class <- unique(DelayedArray::seedApply(counts, class))[[1]] |
618 | 618 |
if (seed.class == "HDF5ArraySeed") { |
... | ... |
@@ -1422,7 +1422,7 @@ simulateContamination <- function(C = 300, |
1422 | 1422 |
logfile = NULL, verbose = FALSE) { |
1423 | 1423 |
# Remove background barcodes that have already appeared in x |
1424 | 1424 |
# If bgBatch param is supplied, also remove duplicate bgBatch |
1425 |
- if(!is.null(colnames(background))) { |
|
1425 |
+ if (!is.null(colnames(background))) { |
|
1426 | 1426 |
dupBarcode <- colnames(background) %in% colnames(x) |
1427 | 1427 |
} else { |
1428 | 1428 |
dupBarcode <- FALSE |
... | ... |
@@ -1432,7 +1432,7 @@ simulateContamination <- function(C = 300, |
1432 | 1432 |
" Please ensure that no true cells are included in the background ", |
1433 | 1433 |
"matrix. Otherwise, results will be incorrect.") |
1434 | 1434 |
} |
1435 |
- |
|
1435 |
+ |
|
1436 | 1436 |
if (any(dupBarcode)) { |
1437 | 1437 |
.logMessages( |
1438 | 1438 |
date(), |
... | ... |
@@ -1445,8 +1445,8 @@ simulateContamination <- function(C = 300, |
1445 | 1445 |
verbose = verbose |
1446 | 1446 |
) |
1447 | 1447 |
background <- background[, !(dupBarcode), drop = FALSE] |
1448 |
- |
|
1449 |
- if(!is.null(bgBatch)){ |
|
1448 |
+ |
|
1449 |
+ if (!is.null(bgBatch)) { |
|
1450 | 1450 |
if (length(bgBatch) != length(dupBarcode)) { |
1451 | 1451 |
stop( |
1452 | 1452 |
"Length of bgBatch must be equal to the number of columns", |
... | ... |
@@ -1456,9 +1456,9 @@ simulateContamination <- function(C = 300, |
1456 | 1456 |
bgBatch <- bgBatch[!(dupBarcode)] |
1457 | 1457 |
} |
1458 | 1458 |
} |
1459 |
- |
|
1460 |
- re = list(background = background, |
|
1459 |
+ |
|
1460 |
+ re <- list(background = background, |
|
1461 | 1461 |
bgBatch = bgBatch) |
1462 |
- |
|
1462 |
+ |
|
1463 | 1463 |
return(re) |
1464 | 1464 |
} |