Hello All,
I have a GRanges object that contains the coordinates of copy number variation regions in my data, and was wondering if there is already an associated GRanges function that allow me to merge segments if they are close enough (for example < =1 kb apart).
Below is a simplistic example of such data that. What I would like to have is a list that combines regions b-c on chr2 (because there are 1 unit apart) and similarly e-f-g on chr3.
Are there any existing GRanges functions for this?
Thanks for your time in advance.
> GRanges(seqnames = Rle(c("chr1", "chr2","chr3"), c(1, 3,3)),
ranges = IRanges(c(1,1,4,9,1,4,6),
end = c(2,3,7,12,3,5,10), names = head(letters, 7)))
GRanges object with 7 ranges and 0 metadata columns:
seqnames ranges strand
<Rle> <IRanges> <Rle>
a chr1 1-2 *
b chr2 1-3 *
c chr2 4-7 *
d chr2 9-12 *
e chr3 1-3 *
f chr3 4-5 *
g chr3 6-10 *
-------
seqinfo: 3 sequences from an unspecified genome; no seqlengths
Hah! I was right...
This was super useful and did the trick for my analysis. Thanks a lot James!