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

Add simBCVMeans function

parent dec1705b
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.6
Version: 0.3.7
Date: 2016-10-10
Author: Luke Zappia
Authors@R: as.person(c(
......
......@@ -73,6 +73,7 @@ splat <- function(params = defaultParams(), method = c("groups", "paths"),
sim <- simGeneMeans(sim, params)
sim <- simDE(sim, params)
sim <- simGroupCellMeans(sim, params)
sim <- simBCVMeans(sim, params)
# Create new SCESet to make sure values are calculated correctly
sce <- newSCESet(countData = counts(sim),
......@@ -167,6 +168,34 @@ simGroupCellMeans <- function(sim, params) {
return(sim)
}
simBCVMeans <- function(sim, params) {
n.genes <- getParams(params, "nGenes")
n.cells <- getParams(params, "nCells")
bcv.common <- getParams(params, "bcv.common")
bcv.DF <- getParams(params, "bcv.DF")
cell.names <- pData(sim)$Cell
gene.names <- fData(sim)$Gene
base.means.cell <- assayData(sim)$BaseCellMeans
bcv <- (bcv.common + (1 / sqrt(base.means.cell))) *
sqrt(bcv.DF / rchisq(n.genes, df = bcv.DF))
means.cell <- matrix(rgamma(n.genes * n.cells, shape = 1 / (bcv ^ 2),
scale = base.means.cell * (bcv ^ 2)),
nrow = n.genes, ncol = n.cells)
colnames(bcv) <- cell.names
rownames(bcv) <- gene.names
colnames(means.cell) <- cell.names
rownames(means.cell) <- gene.names
assayData(sim)$BCV <- bcv
assayData(sim)$CellMeans <- means.cell
return(sim)
}
#' Get log-normal factors
#'
#' Randomly generate multiplication factors from a log-normal distribution.
......
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