A.5 Restricting Ranges
The verb filter
can be used to restrict rows in the Ranges. Note that
grouping will cause the filter
to act within each group of the data.
#> GRanges object with 2 ranges and 1 metadata column:
#> seqnames ranges strand | gc
#> <Rle> <IRanges> <Rle> | <numeric>
#> [1] chr2 2-11 + | 0.180407
#> [2] chr1 5-14 - | 0.130289
#> -------
#> seqinfo: 2 sequences from an unspecified genome; no seqlengths
#> GRanges object with 2 ranges and 1 metadata column:
#> Groups: strand [2]
#> seqnames ranges strand | gc
#> <Rle> <IRanges> <Rle> | <numeric>
#> [1] chr2 1-10 - | 0.889454
#> [2] chr2 4-13 + | 0.989564
#> -------
#> seqinfo: 2 sequences from an unspecified genome; no seqlengths
We also provide the convenience methods filter_by_overlaps
and
filter_by_non_overlaps
for restricting by any overlapping Ranges.
#> IRanges object with 4 ranges and 0 metadata columns:
#> start end width
#> <integer> <integer> <integer>
#> [1] 5 9 5
#> [2] 10 14 5
#> [3] 15 19 5
#> [4] 20 24 5
#> IRanges object with 5 ranges and 0 metadata columns:
#> start end width
#> <integer> <integer> <integer>
#> [1] 2 4 3
#> [2] 3 6 4
#> [3] 4 8 5
#> [4] 5 10 6
#> [5] 6 12 7
#> IRanges object with 2 ranges and 0 metadata columns:
#> start end width
#> <integer> <integer> <integer>
#> [1] 5 9 5
#> [2] 10 14 5
#> IRanges object with 2 ranges and 0 metadata columns:
#> start end width
#> <integer> <integer> <integer>
#> [1] 15 19 5
#> [2] 20 24 5