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

Run checks

parent 9f637dc7
No related branches found
No related tags found
No related merge requests found
Package: splatter
Type: Package
Title: Simple Simulation of Single-cell RNA Sequencing Data
Version: 0.3.15
Version: 0.3.16
Date: 2016-10-11
Author: Luke Zappia
Authors@R: as.person(c(
......@@ -18,12 +18,13 @@ LazyData: TRUE
Depends:
R (>= 3.3),
scater
Imports: limma,
Imports:
fitdistrplus,
edgeR,
stats,
locfit,
akima
akima,
Biobase
Suggests:
testthat
biocViews: SingleCell, RNASeq, Transcriptomics, GeneExpression, Sequencing,
......
......@@ -13,6 +13,9 @@ export(splat)
export(splatGroups)
export(splatParams)
export(splatPaths)
importFrom(Biobase,"assayData<-")
importFrom(Biobase,"fData<-")
importFrom(Biobase,"pData<-")
importFrom(Biobase,assayData)
importFrom(Biobase,fData)
importFrom(Biobase,pData)
......@@ -21,3 +24,10 @@ importFrom(scater,newSCESet)
importFrom(stats,dnbinom)
importFrom(stats,median)
importFrom(stats,nls)
importFrom(stats,rbinom)
importFrom(stats,rchisq)
importFrom(stats,rgamma)
importFrom(stats,rlnorm)
importFrom(stats,rnorm)
importFrom(stats,rpois)
importFrom(stats,runif)
......@@ -190,10 +190,10 @@ print.splatParams <- function(x, ...) {
#' @examples
#' params <- defaultParams()
#' params
#' # Set nGenes and nCells
#' params <- setParams(params, nGenes = 1000, nCells = 200)
#' # Set nGenes
#' params <- setParams(params, nGenes = 1000)
#' params
#' # Set mean rate paramater and library size location parameter
#' # Set mean rate parameter and library size location parameter
#' params <- setParams(params, mean.rate = 1, lib.loc = 12)
#' params
#' @export
......@@ -418,7 +418,7 @@ checkParams <- function(params) {
#'
#' @return Merged splatParams object.
#' @examples
#' params <- splatParams(nGenes = 1000, nCells = 50)
#' params <- splatParams(nGenes = 1000, mean.rate = 0.5)
#' params
#' # Replace unset parameters with default parameters
#' params <- mergeParams(params, defaultParams())
......@@ -477,11 +477,13 @@ defaultParams <- function() {
#'
#' @return expanded splatParams object.
#' @examples
#' \dontrun{
#' params <- defaultParams()
#' params <- setParams(params, groupCells = c(10, 10))
#' params
#' params <- expandPathParams(params)
#' params
#' }
expandPathParams <- function(params) {
n.groups <- getParams(params, "nGroups")
......
......@@ -94,16 +94,16 @@
#' @examples
#' # Simulation with default parameters
#' sim <- splat()
#' # Simulation with different number of cells
#' sim <- splat(nCells = 20)
#' # Simulation with different number of genes
#' sim <- splat(nGenes = 1000)
#' # Simulation with custom parameters
#' params <- splatParams(nGenes = 100, nCells = 20, mean.rate = 0.5)
#' params <- splatParams(nGenes = 100, mean.rate = 0.5)
#' sim <- splat(params)
#' # Simulation with adjusted custom parameters
#' sim <- splat(params, mean.rate = 0.6, out.prob = 0.2)
#' # Simulate paths instead of groups
#' sim <- splat(method = "paths")
#' @importFrom Biobase pData fData assayData
#' @importFrom Biobase fData pData pData<- assayData
#' @importFrom scater newSCESet counts
#' @export
splat <- function(params = defaultParams(), method = c("groups", "paths"),
......@@ -200,6 +200,9 @@ splatPaths <- function(params = defaultParams(), verbose = TRUE, ...) {
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added library sizes.
#'
#' @importFrom Biobase pData pData<-
#' @importFrom stats rlnorm
simLibSizes <- function(sim, params) {
n.cells <- getParams(params, "nCells")
......@@ -221,6 +224,9 @@ simLibSizes <- function(sim, params) {
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added gene means.
#'
#' @importFrom Biobase fData fData<-
#' @importFrom stats rgamma
simGeneMeans <- function(sim, params) {
n.genes <- getParams(params, "nGenes")
......@@ -256,6 +262,8 @@ simGeneMeans <- function(sim, params) {
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added differential expression.
#'
#' @importFrom Biobase fData pData
simGroupDE <- function(sim, params) {
n.genes <- getParams(params, "nGenes")
......@@ -287,6 +295,8 @@ simGroupDE <- function(sim, params) {
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added differential expression.
#'
#' @importFrom Biobase fData pData
simPathDE <- function(sim, params) {
n.genes <- getParams(params, "nGenes")
......@@ -324,7 +334,9 @@ simPathDE <- function(sim, params) {
#' @param sim SCESet to add cell means to.
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added cell means/.
#' @return SCESet with added cell means.
#'
#' @importFrom Biobase fData pData assayData assayData<-
simGroupCellMeans <- function(sim, params) {
n.groups <- getParams(params, "nGroups")
......@@ -361,6 +373,9 @@ simGroupCellMeans <- function(sim, params) {
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added cell means.
#'
#' @importFrom Biobase fData pData assayData
#' @importFrom stats rbinom
simPathCellMeans <- function(sim, params) {
n.genes <- getParams(params, "nGenes")
......@@ -443,6 +458,9 @@ simPathCellMeans <- function(sim, params) {
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added BCV means.
#'
#' @importFrom Biobase fData pData assayData assayData<-
#' @importFrom stats rchisq rgamma
simBCVMeans <- function(sim, params) {
n.genes <- getParams(params, "nGenes")
......@@ -481,6 +499,9 @@ simBCVMeans <- function(sim, params) {
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added true counts.
#'
#' @importFrom Biobase fData pData assayData
#' @importFrom stats rpois
simTrueCounts <- function(sim, params) {
n.genes <- getParams(params, "nGenes")
......@@ -511,6 +532,9 @@ simTrueCounts <- function(sim, params) {
#' @param params splatParams object with simulation parameters.
#'
#' @return SCESet with added dropout and observed counts.
#'
#' @importFrom Biobase fData pData assayData assayData<-
#' @importFrom stats rbinom
simDropout <- function(sim, params) {
dropout.present <- getParams(params, "dropout.present")
......@@ -551,7 +575,7 @@ simDropout <- function(sim, params) {
counts <- true.counts
}
counts(sim) <- counts
scater::counts(sim) <- counts
return(sim)
}
......@@ -568,8 +592,8 @@ simDropout <- function(sim, params) {
#' @param fac.scale Scale factor for the log-normal distribution.
#'
#' @return Vector containing generated factors.
#' @examples
#' factors <- getLNormFactors(100, 0.5, 0.5, 4, 1)
#'
#' @importFrom stats rbinom rlnorm
getLNormFactors <- function(n.facs, sel.prob, neg.prob, fac.loc, fac.scale) {
is.selected <- as.logical(rbinom(n.facs, 1, sel.prob))
......@@ -590,12 +614,10 @@ getLNormFactors <- function(n.facs, sel.prob, neg.prob, fac.loc, fac.scale) {
#' Identify the correct order to process paths so that preceding paths have
#' already been simulated.
#'
#' @param path.from Vector giving the path endpoints that each path orginates
#' @param path.from vector giving the path endpoints that each path orginates
#' from.
#'
#' @return Vector giving the order to process paths in.
#' @examples
#' path.order <- getPathOrder(c(2, 0, 2))
getPathOrder <- function(path.from) {
# Transform the vector into a list of (from, to) pairs
......@@ -638,8 +660,8 @@ getPathOrder <- function(path.from) {
#' @param sigma.fac multiplier specifying how extreme each step can be.
#'
#' @return Vector of length n following a path from x to y.
#' @examples
#' b <- bridge(10, 20)
#'
#' @importFrom stats runif rnorm
bridge <- function (x = 0, y = 0, N = 5, n = 100, sigma.fac = 0.8) {
dt <- 1 / (N - 1)
......
......@@ -24,7 +24,4 @@ Vector of length n following a path from x to y.
Calculate a smoothed Brownian bridge between two points. A Brownian bridge is
a random walk with fixed end points.
}
\examples{
b <- bridge(10, 20)
}
......@@ -17,10 +17,12 @@ Expand the path parameters so that they are the same length as the number
of groups.
}
\examples{
\dontrun{
params <- defaultParams()
params <- setParams(params, groupCells = c(10, 10))
params
params <- expandPathParams(params)
params
}
}
......@@ -24,7 +24,4 @@ Vector containing generated factors.
\description{
Randomly generate multiplication factors from a log-normal distribution.
}
\examples{
factors <- getLNormFactors(100, 0.5, 0.5, 4, 1)
}
......@@ -7,7 +7,7 @@
getPathOrder(path.from)
}
\arguments{
\item{path.from}{Vector giving the path endpoints that each path orginates
\item{path.from}{vector giving the path endpoints that each path orginates
from.}
}
\value{
......@@ -17,7 +17,4 @@ Vector giving the order to process paths in.
Identify the correct order to process paths so that preceding paths have
already been simulated.
}
\examples{
path.order <- getPathOrder(c(2, 0, 2))
}
......@@ -20,7 +20,7 @@ splatParams object are replaced by the value in the second splatParams
object.
}
\examples{
params <- splatParams(nGenes = 1000, nCells = 50)
params <- splatParams(nGenes = 1000, mean.rate = 0.5)
params
# Replace unset parameters with default parameters
params <- mergeParams(params, defaultParams())
......
......@@ -30,10 +30,10 @@ parameters and the splatParams data structure see \code{\link{splatParams}}.
\examples{
params <- defaultParams()
params
# Set nGenes and nCells
params <- setParams(params, nGenes = 1000, nCells = 200)
# Set nGenes
params <- setParams(params, nGenes = 1000)
params
# Set mean rate paramater and library size location parameter
# Set mean rate parameter and library size location parameter
params <- setParams(params, mean.rate = 1, lib.loc = 12)
params
}
......
......@@ -12,7 +12,7 @@ simGroupCellMeans(sim, params)
\item{params}{splatParams object with simulation parameters.}
}
\value{
SCESet with added cell means/.
SCESet with added cell means.
}
\description{
Simulate a gene by cell matrix giving the mean expression for each gene in
......
......@@ -103,10 +103,10 @@ information includes:
\examples{
# Simulation with default parameters
sim <- splat()
# Simulation with different number of cells
sim <- splat(nCells = 20)
# Simulation with different number of genes
sim <- splat(nGenes = 1000)
# Simulation with custom parameters
params <- splatParams(nGenes = 100, nCells = 20, mean.rate = 0.5)
params <- splatParams(nGenes = 100, mean.rate = 0.5)
sim <- splat(params)
# Simulation with adjusted custom parameters
sim <- splat(params, mean.rate = 0.6, out.prob = 0.2)
......
......@@ -135,6 +135,15 @@ test_that("setParams sets correctly", {
expect_equal(params$dropout$present, TRUE)
})
test_that("setParams sets groupCells correctly", {
params <- splatParams()
expect_error(setParams(params, nCells = 50),
"nCells cannot be set directly, set groupCells instead")
expect_error(setParams(params, nGroups = 5),
"nGroups cannot be set directly, set groupCells instead")
expect_silent(setParams(params, groupCells = c(10, 10)))
})
test_that("setParmas sets groupCells correctly", {
params <- splatParams()
expect_error(setParams(params, nCells = 100),
......
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