diff --git a/NAMESPACE b/NAMESPACE index b97422b694085a5fc997f3dbd4527202931578d2..e388c4739b1229bb1dd6937937beb9313068f8d5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,6 +6,8 @@ S3method(lunEstimate,SingleCellExperiment) S3method(lunEstimate,matrix) S3method(mfaEstimate,SingleCellExperiment) S3method(mfaEstimate,matrix) +S3method(phenoEstimate,SingleCellExperiment) +S3method(phenoEstimate,matrix) S3method(scDDEstimate,SingleCellExperiment) S3method(scDDEstimate,default) S3method(scDDEstimate,matrix) @@ -35,6 +37,7 @@ export(newPhenoParams) export(newSCDDParams) export(newSimpleParams) export(newSplatParams) +export(phenoEstimate) export(phenoSimulate) export(scDDEstimate) export(scDDSimulate) diff --git a/R/pheno-estimate.R b/R/pheno-estimate.R new file mode 100644 index 0000000000000000000000000000000000000000..61cf4fc4541fa47916b120a9462338c3d1fa12a9 --- /dev/null +++ b/R/pheno-estimate.R @@ -0,0 +1,49 @@ +#' Estimate PhenoPath simulation parameters +#' +#' Estimate simulation parameters for the PhenoPath simulation from a real +#' dataset. +#' +#' @param counts either a counts matrix or an SingleCellExperiment object +#' containing count data to estimate parameters from. +#' @param params PhenoParams object to store estimated values in. +#' +#' @details +#' The \code{nGenes} and \code{nCells} parameters are taken from the size of the +#' input data. The total number of genes is evenly divided into the four types. +#' See \code{\link{PhenoParams}} for more details on the parameters. +#' +#' @return PhenoParams object containing the estimated parameters. +#' +#' @examples +#' data("sc_example_counts") +#' params <- phenoEstimate(sc_example_counts) +#' params +#' @export +phenoEstimate <- function(counts, params = newPhenoParams()) { + UseMethod("phenoEstimate") +} + +#' @rdname phenoEstimate +#' @export +phenoEstimate.SingleCellExperiment <- function(counts, + params = newPhenoParams()) { + counts <- BiocGenerics::counts(counts) + phenoEstimate(counts, params) +} + +#' @rdname phenoEstimate +#' @export +phenoEstimate.matrix <- function(counts, params = newPhenoParams()) { + + checkmate::assertClass(params, "PhenoParams") + + nGenes <- nrow(counts) + quarter <- floor(nGenes / 4) + + params <- setParams(params, nCells = ncol(counts), + n.de = nGenes - 3 * quarter, + n.pst = quarter, n.pst.beta = quarter, + n.de.pst.beta = quarter) + + return(params) +} diff --git a/man/phenoEstimate.Rd b/man/phenoEstimate.Rd new file mode 100644 index 0000000000000000000000000000000000000000..5b698238acbc48c4a606cc9fd7a2c3b550936311 --- /dev/null +++ b/man/phenoEstimate.Rd @@ -0,0 +1,38 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/pheno-estimate.R +\name{phenoEstimate} +\alias{phenoEstimate} +\alias{phenoEstimate.SingleCellExperiment} +\alias{phenoEstimate.matrix} +\title{Estimate PhenoPath simulation parameters} +\usage{ +phenoEstimate(counts, params = newPhenoParams()) + +\method{phenoEstimate}{SingleCellExperiment}(counts, + params = newPhenoParams()) + +\method{phenoEstimate}{matrix}(counts, params = newPhenoParams()) +} +\arguments{ +\item{counts}{either a counts matrix or an SingleCellExperiment object +containing count data to estimate parameters from.} + +\item{params}{PhenoParams object to store estimated values in.} +} +\value{ +PhenoParams object containing the estimated parameters. +} +\description{ +Estimate simulation parameters for the PhenoPath simulation from a real +dataset. +} +\details{ +The \code{nGenes} and \code{nCells} parameters are taken from the size of the +input data. The total number of genes is evenly divided into the four types. +See \code{\link{PhenoParams}} for more details on the parameters. +} +\examples{ +data("sc_example_counts") +params <- phenoEstimate(sc_example_counts) +params +}