Entering edit mode
Hi there,
Is there a way to bin a GRanges object to small bins?
gr<- GRanges(seqname="chr1", ranges=IRanges(start=c(600,1000),width=1), strand="+") > gr GRanges object with 2 ranges and 0 metadata columns: seqnames ranges strand <Rle> <IRanges> <Rle> [1] chr1 [ 600, 600] + [2] chr1 [1000, 1000] + ------- seqinfo: 1 sequence from an unspecified genome; no seqlengths
I want to extend each point to 200 bp width and bin each interval to 20 * 10bp bin. In the end I want:
seqnames ranges strand <Rle> <IRanges> <Rle> [1] chr1 [ 500, 510] + [2] chr1 [ 510, 520] + [3] chr1 [ 520, 530] + ............. [11] chr1 [600, 610] + [12] chr1 [620, 630] + ........ [20] chr1 [690, 700] ..... chr1[1090, 1100] +
I can do something like:
start(gr) + seq (-100, 90, length.out=20)
and then reconstruct a GRanges object. I want to know if there is an easier way to do it.
Thanks very much!
Ming
Thanks Michael! This saves me a lot! There are just too many functions I am not aware of...
Yea, it took me like 10 minutes to remember that one. And I wrote it. No chance I would have found it otherwise.
methods(class="GRanges")
provides some hints, of which tile is the 117th, so maybe not no chance.