From 38ebd3fb6a3116a9470d9f72858e9f11ee60c68e Mon Sep 17 00:00:00 2001 From: Jay Hesselberth Date: Sat, 21 Dec 2024 07:16:16 -0700 Subject: [PATCH] Deprecate `read_bigwig()` and `read_gtf()` (#424) Closes #424 --- DESCRIPTION | 1 - NAMESPACE | 1 - NEWS.md | 2 ++ R/read_bed.r | 59 ++++++++++++++++++++-------------- man/read_bigwig.Rd | 4 +-- man/read_gtf.Rd | 4 +++ tests/testthat/test_read_bed.r | 8 ++--- 7 files changed, 46 insertions(+), 33 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c78eff4a..b2aca895 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -27,7 +27,6 @@ Imports: Rcpp (>= 1.0.0), readr, rlang, - rtracklayer, stringr, tibble (>= 1.4.2) Suggests: diff --git a/NAMESPACE b/NAMESPACE index 5aa86a3b..a6d76897 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -64,7 +64,6 @@ importFrom(rlang,dots_n) importFrom(rlang,quos) importFrom(rlang,sym) importFrom(rlang,syms) -importFrom(rtracklayer,import) importFrom(stats,fisher.test) importFrom(stats,na.omit) importFrom(stringr,fixed) diff --git a/NEWS.md b/NEWS.md index 02bf2128..944cec90 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # valr (development version) +* `read_bigwig()` and `read_gtf()` were deprecated as rtracklayer is no longer avilable on CRAN. + * valr now depends on R >= 4.0.0. # valr 0.8.2 diff --git a/R/read_bed.r b/R/read_bed.r index 6141b09c..cedab7a1 100644 --- a/R/read_bed.r +++ b/R/read_bed.r @@ -176,7 +176,10 @@ bed12_coltypes <- list( #' Import and convert a bigwig file into a valr compatible tbl #' -#' @description This function will output a 5 column tibble with +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' This function will output a 5 column tibble with #' zero-based chrom, start, end, score, and strand columns. #' #' @param path path to bigWig file @@ -188,29 +191,33 @@ bed12_coltypes <- list( #' #' @examples #' \dontrun{ -#' if (.Platform$OS.type != "windows") { #' bw <- read_bigwig(valr_example("hg19.dnase1.bw")) #' head(bw) #' } -#' } -#' @importFrom rtracklayer import #' @export read_bigwig <- function(path, set_strand = "+") { - check_required(path) - # note that rtracklayer will produce a one-based GRanges object - res <- rtracklayer::import(path) - res <- dplyr::as_tibble(res) - res <- dplyr::mutate(res, - chrom = as.character(seqnames), - start = start - 1L, - strand = set_strand + lifecycle::deprecate_stop( + when = "0.8.3", + what = "read_bigwig()", + details = c( + x = paste0( + "read_bigwig() was removed because rtracklayer is", + "no longer available on CRAN" + ), + i = paste0( + "use `bigWigToBedGraph` to convert bw to bedGraph,", + "and then `read_bedgraph()`." + ) + ) ) - dplyr::select(res, chrom, start, end, score, strand) } #' Import and convert a GTF/GFF file into a valr compatible bed tbl format #' -#' @description This function will output a tibble with the +#' @description +#' `r lifecycle::badge("deprecated")` +#' +#' This function will output a tibble with the #' required chrom, start, and end columns, as well as other columns depending #' on content in GTF/GFF file. #' @@ -219,20 +226,22 @@ read_bigwig <- function(path, set_strand = "+") { #' #' @examples #' +#' \dontrun{ #' gtf <- read_gtf(valr_example("hg19.gencode.gtf.gz")) #' head(gtf) +#' } #' -#' @importFrom rtracklayer import #' @export read_gtf <- function(path, zero_based = TRUE) { - gtf <- rtracklayer::import(path) - gtf <- as.data.frame(gtf) - gtf <- dplyr::mutate_if(gtf, is.factor, as.character) - res <- dplyr::rename(gtf, chrom = seqnames) - - if (zero_based) { - res <- dplyr::mutate(res, start = start - 1L) - } - - tibble::as_tibble(res) + lifecycle::deprecate_stop( + when = "0.8.3", + what = "read_gtf()", + details = c( + x = paste0( + "read_gtf() was removed because rtracklayer is", + "no longer available on CRAN" + ), + i = "convert GTF to BED, and then `read_bed()`." + ) + ) } diff --git a/man/read_bigwig.Rd b/man/read_bigwig.Rd index c24883fd..069fc782 100644 --- a/man/read_bigwig.Rd +++ b/man/read_bigwig.Rd @@ -12,6 +12,8 @@ read_bigwig(path, set_strand = "+") \item{set_strand}{strand to add to output (defaults to "+")} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + This function will output a 5 column tibble with zero-based chrom, start, end, score, and strand columns. } @@ -22,9 +24,7 @@ for windows users (particularly for 32 bit window users). } \examples{ \dontrun{ -if (.Platform$OS.type != "windows") { bw <- read_bigwig(valr_example("hg19.dnase1.bw")) head(bw) } } -} diff --git a/man/read_gtf.Rd b/man/read_gtf.Rd index e1348456..72786151 100644 --- a/man/read_gtf.Rd +++ b/man/read_gtf.Rd @@ -12,13 +12,17 @@ read_gtf(path, zero_based = TRUE) \item{zero_based}{if TRUE, convert to zero based} } \description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} + This function will output a tibble with the required chrom, start, and end columns, as well as other columns depending on content in GTF/GFF file. } \examples{ +\dontrun{ gtf <- read_gtf(valr_example("hg19.gencode.gtf.gz")) head(gtf) +} } diff --git a/tests/testthat/test_read_bed.r b/tests/testthat/test_read_bed.r index 4ec8b68c..7df22ae7 100644 --- a/tests/testthat/test_read_bed.r +++ b/tests/testthat/test_read_bed.r @@ -46,12 +46,12 @@ test_that("read broadPeak", { test_that("read bigwig", { skip_on_os("windows") - x <- read_bigwig(bigwig_path) - expect_equal(ncol(x), 5) + expect_error(read_bigwig(bigwig_path)) + # expect_equal(ncol(x), 5) }) test_that("read gtf", { - x <- read_gtf(gtf_path) - expect_equal(ncol(x), 26) + expect_error(read_gtf(gtf_path)) + # expect_equal(ncol(x), 26) })