diff --git a/R/simulator.R b/R/simulator.R index c129d74..02417c6 100755 --- a/R/simulator.R +++ b/R/simulator.R @@ -74,7 +74,7 @@ simulate_sample <- function(data, if (n == 0) { n <- 1 } - if(!is.na(seed)){ + if (!is.na(seed)) { # fix seed for random selection of cells set.seed(seed) } @@ -437,7 +437,6 @@ simulate_bulk <- function(data, # sample cells and generate pseudo-bulk profiles all_samples <- BiocParallel::bplapply(seq_along(simulation_vector_list), function(i) { - simulation_vector <- simulation_vector_list[[i]] sample <- simulate_sample( data = data, diff --git a/tests/testthat/test_simulator.R b/tests/testthat/test_simulator.R index 41ff342..be14f20 100755 --- a/tests/testthat/test_simulator.R +++ b/tests/testthat/test_simulator.R @@ -48,15 +48,14 @@ test_that("test RNG", { seed <- 123 sim1 <- SimBu::simulate_bulk(data = dataset, scenario = "even", scaling_factor = "NONE", balance_even_mirror_scenario = 0, nsamples = 10, ncells = 100, run_parallel = FALSE, seed = seed) sim2 <- SimBu::simulate_bulk(data = dataset, scenario = "even", scaling_factor = "NONE", balance_even_mirror_scenario = 0, nsamples = 10, ncells = 100, run_parallel = FALSE, seed = seed) - x1 <- Matrix::rowSums(assays(sim1$bulk)[['bulk_counts']]) - x2 <- Matrix::rowSums(assays(sim2$bulk)[['bulk_counts']]) - testthat::expect_equal(x1,x2) - - # test that samples inside one simulation still are different - sample1 <- sim1$bulk[,1] - sample2 <- sim1$bulk[,2] - testthat::expect_false(all(assays(sample1)[['bulk_counts']] == assays(sample2)[['bulk_counts']])) + x1 <- Matrix::rowSums(assays(sim1$bulk)[["bulk_counts"]]) + x2 <- Matrix::rowSums(assays(sim2$bulk)[["bulk_counts"]]) + testthat::expect_equal(x1, x2) + # test that samples inside one simulation still are different + sample1 <- sim1$bulk[, 1] + sample2 <- sim1$bulk[, 2] + testthat::expect_false(all(assays(sample1)[["bulk_counts"]] == assays(sample2)[["bulk_counts"]])) }) test_that("test different scaling factor calculations + mRNA bias removal from counts", {