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

Fix lun2Estimate error

Error when scran::computeSumFactors returns negative values
parent 5a6da139
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,8 @@ Suggests:
covr,
S4Vectors,
SummarizedExperiment,
cowplot
cowplot,
limSolve
biocViews: SingleCell, RNASeq, Transcriptomics, GeneExpression, Sequencing,
Software
URL: https://github.com/Oshlack/splatter
......
......@@ -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,11 @@ 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")
}
dge$samples$norm.factors <- sum.facs / dge$samples$lib.size
# Mean centre normalisation factors
dge$samples$norm.factors <- dge$samples$norm.factors /
......
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