From 9267f271954deb646ad972a2e098c6de43d3354e Mon Sep 17 00:00:00 2001 From: Luke Zappia <lazappi@users.noreply.github.com> Date: Thu, 5 Oct 2017 12:29:53 +1100 Subject: [PATCH] Convert mfaSimulate output to counts --- R/mfa-simulate.R | 15 ++++++++++----- man/mfaSimulate.Rd | 7 ++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/R/mfa-simulate.R b/R/mfa-simulate.R index 70d171d..bca30e7 100644 --- a/R/mfa-simulate.R +++ b/R/mfa-simulate.R @@ -10,9 +10,10 @@ #' @details #' This function is just a wrapper around \code{\link[mfa]{create_synthetic}} #' that takes a \code{\link{MFAParams}}, runs the simulation then converts the -#' output to a \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. -#' See \code{\link[mfa]{create_synthetic}} and the mfa paper for more details -#' about how the simulation works. +#' output from log-expression to counts and returns a +#' \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. See +#' \code{\link[mfa]{create_synthetic}} and the mfa paper for more details about +#' how the simulation works. #' #' @return SingleCellExperiment containing simulated counts #' @@ -57,7 +58,10 @@ mfaSimulate <- function(params = newMFAParams(), verbose = TRUE, ...) { cell.names <- paste0("Cell", seq_len(nCells)) 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 colnames(counts) <- cell.names @@ -75,7 +79,8 @@ mfaSimulate <- function(params = newMFAParams(), verbose = TRUE, ...) { DeltaBranch2 = mfa.sim$delta[, 2]) rownames(features) <- gene.names - sim <- SingleCellExperiment(assays = list(counts = counts), + sim <- SingleCellExperiment(assays = list(counts = counts, + LogExprs = exprs), rowData = features, colData = cells, metadata = list(params = params)) diff --git a/man/mfaSimulate.Rd b/man/mfaSimulate.Rd index 7f7e356..ec2a98e 100644 --- a/man/mfaSimulate.Rd +++ b/man/mfaSimulate.Rd @@ -23,9 +23,10 @@ Simulate a bifurcating pseudotime path using the mfa method. \details{ This function is just a wrapper around \code{\link[mfa]{create_synthetic}} that takes a \code{\link{MFAParams}}, runs the simulation then converts the -output to a \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. -See \code{\link[mfa]{create_synthetic}} and the mfa paper for more details -about how the simulation works. +output from log-expression to counts and returns a +\code{\link[SingleCellExperiment]{SingleCellExperiment}} object. See +\code{\link[mfa]{create_synthetic}} and the mfa paper for more details about +how the simulation works. } \examples{ sim <- mfaSimulate() -- GitLab