Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
^\.RData$
^\.Ruserdata$
^\.Rproj\.user$
^\.github
^\.github
^CITATION\.cff$
37 changes: 37 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
cff-version: 1.2.0
message: "If you use methylTFRAnnotationMm10, please cite it as below."
type: software
title: "methylTFRAnnotationMm10: methylTFR annotations for mm10"
abstract: >-
Precomputed transcription factor binding sites, motif GC frequency tables
and a genome-wide GC distribution for the mouse (mm10) genome, for use with the
methylTFR package. The data are hosted on AnnotationHub and retrieved on
first use.
authors:
- family-names: Gunduz
given-names: Irem B.
email: irembgunduz@gmail.com
orcid: "https://orcid.org/0000-0003-2641-0916"
version: 0.99.10
date-released: "2026-09-29"
doi: 10.18129/B9.bioc.methylTFRAnnotationMm10
license: Artistic-2.0
repository-code: "https://github.com/EpigenomeInformatics/methylTFRAnnotationMm10"
keywords:
- R
- Bioconductor
- AnnotationHub
- DNA methylation
- transcription factor binding sites
references:
- type: software
title: "methylTFR: Quantification of DNA methylation signatures in TFBS"
authors:
- family-names: Gunduz
given-names: Irem B.
- family-names: Murugan
given-names: Sarath Kumar
- family-names: Mueller
given-names: Fabian
doi: 10.18129/B9.bioc.methylTFR
repository-code: "https://github.com/EpigenomeInformatics/methylTFR"
19 changes: 12 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@ Description: Precomputed transcription factor binding sites, motif GC
for sequence composition. The data are hosted on AnnotationHub and
retrieved on first use; this package provides the accessors and the
documentation.
Authors@R: person(
given = "Irem B.", family = "Gunduz",
email = "irembgunduz@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2641-0916"))
Authors@R: c(
person("Irem B.", "Gunduz", , "irembgunduz@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-2641-0916")),
person("ERA-NET Transcan-Neu III - EPILUNAR", role = "fnd",
comment = "Grant 01KT2409"),
person("Saarland University", role = "fnd",
comment = "NanoBioMed Young Investigator Grant")
)
License: Artistic-2.0
Encoding: UTF-8
Version: 0.99.9
Version: 0.99.10
Depends: R (>= 4.3.0)
Imports: AnnotationHub, GenomicRanges, utils
Imports: AnnotationHub, GenomicRanges, stats
Suggests: knitr, rmarkdown, testthat (>= 3.0.0), BiocStyle
VignetteBuilder: knitr
biocViews: AnnotationData, AnnotationHub, FunctionalAnnotation,
SequenceAnnotation, Homo_sapiens
SequenceAnnotation, Mus_musculus
BugReports: https://github.com/EpigenomeInformatics/methylTFRAnnotationMm10/issues
URL: https://github.com/EpigenomeInformatics/methylTFRAnnotationMm10
Roxygen: list(markdown = FALSE)
RoxygenNote: 7.3.3
Config/testthat/edition: 3
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(availableMotifSets)
export(getGCfreq)
export(getGenomeGC)
export(getTFbindsites)
import(GenomicRanges)
importFrom(utils,packageVersion)
importFrom(GenomicRanges,GRanges)
37 changes: 34 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
# methylTFRAnnotationMm10 0.99.10

Changes in response to the Bioconductor review:

* `Authors@R` lists the funders (ERA-NET Transcan-Neu III - EPILUNAR,
grant 01KT2409; Saarland University NanoBioMed Young Investigator
Grant) with the `fnd` role.

* New package help page `?methylTFRAnnotationMm10` summarising the resources and
linking the accessors.

* New help pages describing the structure of each AnnotationHub resource
listed in `inst/extdata/metadata.csv`: `?motif_gcfreq`
(`?altius_motif_gcfreq`, ...), `?tf_bindsites`
(`?altius_tf_bindsites`, ...) and `?genomewide_GC`
(`?genomewide_GC_mm10`).

* New exported `availableMotifSets()` listing the accepted motif sets.

* `getGenomeGC()` accepts `"mm10"` (or no argument) and gives an
informative error for any other assembly.

* biocViews: `Mus_musculus` instead of `Homo_sapiens`.

* Unit tests now cover the local-directory and AnnotationHub code paths
(the hub is mocked, so the tests run offline).

* The vignette no longer hides code: the synthetic example data are
built in a visible chunk, every chunk is evaluated, and each accessor's
output is printed and explained.

# methylTFRAnnotationMm10 0.99.9

* 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.
tables and a genome-wide GC distribution for mm10, for the
jaspar2020, cisbpv2 and altius motif sets.

* Resources are hosted on AnnotationHub and downloaded on first use.

Expand All @@ -15,4 +46,4 @@

* Fixes on NOTES from biocchecks

* Added 4 spaces as suggested
* Added 4 spaces as suggested
52 changes: 42 additions & 10 deletions R/aaa-utils.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
.PKG_NAME <- "methylTFRAnnotationMm10"
.MOTIF_SETS <- c("altius", "cisbpv2", "jaspar2020")
.ASSEMBLY <- "Mm10"
.ASSEMBLY <- "mm10"

#' @keywords internal
#' @noRd
.local_dir <- function() {
d <- getOption(
"methylTFRAnnotationMm10.datadir",
Sys.getenv("METHYL_TFRANNOTATION_Mm10_DIR", "")
)
if (nzchar(d)) d else NULL
if (is.character(d) && length(d) == 1L && nzchar(d)) d else NULL
}

#' @keywords internal
#' @noRd
#' @description AnnotationHub records belonging to this package, as a
#' character vector of titles named by AnnotationHub ID. Kept separate
#' from .resolve_resource() so the lookup logic can be unit-tested
#' without network access.
.hub_titles <- function() {
hub <- AnnotationHub::AnnotationHub()
hits <- AnnotationHub::query(hub, .PKG_NAME)
stats::setNames(hits$title, names(hits))
}

#' @keywords internal
#' @noRd
.hub_get <- function(id) {
AnnotationHub::AnnotationHub()[[id]]
}

#' @keywords internal
Expand All @@ -32,27 +51,40 @@
}
return(readRDS(path))
}
hub <- AnnotationHub::AnnotationHub()
hits <- AnnotationHub::query(hub, .PKG_NAME)
idx <- match(file, hits$title)
titles <- .hub_titles()
idx <- match(file, titles)
if (is.na(idx)) {
stop(
"Resource not found on AnnotationHub: ", file,
"\nAvailable: ", paste(hits$title, collapse = ", ")
"\nAvailable: ", paste(titles, collapse = ", ")
)
}
hits[[names(hits)[idx]]]
.hub_get(names(titles)[idx])
}

#' @keywords internal
#' @noRd
.check_motif_set <- function(motifSet) {
motifSet <- tolower(motifSet)
if (length(motifSet) != 1 || !motifSet %in% .MOTIF_SETS) {
if (!is.character(motifSet) || length(motifSet) != 1L ||
is.na(motifSet) || !tolower(motifSet) %in% .MOTIF_SETS) {
stop(
"Invalid motif set. Available: ",
paste(.MOTIF_SETS, collapse = ", ")
)
}
motifSet
tolower(motifSet)
}

#' @title List the motif sets provided by this package
#' @description Returns the names accepted by the \code{motifSet}
#' argument of \code{\link{getTFbindsites}} and
#' \code{\link{getGCfreq}}.
#' @return A character vector of motif set names.
#' @seealso \code{\link{methylTFRAnnotationMm10}} for an overview of the
#' package.
#' @examples
#' availableMotifSets()
#' @export
availableMotifSets <- function() {
.MOTIF_SETS
}
60 changes: 34 additions & 26 deletions R/getGCfreq.R
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
#' @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.
#' @return A named \code{list} of five-row matrices, one per motif.
#' @import GenomicRanges
#' @importFrom utils packageVersion
#' @title Load motif GC frequency tables
#' @description Load the motif GC frequency tables for a motif set.
#' Downloaded from AnnotationHub on first use and cached locally
#' thereafter.
#' @details Each table describes the GC composition around one motif's
#' binding sites. Column \eqn{j} corresponds to the \eqn{j}-th 30 nt
#' window along the (extended) binding site; row \eqn{i} gives the
#' fraction of binding sites whose window at that position falls into
#' genome-wide GC quintile \eqn{i} (row 1 lowest, row 5 highest GC).
#' Columns therefore sum to one. \pkg{methylTFR} combines these
#' fractions with the observed methylation per GC bin to obtain the
#' methylation a motif would be expected to show from sequence
#' composition alone. See \code{\link{motif_gcfreq}} for the data
#' format.
#' @param motifSet Motif set to load. One of
#' \code{availableMotifSets()}: \code{altius}, \code{cisbpv2},
#' \code{jaspar2020}. Case-insensitive.
#' @return A named \code{list} of numeric matrices with five rows (GC
#' quintiles), one matrix per motif.
#' @seealso \code{\link{motif_gcfreq}}, \code{\link{getTFbindsites}},
#' \code{\link{getGenomeGC}}
#' @examples
#' # 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")
#' # Point the package at a temporary directory holding a small mock
#' # table so the example runs without downloading from AnnotationHub.
#' mock_dir <- file.path(tempdir(), "gcfreq_example")
#' dir.create(mock_dir, showWarnings = FALSE)
#' freq <- matrix(c(0.1, 0.2, 0.4, 0.2, 0.1), nrow = 5, ncol = 3)
#' saveRDS(list(MA0001.1 = freq), file.path(mock_dir,
#' "altius_motif_gcfreq.rds"))
#' old_opt <- options(methylTFRAnnotationMm10.datadir = mock_dir)
#'
#' # (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("methylTFRAnnotationMm10.datadir")
#' options(methylTFRAnnotationMm10.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(methylTFRAnnotationMm10.datadir = old_opt)
#' file.remove(mock_file)
#' gcfreqs <- getGCfreq("altius")
#' gcfreqs$MA0001.1
#' colSums(gcfreqs$MA0001.1)
#'
#' options(old_opt)
#' unlink(mock_dir, recursive = TRUE)
#' @export
getGCfreq <- function(motifSet = "altius") {
motifSet <- .check_motif_set(motifSet)
Expand Down
66 changes: 37 additions & 29 deletions R/getGenomeGC.R
Original file line number Diff line number Diff line change
@@ -1,36 +1,44 @@
#' @title getGenomeGC
#' @description Load the genome-wide GC distribution.
#' @title Load the genome-wide GC distribution
#' @description Load the genome-wide GC distribution for mm10.
#' Downloaded from AnnotationHub on first use and cached locally
#' thereafter.
#' @param assembly Genome assembly. Defaults to the assembly this
#' package was built for.
#' @return A \code{GRanges} with GC_bias and GC_bin metadata columns.
#' @import GenomicRanges
#' @importFrom utils packageVersion
#' @examples
#' # 1. Create a dummy object and save it to a temporary directory
#' mock_dir <- tempdir()
#' mock_file <- file.path(mock_dir, "genomewide_GC_mm10.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)
#' @details The genome is tiled into non-overlapping 30 nt windows. Each
#' window carries its GC fraction and its genome-wide GC quintile.
#' \pkg{methylTFR} uses the table to assign every methylation call to
#' a GC bin. See \code{\link{genomewide_GC}} for the data format.
#'
#' # 2. Temporarily point the package to tempdir
#' old_opt <- getOption("methylTFRAnnotationMm10.datadir")
#' options(methylTFRAnnotationMm10.datadir = mock_dir)
#'
#' # 3. Run the function
#' gc <- getGenomeGC()
#' The package serves a single assembly, so the argument can be left
#' out. It is kept so that code written as
#' \code{getGenomeGC("mm10")} works; any other assembly is an error.
#' @param assembly Genome assembly. Only \code{"mm10"} (the default)
#' is available in this package; case-insensitive.
#' @return A \code{GRanges} with metadata columns \code{GC_bias} (GC
#' fraction of the window) and \code{GC_bin} (quintile, 1 to 5).
#' @seealso \code{\link{genomewide_GC}}, \code{\link{getGCfreq}}
#' @examples
#' # Point the package at a temporary directory holding a small mock
#' # object so the example runs without downloading from AnnotationHub.
#' mock_dir <- file.path(tempdir(), "genomegc_example")
#' dir.create(mock_dir, showWarnings = FALSE)
#' gr <- GenomicRanges::GRanges(c("chr1:1-30", "chr1:31-60", "chr1:61-90"))
#' gr$GC_bias <- c(0.30, 0.43, 0.63)
#' gr$GC_bin <- c(1L, 3L, 5L)
#' saveRDS(gr, file.path(mock_dir, "genomewide_GC_mm10.rds"))
#' old_opt <- options(methylTFRAnnotationMm10.datadir = mock_dir)
#'
#' # 4. Restore options and clean up
#' options(methylTFRAnnotationMm10.datadir = old_opt)
#' file.remove(mock_file)
#' getGenomeGC()
#'
#' options(old_opt)
#' unlink(mock_dir, recursive = TRUE)
#' @export
getGenomeGC <- function(assembly = .ASSEMBLY) {
assembly <- tolower(assembly)
.resolve_resource(paste0("genomewide_GC_", assembly, ".rds"))
getGenomeGC <- function(assembly = "mm10") {
if (!is.character(assembly) || length(assembly) != 1L ||
is.na(assembly) || tolower(assembly) != .ASSEMBLY) {
stop(
.PKG_NAME, " provides the GC distribution for ", .ASSEMBLY,
" only. Call getGenomeGC() without arguments, or load the ",
"methylTFR annotation package for the assembly you need."
)
}
.resolve_resource(paste0("genomewide_GC_", .ASSEMBLY, ".rds"))
}
Loading
Loading