diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..01b8059 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,15 @@ +^LICENSE\.md$ +^README\.Rmd$ +^_pkgdown\.yml$ +^docs$ +^pkgdown$ +^\.github$ +^doc$ +^Meta$ +(^|/)\._ +(^|/)\.DS_Store$ +^\.Rhistory$ +^\.RData$ +^\.Ruserdata$ +^\.Rproj\.user$ +^\.github \ No newline at end of file diff --git a/.github/.gitignore b/.github/.gitignore index 1109a9b..95ac150 100644 --- a/.github/.gitignore +++ b/.github/.gitignore @@ -1,2 +1,2 @@ *.html -/icbb/projects/igunduz/methylTFR/.github/workflows/check-bioc.yml \ No newline at end of file +/icbb/projects/igunduz/methylTFRAnnotationMm10/.github/workflows/check-bioc.yml \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index a1c238c..122e548 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,7 +15,7 @@ Authors@R: person( comment = c(ORCID = "0000-0003-2641-0916")) License: Artistic-2.0 Encoding: UTF-8 -Version: 0.99.4 +Version: 0.99.6 Depends: R (>= 4.3.0) Imports: AnnotationHub, GenomicRanges, utils Suggests: knitr, rmarkdown, testthat (>= 3.0.0), BiocStyle diff --git a/NEWS.md b/NEWS.md index 5408960..06e4fdc 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,18 @@ -# methylTFRAnnotationsMm10 0.99.4 +# methylTFRAnnotationMm10 0.99.6 -- Fix some notes found in bioccheck \ No newline at end of file +* Initial submission to Bioconductor. + +* Provides transcription factor binding sites, motif GC frequency + tables and a genome-wide GC distribution for hg38, for the + jaspar2020, cisbpv2 and altius motif sets GC frequency tables. + +* Resources are hosted on AnnotationHub and downloaded on first use. + +* The genome-wide GC table uses non-overlapping 30 nt windows binned + into five genome-wide GC quintiles. Bin boundaries are recorded with + the object so that the motif frequency tables and the genome table + are always binned on the same scale. + +* Fixes on NOTES from biocchecks + +* Added 4 spaces as suggested \ No newline at end of file diff --git a/R/aaa-utils.R b/R/aaa-utils.R index 8e6fd34..20e83c0 100644 --- a/R/aaa-utils.R +++ b/R/aaa-utils.R @@ -1,18 +1,14 @@ -#' @noRd -.local_dir <- function() { - ... -} .PKG_NAME <- "methylTFRAnnotationMm10" .MOTIF_SETS <- c("altius", "cisbpv2", "jaspar2020") .ASSEMBLY <- "Mm10" #' @keywords internal .local_dir <- function() { - d <- getOption( - "methylTFRAnnotationMm10.datadir", - Sys.getenv("METHYL_TFRANNOTATION_Mm10_DIR", "") - ) - if (nzchar(d)) d else NULL + d <- getOption( + "methylTFRAnnotationMm10.datadir", + Sys.getenv("METHYL_TFRANNOTATION_Mm10_DIR", "") + ) + if (nzchar(d)) d else NULL } #' @keywords internal @@ -24,39 +20,39 @@ #' on the hub, and so users who have downloaded the files by hand #' can point at them. .resolve_resource <- function(file) { - dir <- .local_dir() - if (!is.null(dir)) { - path <- file.path(dir, file) - if (!file.exists(path)) { - stop( - "Annotation file not found: ", path, - "\n(reading from a local directory because ", - .PKG_NAME, ".datadir is set)" - ) + dir <- .local_dir() + if (!is.null(dir)) { + path <- file.path(dir, file) + if (!file.exists(path)) { + stop( + "Annotation file not found: ", path, + "\n(reading from a local directory because ", + .PKG_NAME, ".datadir is set)" + ) + } + return(readRDS(path)) } - return(readRDS(path)) - } - hub <- AnnotationHub::AnnotationHub() - hits <- AnnotationHub::query(hub, .PKG_NAME) - idx <- match(file, hits$title) - if (is.na(idx)) { - stop( - "Resource not found on AnnotationHub: ", file, - "\nAvailable: ", paste(hits$title, collapse = ", ") - ) - } - hits[[names(hits)[idx]]] + hub <- AnnotationHub::AnnotationHub() + hits <- AnnotationHub::query(hub, .PKG_NAME) + idx <- match(file, hits$title) + if (is.na(idx)) { + stop( + "Resource not found on AnnotationHub: ", file, + "\nAvailable: ", paste(hits$title, collapse = ", ") + ) + } + hits[[names(hits)[idx]]] } #' @keywords internal #' @noRd .check_motif_set <- function(motifSet) { - motifSet <- tolower(motifSet) - if (length(motifSet) != 1 || !motifSet %in% .MOTIF_SETS) { - stop( - "Invalid motif set. Available: ", - paste(.MOTIF_SETS, collapse = ", ") - ) - } - motifSet + motifSet <- tolower(motifSet) + if (length(motifSet) != 1 || !motifSet %in% .MOTIF_SETS) { + stop( + "Invalid motif set. Available: ", + paste(.MOTIF_SETS, collapse = ", ") + ) + } + motifSet } diff --git a/R/getGCfreq.R b/R/getGCfreq.R index b08dd43..ca61531 100644 --- a/R/getGCfreq.R +++ b/R/getGCfreq.R @@ -29,6 +29,6 @@ #' #' @export getGCfreq <- function(motifSet = "altius") { - motifSet <- .check_motif_set(motifSet) - .resolve_resource(paste0(motifSet, "_motif_gcfreq.rds")) + motifSet <- .check_motif_set(motifSet) + .resolve_resource(paste0(motifSet, "_motif_gcfreq.rds")) } diff --git a/R/getGenomeGC.R b/R/getGenomeGC.R index 0e5f9bb..498e9ee 100644 --- a/R/getGenomeGC.R +++ b/R/getGenomeGC.R @@ -31,6 +31,6 @@ #' #' @export getGenomeGC <- function(assembly = .ASSEMBLY) { - assembly <- tolower(assembly) - .resolve_resource(paste0("genomewide_GC_", assembly, ".rds")) + assembly <- tolower(assembly) + .resolve_resource(paste0("genomewide_GC_", assembly, ".rds")) } diff --git a/R/getTFbindsites.R b/R/getTFbindsites.R index 9c809cf..464648c 100644 --- a/R/getTFbindsites.R +++ b/R/getTFbindsites.R @@ -13,7 +13,7 @@ #' #' # Mocking a GRangesList as expected by the function output #' mock_grl <- GenomicRanges::GRangesList( -#' mock_motif_1 = GenomicRanges::GRanges("chr1:100-200") +#' mock_motif_1 = GenomicRanges::GRanges("chr1:100-200") #' ) #' saveRDS(mock_grl, mock_file) #' @@ -30,6 +30,6 @@ #' #' @export getTFbindsites <- function(motifSet = "altius") { - motifSet <- .check_motif_set(motifSet) - .resolve_resource(paste0(motifSet, "_tf_bindsites.rds")) + motifSet <- .check_motif_set(motifSet) + .resolve_resource(paste0(motifSet, "_tf_bindsites.rds")) } diff --git a/man/getTFbindsites.Rd b/man/getTFbindsites.Rd index 1bd4b28..ce92884 100644 --- a/man/getTFbindsites.Rd +++ b/man/getTFbindsites.Rd @@ -24,7 +24,7 @@ mock_file <- file.path(mock_dir, "altius_tf_bindsites.rds") # Mocking a GRangesList as expected by the function output mock_grl <- GenomicRanges::GRangesList( - mock_motif_1 = GenomicRanges::GRanges("chr1:100-200") + mock_motif_1 = GenomicRanges::GRanges("chr1:100-200") ) saveRDS(mock_grl, mock_file) diff --git a/tests/testthat/test-accessors.R b/tests/testthat/test-accessors.R index e9fb3ce..b98486e 100644 --- a/tests/testthat/test-accessors.R +++ b/tests/testthat/test-accessors.R @@ -1,17 +1,17 @@ test_that("motif set validation rejects unknown sets", { - expect_error(getGCfreq("not_a_motif_set"), "Invalid motif set") - expect_error(getGCfreq(c("a", "b")), "Invalid motif set") + expect_error(getGCfreq("not_a_motif_set"), "Invalid motif set") + expect_error(getGCfreq(c("a", "b")), "Invalid motif set") }) test_that("motif set validation is case insensitive", { - expect_identical(methylTFRAnnotationMm10:::.check_motif_set("ALTIUS"), "altius") + expect_identical(methylTFRAnnotationMm10:::.check_motif_set("ALTIUS"), "altius") }) test_that("metadata.csv covers every declared motif set", { - md <- utils::read.csv(system.file("extdata", "metadata.csv", package = "methylTFRAnnotationMm10")) - for (s in methylTFRAnnotationMm10:::.MOTIF_SETS) { - expect_true(any(grepl(paste0("^", s, "_"), md$Title)), - info = s - ) - } + md <- utils::read.csv(system.file("extdata", "metadata.csv", package = "methylTFRAnnotationMm10")) + for (s in methylTFRAnnotationMm10:::.MOTIF_SETS) { + expect_true(any(grepl(paste0("^", s, "_"), md$Title)), + info = s + ) + } }) diff --git a/vignettes/methylTFRAnnotationMm10.Rmd b/vignettes/methylTFRAnnotationMm10.Rmd index 0c5e8a2..c7835a2 100644 --- a/vignettes/methylTFRAnnotationMm10.Rmd +++ b/vignettes/methylTFRAnnotationMm10.Rmd @@ -30,8 +30,8 @@ hypomethylated; without the correction that difference in sequence composition would read as a difference in factor activity. The data are too large to ship inside the package, so they are -hosted on `AnnotationHub` and downloaded on first use. Subsequent -calls are served from the local `AnnotationHub` cache. +hosted on AnnotationHub and downloaded on first use. Subsequent +calls are served from the local AnnotationHub cache. ```{r dummy, include = FALSE} @@ -40,7 +40,7 @@ mock_dir <- tempdir() # 1. Mock TF bindsites mock_grl <- GenomicRanges::GRangesList( - mock_motif_1 = GenomicRanges::GRanges("chr1:100-200") + mock_motif_1 = GenomicRanges::GRanges("chr1:100-200") ) saveRDS(mock_grl, file.path(mock_dir, "altius_tf_bindsites.rds"))