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) then annotate using GRCh38 defaults
if (requireNamespace("TxDb.Hsapiens.UCSC.hg38.knownGene", quietly = TRUE) &&
    requireNamespace("org.Hs.eg.db", quietly = TRUE)) {
  exampleTumourNormal %>%
    calculateDMRs(variable = "tumour", contrasts = "first") %>%
    annotateWindows(genome = "hg38")
}
#> 
#> 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
#> >> 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
#> # A tibble: 23 × 29
#>    seqnames    start      end CpG_density Normal_vs_Tumour_log2FC
#>    <fct>       <int>    <int>       <dbl>                   <dbl>
#>  1 7        27102901 27103200       10.8                   -1.94 
#>  2 7        27103501 27103800       13.1                   -1.88 
#>  3 7        27103801 27104100        7.83                  -1.33 
#>  4 7        27108301 27108600       15.7                   -1.18 
#>  5 7        27108601 27108900       16.1                   -0.933
#>  6 7        27144601 27144900       11.1                   -1.47 
#>  7 7        27144901 27145200       16.3                   -1.30 
#>  8 7        27156301 27156600       18.5                   -2.57 
#>  9 7        27159901 27160200        9.48                   1.16 
#> 10 7        27164701 27165000       13.8                   -2.25 
#> # ℹ 13 more rows
#> # ℹ 24 more variables: Normal_vs_Tumour_adjPval <dbl>,
#> #   Normal_vs_Tumour_deltaBeta <dbl>, annotation <chr>, geneChr <int>,
#> #   geneStart <int>, geneEnd <int>, geneLength <int>, geneStrand <int>,
#> #   geneId <chr>, transcriptId <chr>, distanceToTSS <dbl>, ENSEMBL <chr>,
#> #   SYMBOL <chr>, GENENAME <chr>, nIslands <int>, nShore <int>, nShelf <int>,
#> #   landscape <chr>, inFantom <int>, shortAnno <chr>, …

# \donttest{
# Or specify TxDb/annoDb explicitly
exampleTumourNormal %>%
  calculateDMRs(variable = "tumour", contrasts = "first") %>%
  annotateWindows(
    TxDb   = "TxDb.Hsapiens.UCSC.hg38.knownGene",
    annoDb = "org.Hs.eg.db"
  )
#> 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
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> 'select()' returned 1:1 mapping between keys and columns
#> # A tibble: 23 × 24
#>    seqnames    start      end CpG_density Normal_vs_Tumour_log2FC
#>    <fct>       <int>    <int>       <dbl>                   <dbl>
#>  1 7        27102901 27103200       10.8                   -1.94 
#>  2 7        27103501 27103800       13.1                   -1.88 
#>  3 7        27103801 27104100        7.83                  -1.33 
#>  4 7        27108301 27108600       15.7                   -1.18 
#>  5 7        27108601 27108900       16.1                   -0.933
#>  6 7        27144601 27144900       11.1                   -1.47 
#>  7 7        27144901 27145200       16.3                   -1.30 
#>  8 7        27156301 27156600       18.5                   -2.57 
#>  9 7        27159901 27160200        9.48                   1.16 
#> 10 7        27164701 27165000       13.8                   -2.25 
#> # ℹ 13 more rows
#> # ℹ 19 more variables: Normal_vs_Tumour_adjPval <dbl>,
#> #   Normal_vs_Tumour_deltaBeta <dbl>, annotation <chr>, geneChr <int>,
#> #   geneStart <int>, geneEnd <int>, geneLength <int>, geneStrand <int>,
#> #   geneId <chr>, transcriptId <chr>, distanceToTSS <dbl>, ENSEMBL <chr>,
#> #   SYMBOL <chr>, GENENAME <chr>, shortAnno <chr>, Normal_beta_means <dbl>,
#> #   Tumour_beta_means <dbl>, Normal_nrpm_means <dbl>, Tumour_nrpm_means <dbl>

# Mouse example (mm10): supply mouse TxDb and OrgDb
data(exampleMouse, package = "mesa")
exampleMouse %>%
  getRegions() %>%
  annotateWindows(
    TxDb   = "TxDb.Mmusculus.UCSC.mm10.knownGene",
    annoDb = "org.Mm.eg.db"
  )
#> >> Update txdb in cache...
#> >> Using Genome: mm10 ...
#> >> Using Genome: mm10 ...
#> >> Using Genome: mm10 ...
#> Loading required package: org.Mm.eg.db
#> 
#> 'select()' returned 1:1 mapping between keys and columns
#> # A tibble: 153 × 17
#>    seqnames     start       end CpG_density annotation geneChr geneStart geneEnd
#>    <fct>        <int>     <int>       <dbl> <chr>        <int>     <int>   <int>
#>  1 5        142501201 142501500        5.22 Intron (E…       5 142484839  1.43e8
#>  2 5        142506601 142506900        5.98 Exon (ENS…       5 142484839  1.43e8
#>  3 5        142508101 142508400        6.80 5' UTR           5 142484839  1.43e8
#>  4 5        142523701 142524000        5.22 Intron (E…       5 142484839  1.43e8
#>  5 5        142529401 142529700        5.86 Exon (ENS…       5 142484839  1.43e8
#>  6 5        142529701 142530000       14.9  5' UTR           5 142484839  1.43e8
#>  7 5        142530001 142530300       15.4  Promoter …       5 142525838  1.43e8
#>  8 5        142538401 142538700        5.25 Intron (E…       5 142484839  1.43e8
#>  9 5        142550401 142550700       11.0  Promoter …       5 142484839  1.43e8
#> 10 5        142550701 142551000       20.8  Promoter …       5 142543618  1.43e8
#> # ℹ 143 more rows
#> # ℹ 9 more variables: geneLength <int>, geneStrand <int>, geneId <chr>,
#> #   transcriptId <chr>, distanceToTSS <dbl>, ENSEMBL <chr>, SYMBOL <chr>,
#> #   GENENAME <chr>, shortAnno <chr>

# You can also set defaults globally using setMesaTxDb and setMesaAnnoDb:
  setMesaGenome("hg38"); 
  setMesaTxDb("TxDb.Hsapiens.UCSC.hg38.knownGene"); 
  setMesaAnnoDb("org.Hs.eg.db")
# }