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

Add simulateDE function

parent e0b2901c
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: 0.3.3 Version: 0.3.4
Date: 2016-10-09 Date: 2016-10-09
Author: Luke Zappia Author: Luke Zappia
Authors@R: as.person(c( Authors@R: as.person(c(
......
...@@ -70,6 +70,7 @@ splat <- function(params = defaultParams(), method = c("groups", "paths"), ...@@ -70,6 +70,7 @@ splat <- function(params = defaultParams(), method = c("groups", "paths"),
pData(sim)$Group <- group.names[groups] pData(sim)$Group <- group.names[groups]
sim <- simulateGeneMeans(sim, params) sim <- simulateGeneMeans(sim, params)
sim <- simulateDE(sim, params)
# Create new SCESet to make sure values are calculated correctly # Create new SCESet to make sure values are calculated correctly
sce <- newSCESet(countData = counts(sim), sce <- newSCESet(countData = counts(sim),
...@@ -104,6 +105,27 @@ simulateGeneMeans <- function(sim, params) { ...@@ -104,6 +105,27 @@ simulateGeneMeans <- function(sim, params) {
return(sim) return(sim)
} }
simulateDE <- function(sim, params) {
n.genes <- getParams(params, "nGenes")
de.prob <- getParams(params, "de.prob")
de.downProb <- getParams(params, "de.downProb")
de.facLoc <- getParams(params, "de.facLoc")
de.facScale <- getParams(params, "de.facScale")
means.gene <- fData(sim)$GeneMean
group.names <- unique(pData(sim)$Group)
for (group.name in group.names) {
de.facs <- getLNormFactors(n.genes, de.prob, de.downProb, de.facLoc,
de.facScale)
group.means.gene <- means.gene * de.facs
fData(sim)[[paste0("DEFac", group.name)]] <- de.facs
fData(sim)[[paste0("GeneMean", group.name)]] <- group.means.gene
}
return(sim)
}
#' Get log-normal factors #' Get log-normal factors
#' #'
#' Randomly generate multiplication factors from a log-normal distribution. #' 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