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

Use checkParams and getParams

parent ebc0e307
No related branches found
No related tags found
No related merge requests found
...@@ -127,32 +127,38 @@ splatParams <- function(...) { ...@@ -127,32 +127,38 @@ splatParams <- function(...) {
#' @export #' @export
print.splatParams <- function(x, ...) { print.splatParams <- function(x, ...) {
pp <- list("Global:" = c("(Genes)" = x$nGenes, "(Cells)" = x$nCells, pp <- list("Global:" = c("(Genes)" = "nGenes",
"[Group Cells]" = x$groupCells), "(Cells)" = "nCells",
"Mean:" = c("(Rate)" = x$mean$rate, "(Shape)" = x$mean$shape), "[Group Cells]" = "groupCells"),
"Library size:" = c("(Location)" = x$lib$loc, "Mean:" = c("(Rate)" = "mean.rate",
"(Scale)" = x$lib$scale), "(Shape)" = "mean.shape"),
"Expression outliers:" = c("(Probability)" = x$out$prob, "Library size:" = c("(Location)" = "lib.loc",
"(Lo Probability)" = x$out$loProb, "(Scale)" = "lib.scale"),
"(Location)" = x$out$facLoc, "Exprs outliers:" = c("(Probability)" = "out.prob",
"(Scale)" = x$out$facScale), "(Lo Prob)" = "out.loProb",
"Differential expression:" = c("[Probability]" = x$de$prob, "(Location)" = "out.facLoc",
"[Down Prob]" = x$de$downProb, "(Scale)" = "out.facScale"),
"[Location]" = x$de$facLoc, "Differential exprs:" = c("[Probability]" = "de.prob",
"[Scale]" = x$de$facScale), "[Down Prob]" = "de.downProb",
"BCV:" = c("(Common Disp)" = x$bcv$common, "[Location]" = "de.facLoc",
"(Degrees of Freedom)" = x$bcv$DF), "[Scale]" = "de.facScale"),
"Dropout:" = c("(Present T/F)" = x$dropout$present, "BCV:" = c("(Common Disp)" = "bcv.common",
"(Midpoint)" = x$dropout$mid, "(DoF)" = "bcv.DF"),
"(Shape)" = x$dropout$shape), "Dropout:" = c("(Present T/F)" = "dropout.present",
"Paths:" = c("[From]" = x$path$from, "[Length]" = x$path$length, "(Midpoint)" = "dropout.mid",
"[Skew]" = x$path$skew, "(Shape)" = "dropout.shape"),
"[Non-linear Prob]" = x$path$nonlinearProb, "Paths:" = c("[From]" = "path.from",
"[Sigma Factor]" = x$path$sigmaFac)) "[Length]" = "path.length",
"[Skew]" = "path.skew",
"[Non-linear]" = "path.nonlinearProb",
"[Sigma Factor]" = "path.sigmaFac"))
for (category in names(pp)) { for (category in names(pp)) {
parameters <- getParams(x, pp[[category]])
parameters <- sapply(parameters, paste, collapse = ", ")
names(parameters) <- names(pp[[category]])
cat(category, "\n") cat(category, "\n")
print.default(pp[[category]], print.gap = 2) print(noquote(parameters), print.gap = 2)
cat("\n") cat("\n")
} }
} }
...@@ -205,6 +211,8 @@ setParams <- function(params, ...) { ...@@ -205,6 +211,8 @@ setParams <- function(params, ...) {
} }
} }
checkParams(params)
return(params) return(params)
} }
...@@ -310,13 +318,8 @@ checkParams <- function(params) { ...@@ -310,13 +318,8 @@ checkParams <- function(params) {
for (idx in seq_along(types)) { for (idx in seq_along(types)) {
name <- names(types)[idx] name <- names(types)[idx]
name.split <- strsplit(name, ".", fixed = TRUE)[[1]]
type <- types[idx] type <- types[idx]
if (length(name.split) == 1) { value <- getParams(name)
value <- params[[name]]
} else {
value <- params[[name.split[1]]][[name.split[2]]]
}
# Check vector properties first so we can exclude vectors with an NA # Check vector properties first so we can exclude vectors with an NA
# before the next section # before the next section
...@@ -387,6 +390,8 @@ mergeParams <- function(params1, params2) { ...@@ -387,6 +390,8 @@ mergeParams <- function(params1, params2) {
} }
} }
checkParams()
return(params1) return(params1)
} }
...@@ -405,15 +410,17 @@ defaultParams <- function() { ...@@ -405,15 +410,17 @@ defaultParams <- function() {
params <- splatParams() params <- splatParams()
params <- setParams(params, nGenes = 10000, nCells = 100, params <- setParams(params, nGenes = 10000, nCells = 100,
groupCells = 100, mean.rate = 0.3, mean.shape = 0.4, groupCells = 100, mean.rate = 0.3, mean.shape = 0.4,
lib.loc = 10, lib.scale = 0.5, out.prob = 0.1, lib.loc = 10, lib.scale = 0.5, out.prob = 0.1,
out.loProb = 0.5, out.facLoc = 4, out.facScale = 1, out.loProb = 0.5, out.facLoc = 4, out.facScale = 1,
de.prob = 0.1, de.downProb = 0.5, de.facLoc = 4, de.prob = 0.1, de.downProb = 0.5, de.facLoc = 4,
de.facScale = 1, bcv.common = 0.1, bcv.DF = 25, de.facScale = 1, bcv.common = 0.1, bcv.DF = 25,
dropout.present = TRUE, dropout.mid = 0, dropout.present = TRUE, dropout.mid = 0,
dropout.shape = -1, path.from = 0, dropout.shape = -1, path.from = 0, path.length = 100,
path.length = 100, path.skew = 0.5, path.skew = 0.5, path.nonlinearProb = 0.1,
path.nonlinearProb = 0.1, path.sigmaFac = 0.8) path.sigmaFac = 0.8)
checkParams()
return(params) return(params)
} }
\ 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