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

Add ZINBParams tests

parent e0017803
No related branches found
No related tags found
No related merge requests found
......@@ -559,7 +559,8 @@ setClass("PhenoParams",
#'
#' The majority of the parameters for this simulation are stored in a
#' \code{\link[zinbwave]{ZinbModel}} object. Please refer to the documentation
#' for this class for details about all the parameters.
#' for this class and its constructor(\code{\link[zinbwave]{zinbModel}}) for
#' details about all the parameters.
#'
#' The parameters not shown in brackets can be estimated from real data using
#' \code{\link{zinbEstimate}}. For details of the ZINB-WaVE simulation
......
......@@ -38,14 +38,19 @@ setValidity("ZINBParams", function(object) {
setMethod("setParam", "ZINBParams", function(object, name, value) {
checkmate::assertString(name)
if (name %in% names(getSlots("ZinbModel"))) {
model <- getParam(object, "model")
slot(model, name) <- value
object <- setParam(object, "model", model)
} else {
object <- callNextMethod()
if (name %in% c("nGenes", "nCells")) {
stop(name, " cannot be set directly, set model instead")
}
if (name == "model") {
object <- setParamUnchecked(object, "nGenes",
zinbwave::nFeatures(value))
object <- setParamUnchecked(object, "nCells",
zinbwave::nSamples(value))
}
object <- cellNextMethod()
return(object)
})
......
context("PhenoParams")
test_that("constructor is valid", {
expect_true(validObject(newSCDDParams()))
expect_true(validObject(newPhenoParams()))
})
test_that("nGenes checks work", {
......
context("ZINBParams")
test_that("constructor is valid", {
expect_true(validObject(newZINBParams()))
})
test_that("nGenes checks work", {
params <- newZINBParams()
expect_error(setParam(params, "nGenes", 1),
"nGenes cannot be set directly")
expect_error(setParam(params, "nCells", 1),
"nGenes cannot be set directly")
})
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