Uses ChIPseeker::annotatePeak() to assign transcript-relative annotations (promoter, exon, intron, intergenic, etc.) to genomic windows in dataTable. If a genome is specified or globally set via setMesaGenome(), defaults and convenience datasets are applied for GRCh38. CpG island context and FANTOM enhancer overlaps can be added if the corresponding ranges are provided (or left NULL to use mesa defaults for GRCh38).

annotateWindows(
  dataTable,
  genome = .getMesaGenome(),
  TxDb = .getMesaTxDb(),
  annoDb = .getMesaAnnoDb(),
  CpGislandsGR = NULL,
  FantomRegionsGR = NULL
)

Arguments

dataTable

data.frame/tibble (coercible to GRanges) or GRanges. Windows to annotate. Data frames must include seqnames, start, and end (or columns convertible by qseaTableToChrGRanges()).

genome

character(1) or NULL. Guides annotation defaults. Currently supports "hg38"/"GRCh38". Default: value set by setMesaGenome() (via internal .getMesaGenome()), or NULL.

TxDb

TxDb object or character(1). Either an unquoted TxDb object or a string like "TxDb.Hsapiens.UCSC.hg38.knownGene". If character, it is resolved at runtime. Default: value set by setMesaTxDb() (via .getMesaTxDb()), or for GRCh38/hg38 when NULL, use TxDb.Hsapiens.UCSC.hg38.knownGene::TxDb.Hsapiens.UCSC.hg38.knownGene if installed.

annoDb

character(1) or NULL. OrgDb package name (e.g., "org.Hs.eg.db"). Default: value set by setMesaAnnoDb() (via .getMesaAnnoDb()), or for GRCh38/hg38 when NULL, use "org.Hs.eg.db" if installed.

CpGislandsGR

GRanges or NULL. CpG island regions for island/shore/shelf context. Default: NULL (for GRCh38/hg38, uses mesa::hg38CpGIslands).

FantomRegionsGR

GRanges or NULL. FANTOM enhancer regions for overlap counts. Default: NULL (for GRCh38/hg38, uses mesa::FantomRegions).

Value

A tibble with the input windows augmented by ChIPseeker annotations and, when available, CpG island landscape and Fantom overlap.

Details

  • Conversion: Non-GRanges inputs are converted via qseaTableToChrGRanges().

  • Genome-aware defaults (GRCh38/hg38): Missing TxDb/annoDb/contexts are filled using the packages noted above when installed.

  • Seqlevels style: Output seqnames have the "chr" prefix removed (e.g., "chr1" → "1").

  • ChIPseeker call: Uses tssRegion = c(-2000, 500), level = "transcript", overlap = "all", verbose = FALSE.

  • Output columns: Includes annotation (full label), shortAnno (without the trailing parenthetical), and—when contexts are provided—landscape (Island/Shore/Shelf/Open Sea) and inFantom (overlap count with FANTOM).

Examples

data(exampleTumourNormal, package = "mesa")

# Derive some regions (e.g., DMRs) once, then annotate them
dmrs <- exampleTumourNormal %>%
    calculateDMRs(variable = "tumour", contrasts = "first")
#> Calculating the first possible contrast on the tumour column.
#> Generating table of nrpm values for 819 regions across 10 samples.
#> Fitting initial GLM on 309 windows, without using parallelisation.
#> Performing contrast Normal_vs_Tumour
#> Contrasts Complete
#> selecting regions from contrast Normal_vs_Tumour
#> selected 23/309 windows
#> adding test results from Normal_vs_Tumour

if (requireNamespace("TxDb.Hsapiens.UCSC.hg38.knownGene", quietly = TRUE) &&
    requireNamespace("org.Hs.eg.db", quietly = TRUE) &&
    requireNamespace("GO.db", quietly = TRUE)) {
    # Annotate using GRCh38 defaults
    dmrs %>%
        annotateWindows(genome = "hg38")

    # Or specify TxDb/annoDb explicitly
    dmrs %>%
        annotateWindows(
            TxDb = "TxDb.Hsapiens.UCSC.hg38.knownGene",
            annoDb = "org.Hs.eg.db"
        )

    # You can also set defaults globally using setMesaGenome, setMesaTxDb
    # and setMesaAnnoDb (saving the current settings to restore them)
    oldOptions <- options("mesa_genome", "mesa_TxDb", "mesa_annoDb")
    setMesaGenome("hg38")
    setMesaTxDb("TxDb.Hsapiens.UCSC.hg38.knownGene")
    setMesaAnnoDb("org.Hs.eg.db")
    dmrs %>%
        annotateWindows()
    options(oldOptions)
}
#> 
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> Loading required package: org.Hs.eg.db
#> Loading required package: AnnotationDbi
#> Loading required package: Biobase
#> Welcome to Bioconductor
#> 
#>     Vignettes contain introductory material; view with
#>     'browseVignettes()'. To cite Bioconductor, see
#>     'citation("Biobase")', and for packages 'citation("pkgname")'.
#> 
#> Attaching package: ‘AnnotationDbi’
#> The following object is masked from ‘package:dplyr’:
#> 
#>     select
#> 'select()' returned 1:1 mapping between keys and columns
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> 'select()' returned 1:1 mapping between keys and columns
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> 'select()' returned 1:1 mapping between keys and columns