diff --git a/R/AllClasses.R b/R/AllClasses.R index eb6a41484cb206e6fbb9e3c1bda8bc41f6be2133..32f13df826437fc10230d9591df6f8faa580398f 100644 --- a/R/AllClasses.R +++ b/R/AllClasses.R @@ -167,9 +167,10 @@ setClass("SimpleParams", #' this form would have a "from" parameter of c(0, 1, 1) (where 0 is #' the origin). If no vector is given all paths will start at the #' origin.} -#' \item{\code{[path.length]}}{Vector giving the number of steps to +#' \item{\code{[path.nSteps]}}{Vector giving the number of steps to #' simulate along each path. If a single value is given it will be -#' applied to all paths.} +#' applied to all paths. This parameter was previously called +#' \code{path.length}.} #' \item{\code{[path.skew]}}{Vector giving the skew of each path. #' Values closer to 1 will give more cells towards the starting #' population, values closer to 0 will give more cells towards the @@ -221,7 +222,7 @@ setClass("SplatParams", dropout.mid = "numeric", dropout.shape = "numeric", path.from = "numeric", - path.length = "numeric", + path.nSteps = "numeric", path.skew = "numeric", path.nonlinearProb = "numeric", path.sigmaFac = "numeric"), @@ -249,7 +250,7 @@ setClass("SplatParams", dropout.mid = 0, dropout.shape = -1, path.from = 0, - path.length = 100, + path.nSteps = 100, path.skew = 0.5, path.nonlinearProb = 0.1, path.sigmaFac = 0.8)) diff --git a/R/SplatParams-methods.R b/R/SplatParams-methods.R index 368ca553e73a110f87e952d9624ac76bf64456ba..8a82e79c88b7b991ccd2305b773143f62e4bfa21 100644 --- a/R/SplatParams-methods.R +++ b/R/SplatParams-methods.R @@ -54,8 +54,8 @@ setValidity("SplatParams", function(object) { any.missing = FALSE, min.len = 1), path.from = checkIntegerish(v$path.from, lower = 0, upper = nGroups, len = nGroups), - path.length = checkIntegerish(v$path.length, lower = 1, - len = nGroups), + path.nSteps = checkIntegerish(v$path.nSteps, lower = 1, + len = nGroups), path.skew = checkNumeric(v$path.skew, lower = 0, upper = 1, len = nGroups), path.nonlinearProb = checkNumber(v$path.nonlinearProb, @@ -103,6 +103,12 @@ setValidity("SplatParams", function(object) { setMethod("setParam", "SplatParams", function(object, name, value) { checkmate::assertString(name) + if (name == "path.length") { + warning("path.length has been renamed path.nSteps, ", + "please use path.nSteps in the future.") + name <- "path.nSteps" + } + if (name == "nCells" || name == "nBatches") { stop(name, " cannot be set directly, set batchCells instead") } @@ -211,7 +217,7 @@ setMethod("show", "SplatParams", function(object) { "(Midpoint)" = "dropout.mid", "(Shape)" = "dropout.shape"), "Paths:" = c("[From]" = "path.from", - "[Length]" = "path.length", + "[Steps]" = "path.nSteps", "[Skew]" = "path.skew", "[Non-linear]" = "path.nonlinearProb", "[Sigma Factor]" = "path.sigmaFac")) @@ -232,7 +238,7 @@ setMethod("expandParams", "SplatParams", function(object) { n <- getParam(object, "nGroups") vectors <- c("de.prob", "de.downProb", "de.facLoc", "de.facScale", - "path.from", "path.length", "path.skew") + "path.from", "path.nSteps", "path.skew") object <- callNextMethod(object, vectors, n) diff --git a/R/splat-simulate.R b/R/splat-simulate.R index 0cb90b3246ecbc8c191247a367e9253f878ae7be..efa087fdd0a07116e920b8d2b82cf1a1649b1425 100644 --- a/R/splat-simulate.R +++ b/R/splat-simulate.R @@ -530,7 +530,7 @@ splatSimPathCellMeans <- function(sim, params) { cell.names <- colData(sim)$Cell gene.names <- rowData(sim)$Gene path.from <- getParam(params, "path.from") - path.length <- getParam(params, "path.length") + path.nSteps <- getParam(params, "path.nSteps") path.skew <- getParam(params, "path.skew") path.nonlinearProb <- getParam(params, "path.nonlinearProb") path.sigmaFac <- getParam(params, "path.sigmaFac") @@ -558,7 +558,7 @@ splatSimPathCellMeans <- function(sim, params) { rowData(sim)[[paste0("SigmaFacPath", idx)]] <- sigma.facs } - # Generate paths. Each path is a matrix with path.length columns and + # Generate paths. Each path is a matrix with path.nSteps columns and # nGenes rows where the expression from each genes changes along the path. path.steps <- lapply(seq_along(path.from), function(idx) { from <- path.from[idx] @@ -575,7 +575,7 @@ splatSimPathCellMeans <- function(sim, params) { sigma.facs <- rowData(sim)[[paste0("SigmaFacPath", idx)]] # Build Brownian bridges from start to end - steps <- buildBridges(facs.start, facs.end, n = path.length[idx], + steps <- buildBridges(facs.start, facs.end, n = path.nSteps[idx], sigma.fac = sigma.facs) return(t(steps)) @@ -584,13 +584,13 @@ splatSimPathCellMeans <- function(sim, params) { # Randomly assign a position in the appropriate path to each cell path.probs <- lapply(seq_len(nGroups), function(idx) { probs <- seq(path.skew[idx], 1 - path.skew[idx], - length = path.length[idx]) + length = path.nSteps[idx]) probs <- probs / sum(probs) return(probs) }) steps <- sapply(factor(groups), function(path) { - step <- sample(seq_len(path.length[path]), 1, prob = path.probs[[path]]) + step <- sample(seq_len(path.nSteps[path]), 1, prob = path.probs[[path]]) }) # Collect the underlying expression levels for each cell diff --git a/man/SplatParams.Rd b/man/SplatParams.Rd index 23b089c7d31c3bcad9a80e5dbfc09939134fd24d..bb906f959b313a7dcee5dfd3b5f1d2797f3307a6 100644 --- a/man/SplatParams.Rd +++ b/man/SplatParams.Rd @@ -111,9 +111,10 @@ The Splatter simulation requires the following parameters: this form would have a "from" parameter of c(0, 1, 1) (where 0 is the origin). If no vector is given all paths will start at the origin.} - \item{\code{[path.length]}}{Vector giving the number of steps to + \item{\code{[path.nSteps]}}{Vector giving the number of steps to simulate along each path. If a single value is given it will be - applied to all paths.} + applied to all paths. This parameter was previously called + \code{path.length}.} \item{\code{[path.skew]}}{Vector giving the skew of each path. Values closer to 1 will give more cells towards the starting population, values closer to 0 will give more cells towards the diff --git a/vignettes/splatter.Rmd b/vignettes/splatter.Rmd index be82bd389bad6e9e843b646fc9399c7558c133bd..b92584956930bde9ac10e87e101235398fa40a99 100644 --- a/vignettes/splatter.Rmd +++ b/vignettes/splatter.Rmd @@ -137,7 +137,7 @@ The parameters required for the Splat simulation are briefly described here: * `dropout.shape` - Shape parameter for the dropout logistic function. * **Differentiation path parameters** * `path.from` - Vector giving the originating point of each path. - * `path.length` - Vector giving the number of steps to simulate along each + * `path.steps` - Vector giving the number of steps to simulate along each path. * `path.skew` - Vector giving the skew of each path. * `path.nonlinearProb` - Probability that a gene changes expression in a