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

Add SplotchParams object

Basic skeleton so far
parent 3d43018f
No related branches found
No related tags found
No related merge requests found
Package: splatter Package: splatter
Type: Package Type: Package
Title: Simple Simulation of Single-cell RNA Sequencing Data Title: Simple Simulation of Single-cell RNA Sequencing Data
Version: 1.9.2 Version: 1.9.2.9000
Date: 2019-06-13 Date: 2019-07-11
Author: Luke Zappia Author: Luke Zappia
Authors@R: Authors@R:
c(person("Luke", "Zappia", role = c("aut", "cre"), c(person("Luke", "Zappia", role = c("aut", "cre"),
...@@ -62,7 +62,8 @@ Suggests: ...@@ -62,7 +62,8 @@ Suggests:
zinbwave, zinbwave,
SparseDC, SparseDC,
BiocManager, BiocManager,
spelling spelling,
igraph
biocViews: SingleCell, RNASeq, Transcriptomics, GeneExpression, Sequencing, biocViews: SingleCell, RNASeq, Transcriptomics, GeneExpression, Sequencing,
Software, ImmunoOncology Software, ImmunoOncology
URL: https://github.com/Oshlack/splatter URL: https://github.com/Oshlack/splatter
......
### Version 1.9.2.9000 (2019-07-11)
* Add SplotchParams object
## Version 1.9.2 (2019-06-13) ## Version 1.9.2 (2019-06-13)
* Add variable gene correlation plot to compareSCEs * Add variable gene correlation plot to compareSCEs
......
...@@ -63,11 +63,11 @@ setClass("SimpleParams", ...@@ -63,11 +63,11 @@ setClass("SimpleParams",
#' The SplatParams class #' The SplatParams class
#' #'
#' S4 class that holds parameters for the Splatter simulation. #' S4 class that holds parameters for the Splat simulation.
#' #'
#' @section Parameters: #' @section Parameters:
#' #'
#' The Splatter simulation requires the following parameters: #' The Splat simulation requires the following parameters:
#' #'
#' \describe{ #' \describe{
#' \item{\code{nGenes}}{The number of genes to simulate.} #' \item{\code{nGenes}}{The number of genes to simulate.}
...@@ -189,7 +189,7 @@ setClass("SimpleParams", ...@@ -189,7 +189,7 @@ setClass("SimpleParams",
#' } #' }
#' #'
#' The parameters not shown in brackets can be estimated from real data using #' The parameters not shown in brackets can be estimated from real data using
#' \code{\link{splatEstimate}}. For details of the Splatter simulation #' \code{\link{splatEstimate}}. For details of the Splat simulation
#' see \code{\link{splatSimulate}}. #' see \code{\link{splatSimulate}}.
#' #'
#' @name SplatParams #' @name SplatParams
...@@ -255,6 +255,37 @@ setClass("SplatParams", ...@@ -255,6 +255,37 @@ setClass("SplatParams",
path.nonlinearProb = 0.1, path.nonlinearProb = 0.1,
path.sigmaFac = 0.8)) path.sigmaFac = 0.8))
#' The SplotchParams class
#'
#' S4 class that holds parameters for the Splotch simulation.
#'
#' @section Parameters:
#'
#' The Splotch simulation uses the following parameters:
#'
#' \describe{
#' \item{\code{nGenes}}{The number of genes to simulate.}
#' \item{\code{nCells}}{The number of cells to simulate.}
#' \item{\code{[seed]}}{Seed to use for generating random numbers.}
#' \item{\code{[network.graph]}}{Graph containing the gene network.}
#' \item{\code{[network.nRegs]}}{Number of regulators in a the network.}
#' }
#'
#' The parameters not shown in brackets can be estimated from real data using
#' \code{\link{splotchEstimate}}. For details of the Splotch simulation
#' see \code{\link{splotchSimulate}}.
#'
#' @name SplotchParams
#' @rdname SplotchParams
#' @aliases SplotchParams-class
#' @exportClass SplotchParams
setClass("SplotchParams",
contains = "Params",
slots = c(network.graph = "ANY",
network.nRegs = "numeric"),
prototype = prototype(network.graph = NULL,
network.nRegs = 100))
#' The LunParams class #' The LunParams class
#' #'
#' S4 class that holds parameters for the Lun simulation. #' S4 class that holds parameters for the Lun simulation.
......
#' @rdname newParams
#' @importFrom methods new
#' @export
newSplotchParams <- function(...) {
if (!requireNamespace("igraph", quietly = TRUE)) {
stop("The Splotch simulation requires the 'igraph' package.")
}
params <- new("SplotchParams")
params <- setParams(params, ...)
return(params)
}
setValidity("SplotchParams", function(object) {
v <- getParams(object, slotNames(object))
checks <- c(nGenes = checkmate::checkInt(v$nGenes, lower = 1),
nCells = checkmate::checkInt(v$nCells, lower = 1),
seed = checkmate::checkInt(v$seed, lower = 0),
network.graph = checkmate::checkClass(v$network, "igraph",
null.ok = TRUE),
network.nRegs = checkmate::checkInt(v$network.nRegs,
lower = 0))
if (all(checks == TRUE)) {
valid <- TRUE
} else {
valid <- checks[checks != TRUE]
valid <- paste(names(valid), valid, sep = ": ")
}
return(valid)
})
setMethod("show", "SplotchParams", function(object) {
pp.network <- list("Network:" = c("[Graph]" = "network.graph",
"[nRegs]" = "network.nRegs"))
callNextMethod()
network.graph <- getParam(object, "network.graph")
if (is.null(network.graph)) {
showPP(object, pp.network)
} else {
cat(crayon::bold("Network:"), "\n")
cat(crayon::bold(crayon::blue("[GRAPH]\n")))
cat(crayon::bold(crayon::green(paste(
"Graph with", igraph::gorder(network.graph), "nodes and",
igraph::gsize(network.graph), "edges\n"
))))
show(network.graph)
network.nRegs <- getParam(object, "network.nRegs")
names(network.nRegs) <- c("[nRegs]")
if (network.nRegs == 100) {
showValues(network.nRegs, FALSE)
} else {
showValues(network.nRegs, TRUE)
}
}
# showPP(object, pp)
})
...@@ -76,6 +76,8 @@ showPP <- function(params, pp) { ...@@ -76,6 +76,8 @@ showPP <- function(params, pp) {
not.default <- sapply(seq_along(values), function(i) { not.default <- sapply(seq_along(values), function(i) {
!identical(values[i], default.values[i]) !identical(values[i], default.values[i])
}) })
null.values <- sapply(values, is.null)
values[null.values] <- "Not set"
cat(crayon::bold(category), "\n") cat(crayon::bold(category), "\n")
if (sum(!is.df) > 0) { if (sum(!is.df) > 0) {
...@@ -88,9 +90,9 @@ showPP <- function(params, pp) { ...@@ -88,9 +90,9 @@ showPP <- function(params, pp) {
} }
} }
#' Show vales #' Show values
#' #'
#' Function used for pretty printing scale or vector parameters. #' Function used for pretty printing scalar or vector parameters.
#' #'
#' @param values list of values to show. #' @param values list of values to show.
#' @param not.default logical vector giving which have changed from the default. #' @param not.default logical vector giving which have changed from the default.
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AllClasses.R
\docType{class}
\name{SplotchParams}
\alias{SplotchParams}
\alias{SplotchParams-class}
\title{The SplotchParams class}
\description{
S4 class that holds parameters for the Splotch simulation.
}
\section{Parameters}{
The Splotch simulation uses the following parameters:
\describe{
\item{\code{nGenes}}{The number of genes to simulate.}
\item{\code{nCells}}{The number of cells to simulate.}
\item{\code{[seed]}}{Seed to use for generating random numbers.}
\item{\code{[network.graph]}}{Graph containing the gene network.}
\item{\code{[network.nRegs]}}{Number of regulators in a the network.}
}
The parameters not shown in brackets can be estimated from real data using
\code{\link{splotchEstimate}}. For details of the Splotch simulation
see \code{\link{splotchSimulate}}.
}
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