Skip to content

Commit

Permalink
Tested bugfix in release
Browse files Browse the repository at this point in the history
  • Loading branch information
smped committed May 18, 2024
1 parent ab84ee0 commit f601063
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]",
Expand Down
10 changes: 5 additions & 5 deletions R/addDiffStatus.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
8 changes: 2 additions & 6 deletions R/colToRanges.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions man/colToRanges-methods.Rd

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

5 changes: 1 addition & 4 deletions tests/testthat/test_colToRanges.R
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit f601063

Please sign in to comment.