Annotate windows, then summarise signal and counts by CpG landscape (Island/Shore/Shelf/Open Sea) and short genomic annotation (e.g., Promoter/Exon/Intron/Intergenic).

getGenomicFeatureDistribution(
  qseaSet,
  cutoff = 1,
  normMethod = "nrpm",
  minEnrichment = 3
)

Arguments

qseaSet

qseaSet. Input object containing windows and signal. Default: none (must be supplied).

cutoff

numeric(1). Threshold used to call a window “over cutoff” for counting. Default: 1.

normMethod

character(1). Measure to summarise. One of "nrpm" or "beta". Default: "nrpm".

minEnrichment

integer(1). Minimum reads per window required for a non-NA beta (relevant when normMethod = "beta"). Default: 3.

Value

A tibble with columns: sample_name, landscape, shortAnno, nWindows, sum, nOverCutoff, followed by sample-table metadata joined from qseaSet.

Details

Windows are annotated via annotateWindows() (which can add CpG landscape and a concise shortAnno label). The function then groups by sample_name, landscape, and shortAnno to compute:

  • nWindows: number of windows in the group,

  • sum: sum of the selected measure across those windows,

  • nOverCutoff: number of windows with value >= cutoff. When using beta, windows failing minEnrichment are treated as NA before summarisation.

This function requires a transcript database and OrgDb to annotate windows (via annotateWindows()). Either:

  • set them globally with setMesaGenome() (recommended for GRCh38/hg38), or

  • provide compatible TxDb/annoDb packages yourself.

Examples

# Ensure annotation defaults are available (GRCh38/hg38), saving the
# current setting
oldGenome <- getOption("mesa_genome")
setMesaGenome("hg38")

data(exampleTumourNormal, package = "mesa")

# NRPM-based context summary
if (requireNamespace("TxDb.Hsapiens.UCSC.hg38.knownGene", quietly = TRUE) &&
    requireNamespace("org.Hs.eg.db", quietly = TRUE)) {
  exampleTumourNormal %>%
    getGenomicFeatureDistribution(cutoff = 1, normMethod = "nrpm") %>%
    head()
}
#> Generating table of nrpm values for 819 regions across 10 samples.
#> >> Update txdb in cache...
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> 'select()' returned 1:1 mapping between keys and columns
#> Joining with `by = join_by(landscape, sample_name)`
#> Joining with `by = join_by(landscape, sample_name)`
#> Joining with `by = join_by(shortAnno, sample_name)`
#> Joining with `by = join_by(shortAnno, nWindows, sample_name)`
#> Joining with `by = join_by(sample_name, sum, nOverCutoff, nWindows)`
#> Joining with `by = join_by(sample_name)`
#> # A tibble: 6 × 14
#>   sample_name landscape shortAnno nWindows   sum nOverCutoff group patient type 
#>   <chr>       <chr>     <chr>        <int> <dbl>       <int> <chr> <chr>   <chr>
#> 1 Colon1_N    Island    NA             206  358.          64 Colo… Colon1  Norm…
#> 2 Colon1_T    Island    NA             206  566.          68 Colo… Colon1  CRC  
#> 3 Colon2_N    Island    NA             206  327.          55 Colo… Colon2  Norm…
#> 4 Colon2_T    Island    NA             206  474.          89 Colo… Colon2  CRC  
#> 5 Lung1_N     Island    NA             206  201.          49 Lung… Lung1   Norm…
#> 6 Lung1_T     Island    NA             206  236.          54 Lung… Lung1   LUAD 
#> # ℹ 5 more variables: tumour <chr>, tissue <chr>, age <dbl>, gender <chr>,
#> #   stage <chr>

# \donttest{
# Beta-based summary (apply a minimum enrichment for non-NA betas)
exampleTumourNormal %>%
  getGenomicFeatureDistribution(
      cutoff = 0.7,
      normMethod = "beta",
      minEnrichment = 3
  ) %>%
  head()
#> Generating table of beta values for 819 regions across 10 samples.
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> >> Using Genome: hg38 ...
#> 'select()' returned 1:1 mapping between keys and columns
#> Joining with `by = join_by(landscape, sample_name)`
#> Joining with `by = join_by(landscape, sample_name)`
#> Joining with `by = join_by(shortAnno, sample_name)`
#> Joining with `by = join_by(shortAnno, nWindows, sample_name)`
#> Joining with `by = join_by(sample_name, sum, nOverCutoff, nWindows)`
#> Joining with `by = join_by(sample_name)`
#> # A tibble: 6 × 14
#>   sample_name landscape shortAnno nWindows   sum nOverCutoff group patient type 
#>   <chr>       <chr>     <chr>        <int> <dbl>       <int> <chr> <chr>   <chr>
#> 1 Colon1_N    Island    NA             206  43.7          22 Colo… Colon1  Norm…
#> 2 Colon1_T    Island    NA             206  58.2          45 Colo… Colon1  CRC  
#> 3 Colon2_N    Island    NA             206  42.0          20 Colo… Colon2  Norm…
#> 4 Colon2_T    Island    NA             206  50.4          22 Colo… Colon2  CRC  
#> 5 Lung1_N     Island    NA             206  35.5          15 Lung… Lung1   Norm…
#> 6 Lung1_T     Island    NA             206  45.3          16 Lung… Lung1   LUAD 
#> # ℹ 5 more variables: tumour <chr>, tissue <chr>, age <dbl>, gender <chr>,
#> #   stage <chr>
# }

# Restore the previous genome setting
options(mesa_genome = oldGenome)