Skip to content
Snippets Groups Projects
Commit 83837f38 authored by Luke Zappia's avatar Luke Zappia
Browse files

Add seed paramater and seed simulation

parent 0e4f7aa2
No related branches found
No related tags found
No related merge requests found
Package: splatter
Type: Package
Title: Simple Simulation of Single-cell RNA Sequencing Data
Version: 0.3.18
Version: 0.3.19
Date: 2016-10-11
Author: Luke Zappia
Authors@R: as.person(c(
......
......@@ -83,6 +83,7 @@
#' value will result in more extreme non-linear variations along a
#' path.
#' }
#' \item seed - Random seed used during the simulation
#' }
#'
#' Those shown in brackets cannot currently be easily estimated from a real
......@@ -105,7 +106,8 @@ splatParams <- function(...) {
bcv = list(common = NA, DF = NA),
dropout = list(present = NA, mid = NA, shape = NA),
path = list(from = NA, length = NA, skew = NA,
nonlinearProb = NA, sigmaFac = NA))
nonlinearProb = NA, sigmaFac = NA),
seed = NA)
class(params) <- "splatParams"
......@@ -155,7 +157,8 @@ print.splatParams <- function(x, ...) {
"[Length]" = "path.length",
"[Skew]" = "path.skew",
"[Non-linear]" = "path.nonlinearProb",
"[Sigma Factor]" = "path.sigmaFac"))
"[Sigma Factor]" = "path.sigmaFac"),
"Seed:" = c("Seed" = "seed"))
for (category in names(pp)) {
parameters <- getParams(x, pp[[category]])
......@@ -332,7 +335,7 @@ checkParams <- function(params) {
dropout.present = "LOG", dropout.mid = "NUM",
dropout.shape = "NUM", path.from = "INT", path.length = "INT",
path.skew = "PROB", path.nonlinearProb = "PROB",
path.sigmaFac = "POS")
path.sigmaFac = "POS", seed = "INT")
# Define which parameters are allowed to be vectors
vectors <- c("groupCells", "path.from", "path.length", "path.skew")
......@@ -462,7 +465,7 @@ defaultParams <- function() {
dropout.present = TRUE, dropout.mid = 0,
dropout.shape = -1, path.from = 0, path.length = 100,
path.skew = 0.5, path.nonlinearProb = 0.1,
path.sigmaFac = 0.8)
path.sigmaFac = 0.8, seed = sample(1:1e6, 1))
return(params)
}
......
......@@ -115,6 +115,10 @@ splat <- function(params = defaultParams(), method = c("groups", "paths"),
params <- mergeParams(params, defaultParams())
params <- expandPathParams(params)
# Set random seed
seed <- getParams(params, "seed")
set.seed(seed)
# Get the parameters we are going to use
nCells <- getParams(params, "nCells")
nGenes <- getParams(params, "nGenes")
......
......@@ -94,6 +94,7 @@ parameters. It has the following sections and values:
value will result in more extreme non-linear variations along a
path.
}
\item seed - Random seed used during the simulation
}
Those shown in brackets cannot currently be easily estimated from a real
......
......@@ -185,4 +185,10 @@ test_that("constructor is valid", {
test_that("defaultParams is valid", {
expect_silent(checkParams(defaultParams()))
})
test_that("default seed is random", {
params1 <- defaultParams()
params2 <- defaultParams()
expect_false(getParams(params1, "seed") == getParams(params2, "seed"))
})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment