Skip to content

Commit 2ba7914

Browse files
Use cpp11bigwig for read_bigwig() (#425)
* Use cpp11bigwig for `read_bigwig()` * Update news
1 parent c27797f commit 2ba7914

File tree

5 files changed

+45
-71
lines changed

5 files changed

+45
-71
lines changed

DESCRIPTION

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Depends:
2121
Imports:
2222
broom,
2323
cli,
24+
cpp11bigwig,
2425
dplyr (>= 0.8.0),
2526
ggplot2,
2627
lifecycle,

NEWS.md

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# valr (development version)
22

3-
* `read_bigwig()` and `read_gtf()` were deprecated. The rtracklayer package used
4-
for this functionality is no longer a dependency of valr due to errors from
3+
* `read_bigwig()` now uses cpp11bigwig on CRAN. The `set_strand` param was removed to be
4+
more consistent with expected bigWig contents.
5+
6+
* `read_gtf()` was deprecated. The rtracklayer package used
7+
for this functionality is no longer a dependency of valr due to errors from
58
CRAN AddressSantizer checks of the UCSC c-library code vendored in rtracklayer.
69

710
* valr now depends on R >= 4.0.0.
811

912
# valr 0.8.2
1013

11-
* Address NOTE on CRAN about Rd link targets.
14+
* Address NOTE on CRAN about Rd link targets.
1215

13-
* Change maintainer email address.
16+
* Change maintainer email address.
1417

1518
# valr 0.8.1
1619

17-
* Make vdiffr dependency optional during package testing.
20+
* Make vdiffr dependency optional during package testing.
1821

1922
# valr 0.8.0
2023

@@ -26,17 +29,17 @@ CRAN AddressSantizer checks of the UCSC c-library code vendored in rtracklayer.
2629

2730
# valr 0.6.8
2831

29-
* `bed_closest()` now reports all x intervals, even when there are no closest y intervals (e.g. when there is no matching chromosome in y intervals). These intervals are returned populated with `NA` for `.overlap`, `.dist` and y interval locations.
32+
* `bed_closest()` now reports all x intervals, even when there are no closest y intervals (e.g. when there is no matching chromosome in y intervals). These intervals are returned populated with `NA` for `.overlap`, `.dist` and y interval locations.
3033

31-
* Reimplemented `bed_closest()` to use binary search rather than an interval tree search. The closest y interval can be missed with the previous search strategy in high depth interval trees.
34+
* Reimplemented `bed_closest()` to use binary search rather than an interval tree search. The closest y interval can be missed with the previous search strategy in high depth interval trees.
3235

3336
* Fix off by one error when using `max_dist` argument in `bed_cluster()` (#401).
3437

3538
# valr 0.6.7
3639

3740
* Removed `SystemRequirements` from DESCRIPTION to eliminate a NOTE on CRAN.
3841

39-
* `bed_coverage()` now reports intervals from `x` with no matching group in `y` (#395).
42+
* `bed_coverage()` now reports intervals from `x` with no matching group in `y` (#395).
4043

4144
# valr 0.6.6
4245

@@ -49,15 +52,15 @@ CRAN AddressSantizer checks of the UCSC c-library code vendored in rtracklayer.
4952

5053
# valr 0.6.5
5154

52-
* Handle `max_dist` for first intervals in `bed_cluster()` (#388)
55+
* Handle `max_dist` for first intervals in `bed_cluster()` (#388)
5356

5457
# valr 0.6.4
5558

56-
* Fixed intron score numbering error in `create_introns` (#377 @sheridar)
59+
* Fixed intron score numbering error in `create_introns` (#377 @sheridar)
5760

58-
* Fixed bug in handling of list inputs for `bed_intersect()`(#380 @sheridar)
61+
* Fixed bug in handling of list inputs for `bed_intersect()`(#380 @sheridar)
5962

60-
* Added `read_bigwig` and `read_gtf` functions to import data into valr compatible tibbles (#379)
63+
* Added `read_bigwig` and `read_gtf` functions to import data into valr compatible tibbles (#379)
6164

6265
* Kent Riemondy is now maintainer.
6366

@@ -69,7 +72,7 @@ CRAN AddressSantizer checks of the UCSC c-library code vendored in rtracklayer.
6972

7073
## Minor changes
7174

72-
* `RMariaDB` has replaced the deprecated `RMySQL` package as the database backend.
75+
* `RMariaDB` has replaced the deprecated `RMySQL` package as the database backend.
7376

7477
* valr now imports Rcpp, which should have always been the case,
7578
but was masked by its Import by readr, which recently dropped use of Rcpp.
@@ -84,17 +87,17 @@ but was masked by its Import by readr, which recently dropped use of Rcpp.
8487

8588
## Major changes
8689

87-
* `trbl_interval()` and `trbl_genome()` custom `tibble` subclasses have been deemed unnecessary and have been removed from the package.
90+
* `trbl_interval()` and `trbl_genome()` custom `tibble` subclasses have been deemed unnecessary and have been removed from the package.
8891

89-
* coercing `GRanges` to a `valr` compatible data.frame now uses the `gr_to_bed()` function rather than `as.trbl_interal()` methods.
92+
* coercing `GRanges` to a `valr` compatible data.frame now uses the `gr_to_bed()` function rather than `as.trbl_interal()` methods.
9093

9194
## Minor changes
9295

9396
* dplyr version < 0.8.0 is no longer supported due to unnecessary code bloat and challenges with handling multiple grouping structures (#359).
9497

9598
* The `sort_by` argument of `bed_random()` has been changed to `sorted`, and will now by default
9699
use `bed_sort()` to sort the output, rather than rely on naming the sorting columns. Sorting can
97-
be suppressed by using `sorted = FALSE`.
100+
be suppressed by using `sorted = FALSE`.
98101

99102
* `bed_sort()` now uses base R sorting with the `radix` method for increased speed. (#353)
100103

@@ -108,13 +111,13 @@ be suppressed by using `sorted = FALSE`.
108111

109112
# valr 0.5.0
110113

111-
## Major changes
114+
## Major changes
112115

113-
* Internal `Rcpp` functions have been reorganized to remove all dependencies on `dplyr` C++ functions.
116+
* Internal `Rcpp` functions have been reorganized to remove all dependencies on `dplyr` C++ functions.
114117

115118
## Minor changes
116119

117-
* Due to internal refactoring of Rcpp functions, only data.frames containing Numeric, Logical, Integer, Character, and List column types are supported. Columns containing Raw, Complex, or other R classes are not supported and will issue an error.
120+
* Due to internal refactoring of Rcpp functions, only data.frames containing Numeric, Logical, Integer, Character, and List column types are supported. Columns containing Raw, Complex, or other R classes are not supported and will issue an error.
118121

119122
* Factors are now disallowed from grouping variables in multiset operations to avoid sort order discrepancies, and compatibility with factor handling in `dplyr` v.0.8.0. Factors will now be internally type-converted to character and a warning is issued.
120123

@@ -199,7 +202,7 @@ be suppressed by using `sorted = FALSE`.
199202
## Minor changes
200203

201204
* intervals returned from `bed_random()` are sorted by `chrom` and `start` by default.
202-
205+
203206
## Bug fixes
204207

205208
* Merge intervals in `bed_jaccard()` and use numeric values for calculation (fixes #204).

R/read_bed.r

+10-32
Original file line numberDiff line numberDiff line change
@@ -174,44 +174,22 @@ bed12_coltypes <- list(
174174
)
175175

176176

177-
#' Import and convert a bigwig file into a valr compatible tbl
177+
#' Read a bigwig file into a valr compatible tbl
178178
#'
179-
#' @description
180-
#' `r lifecycle::badge("deprecated")`
181-
#'
182-
#' This function will output a 5 column tibble with
183-
#' zero-based chrom, start, end, score, and strand columns.
179+
#' This function will output a 4 column tibble with
180+
#' zero-based chrom, start, end, value columns.
184181
#'
185182
#' @param path path to bigWig file
186-
#' @param set_strand strand to add to output (defaults to "+")
187-
#'
188-
#' @note This functions uses \code{rtracklayer} to import bigwigs which
189-
#' has unstable support for the windows platform and therefore may error
190-
#' for windows users (particularly for 32 bit window users).
183+
#' @param ... params for `cpp11bigwig::read_bigwig()`
191184
#'
192185
#' @examples
193-
#' \dontrun{
194-
#' bw <- read_bigwig(valr_example("hg19.dnase1.bw"))
195-
#' head(bw)
196-
#' }
186+
#' read_bigwig(valr_example("hg19.dnase1.bw"))
187+
#'
188+
#' read_bigwig(valr_example("hg19.dnase1.bw"), as = "GRanges")
189+
#'
197190
#' @export
198-
read_bigwig <- function(path, set_strand = "+") {
199-
lifecycle::deprecate_stop(
200-
when = "0.8.3",
201-
what = "read_bigwig()",
202-
details = c(
203-
x = paste0(
204-
"read_bigwig() was removed because rtracklayer does not pass ",
205-
"CRAN AddressSantizer checks of the UCSC C-library code vendored ",
206-
"in rtracklayer."
207-
),
208-
i = paste0(
209-
"use `bigWigToBedGraph` to convert bw to bedGraph,",
210-
" and then `read_bedgraph()`. Alternatively use ",
211-
"`rtracklayer::import()` then `gr_to_bed()`."
212-
)
213-
)
214-
)
191+
read_bigwig <- function(path, ...) {
192+
cpp11bigwig::read_bigwig(path, ...)
215193
}
216194

217195
#' Import and convert a GTF/GFF file into a valr compatible bed tbl format

man/read_bigwig.Rd

+9-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_read_bed.r

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ test_that("read broadPeak", {
4545
})
4646

4747
test_that("read bigwig", {
48-
skip_on_os("windows")
49-
expect_error(read_bigwig(bigwig_path))
50-
# expect_equal(ncol(x), 5)
48+
x <- read_bigwig(bigwig_path)
49+
expect_equal(ncol(x), 4)
5150
})
5251

5352

0 commit comments

Comments
 (0)