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

Add simSimple function

parent 888cbf78
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.4.0
Version: 0.4.1
Date: 2016-10-12
Author: Luke Zappia
Authors@R: as.person(c(
......
......@@ -9,6 +9,7 @@ export(estimateParams)
export(getParams)
export(mergeParams)
export(setParams)
export(simSimple)
export(splat)
export(splatGroups)
export(splatParams)
......
#' Simple simulation
#'
#' Simulate counts from a simple negative binomial distribution without
#' simulated library sizes, differential expression etc.
#'
#' @param params splatParams object containing simulation parameters.
#' @param verbose logical. Whether to print progress messages
#' @param ... any additional parameter settings to override what is provided in
#' \code{params}.
#'
#' @details
#' Uses the following parameters: \code{nCells}, \code{nGenes},
#' \code{mean.shape}, \code{mean.rate}, \code{bcv.common}.
#'
#' Gene means are simulated from a gamma distribution with
#' \code{shape = mean.shape} and \code{rate = mean.rate}. Counts are then
#' simulated from a negative binomial distribution with \code{mu = means} and
#' \code{size = 1 / bcv.common}.
#'
#' Parameters are set in the tiered manner described in \code{\link{splat}}.
#'
#' @return SCESet containing simulated counts
#' @examples
#' sim <- simSimple()
#' @export
simSimple <- function(params = defaultParams(), verbose = TRUE, ...) {
if (verbose) {message("Getting parameters...")}
params <- setParams(params, ...)
params <- mergeParams(params, defaultParams())
params <- expandParams(params)
# Set random seed
seed <- getParams(params, "seed")
set.seed(seed)
# Get the parameters we are going to use
nCells <- getParams(params, "nCells")
nGenes <- getParams(params, "nGenes")
mean.shape <- getParams(params, "mean.shape")
mean.rate <- getParams(params, "mean.rate")
bcv.common <- getParams(params, "bcv.common")
if (verbose) {message("Simulating means...")}
means <- rgamma(nGenes, shape = mean.shape, rate = mean.rate)
if (verbose) {message("Simulating counts...")}
counts <- matrix(rnbinom(nGenes * nCells, mu = means,
size = 1 / bcv.common),
nrow = nGenes, ncol = nCells)
if (verbose) {message("Creating final SCESet...")}
cell.names <- paste0("Cell", 1:nCells)
gene.names <- paste0("Gene", 1:nGenes)
rownames(counts) <- gene.names
colnames(counts) <- cell.names
phenos <- new("AnnotatedDataFrame", data = data.frame(Cell = cell.names))
rownames(phenos) <- cell.names
features <- new("AnnotatedDataFrame",
data = data.frame(Gene = gene.names, GeneMean = means))
rownames(features) <- gene.names
sim <- newSCESet(countData = counts, phenoData = phenos,
featureData = features)
return(sim)
}
\ No newline at end of file
File moved
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{bridge}
\alias{bridge}
\title{Brownian bridge}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{getLNormFactors}
\alias{getLNormFactors}
\title{Get log-normal factors}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{getPathOrder}
\alias{getPathOrder}
\title{Get path order}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simBCVMeans}
\alias{simBCVMeans}
\title{Simulate BCV means}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simDropout}
\alias{simDropout}
\title{Simulate dropout}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simGeneMeans}
\alias{simGeneMeans}
\title{Simulate gene means}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simGroupCellMeans}
\alias{simGroupCellMeans}
\title{Simulate group cell means}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simGroupDE}
\alias{simGroupDE}
\title{Simulate group differential expression}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simLibSizes}
\alias{simLibSizes}
\title{Simulate library sizes}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simPathCellMeans}
\alias{simPathCellMeans}
\title{Simulate path cell means}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simPathDE}
\alias{simPathDE}
\title{Simulate path differential expression}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate-simple.R
\name{simSimple}
\alias{simSimple}
\title{Simple simulation}
\usage{
simSimple(params = defaultParams(), verbose = TRUE, ...)
}
\arguments{
\item{params}{splatParams object containing simulation parameters.}
\item{verbose}{logical. Whether to print progress messages}
\item{...}{any additional parameter settings to override what is provided in
\code{params}.}
}
\value{
SCESet containing simulated counts
}
\description{
Simulate counts from a simple negative binomial distribution without
simulated library sizes, differential expression etc.
}
\details{
Uses the following parameters: \code{nCells}, \code{nGenes},
\code{mean.shape}, \code{mean.rate}, \code{bcv.common}.
Gene means are simulated from a gamma distribution with
\code{shape = mean.shape} and \code{rate = mean.rate}. Counts are then
simulated from a negative binomial distribution with \code{mu = means} and
\code{size = 1 / bcv.common}.
Parameters are set in the tiered manner described in \code{\link{splat}}.
}
\examples{
sim <- simSimple()
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simSingleCellMeans}
\alias{simSingleCellMeans}
\title{Simulate single population cell means}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{simTrueCounts}
\alias{simTrueCounts}
\title{Simulate true counts}
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simulate.R
% Please edit documentation in R/simulate-splat.R
\name{splat}
\alias{splat}
\alias{splatGroups}
......
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