From a0f9e870dd63ae6388f656eb97540b1e44fc5e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cigunduz=E2=80=9D?= Date: Sun, 23 Aug 2026 14:37:45 +0200 Subject: [PATCH 1/5] style package --- R/aaa-utils.R | 70 ++++++++++++++------------- R/getGCfreq.R | 18 +++---- R/getGenomeGC.R | 16 +++--- R/getTFbindsites.R | 18 +++---- man/getGCfreq.Rd | 2 +- man/getTFbindsites.Rd | 2 +- tests/testthat/test-accessors.R | 17 ++++--- vignettes/methylTFRAnnotationHg38.Rmd | 8 +-- 8 files changed, 78 insertions(+), 73 deletions(-) diff --git a/R/aaa-utils.R b/R/aaa-utils.R index e94f595..e2fba1d 100644 --- a/R/aaa-utils.R +++ b/R/aaa-utils.R @@ -1,16 +1,18 @@ #' @noRd -.local_dir <- function() { ... } +.local_dir <- function() { + ... +} .PKG_NAME <- "methylTFRAnnotationHg38" .MOTIF_SETS <- c("altius", "cisbpv2", "jaspar2020", "jaspar2020_distal") .ASSEMBLY <- "hg38" #' @keywords internal .local_dir <- function() { - d <- getOption( - "methylTFRAnnotationHg38.datadir", - Sys.getenv("METHYL_TFRANNOTATION_HG38_DIR", "") - ) - if (nzchar(d)) d else NULL + d <- getOption( + "methylTFRAnnotationHg38.datadir", + Sys.getenv("METHYL_TFRANNOTATION_HG38_DIR", "") + ) + if (nzchar(d)) d else NULL } #' @keywords internal @@ -22,37 +24,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)" - ) - } - 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 = ", ") - ) + 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)" + ) } - hits[[names(hits)[idx]]] + 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]]] } #' @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 3121416..2b3382a 100644 --- a/R/getGCfreq.R +++ b/R/getGCfreq.R @@ -3,28 +3,28 @@ #' @param motifSet Motif set to load. One of: altius, cisbpv2, jaspar2020, jaspar2020_distal. #' @return A named \code{list} of five-row matrices, one per motif. #' @examples -#' # 1. Create a dummy object and save it to a temporary directory +#' # 1. Create a dummy object and save it to a temporary directory #' # to bypass AnnotationHub during package checks. #' mock_dir <- tempdir() #' mock_file <- file.path(mock_dir, "altius_motif_gcfreq.rds") -#' +#' #' # (Mocking a 5-row matrix as expected by the function output) #' mock_data <- list(mock_motif_1 = matrix(0.25, nrow = 5, ncol = 4)) #' saveRDS(mock_data, mock_file) -#' +#' #' # 2. Temporarily point the package's local directory to tempdir() #' old_opt <- getOption("methylTFRAnnotationHg38.datadir") #' options(methylTFRAnnotationHg38.datadir = mock_dir) -#' +#' #' # 3. Run the function (it will now read the mock file) #' x <- getGCfreq(motifSet = "altius") -#' +#' #' # 4. Restore options and clean up the temporary file #' options(methylTFRAnnotationHg38.datadir = old_opt) #' file.remove(mock_file) -#' +#' #' @export getGCfreq <- function(motifSet = "altius") { - motifSet <- .check_motif_set(motifSet) - .resolve_resource(paste0(motifSet, "_motif_gcfreq.rds")) -} \ No newline at end of file + motifSet <- .check_motif_set(motifSet) + .resolve_resource(paste0(motifSet, "_motif_gcfreq.rds")) +} diff --git a/R/getGenomeGC.R b/R/getGenomeGC.R index b06974f..c8701eb 100644 --- a/R/getGenomeGC.R +++ b/R/getGenomeGC.R @@ -11,26 +11,26 @@ #' # 1. Create a dummy object and save it to a temp directory #' mock_dir <- tempdir() #' mock_file <- file.path(mock_dir, "genomewide_GC_hg38.rds") -#' +#' #' # Mocking a GRanges object with the expected metadata columns #' mock_gr <- GenomicRanges::GRanges("chr1:1-100") #' mock_gr$GC_bias <- 0.5 #' mock_gr$GC_bin <- 1L #' saveRDS(mock_gr, mock_file) -#' +#' #' # 2. Point the local directory option to the temp directory #' old_opt <- getOption("methylTFRAnnotationHg38.datadir") #' options(methylTFRAnnotationHg38.datadir = mock_dir) -#' +#' #' # 3. Run the function #' gc <- getGenomeGC() -#' +#' #' # 4. Restore options and clean up #' options(methylTFRAnnotationHg38.datadir = old_opt) #' file.remove(mock_file) -#' +#' #' @export getGenomeGC <- function(assembly = .ASSEMBLY) { - assembly <- tolower(assembly) - .resolve_resource(paste0("genomewide_GC_", assembly, ".rds")) -} \ No newline at end of file + assembly <- tolower(assembly) + .resolve_resource(paste0("genomewide_GC_", assembly, ".rds")) +} diff --git a/R/getTFbindsites.R b/R/getTFbindsites.R index b10b815..baddf62 100644 --- a/R/getTFbindsites.R +++ b/R/getTFbindsites.R @@ -7,26 +7,26 @@ #' # 1. Create a dummy object and save it to a temp directory #' mock_dir <- tempdir() #' 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) -#' +#' #' # 2. Point the local directory option to the temp directory #' old_opt <- getOption("methylTFRAnnotationHg38.datadir") #' options(methylTFRAnnotationHg38.datadir = mock_dir) -#' +#' #' # 3. Run the function #' x <- getTFbindsites() -#' +#' #' # 4. Restore options and clean up #' options(methylTFRAnnotationHg38.datadir = old_opt) #' file.remove(mock_file) -#' +#' #' @export getTFbindsites <- function(motifSet = "altius") { - motifSet <- .check_motif_set(motifSet) - .resolve_resource(paste0(motifSet, "_tf_bindsites.rds")) -} \ No newline at end of file + motifSet <- .check_motif_set(motifSet) + .resolve_resource(paste0(motifSet, "_tf_bindsites.rds")) +} diff --git a/man/getGCfreq.Rd b/man/getGCfreq.Rd index 2c4c66e..8ea9de0 100644 --- a/man/getGCfreq.Rd +++ b/man/getGCfreq.Rd @@ -16,7 +16,7 @@ A named \code{list} of five-row matrices, one per motif. Load the motif GC frequency table for a motif set. Downloaded from AnnotationHub on first use and cached locally thereafter. } \examples{ -# 1. Create a dummy object and save it to a temporary directory +# 1. Create a dummy object and save it to a temporary directory # to bypass AnnotationHub during package checks. mock_dir <- tempdir() mock_file <- file.path(mock_dir, "altius_motif_gcfreq.rds") diff --git a/man/getTFbindsites.Rd b/man/getTFbindsites.Rd index 83ff080..5252a30 100644 --- a/man/getTFbindsites.Rd +++ b/man/getTFbindsites.Rd @@ -22,7 +22,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 cb7d5cd..f26f831 100644 --- a/tests/testthat/test-accessors.R +++ b/tests/testthat/test-accessors.R @@ -1,16 +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(methylTFRAnnotationHg38:::.check_motif_set("ALTIUS"), "altius") + expect_identical(methylTFRAnnotationHg38:::.check_motif_set("ALTIUS"), "altius") }) test_that("metadata.csv covers every declared motif set", { - md <- utils::read.csv(system.file("extdata", "metadata.csv", package = "methylTFRAnnotationHg38")) - for (s in methylTFRAnnotationHg38:::.MOTIF_SETS) { - expect_true(any(grepl(paste0("^", s, "_"), md$Title)), - info = s) - } + md <- utils::read.csv(system.file("extdata", "metadata.csv", package = "methylTFRAnnotationHg38")) + for (s in methylTFRAnnotationHg38:::.MOTIF_SETS) { + expect_true(any(grepl(paste0("^", s, "_"), md$Title)), + info = s + ) + } }) diff --git a/vignettes/methylTFRAnnotationHg38.Rmd b/vignettes/methylTFRAnnotationHg38.Rmd index 0c3f4ef..9c018b0 100644 --- a/vignettes/methylTFRAnnotationHg38.Rmd +++ b/vignettes/methylTFRAnnotationHg38.Rmd @@ -39,7 +39,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")) @@ -64,8 +64,8 @@ options(methylTFRAnnotationHg38.datadir = mock_dir) library(methylTFRAnnotationHg38) tf_bindsites <- getTFbindsites("altius") -gcfreqs <- getGCfreq("altius") -gc_dist <- getGenomeGC() +gcfreqs <- getGCfreq("altius") +gc_dist <- getGenomeGC() ``` These are passed straight to `methylTFR::run_methyltfr()`. @@ -87,4 +87,4 @@ sessionInfo() ```{r cleanup, include = FALSE} # HIDDEN CHUNK: Clean up the options options(methylTFRAnnotationHg38.datadir = old_opt) -``` \ No newline at end of file +``` From 34e3fce15b32b1841a6efc0bc114ed42bb5d6fa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cigunduz=E2=80=9D?= Date: Sun, 23 Aug 2026 15:33:28 +0200 Subject: [PATCH 2/5] Fix some notes --- DESCRIPTION | 2 +- NEWS.md | 2 +- R/aaa-utils.R | 4 ---- R/getGCfreq.R | 6 ++++-- R/getTFbindsites.R | 6 ++++-- man/getGCfreq.Rd | 6 ++++-- man/getTFbindsites.Rd | 6 ++++-- vignettes/methylTFRAnnotationHg38.Rmd | 18 ++++++++++-------- 8 files changed, 28 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 66ddb73..d72054f 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.2 +Version: 0.99.3 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 ca40f5a..dbb6d8c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# methylTFRAnnotationHg38 0.99.0 +# methylTFRAnnotationHg38 0.99.3 * Initial submission to Bioconductor. diff --git a/R/aaa-utils.R b/R/aaa-utils.R index e2fba1d..e136419 100644 --- a/R/aaa-utils.R +++ b/R/aaa-utils.R @@ -1,7 +1,3 @@ -#' @noRd -.local_dir <- function() { - ... -} .PKG_NAME <- "methylTFRAnnotationHg38" .MOTIF_SETS <- c("altius", "cisbpv2", "jaspar2020", "jaspar2020_distal") .ASSEMBLY <- "hg38" diff --git a/R/getGCfreq.R b/R/getGCfreq.R index 2b3382a..5507f3a 100644 --- a/R/getGCfreq.R +++ b/R/getGCfreq.R @@ -1,6 +1,8 @@ #' @title getGCfreq -#' @description Load the motif GC frequency table for a motif set. Downloaded from AnnotationHub on first use and cached locally thereafter. -#' @param motifSet Motif set to load. One of: altius, cisbpv2, jaspar2020, jaspar2020_distal. +#' @description Load the motif GC frequency table for a motif set. +#' Downloaded from AnnotationHub on first use and cached locally thereafter. +#' @param motifSet Motif set to load. One of: altius, cisbpv2, jaspar2020, +#' jaspar2020_distal. #' @return A named \code{list} of five-row matrices, one per motif. #' @examples #' # 1. Create a dummy object and save it to a temporary directory diff --git a/R/getTFbindsites.R b/R/getTFbindsites.R index baddf62..d8082e0 100644 --- a/R/getTFbindsites.R +++ b/R/getTFbindsites.R @@ -1,6 +1,8 @@ #' @title getTFbindsites -#' @description Retrieve transcription factor binding sites for a motif set. Downloaded from AnnotationHub on first use and cached locally thereafter. -#' @param motifSet Motif set to load. One of: altius, cisbpv2, jaspar2020, jaspar2020_distal. +#' @description Retrieve transcription factor binding sites for a motif set. +#' Downloaded from AnnotationHub on first use and cached locally thereafter. +#' @param motifSet Motif set to load. One of: altius, cisbpv2, jaspar2020, +#' jaspar2020_distal. #' @return A \code{GRangesList}, one element per motif. #' @import GenomicRanges #' @examples diff --git a/man/getGCfreq.Rd b/man/getGCfreq.Rd index 8ea9de0..5d303b6 100644 --- a/man/getGCfreq.Rd +++ b/man/getGCfreq.Rd @@ -7,13 +7,15 @@ getGCfreq(motifSet = "altius") } \arguments{ -\item{motifSet}{Motif set to load. One of: altius, cisbpv2, jaspar2020, jaspar2020_distal.} +\item{motifSet}{Motif set to load. One of: altius, cisbpv2, jaspar2020, +jaspar2020_distal.} } \value{ A named \code{list} of five-row matrices, one per motif. } \description{ -Load the motif GC frequency table for a motif set. Downloaded from AnnotationHub on first use and cached locally thereafter. +Load the motif GC frequency table for a motif set. +Downloaded from AnnotationHub on first use and cached locally thereafter. } \examples{ # 1. Create a dummy object and save it to a temporary directory diff --git a/man/getTFbindsites.Rd b/man/getTFbindsites.Rd index 5252a30..5579a4d 100644 --- a/man/getTFbindsites.Rd +++ b/man/getTFbindsites.Rd @@ -7,13 +7,15 @@ getTFbindsites(motifSet = "altius") } \arguments{ -\item{motifSet}{Motif set to load. One of: altius, cisbpv2, jaspar2020, jaspar2020_distal.} +\item{motifSet}{Motif set to load. One of: altius, cisbpv2, jaspar2020, +jaspar2020_distal.} } \value{ A \code{GRangesList}, one element per motif. } \description{ -Retrieve transcription factor binding sites for a motif set. Downloaded from AnnotationHub on first use and cached locally thereafter. +Retrieve transcription factor binding sites for a motif set. +Downloaded from AnnotationHub on first use and cached locally thereafter. } \examples{ # 1. Create a dummy object and save it to a temp directory diff --git a/vignettes/methylTFRAnnotationHg38.Rmd b/vignettes/methylTFRAnnotationHg38.Rmd index 9c018b0..1aedc1c 100644 --- a/vignettes/methylTFRAnnotationHg38.Rmd +++ b/vignettes/methylTFRAnnotationHg38.Rmd @@ -7,7 +7,7 @@ vignette: > %\VignetteEncoding{UTF-8} --- -```{r, include = FALSE} +```{r setup, include = FALSE} knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ``` @@ -17,11 +17,11 @@ knitr::opts_chunk$set(collapse = TRUE, comment = "#>") compute bias-corrected transcription factor deviation scores on hg38: - **binding sites**, one `GRanges` per motif, each range extended - so that methylation can be read across the footprint window; + so that methylation can be read across the footprint window; - **motif GC frequency tables**, recording how each motif's binding - sites distribute across genome-wide GC quintiles; + sites distribute across genome-wide GC quintiles; - **the genome-wide GC distribution**, which assigns each - methylation call to a GC bin. + methylation call to a GC bin. The GC tables are what make the deviation score bias-corrected. A motif whose binding sites sit in GC-rich sequence will overlap CpG @@ -60,7 +60,7 @@ options(methylTFRAnnotationHg38.datadir = mock_dir) # Usage -```{r} +```{r usage} library(methylTFRAnnotationHg38) tf_bindsites <- getTFbindsites("altius") @@ -72,15 +72,17 @@ These are passed straight to `methylTFR::run_methyltfr()`. # Available motif sets -```{r, eval = FALSE} +```{r available_motifs, eval = FALSE} methylTFRAnnotationHg38:::.MOTIF_SETS ``` -Sets ending in `_distal` provide GC frequency tables computed over distal regulatory regions only. They share the unrestricted binding sites, so pass the base set name to `getTFbindsites()` and the `_distal` name to `getGCfreq()`. +Sets ending in `_distal` provide GC frequency tables computed over distal regulatory regions only. +They share the unrestricted binding sites, so pass the base set name to `getTFbindsites()` and +the `_distal` name to `getGCfreq()`. # Session info -```{r} +```{r session_info} sessionInfo() ``` From 08ee203253776646dca4da99413c506a6a396c04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cigunduz=E2=80=9D?= Date: Sun, 23 Aug 2026 15:52:40 +0200 Subject: [PATCH 3/5] fix notes --- .Rbuildignore | 15 ++++++ .github/.gitignore | 2 +- DESCRIPTION | 2 +- NEWS.md | 6 ++- R/aaa-utils.R | 70 +++++++++++++-------------- vignettes/methylTFRAnnotationHg38.Rmd | 10 ++-- 6 files changed, 61 insertions(+), 44 deletions(-) create mode 100644 .Rbuildignore 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..c470b3b 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/methylTFRAnnotationHg38/.github/workflows/check-bioc.yml \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index d72054f..58b5238 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.3 +Version: 0.99.4 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 dbb6d8c..ffa9932 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# methylTFRAnnotationHg38 0.99.3 +# methylTFRAnnotationHg38 0.99.4 * Initial submission to Bioconductor. @@ -12,4 +12,6 @@ * 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. \ No newline at end of file + are always binned on the same scale. + +* Fixes on NOTES from biocchecks \ No newline at end of file diff --git a/R/aaa-utils.R b/R/aaa-utils.R index e136419..c422f3f 100644 --- a/R/aaa-utils.R +++ b/R/aaa-utils.R @@ -4,11 +4,11 @@ #' @keywords internal .local_dir <- function() { - d <- getOption( - "methylTFRAnnotationHg38.datadir", - Sys.getenv("METHYL_TFRANNOTATION_HG38_DIR", "") - ) - if (nzchar(d)) d else NULL + d <- getOption( + "methylTFRAnnotationHg38.datadir", + Sys.getenv("METHYL_TFRANNOTATION_HG38_DIR", "") + ) + if (nzchar(d)) d else NULL } #' @keywords internal @@ -20,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 +} \ No newline at end of file diff --git a/vignettes/methylTFRAnnotationHg38.Rmd b/vignettes/methylTFRAnnotationHg38.Rmd index 1aedc1c..6680b32 100644 --- a/vignettes/methylTFRAnnotationHg38.Rmd +++ b/vignettes/methylTFRAnnotationHg38.Rmd @@ -39,7 +39,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")) @@ -76,9 +76,9 @@ These are passed straight to `methylTFR::run_methyltfr()`. methylTFRAnnotationHg38:::.MOTIF_SETS ``` -Sets ending in `_distal` provide GC frequency tables computed over distal regulatory regions only. -They share the unrestricted binding sites, so pass the base set name to `getTFbindsites()` and -the `_distal` name to `getGCfreq()`. +Sets ending in `_distal` provide GC frequency tables computed over distal regulatory regions only. +They share the unrestricted binding sites, so pass the base set name to `getTFbindsites()` +and the `_distal` name to `getGCfreq()`. # Session info @@ -89,4 +89,4 @@ sessionInfo() ```{r cleanup, include = FALSE} # HIDDEN CHUNK: Clean up the options options(methylTFRAnnotationHg38.datadir = old_opt) -``` +``` \ No newline at end of file From dd46223dad8a4425b83ba8a736681d9a7bbf4061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cigunduz=E2=80=9D?= Date: Sun, 23 Aug 2026 16:05:30 +0200 Subject: [PATCH 4/5] styling --- DESCRIPTION | 2 +- NEWS.md | 6 ++++-- R/aaa-utils.R | 2 +- R/getGCfreq.R | 4 ++-- R/getGenomeGC.R | 4 ++-- R/getTFbindsites.R | 6 +++--- man/getTFbindsites.Rd | 2 +- tests/testthat/test-accessors.R | 18 +++++++++--------- vignettes/methylTFRAnnotationHg38.Rmd | 2 +- 9 files changed, 24 insertions(+), 22 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 58b5238..f5d0c87 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.5 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 ffa9932..08ae1ab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# methylTFRAnnotationHg38 0.99.4 +# methylTFRAnnotationHg38 0.99.5 * Initial submission to Bioconductor. @@ -14,4 +14,6 @@ the object so that the motif frequency tables and the genome table are always binned on the same scale. -* Fixes on NOTES from biocchecks \ No newline at end of file +* 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 c422f3f..a3de1b2 100644 --- a/R/aaa-utils.R +++ b/R/aaa-utils.R @@ -55,4 +55,4 @@ ) } motifSet -} \ No newline at end of file +} diff --git a/R/getGCfreq.R b/R/getGCfreq.R index 5507f3a..a6cada0 100644 --- a/R/getGCfreq.R +++ b/R/getGCfreq.R @@ -27,6 +27,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 c8701eb..a4e4ca6 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 d8082e0..c363830 100644 --- a/R/getTFbindsites.R +++ b/R/getTFbindsites.R @@ -12,7 +12,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) #' @@ -29,6 +29,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 5579a4d..fd58c80 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 f26f831..41c6ef7 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(methylTFRAnnotationHg38:::.check_motif_set("ALTIUS"), "altius") + expect_identical(methylTFRAnnotationHg38:::.check_motif_set("ALTIUS"), "altius") }) test_that("metadata.csv covers every declared motif set", { - md <- utils::read.csv(system.file("extdata", "metadata.csv", package = "methylTFRAnnotationHg38")) - for (s in methylTFRAnnotationHg38:::.MOTIF_SETS) { - expect_true(any(grepl(paste0("^", s, "_"), md$Title)), - info = s - ) - } + md <- utils::read.csv(system.file("extdata", "metadata.csv", package = "methylTFRAnnotationHg38")) + for (s in methylTFRAnnotationHg38:::.MOTIF_SETS) { + expect_true(any(grepl(paste0("^", s, "_"), md$Title)), + info = s + ) + } }) diff --git a/vignettes/methylTFRAnnotationHg38.Rmd b/vignettes/methylTFRAnnotationHg38.Rmd index 6680b32..650df5f 100644 --- a/vignettes/methylTFRAnnotationHg38.Rmd +++ b/vignettes/methylTFRAnnotationHg38.Rmd @@ -89,4 +89,4 @@ sessionInfo() ```{r cleanup, include = FALSE} # HIDDEN CHUNK: Clean up the options options(methylTFRAnnotationHg38.datadir = old_opt) -``` \ No newline at end of file +``` From a0f2e9350d7085f3466d719eec8a6f1cfb81a907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cigunduz=E2=80=9D?= Date: Sun, 23 Aug 2026 17:08:46 +0200 Subject: [PATCH 5/5] update versions --- DESCRIPTION | 2 +- NEWS.md | 2 +- vignettes/methylTFRAnnotationHg38.Rmd | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f5d0c87..309c8e6 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.5 +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 08ae1ab..b32926b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# methylTFRAnnotationHg38 0.99.5 +# methylTFRAnnotationHg38 0.99.6 * Initial submission to Bioconductor. diff --git a/vignettes/methylTFRAnnotationHg38.Rmd b/vignettes/methylTFRAnnotationHg38.Rmd index 650df5f..31ee4b6 100644 --- a/vignettes/methylTFRAnnotationHg38.Rmd +++ b/vignettes/methylTFRAnnotationHg38.Rmd @@ -76,8 +76,9 @@ These are passed straight to `methylTFR::run_methyltfr()`. methylTFRAnnotationHg38:::.MOTIF_SETS ``` -Sets ending in `_distal` provide GC frequency tables computed over distal regulatory regions only. -They share the unrestricted binding sites, so pass the base set name to `getTFbindsites()` +Sets ending in `_distal` provide GC frequency tables computed +over distal regulatory regions only. They share the unrestricted +binding sites, so pass the base set name to `getTFbindsites()` and the `_distal` name to `getGCfreq()`. # Session info