From c8059ef54ffff34603132401bcc4e6f7c94e6b3c Mon Sep 17 00:00:00 2001
From: Luke Zappia <lazappi@users.noreply.github.com>
Date: Thu, 19 Sep 2019 16:59:05 +1000
Subject: [PATCH] Rescale Phi when sampling in BASiCSSimulate

---
 DESCRIPTION         | 4 ++--
 NEWS.md             | 4 ++++
 R/BASiCS-simulate.R | 6 ++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index 5a1c60c..2f30b33 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
 Package: splatter
 Type: Package
 Title: Simple Simulation of Single-cell RNA Sequencing Data
-Version: 1.9.6
-Date: 2019-09-17
+Version: 1.9.7
+Date: 2019-09-19
 Author: Luke Zappia
 Authors@R:
     c(person("Luke", "Zappia", role = c("aut", "cre"),
diff --git a/NEWS.md b/NEWS.md
index fba5bbb..283654b 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,7 @@
+## Version 1.9.7 (2019-09-19)
+
+* Rescale when sampling Phi in BASiCSSimulate
+
 ## Version 1.9.6 (2019-09-17)
 
 * Adjust BASiCSSimulate to match development version of BASiCS
diff --git a/R/BASiCS-simulate.R b/R/BASiCS-simulate.R
index 345ba5b..2b5ab17 100644
--- a/R/BASiCS-simulate.R
+++ b/R/BASiCS-simulate.R
@@ -72,6 +72,8 @@ BASiCSSimulate <- function(params = newBASiCSParams(), verbose = TRUE, ...) {
                     "spike.means will be sampled.")
             selected <- sample(length(spike.mu), nSpikes, replace = TRUE)
             spike.mu <- spike.mu[selected]
+
+            params <- setParam(params, "spike.mu", spike.mu)
         }
     }
 
@@ -81,6 +83,10 @@ BASiCSSimulate <- function(params = newBASiCSParams(), verbose = TRUE, ...) {
                 "cell.params will be sampled.")
         selected <- sample(nrow(cell.params), nCells, replace = TRUE)
         cell.params <- cell.params[selected, ]
+
+        cell.params$Phi <- (cell.params$Phi / sum(cell.params$Phi)) * nCells
+
+        params <- setParam(params, "cell.params", cell.params)
     }
 
     thetas <- getParam(params, "theta")
-- 
GitLab