chop_by_introns {plyranges} | R Documentation

## Group a GRanges object by introns or gaps

### Description

Group a GRanges object by introns or gaps

### Usage

    chop_by_introns(x)

    chop_by_gaps(x)

### Arguments

`x` | a GenomicRanges object with a cigar string column

### Details

Creates a grouped Ranges object from a cigar string column, for `chop_by_introns()` will check for the presence of "N" in the cigar string and create a new column called `intron` where TRUE indicates the alignment has a skipped region from the reference. For `chop_by_gaps()` will check for the presence of "N" or "D" in the cigar string and create a new column called "gaps" where TRUE indicates the alignment has a deletion from the reference or has an intron.

### Value

a GRanges object

### Examples

    if (require(pasillaBamSubset)) {
       bamfile <- untreated1_chr4()
       # define a region of interest
       roi <- data.frame(seqnames = "chr4", start = 5e5, end = 7e5) %>%
                as_granges()
       # results in a grouped ranges object
       rng <- read_bam(bamfile) %>%
                filter_by_overlaps(roi) %>%
                chop_by_gaps()
       # to find ranges that have gaps use filter with `n()`
       rng %>% filter(n() >= 2)

    }

[Package plyranges version 1.14.0 Index]