Entering edit mode
Is there an easy way to obtain the flank range and the flanked range in one GRanges object after calling flank()?
See the following example:
> gr1 <- GRanges(c(1,1),strand=Rle(c("+","-"),c(1,1)), IRanges(c(30,120), c(70,170)),mcols=data.frame(id=c("T1","T3"))) > gr1 GRanges object with 2 ranges and 1 metadata column: seqnames ranges strand | mcols.id <Rle> <IRanges> <Rle> | <factor> [1] 1 [ 30, 70] + | T1 [2] 1 [120, 170] - | T3 ------- seqinfo: 1 sequence from an unspecified genome; no seqlengths
flank(gr1, 10) > flank(gr1, 10) GRanges object with 2 ranges and 1 metadata column: seqnames ranges strand | mcols.id <Rle> <IRanges> <Rle> | <factor> [1] 1 [ 20, 29] + | T1 [2] 1 [171, 180] - | T3 ------- seqinfo: 1 sequence from an unspecified genome; no seqlengths
What I would like to get is:
> gr1 GRanges object with 2 ranges and 1 metadata column: seqnames ranges strand | mcols.id <Rle> <IRanges> <Rle> | <factor> [1] 1 [ 20, 70] + | T1 [2] 1 [120, 180] - | T3 ------- seqinfo: 1 sequence from an unspecified genome; no seqlengths
Any hint on this is greatly appreciated!
Thank you so much Valerie, that is quite smart (-: