Skip to content

Commit

Permalink
correct assay call due to changes in SummarizedExperiment and the fol…
Browse files Browse the repository at this point in the history
  • Loading branch information
c-mertes committed Mar 7, 2020
1 parent cb71371 commit 76fde67
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 27 deletions.
10 changes: 5 additions & 5 deletions R/class-OutriderDataSet.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
14 changes: 7 additions & 7 deletions R/getNSetterFuns.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand All @@ -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)
}

Expand Down
5 changes: 3 additions & 2 deletions R/method-counts.R
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}}
Expand Down
7 changes: 4 additions & 3 deletions R/method-gridSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions R/pValMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 3 additions & 1 deletion man/counts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/getter_setter_functions.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/helper_test_data_set.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 4 additions & 2 deletions tests/testthat/test_helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 76fde67

Please sign in to comment.