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

Convert mfaSimulate output to counts

parent eafecf42
No related branches found
No related tags found
No related merge requests found
...@@ -10,9 +10,10 @@ ...@@ -10,9 +10,10 @@
#' @details #' @details
#' This function is just a wrapper around \code{\link[mfa]{create_synthetic}} #' This function is just a wrapper around \code{\link[mfa]{create_synthetic}}
#' that takes a \code{\link{MFAParams}}, runs the simulation then converts the #' that takes a \code{\link{MFAParams}}, runs the simulation then converts the
#' output to a \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. #' output from log-expression to counts and returns a
#' See \code{\link[mfa]{create_synthetic}} and the mfa paper for more details #' \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. See
#' about how the simulation works. #' \code{\link[mfa]{create_synthetic}} and the mfa paper for more details about
#' how the simulation works.
#' #'
#' @return SingleCellExperiment containing simulated counts #' @return SingleCellExperiment containing simulated counts
#' #'
...@@ -57,7 +58,10 @@ mfaSimulate <- function(params = newMFAParams(), verbose = TRUE, ...) { ...@@ -57,7 +58,10 @@ mfaSimulate <- function(params = newMFAParams(), verbose = TRUE, ...) {
cell.names <- paste0("Cell", seq_len(nCells)) cell.names <- paste0("Cell", seq_len(nCells))
gene.names <- paste0("Gene", seq_len(nGenes)) gene.names <- paste0("Gene", seq_len(nGenes))
counts <- t(mfa.sim$X) exprs <- t(mfa.sim$X)
counts <- 2 ^ exprs - 1
counts[counts < 0] <- 0
counts <- round(counts)
rownames(counts) <- gene.names rownames(counts) <- gene.names
colnames(counts) <- cell.names colnames(counts) <- cell.names
...@@ -75,7 +79,8 @@ mfaSimulate <- function(params = newMFAParams(), verbose = TRUE, ...) { ...@@ -75,7 +79,8 @@ mfaSimulate <- function(params = newMFAParams(), verbose = TRUE, ...) {
DeltaBranch2 = mfa.sim$delta[, 2]) DeltaBranch2 = mfa.sim$delta[, 2])
rownames(features) <- gene.names rownames(features) <- gene.names
sim <- SingleCellExperiment(assays = list(counts = counts), sim <- SingleCellExperiment(assays = list(counts = counts,
LogExprs = exprs),
rowData = features, rowData = features,
colData = cells, colData = cells,
metadata = list(params = params)) metadata = list(params = params))
......
...@@ -23,9 +23,10 @@ Simulate a bifurcating pseudotime path using the mfa method. ...@@ -23,9 +23,10 @@ Simulate a bifurcating pseudotime path using the mfa method.
\details{ \details{
This function is just a wrapper around \code{\link[mfa]{create_synthetic}} This function is just a wrapper around \code{\link[mfa]{create_synthetic}}
that takes a \code{\link{MFAParams}}, runs the simulation then converts the that takes a \code{\link{MFAParams}}, runs the simulation then converts the
output to a \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. output from log-expression to counts and returns a
See \code{\link[mfa]{create_synthetic}} and the mfa paper for more details \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. See
about how the simulation works. \code{\link[mfa]{create_synthetic}} and the mfa paper for more details about
how the simulation works.
} }
\examples{ \examples{
sim <- mfaSimulate() sim <- mfaSimulate()
......
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