From 8b98f4acb5258df432119a50a9ed7dec564759a5 Mon Sep 17 00:00:00 2001
From: Luke Zappia <luke.zappia@mcri.edu.au>
Date: Sun, 16 Jul 2017 06:30:22 +0000
Subject: [PATCH] Merge branch 'master' into devel

* master:
  Bump version number
  Run checks
  Patch fix to lun2Estimate from basics branch
  Update summariseDiff
  Add counts check to scDDEstimate
  Adjust nEE/nEP estimation
  Update scDD estimation

From: Luke Zappia <lazappi@users.noreply.github.com>

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/splatter@131258 bc3139a8-67e5-0310-9ffc-ced21a209358
---
 DESCRIPTION            |  11 ++--
 NEWS.md                |   7 +++
 R/AllClasses.R         |  18 +++---
 R/SCDDParams-methods.R |  12 ++--
 R/compare.R            | 129 ++++++++++++++++++++++++++++++++++++-----
 R/lun2-estimate.R      |  12 +++-
 R/scDD-estimate.R      |  52 ++++++++++++++---
 man/SCDDParams.Rd      |  18 +++---
 man/scDDEstimate.Rd    |  22 +++++--
 man/summariseDiff.Rd   |  11 ++--
 10 files changed, 225 insertions(+), 67 deletions(-)

diff --git a/DESCRIPTION b/DESCRIPTION
index f715be4..594612b 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
 Package: splatter
 Type: Package
 Title: Simple Simulation of Single-cell RNA Sequencing Data
-Version: 1.1.1
-Date: 2017-07-07
+Version: 1.1.2
+Date: 2017-07-16
 Author: Luke Zappia
 Authors@R:
     c(person("Luke", "Zappia", role = c("aut", "cre"),
@@ -35,7 +35,8 @@ Imports:
     matrixStats,
     ggplot2,
     scales,
-    BiocParallel
+    BiocParallel,
+    SummarizedExperiment
 Suggests:
     testthat,
     scran,
@@ -48,8 +49,8 @@ Suggests:
     BiocStyle,
     covr,
     S4Vectors,
-    SummarizedExperiment,
-    cowplot
+    cowplot,
+    limSolve
 biocViews: SingleCell, RNASeq, Transcriptomics, GeneExpression, Sequencing,
     Software
 URL: https://github.com/Oshlack/splatter
diff --git a/NEWS.md b/NEWS.md
index 7cb1f83..3ced178 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,10 @@
+# 1.1.2
+
+* Update summariseDiff
+* Update scDDEstimate, now estimates gene types
+* Fix error in lun2Estimate
+* Import SummarizedExperiment to avoid warnings
+
 # 1.1.1
 
 * Add batch effects to Splat simulation
diff --git a/R/AllClasses.R b/R/AllClasses.R
index 3b37656..59432fe 100644
--- a/R/AllClasses.R
+++ b/R/AllClasses.R
@@ -405,24 +405,24 @@ setClass("Lun2Params",
 #' The SCDD simulation uses the following parameters:
 #'
 #' \describe{
-#'     \item{\code{[nGenes]}}{The number of genes to simulate (not used).}
+#'     \item{\code{nGenes}}{The number of genes to simulate (not used).}
 #'     \item{\code{nCells}}{The number of cells to simulate in each condition.}
 #'     \item{\code{[seed]}}{Seed to use for generating random numbers.}
 #'     \item{\code{SCdat}}{
 #'     \code{\link[SummarizedExperiment]{SummarizedExperiment}} containing real
 #'     data.}
-#'     \item{\code{[nDE]}}{Number of DE genes to simulate.}
-#'     \item{\code{[nDP]}}{Number of DP genes to simulate.}
-#'     \item{\code{[nDM]}}{Number of DM genes to simulate.}
-#'     \item{\code{[nDB]}}{Number of DB genes to simulate.}
-#'     \item{\code{[nEE]}}{Number of EE genes to simulate.}
-#'     \item{\code{[nEP]}}{Number of EP genes to simulate.}
+#'     \item{\code{nDE}}{Number of DE genes to simulate.}
+#'     \item{\code{nDP}}{Number of DP genes to simulate.}
+#'     \item{\code{nDM}}{Number of DM genes to simulate.}
+#'     \item{\code{nDB}}{Number of DB genes to simulate.}
+#'     \item{\code{nEE}}{Number of EE genes to simulate.}
+#'     \item{\code{nEP}}{Number of EP genes to simulate.}
 #'     \item{\code{[sd.range]}}{Interval for fold change standard deviations.}
 #'     \item{\code{[modeFC]}}{Values for DP, DM and DB mode fold changes.}
 #'     \item{\code{[varInflation]}}{Variance inflation factors for each
-#'     condition. If all equal to 1 will be set to \code{NULL} (default)}
+#'     condition. If all equal to 1 will be set to \code{NULL} (default).}
 #'     \item{\code{[condition]}}{String giving the column that represents
-#'     biological group of interest}
+#'     biological group of interest.}
 #' }
 #'
 #' The parameters not shown in brackets can be estimated from real data using
diff --git a/R/SCDDParams-methods.R b/R/SCDDParams-methods.R
index 97c839d..09aa786 100644
--- a/R/SCDDParams-methods.R
+++ b/R/SCDDParams-methods.R
@@ -86,12 +86,12 @@ setMethod("setParam", "SCDDParams", function(object, name, value) {
 
 setMethod("show", "SCDDParams", function(object) {
 
-    pp <- list("Genes:"       = c("[nDE]"       = "nDE",
-                                  "[nDP]"       = "nDP",
-                                  "[nDM]"       = "nDM",
-                                  "[nDP]"       = "nDP",
-                                  "[nEE]"       = "nEE",
-                                  "[nEP]"       = "nEP"),
+    pp <- list("Genes:"       = c("(nDE)"       = "nDE",
+                                  "(nDP)"       = "nDP",
+                                  "(nDM)"       = "nDM",
+                                  "(nDP)"       = "nDP",
+                                  "(nEE)"       = "nEE",
+                                  "(nEP)"       = "nEP"),
                "Fold change:" = c("[SD Range]"  = "sd.range",
                                   "[Mode FC]"   = "modeFC"),
                "Variance:"    = c("[Inflation]" = "varInflation"),
diff --git a/R/compare.R b/R/compare.R
index f70c76b..ffee65d 100644
--- a/R/compare.R
+++ b/R/compare.R
@@ -790,20 +790,19 @@ makeOverallPanel <- function(comp, diff, title = "Overall comparison",
 
 #' Summarise diffSCESets
 #'
-#' Summarise the results of \code{\link{diffSCESets}}. The various
-#' properties are sorted, differences calculated, the Median Absolute Deviation
-#' taken as the summary statistic and the ranks calculated.
+#' Summarise the results of \code{\link{diffSCESets}}. Calculates the Median
+#' Absolute Deviation (MAD), Mean Absolute Error (MAE) and Root Mean Squared
+#' Error (RMSE) for the various properties and ranks them.
 #'
 #' @param diff Output from \code{\link{diffSCESets}}
 #'
-#' @return List with MADs, ranks and both combined in long format
+#' @return data.frame with MADs, MAEs, RMSEs, scaled statistics and ranks
 #' @examples
 #' sim1 <- splatSimulate(nGenes = 1000, batchCells = 20)
 #' sim2 <- simpleSimulate(nGenes = 1000, nCells = 20)
 #' difference <- diffSCESets(list(Splat = sim1, Simple = sim2), ref = "Simple")
 #' summary <- summariseDiff(difference)
-#' names(summary)
-#' head(summary$Long)
+#' head(summary)
 #' @export
 summariseDiff <- function(diff) {
 
@@ -819,6 +818,7 @@ summariseDiff <- function(diff) {
         return(c(Mean = mean, Variance = var, ZerosGene = zeros,
                  MeanVar = mean.var, MeanZeros = mean.zeros))
     })
+    fData.mads.z <- t(scale(t(fData.mads)))
 
     pData.mads <- sapply(datasets, function(dataset) {
         df <- diff$PhenoData[diff$PhenoData$Dataset == dataset, ]
@@ -826,27 +826,124 @@ summariseDiff <- function(diff) {
         zeros <- median(abs(df$RankDiffZeros))
         return(c(LibSize = lib.size, ZerosCell = zeros))
     })
+    pData.mads.z <- t(scale(t(pData.mads)))
 
     mads <- data.frame(Dataset = datasets, t(fData.mads), t(pData.mads))
+    mads.z <- data.frame(Dataset = datasets, t(fData.mads.z), t(pData.mads.z))
 
     fData.ranks <- matrixStats::rowRanks(fData.mads)
     pData.ranks <- matrixStats::rowRanks(pData.mads)
 
-    ranks <- data.frame(Dataset = datasets, t(fData.ranks), t(pData.ranks))
-    colnames(ranks) <- paste0(colnames(mads), "Rank")
+    ranks.mads <- data.frame(Dataset = datasets, t(fData.ranks), t(pData.ranks))
+    colnames(ranks.mads) <- paste0(colnames(mads), "Rank")
 
-    mads.long <- stats::reshape(mads, varying = 2:8, direction = "long",
-                                idvar = "Dataset", timevar = "Statistic",
-                                times = colnames(mads)[2:8], v.names = "MAD")
+    fData.maes <- sapply(datasets, function(dataset) {
+        df <- diff$FeatureData[diff$FeatureData$Dataset == dataset, ]
+        mean <- mean(abs(df$RankDiffMeanLogCPM))
+        var <- mean(abs(df$RankDiffVarLogCPM))
+        zeros <- mean(abs(df$RankDiffZeros))
+        mean.var <- mean(abs(df$MeanRankVarDiff))
+        mean.zeros <- mean(abs(df$MeanRankZerosDiff))
+        return(c(Mean = mean, Variance = var, ZerosGene = zeros,
+                 MeanVar = mean.var, MeanZeros = mean.zeros))
+    })
+    fData.maes.z <- t(scale(t(fData.maes)))
+
+    pData.maes <- sapply(datasets, function(dataset) {
+        df <- diff$PhenoData[diff$PhenoData$Dataset == dataset, ]
+        lib.size <- mean(abs(df$RankDiffLibSize))
+        zeros <- mean(abs(df$RankDiffZeros))
+        return(c(LibSize = lib.size, ZerosCell = zeros))
+    })
+    pData.maes.z <- t(scale(t(pData.maes)))
+
+    maes <- data.frame(Dataset = datasets, t(fData.maes), t(pData.maes))
+    maes.z <- data.frame(Dataset = datasets, t(fData.maes.z), t(pData.maes.z))
+
+    fData.ranks <- matrixStats::rowRanks(fData.maes)
+    pData.ranks <- matrixStats::rowRanks(pData.maes)
+
+    ranks.maes <- data.frame(Dataset = datasets, t(fData.ranks), t(pData.ranks))
+    colnames(ranks.maes) <- paste0(colnames(mads), "Rank")
+
+    fData.rmse <- sapply(datasets, function(dataset) {
+        df <- diff$FeatureData[diff$FeatureData$Dataset == dataset, ]
+        mean <- sqrt(mean(df$RankDiffMeanLogCPM ^ 2))
+        var <- sqrt(mean(df$RankDiffVarLogCPM ^ 2))
+        zeros <- sqrt(mean(df$RankDiffZeros ^ 2))
+        mean.var <- sqrt(mean(df$MeanRankVarDiff ^ 2))
+        mean.zeros <- sqrt(mean(df$MeanRankZerosDiff ^ 2))
+        return(c(Mean = mean, Variance = var, ZerosGene = zeros,
+                 MeanVar = mean.var, MeanZeros = mean.zeros))
+    })
+    fData.rmse.z <- t(scale(t(fData.rmse)))
 
-    ranks.long <- stats::reshape(ranks, varying = 2:8, direction = "long",
+    pData.rmse <- sapply(datasets, function(dataset) {
+        df <- diff$PhenoData[diff$PhenoData$Dataset == dataset, ]
+        lib.size <- sqrt(mean(df$RankDiffLibSize ^ 2))
+        zeros <- sqrt(mean(df$RankDiffZeros ^ 2))
+        return(c(LibSize = lib.size, ZerosCell = zeros))
+    })
+    pData.rmse.z <- t(scale(t(pData.rmse)))
+
+    rmse <- data.frame(Dataset = datasets, t(fData.rmse), t(pData.rmse))
+    rmse.z <- data.frame(Dataset = datasets, t(fData.rmse.z), t(pData.rmse.z))
+
+    fData.ranks <- matrixStats::rowRanks(fData.rmse)
+    pData.ranks <- matrixStats::rowRanks(pData.rmse)
+
+    ranks.rmse <- data.frame(Dataset = datasets, t(fData.ranks), t(pData.ranks))
+    colnames(ranks.rmse) <- paste0(colnames(rmse), "Rank")
+
+    mads <- stats::reshape(mads, varying = 2:8, direction = "long",
+                           idvar = "Dataset", timevar = "Statistic",
+                           times = colnames(mads)[2:8], v.names = "MAD")
+
+    mads.z <- stats::reshape(mads.z, varying = 2:8, direction = "long",
+                             idvar = "Dataset", timevar = "Statistic",
+                             times = colnames(mads)[2:8],
+                             v.names = "MADScaled")
+
+    ranks.mads <- stats::reshape(ranks.mads, varying = 2:8, direction = "long",
                                  idvar = "Dataset", timevar = "Statistic",
-                                 times = colnames(ranks)[2:8], v.names = "Rank")
+                                 times = colnames(ranks.mads)[2:8],
+                                 v.names = "Rank")
+
+    maes <- stats::reshape(maes, varying = 2:8, direction = "long",
+                           idvar = "Dataset", timevar = "Statistic",
+                           times = colnames(maes)[2:8], v.names = "MAE")
 
-    long <- data.frame(mads.long, Rank = ranks.long$Rank)
-    row.names(long) <- NULL
+    maes.z <- stats::reshape(maes.z, varying = 2:8, direction = "long",
+                             idvar = "Dataset", timevar = "Statistic",
+                             times = colnames(mads)[2:8],
+                             v.names = "MAEScaled")
+
+    ranks.maes <- stats::reshape(ranks.maes, varying = 2:8, direction = "long",
+                                 idvar = "Dataset", timevar = "Statistic",
+                                 times = colnames(ranks.maes)[2:8],
+                                 v.names = "Rank")
 
-    summary <- list(MADs = mads, Ranks = ranks, Long = long)
+    rmse <- stats::reshape(rmse, varying = 2:8, direction = "long",
+                           idvar = "Dataset", timevar = "Statistic",
+                           times = colnames(mads)[2:8], v.names = "RMSE")
+
+    rmse.z <- stats::reshape(rmse.z, varying = 2:8, direction = "long",
+                             idvar = "Dataset", timevar = "Statistic",
+                             times = colnames(mads)[2:8],
+                             v.names = "RMSEScaled")
+
+    ranks.rmse <- stats::reshape(ranks.rmse, varying = 2:8, direction = "long",
+                                 idvar = "Dataset", timevar = "Statistic",
+                                 times = colnames(ranks.rmse)[2:8],
+                                 v.names = "Rank")
+
+    summary <- data.frame(mads, MADScaled = mads.z$MADScaled,
+                          MADRank = ranks.mads$Rank,
+                          MAE = maes$MAE, MAEScaled = maes.z$MAEScaled,
+                          MAERank = ranks.maes$Rank,
+                          RMSE = rmse$RMSE, RMSEScaled = rmse.z$RMSEScaled,
+                          RMSERank = ranks.rmse$Rank)
+    row.names(summary) <- NULL
 
     return(summary)
 }
diff --git a/R/lun2-estimate.R b/R/lun2-estimate.R
index ffd4155..cca9f6e 100644
--- a/R/lun2-estimate.R
+++ b/R/lun2-estimate.R
@@ -64,6 +64,11 @@ lun2Estimate.matrix <- function(counts, plates, params = newLun2Params(),
         stop("The Lun2 simulation requires the 'pscl' package for estimation.")
     }
 
+    if (!requireNamespace("limSolve", quietly = TRUE)) {
+        stop("The Lun2 simulation requires the 'limSolve' package for ",
+             "estimation.")
+    }
+
     progress <- FALSE
     if (requireNamespace("progress", quietly = TRUE)) {
         progress <- TRUE
@@ -97,7 +102,12 @@ lun2Estimate.matrix <- function(counts, plates, params = newLun2Params(),
         sizes <- seq(20, 100, 20)
     }
     sum.facs <- scran::computeSumFactors(dge$counts, cluster = groups,
-                                         sizes = sizes)
+                                         sizes = sizes, positive = TRUE)
+    if (any(sum.facs == 0)) {
+        warning("Some sum factors are zero. See ?scran::computeSumFactors ",
+                "for details.")
+        sum.facs <- sum.facs + 1e-6
+    }
     dge$samples$norm.factors <- sum.facs / dge$samples$lib.size
     # Mean centre normalisation factors
     dge$samples$norm.factors <- dge$samples$norm.factors /
diff --git a/R/scDD-estimate.R b/R/scDD-estimate.R
index 8f9a5c2..542d3af 100644
--- a/R/scDD-estimate.R
+++ b/R/scDD-estimate.R
@@ -7,27 +7,36 @@
 #' @param conditions Vector giving the condition that each cell belongs to.
 #'        Conditions can be 1 or 2.
 #' @param params SCDDParams object to store estimated values in.
+#' @param BPPARAM A \code{\link[BiocParallel]{BiocParallelParam}} instance
+#'        giving the parallel back-end to be used. Default is
+#'        \code{\link[BiocParallel]{SerialParam}} which uses a single core.
 #'
 #' @details
-#' This function is just a wrapper around \code{\link[scDD]{preprocess}} that
-#' takes the output and converts it to a SCDDParams object. See
-#' \code{\link[scDD]{preprocess}} for details.
+#' This function applies \code{\link[scDD]{preprocess}} to the counts then uses
+#' \code{\link[scDD]{scDD}} to estimate the numbers of each gene type to
+#' simulate. The output is then converted to a SCDDParams object. See
+#' \code{\link[scDD]{preprocess}} and \code{\link[scDD]{scDD}} for details.
 #'
 #' @return SCDDParams object containing the estimated parameters.
 #'
 #' @examples
+#' \dontrun{
 #' data("sc_example_counts")
 #' conditions <- sample(1:2, ncol(sc_example_counts), replace = TRUE)
 #' params <- scDDEstimate(sc_example_counts, conditions)
 #' params
+#' }
+#' @importFrom BiocParallel SerialParam
 #' @export
-scDDEstimate <- function(counts, conditions, params = newSCDDParams()) {
+scDDEstimate <- function(counts, conditions, params = newSCDDParams(),
+                         BPPARAM = SerialParam()) {
     UseMethod("scDDEstimate")
 }
 
 #' @rdname scDDEstimate
 #' @export
-scDDEstimate.SCESet <- function(counts, conditions, params = newSCDDParams()) {
+scDDEstimate.SCESet <- function(counts, conditions, params = newSCDDParams(),
+                                BPPARAM = SerialParam()) {
     counts <- scater::counts(counts)
     scDDEstimate(counts, conditions, params)
 }
@@ -35,13 +44,17 @@ scDDEstimate.SCESet <- function(counts, conditions, params = newSCDDParams()) {
 #' @rdname scDDEstimate
 #' @importFrom methods as
 #' @export
-scDDEstimate.matrix <- function(counts, conditions, params = newSCDDParams()) {
+scDDEstimate.matrix <- function(counts, conditions, params = newSCDDParams(),
+                                BPPARAM = SerialParam()) {
 
     if (!requireNamespace("scDD", quietly = TRUE)) {
         stop("The scDD simulation requires the 'scDD' package.")
     }
 
     checkmate::assertClass(params, "SCDDParams")
+    checkmate::assertMatrix(counts, mode = "numeric", any.missing = FALSE,
+                            min.rows = 1, min.cols = 1, row.names = "unique",
+                            col.names = "unique")
     checkmate::assertIntegerish(conditions, len = ncol(counts), lower = 1,
                                 upper = 2)
 
@@ -59,8 +72,29 @@ scDDEstimate.matrix <- function(counts, conditions, params = newSCDDParams()) {
     SCdat <- SummarizedExperiment::SummarizedExperiment(assays = assays,
                                                         colData = colData)
 
-    params <- setParams(params, nCells = round(dim(SCdat)[2] / 2),
-                        SCdat = SCdat)
+    SCdat <- scDD::scDD(SCdat, testZeroes = FALSE, param = BPPARAM)
+
+    res <- scDD::results(SCdat)
+    res <- res[!is.na(res$DDcategory), ]
+    dd.cats <- table(res$DDcategory)
+
+    not.dd <- res$DDcategory == "NS"
+    nDE <- ifelse("DE" %in% names(dd.cats), dd.cats["DE"], 0)
+    nDP <- ifelse("DP" %in% names(dd.cats), dd.cats["DP"], 0)
+    nDM <- ifelse("DM" %in% names(dd.cats), dd.cats["DM"], 0)
+    nDB <- ifelse("DB" %in% names(dd.cats), dd.cats["DB"], 0)
+    nEP <- sum(res$Clusters.c1[not.dd] > 1 & res$Clusters.c2[not.dd] > 1)
+    nEE <- nrow(counts) - nDE - nDP - nDM - nDB - nEP
+
+    params <- setParams(params,
+                        nCells = round(dim(SCdat)[2] / 2),
+                        SCdat = SCdat,
+                        nDE = nDE,
+                        nDP = nDP,
+                        nDM = nDM,
+                        nDB = nDB,
+                        nEE = nEE,
+                        nEP = nEP)
 
     return(params)
-}
\ No newline at end of file
+}
diff --git a/man/SCDDParams.Rd b/man/SCDDParams.Rd
index 8e3b2ea..aef9df9 100644
--- a/man/SCDDParams.Rd
+++ b/man/SCDDParams.Rd
@@ -14,24 +14,24 @@ S4 class that holds parameters for the scDD simulation.
 The SCDD simulation uses the following parameters:
 
 \describe{
-    \item{\code{[nGenes]}}{The number of genes to simulate (not used).}
+    \item{\code{nGenes}}{The number of genes to simulate (not used).}
     \item{\code{nCells}}{The number of cells to simulate in each condition.}
     \item{\code{[seed]}}{Seed to use for generating random numbers.}
     \item{\code{SCdat}}{
     \code{\link[SummarizedExperiment]{SummarizedExperiment}} containing real
     data.}
-    \item{\code{[nDE]}}{Number of DE genes to simulate.}
-    \item{\code{[nDP]}}{Number of DP genes to simulate.}
-    \item{\code{[nDM]}}{Number of DM genes to simulate.}
-    \item{\code{[nDB]}}{Number of DB genes to simulate.}
-    \item{\code{[nEE]}}{Number of EE genes to simulate.}
-    \item{\code{[nEP]}}{Number of EP genes to simulate.}
+    \item{\code{nDE}}{Number of DE genes to simulate.}
+    \item{\code{nDP}}{Number of DP genes to simulate.}
+    \item{\code{nDM}}{Number of DM genes to simulate.}
+    \item{\code{nDB}}{Number of DB genes to simulate.}
+    \item{\code{nEE}}{Number of EE genes to simulate.}
+    \item{\code{nEP}}{Number of EP genes to simulate.}
     \item{\code{[sd.range]}}{Interval for fold change standard deviations.}
     \item{\code{[modeFC]}}{Values for DP, DM and DB mode fold changes.}
     \item{\code{[varInflation]}}{Variance inflation factors for each
-    condition. If all equal to 1 will be set to \code{NULL} (default)}
+    condition. If all equal to 1 will be set to \code{NULL} (default).}
     \item{\code{[condition]}}{String giving the column that represents
-    biological group of interest}
+    biological group of interest.}
 }
 
 The parameters not shown in brackets can be estimated from real data using
diff --git a/man/scDDEstimate.Rd b/man/scDDEstimate.Rd
index c0e3094..259a698 100644
--- a/man/scDDEstimate.Rd
+++ b/man/scDDEstimate.Rd
@@ -6,11 +6,14 @@
 \alias{scDDEstimate.matrix}
 \title{Estimate scDD simulation parameters}
 \usage{
-scDDEstimate(counts, conditions, params = newSCDDParams())
+scDDEstimate(counts, conditions, params = newSCDDParams(),
+  BPPARAM = SerialParam())
 
-\method{scDDEstimate}{SCESet}(counts, conditions, params = newSCDDParams())
+\method{scDDEstimate}{SCESet}(counts, conditions, params = newSCDDParams(),
+  BPPARAM = SerialParam())
 
-\method{scDDEstimate}{matrix}(counts, conditions, params = newSCDDParams())
+\method{scDDEstimate}{matrix}(counts, conditions, params = newSCDDParams(),
+  BPPARAM = SerialParam())
 }
 \arguments{
 \item{counts}{either a counts matrix or an SCESet object containing count
@@ -20,6 +23,10 @@ data to estimate parameters from.}
 Conditions can be 1 or 2.}
 
 \item{params}{SCDDParams object to store estimated values in.}
+
+\item{BPPARAM}{A \code{\link[BiocParallel]{BiocParallelParam}} instance
+giving the parallel back-end to be used. Default is
+\code{\link[BiocParallel]{SerialParam}} which uses a single core.}
 }
 \value{
 SCDDParams object containing the estimated parameters.
@@ -28,13 +35,16 @@ SCDDParams object containing the estimated parameters.
 Estimate simulation parameters for the scDD simulation from a real dataset.
 }
 \details{
-This function is just a wrapper around \code{\link[scDD]{preprocess}} that
-takes the output and converts it to a SCDDParams object. See
-\code{\link[scDD]{preprocess}} for details.
+This function applies \code{\link[scDD]{preprocess}} to the counts then uses
+\code{\link[scDD]{scDD}} to estimate the numbers of each gene type to
+simulate. The output is then converted to a SCDDParams object. See
+\code{\link[scDD]{preprocess}} and \code{\link[scDD]{scDD}} for details.
 }
 \examples{
+\dontrun{
 data("sc_example_counts")
 conditions <- sample(1:2, ncol(sc_example_counts), replace = TRUE)
 params <- scDDEstimate(sc_example_counts, conditions)
 params
 }
+}
diff --git a/man/summariseDiff.Rd b/man/summariseDiff.Rd
index 3131547..cd6cb62 100644
--- a/man/summariseDiff.Rd
+++ b/man/summariseDiff.Rd
@@ -10,18 +10,17 @@ summariseDiff(diff)
 \item{diff}{Output from \code{\link{diffSCESets}}}
 }
 \value{
-List with MADs, ranks and both combined in long format
+data.frame with MADs, MAEs, RMSEs, scaled statistics and ranks
 }
 \description{
-Summarise the results of \code{\link{diffSCESets}}. The various
-properties are sorted, differences calculated, the Median Absolute Deviation
-taken as the summary statistic and the ranks calculated.
+Summarise the results of \code{\link{diffSCESets}}. Calculates the Median
+Absolute Deviation (MAD), Mean Absolute Error (MAE) and Root Mean Squared
+Error (RMSE) for the various properties and ranks them.
 }
 \examples{
 sim1 <- splatSimulate(nGenes = 1000, batchCells = 20)
 sim2 <- simpleSimulate(nGenes = 1000, nCells = 20)
 difference <- diffSCESets(list(Splat = sim1, Simple = sim2), ref = "Simple")
 summary <- summariseDiff(difference)
-names(summary)
-head(summary$Long)
+head(summary)
 }
-- 
GitLab