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 66ddb73..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.2 +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 ca40f5a..b32926b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# methylTFRAnnotationHg38 0.99.0 +# methylTFRAnnotationHg38 0.99.6 * Initial submission to Bioconductor. @@ -12,4 +12,8 @@ * 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 + +* Added 4 spaces as suggested \ No newline at end of file diff --git a/R/aaa-utils.R b/R/aaa-utils.R index e94f595..a3de1b2 100644 --- a/R/aaa-utils.R +++ b/R/aaa-utils.R @@ -1,5 +1,3 @@ -#' @noRd -.local_dir <- function() { ... } .PKG_NAME <- "methylTFRAnnotationHg38" .MOTIF_SETS <- c("altius", "cisbpv2", "jaspar2020", "jaspar2020_distal") .ASSEMBLY <- "hg38" @@ -51,8 +49,10 @@ .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 = ", ")) + stop( + "Invalid motif set. Available: ", + paste(.MOTIF_SETS, collapse = ", ") + ) } motifSet } diff --git a/R/getGCfreq.R b/R/getGCfreq.R index 3121416..a6cada0 100644 --- a/R/getGCfreq.R +++ b/R/getGCfreq.R @@ -1,30 +1,32 @@ #' @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 +#' # 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 +} diff --git a/R/getGenomeGC.R b/R/getGenomeGC.R index b06974f..a4e4ca6 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 +} diff --git a/R/getTFbindsites.R b/R/getTFbindsites.R index b10b815..c363830 100644 --- a/R/getTFbindsites.R +++ b/R/getTFbindsites.R @@ -1,32 +1,34 @@ #' @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 #' # 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") #' ) #' 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 +} diff --git a/man/getGCfreq.Rd b/man/getGCfreq.Rd index 2c4c66e..5d303b6 100644 --- a/man/getGCfreq.Rd +++ b/man/getGCfreq.Rd @@ -7,16 +7,18 @@ 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 +# 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..fd58c80 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/tests/testthat/test-accessors.R b/tests/testthat/test-accessors.R index cb7d5cd..41c6ef7 100644 --- a/tests/testthat/test-accessors.R +++ b/tests/testthat/test-accessors.R @@ -11,6 +11,7 @@ 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) + info = s + ) } }) diff --git a/vignettes/methylTFRAnnotationHg38.Rmd b/vignettes/methylTFRAnnotationHg38.Rmd index 0c3f4ef..31ee4b6 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,31 +60,34 @@ options(methylTFRAnnotationHg38.datadir = mock_dir) # Usage -```{r} +```{r usage} 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()`. # 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() ``` ```{r cleanup, include = FALSE} # HIDDEN CHUNK: Clean up the options options(methylTFRAnnotationHg38.datadir = old_opt) -``` \ No newline at end of file +```