Skip to content

Commit

Permalink
Enforce use of TMM to bypass changes in calcNormFactors defaults.
Browse files Browse the repository at this point in the history
Relaxed normalization test.
  • Loading branch information
LTLA committed Apr 26, 2019
1 parent a97b9f7 commit 250f29b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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"),
Expand Down
4 changes: 2 additions & 2 deletions R/normFactors.R
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)) {
Expand Down
4 changes: 3 additions & 1 deletion man/normOffsets.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -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.}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-norm.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 250f29b

Please sign in to comment.