Skip to content

Commit bf8c782

Browse files
committed
fix: no more reexports, attach tidyverse packages on load, tidy up expand and as_tibble methods
1 parent 4a2d337 commit bf8c782

15 files changed

Lines changed: 252 additions & 156 deletions

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Imports:
3535
rtracklayer,
3636
methods,
3737
tidyr,
38+
tibble,
3839
ggplot2,
3940
ggrastr,
4041
dplyr,

NAMESPACE

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ S3method(print,CoverageExperiment)
77
S3method(tbl_format_header,tidyAggregatedCoverage)
88
S3method(tbl_format_header,tidyCoverageExperiment)
99
export(CoverageExperiment)
10-
export(aggregate)
11-
export(as_tibble)
1210
export(coarsen)
13-
export(expand)
1411
export(geom_aggrcoverage)
1512
export(geom_coverage)
1613
export(scale_x_genome)
1714
export(scale_y_coverage)
18-
export(show)
1915
exportMethods(CoverageExperiment)
2016
exportMethods(aggregate)
2117
exportMethods(coarsen)
@@ -57,4 +53,5 @@ importFrom(tidyr,all_of)
5753
importFrom(tidyr,any_of)
5854
importFrom(tidyr,expand)
5955
importFrom(tidyr,pivot_longer)
56+
importFrom(utils,packageDescription)
6057
importFrom(vctrs,new_data_frame)

R/as_tibble.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
#'
33
#' Coerce an `CoverageExperiment` or `AggregatedCoverage` object into a `tibble`
44
#'
5-
#' @name as_tibble-methods
6-
#' @rdname as_tibble-methods
7-
#' @param x an `CoverageExperiment` object
8-
#' @param ... ignored
5+
#' @name as_tibble-AggregatedCoverage
6+
#' @rdname as_tibble-AggregatedCoverage
7+
#' @inherit tibble::as_tibble
98
#' @return `tibble`
109
#'
1110
#' @importFrom tidyr any_of
@@ -17,7 +16,8 @@
1716
#' as_tibble(ac)
1817
NULL
1918

20-
#' @rdname as_tibble-methods
19+
#' @rdname as_tibble-AggregatedCoverage
20+
#' @method as_tibble AggregatedCoverage
2121
#' @export
2222

2323
as_tibble.AggregatedCoverage <- function(x, ...) {

R/attach.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
core <- c("dplyr", "tidyr", "ggplot2")
2+
3+
core_unloaded <- function() {
4+
search <- paste0("package:", core)
5+
core[!search %in% search()]
6+
}
7+
8+
same_library <- function(pkg) {
9+
loc <- if (pkg %in% loadedNamespaces())
10+
dirname(getNamespaceInfo(pkg, "path"))
11+
library(pkg, lib.loc=loc, character.only=TRUE, warn.conflicts=FALSE)
12+
}
13+
14+
tidyverse_attach <- function() {
15+
to_load <- core_unloaded()
16+
17+
suppressPackageStartupMessages(
18+
lapply(to_load, same_library))
19+
20+
invisible(to_load)
21+
}

R/expand.R

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
#' object into a long data frame, and adds the `ranges`
99
#' and `seqnames` to the resulting `tibble`.
1010
#'
11-
#' @name expand,CoverageExperiment
12-
#' @aliases expand,CoverageExperiment-method
13-
#' @rdname expand
14-
#'
15-
#' @param data a `CoverageExperiment` object
16-
#' @param ...,.name_repair ignored
11+
#' @name expand-CoverageExperiment
12+
#' @rdname expand-CoverageExperiment
13+
#' @inherit tidyr::expand
1714
#' @return a `tibble` object
1815
#'
1916
#' @importFrom tidyr expand
20-
#' @export
2117
#' @examples
2218
#' data(ce)
2319
#' ce
24-
#'
2520
#' expand(ce)
21+
NULL
2622

23+
#' @rdname expand-CoverageExperiment
24+
#' @method expand CoverageExperiment
25+
#' @export
2726
expand.CoverageExperiment <- function(data, ..., .name_repair = NULL) {
2827
tracks <- colData(data)$track
2928
features <- rowData(data)$features

R/reexports.R

Lines changed: 0 additions & 21 deletions
This file was deleted.

R/show.R

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#' show
1+
#' @title show method for `CoverageExperiment` and `AggregatedCoverage` objects
22
#'
3-
#' show method for `CoverageExperiment` and `AggregatedCoverage` objects
4-
#'
5-
#' @name show
3+
#' @name show-tidyCoverage
64
#' @aliases show,CoverageExperiment-method
75
#' @aliases show,AggregatedCoverage-method
86
#'
@@ -20,9 +18,7 @@
2018
#' @importFrom vctrs new_data_frame
2119
#' @importFrom SummarizedExperiment assayNames
2220
#' @importFrom stats setNames
23-
#' @export
2421
#'
25-
#' @inherit tibble::formatting
2622
#' @return `Prints a message to the console describing
2723
#' the contents of the `CoverageExperiment` or `AggregatedCoverage` objects.
2824
#' @examples
@@ -32,7 +28,8 @@
3228
#' print(ac)
3329
NULL
3430

35-
#' @name show
31+
#' @method show CoverageExperiment
32+
#' @aliases show,CoverageExperiment-method
3633
#' @export
3734

3835
setMethod("show", signature("CoverageExperiment"), function(object) {
@@ -52,7 +49,8 @@ setMethod("show", signature("CoverageExperiment"), function(object) {
5249
}
5350
})
5451

55-
#' @name show
52+
#' @method show AggregatedCoverage
53+
#' @aliases show,AggregatedCoverage-method
5654
#' @export
5755

5856
setMethod("show", signature("AggregatedCoverage"), function(object) {
@@ -74,7 +72,7 @@ setMethod("show", signature("AggregatedCoverage"), function(object) {
7472
}
7573
})
7674

77-
#' @name show
75+
#' @method print CoverageExperiment
7876
#' @export
7977

8078
print.CoverageExperiment <- function (x, ..., n = NULL) {
@@ -105,7 +103,7 @@ print.CoverageExperiment <- function (x, ..., n = NULL) {
105103
}
106104
}
107105

108-
#' @name show
106+
#' @method print AggregatedCoverage
109107
#' @export
110108

111109
print.AggregatedCoverage <- function (x, ..., n = NULL) {
@@ -136,7 +134,7 @@ print.AggregatedCoverage <- function (x, ..., n = NULL) {
136134
}
137135
}
138136

139-
#' @name show
137+
#' @method tbl_format_header tidyCoverageExperiment
140138
#' @export
141139

142140
tbl_format_header.tidyCoverageExperiment <- function(x, setup, ...) {
@@ -170,7 +168,7 @@ tbl_format_header.tidyCoverageExperiment <- function(x, setup, ...) {
170168
pillar::style_subtle(.pillar___format_comment(header, width=setup$width))
171169
}
172170

173-
#' @name show
171+
#' @method tbl_format_header tidyAggregatedCoverage
174172
#' @export
175173

176174
tbl_format_header.tidyAggregatedCoverage <- function(x, setup, ...) {

R/zzz.R

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#' tidyCoverage: Tidyomics-based analysis of coverage tracks over genomic features
2+
#'
3+
#' @description
4+
#' The tidyCoverage package provides a bridge between Bioconductor
5+
#' SummarizedExperiment objects and the tidyomics project.
6+
#'
7+
#' @references
8+
#' Serizay J, Koszul R., Epigenomics coverage data extraction and aggregation
9+
#' in R with tidyCoverage. Bioinformatics 40, btae487 (2024).
10+
#' \doi{10.1093/bioinformatics/btae487}
11+
#'
12+
#' @seealso
13+
#' Useful links:
14+
#' \itemize{
15+
#' \item \url{https://github.com/js2264/tidyCoverage}
16+
#' \item Report bugs at \url{https://github.com/js2264/tidyCoverage/issues}
17+
#' }
18+
#'
19+
#' @author Jacques Serizay
20+
#'
21+
#' @docType package
22+
#' @name tidyCoverage-package
23+
#' @aliases tidyCoverage
24+
#' @keywords internal
25+
"_PACKAGE"
26+
27+
#' @importFrom utils packageDescription
28+
.onAttach <- function(libname, pkgname) {
29+
attached <- tidyverse_attach()
30+
31+
# Print loading message about printing
32+
cli::cli_alert_info(paste0(
33+
"tidyCoverage says: The tidy printing is now handled externally.\n",
34+
"If you want to visualize the data in a tidy way, do `library(tidyprint)`.\n",
35+
"See `https://github.com/tidyomics/tidyprint` for more information."
36+
))
37+
}

man/as_tibble-AggregatedCoverage.Rd

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/as_tibble-methods.Rd

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)