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

Rename path.length to path.nSteps

parent d60addd0
No related branches found
No related tags found
No related merge requests found
......@@ -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))
......
......@@ -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)
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
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