A.8 Grouping by overlaps
It’s also possible to group by overlaps. Using this approach we can count the number of overlaps that are greater than 0.
#> IRanges object with 6 ranges and 2 metadata columns:
#> Groups: query [2]
#> start end width | gc query
#> <integer> <integer> <integer> | <numeric> <integer>
#> [1] 5 9 5 | 0.827303 1
#> [2] 5 9 5 | 0.603324 1
#> [3] 5 9 5 | 0.491232 1
#> [4] 5 9 5 | 0.780359 1
#> [5] 10 14 5 | 0.491232 2
#> [6] 10 14 5 | 0.780359 2
#> IRanges object with 6 ranges and 3 metadata columns:
#> Groups: query [2]
#> start end width | gc query n_overlaps
#> <integer> <integer> <integer> | <numeric> <integer> <integer>
#> [1] 5 9 5 | 0.827303 1 4
#> [2] 5 9 5 | 0.603324 1 4
#> [3] 5 9 5 | 0.491232 1 4
#> [4] 5 9 5 | 0.780359 1 4
#> [5] 10 14 5 | 0.491232 2 2
#> [6] 10 14 5 | 0.780359 2 2
Of course we can also add overlap counts via the count_overlaps()
function.
#> IRanges object with 4 ranges and 1 metadata column:
#> start end width | n_overlaps
#> <integer> <integer> <integer> | <integer>
#> [1] 5 9 5 | 4
#> [2] 10 14 5 | 2
#> [3] 15 19 5 | 0
#> [4] 20 24 5 | 0