Stitch together ranges within a given distance, using excluded ranges as barriers that cannot be crossed
stitchRanges(x, exclude, maxgap = 12500L, ignore.strand = TRUE)
A GRanges object
Stitches together ranges within a given distance, using any ranges provided for exclusion as barriers between stitched ranges. This may be particularly useful if wanting to stitch enhancers whilst excluding promoters.
All inputs and outputs are Genomic Ranges objects
x <- GRanges(c("chr1:1-10", "chr1:101-110", "chr1:201-210", "chr2:1-10"))
y <- GRanges("chr1:200:+")
stitchRanges(x, exclude = y, maxgap = 100)
#> GRanges object with 3 ranges and 0 metadata columns:
#> seqnames ranges strand
#> <Rle> <IRanges> <Rle>
#> [1] chr1 1-110 *
#> [2] chr1 201-210 *
#> [3] chr2 1-10 *
#> -------
#> seqinfo: 2 sequences from an unspecified genome; no seqlengths