From 250f29b71fc7727e7422bcd05276a64a505340ff Mon Sep 17 00:00:00 2001 From: LTLA Date: Thu, 25 Apr 2019 17:38:18 -0700 Subject: [PATCH] Enforce use of TMM to bypass changes in calcNormFactors defaults. Relaxed normalization test. --- DESCRIPTION | 4 ++-- R/normFactors.R | 4 ++-- man/normOffsets.Rd | 4 +++- tests/testthat/test-norm.R | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b78c21f..3c39664 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: csaw -Version: 1.17.8 -Date: 2019-03-13 +Version: 1.17.9 +Date: 2019-04-25 Title: ChIP-Seq Analysis with Windows Authors@R: c(person("Aaron", "Lun", role=c("aut", "cre"), email = "infinite.monkeys.with.keyboards@gmail.com"), diff --git a/R/normFactors.R b/R/normFactors.R index 35410fe..05bf859 100644 --- a/R/normFactors.R +++ b/R/normFactors.R @@ -1,7 +1,7 @@ #' @export #' @importFrom edgeR calcNormFactors #' @importFrom SummarizedExperiment assay -normFactors <- function(object, weighted=FALSE, ..., assay.id="counts", se.out=TRUE) +normFactors <- function(object, method="TMM", weighted=FALSE, ..., assay.id="counts", se.out=TRUE) # This provides a wrapper to perform TMM normalization with non-standard # library sizes (e.g. due to filtering) and weighting turned off. # Alternatively, it can do a form a fast loess-like normalization which uses @@ -17,7 +17,7 @@ normFactors <- function(object, weighted=FALSE, ..., assay.id="counts", se.out=T } out <- calcNormFactors(assay(object, i=assay.id, withDimnames=FALSE), - lib.size=lib.sizes, doWeighting=weighted, ...) + lib.size=lib.sizes, doWeighting=weighted, method=method, ...) # Choosing to put these values in a different location, if requested. if (!is.logical(se.out)) { diff --git a/man/normOffsets.Rd b/man/normOffsets.Rd index c40c758..1701ca0 100644 --- a/man/normOffsets.Rd +++ b/man/normOffsets.Rd @@ -9,12 +9,14 @@ \usage{ normOffsets(object, type=NULL, ..., assay.id="counts", se.out=TRUE) -normFactors(object, weighted=FALSE, ..., assay.id="counts", se.out=TRUE) +normFactors(object, method="TMM", weighted=FALSE, ..., + assay.id="counts", se.out=TRUE) } \arguments{ \item{object}{A SummarizedExperiment object containing a count matrix.} \item{type}{Deprecated; a character string indicating what type of normalization is to be performed.} + \item{method}{String specifying the type of scaling normalization method to use.} \item{weighted}{A logical scalar indicating whether precision weights should be used for TMM normalization.} \item{...}{Other arguments to be passed to \code{\link{calcNormFactors}} for \code{type="scaling"}, or \code{\link{loessFit}} for \code{type="loess"}.} \item{assay.id}{An integer scalar or string specifying the assay values to use for normalization.} diff --git a/tests/testthat/test-norm.R b/tests/testthat/test-norm.R index 0181f31..0798012 100644 --- a/tests/testthat/test-norm.R +++ b/tests/testthat/test-norm.R @@ -47,7 +47,7 @@ test_that("testing what happens with undersampling", { data <- SummarizedExperiment(list(counts=counts)) data$totals <- c(sum(mu1), sum(mu2)) truth <- sqrt(c(1/undersamp, undersamp)) - expect_true(all(abs(normFactors(data)$norm.factors - truth) < 0.05)) + expect_true(all(abs(normFactors(data)$norm.factors - truth) < 0.1)) # Testing what happens with weighting, after adding some high-abundance DB regions. # The errors should be larger than the unweighted version.