diff --git a/DESCRIPTION b/DESCRIPTION index 1f1531f..bd5b551 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: extraChIPs -Version: 1.9.2 +Version: 1.8.2 Title: Additional functions for working with ChIP-Seq data Authors@R: person("Stevie", "Pederson", email = "stephen.pederson.au@gmail.com", diff --git a/R/addDiffStatus.R b/R/addDiffStatus.R index fa93ddd..6dd76f8 100644 --- a/R/addDiffStatus.R +++ b/R/addDiffStatus.R @@ -64,11 +64,11 @@ setMethod( stopifnot(is.numeric(x[[sig_col]])) sig <- x[[sig_col]] < alpha status <- case_when( - is.na(sig) | is.na(fc) ~ missing[[1]], - !sig ~ other[[1]], - fc > abs(cutoff) ~ up[[1]], - fc < -abs(cutoff) ~ down[[1]], - TRUE ~ other[[1]] + is.na(sig) | is.na(fc) ~ missing[[1]], + !sig ~ other[[1]], + fc > abs(cutoff) ~ up[[1]], + fc < -abs(cutoff) ~ down[[1]], + TRUE ~ other[[1]] ) ## Do we need to add an explicit NA value here? lv <- unique(c(other, down, up, missing)) diff --git a/R/colToRanges.R b/R/colToRanges.R index 9cf10a6..2f3d8c6 100644 --- a/R/colToRanges.R +++ b/R/colToRanges.R @@ -29,8 +29,6 @@ #' @param seqinfo A seqinfo object to be applied to the new GRanges object. #' Ignored if the column is already a GRanges object #' @param ... Used to pass arguments to lower-level functions -#' @param keep_metadata logical(1) If the original object is a GRanges object, -#' retain all metadata from the original ranges in the replaced ranges #' #' @importFrom methods as #' @import GenomicRanges @@ -59,11 +57,9 @@ setMethod( #' @export setMethod( "colToRanges", signature = signature(x = "GRanges"), - function(x, var, ..., keep_metadata = TRUE) { + function(x, var, ...) { df <- mcols(x) - gr <- colToRanges(df, var, ...) - if (keep_metadata) metadata(gr) <- metadata(x) - gr + colToRanges(df, var, ...) } ) #' @import GenomicRanges diff --git a/man/colToRanges-methods.Rd b/man/colToRanges-methods.Rd index 398225e..3b67cf6 100644 --- a/man/colToRanges-methods.Rd +++ b/man/colToRanges-methods.Rd @@ -11,7 +11,7 @@ colToRanges(x, ...) \S4method{colToRanges}{DataFrame}(x, var, seqinfo = NULL, ...) -\S4method{colToRanges}{GRanges}(x, var, ..., keep_metadata = TRUE) +\S4method{colToRanges}{GRanges}(x, var, ...) \S4method{colToRanges}{data.frame}(x, var, seqinfo = NULL, ...) } @@ -24,9 +24,6 @@ colToRanges(x, ...) \item{seqinfo}{A seqinfo object to be applied to the new GRanges object. Ignored if the column is already a GRanges object} - -\item{keep_metadata}{logical(1) If the original object is a GRanges object, -retain all metadata from the original ranges in the replaced ranges} } \value{ A GenomicRanges object diff --git a/tests/testthat/test_colToRanges.R b/tests/testthat/test_colToRanges.R index 7112146..eae5460 100644 --- a/tests/testthat/test_colToRanges.R +++ b/tests/testthat/test_colToRanges.R @@ -1,20 +1,17 @@ sq <- Seqinfo("chr1", 100, FALSE, "test") x <- GRanges(c("chr1:1-10", "chr1:6-15", "chr1:51-60"), seqinfo = sq) df <- data.frame(logFC = rnorm(3), logCPM = rnorm(3,8), p = 10^-rexp(3)) -gr <- mergeByCol(x, df, col = "logCPM", pval = "p") -metadata(gr) <- list(check = TRUE) +gr <-mergeByCol(x, df, col = "logCPM", pval = "p") test_that("Coercion is correct where it should be", { new_gr <- colToRanges(gr, "keyval_range") expect_s4_class(new_gr, "GRanges") - expect_true(metadata(new_gr)$check) expect_equal( colnames(mcols(new_gr)), c("n_windows", "n_up", "n_down", "logCPM", "logFC", "p", "p_fdr") ) expect_equal(length(new_gr), 2) df$gr <- as.character(x) - ## Now try using a df new_gr <- colToRanges(df, "gr", seqinfo = sq) expect_s4_class(new_gr, "GRanges") expect_equal(seqinfo(new_gr), sq)