annotate_regions {annotatr} | R Documentation

## A function to intersect user region data with annotation data

### Description

Annotate genomic regions to selected genomic annotations while preserving the data associated with the genomic regions.

### Usage

    annotate_regions(
      regions,
      annotations,
      minoverlap = 1L,
      ignore.strand = TRUE,
      quiet = FALSE
    )

### Arguments

`regions` | The GRanges object returned by `read_regions()`.
`annotations` | A character vector of annotations to build. Valid annotation codes are listed with `builtin_annotations()`. The "basicgenes" shortcut builds the following regions: 1-5Kb upstream of TSSs, promoters, 5UTRs, exons, introns, and 3UTRs. The "cpgs" shortcut builds the following regions: CpG islands, shores, shelves, and interCGI regions. NOTE: Shortcuts need to be appended by the genome, e.g. `hg19_basicgenes`. Custom annotations whose names are of the form `[genome]_custom_[name]` should also be included. Custom annotations should be read in and converted to `GRanges` with `read_annotations()`. They can be for a `supported_genome()`, or for an unsupported genome.
`minoverlap` | A scalar, positive integer, indicating the minimum required overlap of regions with annotations.
`ignore.strand` | Logical indicating whether strandedness should be respected in findOverlaps(). Default FALSE.
`quiet` | Print progress messages (FALSE) or not (TRUE).

### Value

A `GRanges` where the `granges` are from the regions, and the `mcols` include the `mcols` from the regions and a column with the annotation `GRanges`.

### Examples

       r_file = system.file('extdata', 'test_read_multiple_data_nohead.bed', package='annotatr')
       extraCols = c(pval = 'numeric', mu1 = 'integer', mu0 = 'integer', diff_exp = 'character')
       r = read_regions(con = r_file, extraCols = extraCols, rename_score = 'coverage')

       # Get premade CpG annotations
       data('annotations', package = 'annotatr')

       a = annotate_regions(
           regions = r,
           annotations = annotations,
           ignore.strand = TRUE)

[Package annotatr version 1.16.0 Index]