From 76fde674dc79a2ab88e8fa0456000346b66edea1 Mon Sep 17 00:00:00 2001 From: Christian Mertes Date: Sat, 7 Mar 2020 06:27:21 +0100 Subject: [PATCH] correct assay call due to changes in SummarizedExperiment and the following commit https://github.com/Bioconductor/SummarizedExperiment/commit/495ab00fa0b6bb5c76ad8cac39431c3beb73714f --- R/class-OutriderDataSet.R | 10 +++++----- R/getNSetterFuns.R | 14 +++++++------- R/method-counts.R | 5 +++-- R/method-gridSearch.R | 7 ++++--- R/pValMatrix.R | 4 ++-- man/counts.Rd | 4 +++- man/getter_setter_functions.Rd | 2 +- tests/testthat/helper_test_data_set.R | 6 +++--- tests/testthat/test_helper.R | 6 ++++-- tests/testthat/test_methods.R | 2 +- 10 files changed, 33 insertions(+), 27 deletions(-) diff --git a/R/class-OutriderDataSet.R b/R/class-OutriderDataSet.R index b7bd95e..bd5124d 100644 --- a/R/class-OutriderDataSet.R +++ b/R/class-OutriderDataSet.R @@ -210,8 +210,8 @@ makeExampleOutriderDataSet <- function(n=200, m=80, q=10, freq=1E-3, zScore=6, colnames(countData) <- paste0("sample_", seq_len(m)) ods <- OutriderDataSet(countData=countData) - assay(ods, "trueMean") <- mu - assay(ods, "trueSd") <- matrix(true_sd, nrow=n, ncol=m) + assay(ods, "trueMean", withDimnames=FALSE) <- mu + assay(ods, "trueSd", withDimnames=FALSE) <- matrix(true_sd, nrow=n, ncol=m) mcols(ods)[,"trueTheta"] <- theta colData(ods)[['trueSizeFactor']] <- sf metadata(ods)[['optimalEncDim']] <- q @@ -254,9 +254,9 @@ makeExampleOutriderDataSet <- function(n=200, m=80, q=10, freq=1E-3, zScore=6, } mode(k) <- "integer" - assay(ods, 'trueCounts') <- counts(ods) - counts(ods) <- k - assay(ods, "trueOutliers") <- indexOut + assay(ods, 'trueCounts', withDimnames=FALSE) <- counts(ods) + counts(ods, withDimnames=FALSE) <- k + assay(ods, "trueOutliers", withDimnames=FALSE) <- indexOut return(ods) } diff --git a/R/getNSetterFuns.R b/R/getNSetterFuns.R index 6af7b11..dc67fb9 100644 --- a/R/getNSetterFuns.R +++ b/R/getNSetterFuns.R @@ -4,7 +4,7 @@ #' the values within the OUTRIDER model. #' #' @param ods,object An OutriderDataSet object. -#' @param ... Further arguments currently not in use. +#' @param ... Further arguments passed on to the underlying assay function. #' @return A matrix or vector dependent on the type of data retrieved. #' #' @name getter_setter_functions @@ -33,10 +33,10 @@ zScore <- function(ods){ assay(ods, 'zScore') } -`zScore<-` <- function(ods, value){ +`zScore<-` <- function(ods, ..., value){ stopifnot(is.matrix(value)) stopifnot(dim(ods) == dim(value)) - assay(ods, 'zScore') <- value + assay(ods, 'zScore', ...) <- value return(ods) } @@ -49,10 +49,10 @@ pValue <- function(ods){ assay(ods, 'pValue') } -`pValue<-` <- function(ods, value){ +`pValue<-` <- function(ods, ..., value){ stopifnot(is.matrix(value)) stopifnot(dim(ods) == dim(value)) - assay(ods, 'pValue') <- value + assay(ods, 'pValue', ...) <- value return(ods) } @@ -66,10 +66,10 @@ padj <- function(ods){ assay(ods, 'padjust') } -`padj<-` <- function(ods, value){ +`padj<-` <- function(ods, ..., value){ stopifnot(is.matrix(value)) stopifnot(dim(ods) == dim(value)) - assay(ods, 'padjust') <- value + assay(ods, 'padjust', ...) <- value return(ods) } diff --git a/R/method-counts.R b/R/method-counts.R index 9d4bd62..4808813 100644 --- a/R/method-counts.R +++ b/R/method-counts.R @@ -1,7 +1,7 @@ -counts.replace.OutriderDataSet <- function(object, value){ +counts.replace.OutriderDataSet <- function(object, ..., value){ mode(value) <- "integer" - assays(object)[["counts"]] <- value + assay(object, "counts", ...) <- value validObject(object) object @@ -53,6 +53,7 @@ counts.OutriderDataSet <- function(object, normalized=FALSE, minE=0.5){ #' @param normalized TRUE/FALSE whether counts should be normalized #' @param value An integer matrix containing the counts #' @param minE minimal expected count. +#' @param ... Further arguments are passed on to the underlying assay function #' @return A matrix containing the counts #' #' @seealso \code{\link{sizeFactors}}, \code{\link{normalizationFactors}} diff --git a/R/method-gridSearch.R b/R/method-gridSearch.R index bd8db4e..d106a90 100644 --- a/R/method-gridSearch.R +++ b/R/method-gridSearch.R @@ -207,9 +207,10 @@ injectOutliers <- function(ods, freq, zScore, inj, lnorm, sdlog){ } } # save coruppted counts and index of corruption into ods - assay(ods, 'counts') <- matrix(as.integer(counts),nrow(ods)) - assay(ods, 'trueCorruptions') <- index - assay(ods, 'injectedZscore') <- zScore + assay(ods, 'counts', withDimnames=FALSE) <- matrix(as.integer(counts), + nrow=nrow(ods)) + assay(ods, 'trueCorruptions', withDimnames=FALSE) <- index + assay(ods, 'injectedZscore', withDimnames=FALSE) <- zScore return(ods) } diff --git a/R/pValMatrix.R b/R/pValMatrix.R index f688524..3dbb05b 100644 --- a/R/pValMatrix.R +++ b/R/pValMatrix.R @@ -74,8 +74,8 @@ pValMatrix <- function(ods, alternative, BPPARAM){ pValMat <- bplapply(seq_along(ods), pVal, ctsData=ctsData, theta=thetaMat, mu=mu, normF=normF, alternative=alternative, BPPARAM=BPPARAM) - pValMat <- - pValue(ods) <- matrix(unlist(pValMat), nrow=length(ods), byrow=TRUE) + pValue(ods) <- matrix(unlist(pValMat), nrow=length(ods), + byrow=TRUE, dimnames=dimnames(ods)) validObject(ods) return(ods) } diff --git a/man/counts.Rd b/man/counts.Rd index 30fcfe5..87442f5 100644 --- a/man/counts.Rd +++ b/man/counts.Rd @@ -9,7 +9,7 @@ \usage{ \S4method{counts}{OutriderDataSet}(object, normalized = FALSE, minE = 0.5) -\S4method{counts}{OutriderDataSet,matrix}(object) <- value +\S4method{counts}{OutriderDataSet,matrix}(object, ...) <- value } \arguments{ \item{object}{OutriderDataSet} @@ -18,6 +18,8 @@ \item{minE}{minimal expected count.} +\item{...}{Further arguments are passed on to the underlying assay function} + \item{value}{An integer matrix containing the counts} } \value{ diff --git a/man/getter_setter_functions.Rd b/man/getter_setter_functions.Rd index 47b91e1..90835a7 100644 --- a/man/getter_setter_functions.Rd +++ b/man/getter_setter_functions.Rd @@ -30,7 +30,7 @@ theta(ods) \arguments{ \item{ods, object}{An OutriderDataSet object.} -\item{...}{Further arguments currently not in use.} +\item{...}{Further arguments passed on to the underlying assay function.} } \value{ A matrix or vector dependent on the type of data retrieved. diff --git a/tests/testthat/helper_test_data_set.R b/tests/testthat/helper_test_data_set.R index aad17c0..eb46984 100644 --- a/tests/testthat/helper_test_data_set.R +++ b/tests/testthat/helper_test_data_set.R @@ -71,9 +71,9 @@ get_test_outrider_dataset <- function(){ normalizationFactors(ods) <- normF_round3 mcols(ods)[['mu']] <- mu_round4 mcols(ods)[['disp']] <- disp_round4 - assays(ods)[['pValue']] <- pval_round4 - assays(ods)[['padjust']] <- padj_round4 - assays(ods)[['zScore']] <- zscore_round4 + assay(ods, 'pValue', withDimnames=FALSE) <- pval_round4 + assay(ods, 'padjust', withDimnames=FALSE) <- padj_round4 + assay(ods, 'zScore', withDimnames=FALSE) <- zscore_round4 return(ods) } diff --git a/tests/testthat/test_helper.R b/tests/testthat/test_helper.R index 4f3b5be..b722cdb 100644 --- a/tests/testthat/test_helper.R +++ b/tests/testthat/test_helper.R @@ -9,10 +9,12 @@ test_that("check ODS object", { ods <- estimateSizeFactors(ods) expect_error(checkFullAnalysis(ods), "Please calculate the P-values before") - padj(ods) <- matrix(runif(ncol(ods)*nrow(ods)), ncol=ncol(ods)) + padj(ods) <- matrix(runif(ncol(ods)*nrow(ods)), + ncol=ncol(ods), dimnames=dimnames(ods)) expect_error(checkFullAnalysis(ods), "Please calculate the Z-scores before") - zScore(ods) <- matrix(runif(ncol(ods)*nrow(ods)), ncol=ncol(ods)) + zScore(ods) <- matrix(runif(ncol(ods)*nrow(ods)), + ncol=ncol(ods), dimnames=dimnames(ods)) expect_true(checkFullAnalysis(ods)) }) diff --git a/tests/testthat/test_methods.R b/tests/testthat/test_methods.R index 361155d..6c06910 100644 --- a/tests/testthat/test_methods.R +++ b/tests/testthat/test_methods.R @@ -37,7 +37,7 @@ test_that("result method", { test_that("normalization method", { ods <- makeExampleOutriderDataSet(5, 5) - counts(ods) <- matrix(1:5, ncol=5, nrow=5) + counts(ods) <- matrix(1:5, ncol=5, nrow=5, dimnames=dimnames(ods)) expect_null(normalizationFactors(ods)) nMat <- matrix(6:10, ncol=5, nrow=5) normalizationFactors(ods) <- nMat