From a681f8648161f158b043b0a25a602651c23d0b1a Mon Sep 17 00:00:00 2001 From: Luke Zappia <lazappi@users.noreply.github.com> Date: Thu, 5 Oct 2017 12:15:50 +1100 Subject: [PATCH] Convert phenoSimulate output to counts --- R/pheno-simulate.R | 12 +++++++++--- man/phenoSimulate.Rd | 4 +++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/R/pheno-simulate.R b/R/pheno-simulate.R index 70042e4..ff0e4c1 100644 --- a/R/pheno-simulate.R +++ b/R/pheno-simulate.R @@ -11,7 +11,9 @@ #' This function is just a wrapper around #' \code{\link[phenopath]{simulate_phenopath}} that takes a #' \code{\link{PhenoParams}}, runs the simulation then converts the -#' output to a \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. +#' output from log-counts to counts and returns a +#' \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. The original +#' simulated log-expression values are returned in the \code{LogExprs} asssay. #' See \code{\link[phenopath]{simulate_phenopath}} and the PhenoPath paper for #' more details about how the simulation works. #' @@ -59,7 +61,10 @@ phenoSimulate <- function(params = newPhenoParams(), verbose = TRUE, ...) { cell.names <- paste0("Cell", seq_len(nCells)) gene.names <- paste0("Gene", seq_len(nGenes)) - counts <- t(pheno.sim$y) + exprs <- t(pheno.sim$y) + counts <- 2 ^ exprs - 1 + counts[counts < 0] <- 0 + counts <- round(counts) rownames(counts) <- gene.names colnames(counts) <- cell.names @@ -75,7 +80,8 @@ phenoSimulate <- function(params = newPhenoParams(), verbose = TRUE, ...) { Regime = pheno.sim$parameters$regime) 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/phenoSimulate.Rd b/man/phenoSimulate.Rd index 2effe20..ff60d00 100644 --- a/man/phenoSimulate.Rd +++ b/man/phenoSimulate.Rd @@ -24,7 +24,9 @@ Simulate counts from a pseudotime trajectory using the PhenoPath method. This function is just a wrapper around \code{\link[phenopath]{simulate_phenopath}} that takes a \code{\link{PhenoParams}}, runs the simulation then converts the -output to a \code{\link[SingleCellExperiment]{SingleCellExperiment}} object. +output from log-counts to counts and returns a +\code{\link[SingleCellExperiment]{SingleCellExperiment}} object. The original +simulated log-expression values are returned in the \code{LogExprs} asssay. See \code{\link[phenopath]{simulate_phenopath}} and the PhenoPath paper for more details about how the simulation works. } -- GitLab