Browse code

Add additional check on bgBatch

Yuan authored on 13/01/2022 21:39:18
Showing 1 changed files

... ...
@@ -424,7 +424,7 @@ setMethod(
424 424
     # If batch null, bgBatch has to be null
425 425
     if (!is.null(batchBackground)){
426 426
       stop(
427
-        "When experiment default to no bacth, background should",
427
+        "When experiment default to no bacth, background should ",
428 428
         "also default to no batch."
429 429
       )
430 430
     }
... ...
@@ -432,6 +432,17 @@ setMethod(
432 432
     if (!is.null(countsBackground)) {
433 433
       batchBackground <- rep("all_cells", ncol(countsBackground))
434 434
     }
435
+  } else {
436
+
437
+    # If batch not null and countsBackground supplied,
438
+    # user has to supply batchBackground as well
439
+    if (!is.null(countsBackground) & is.null(batchBackground)){
440
+      stop(
441
+        "Cell batch, and background are supplied. Please also ",
442
+        "supply background batch."
443
+      )
444
+    }
445
+
435 446
   }
436 447
   runParams$batch <- batch
437 448
   runParams$batchBackground <- batchBackground