Flank GenomicRanges on Both Sides
1
0
Entering edit mode
Dario Strbenac ★ 1.5k
@dario-strbenac-5916
Last seen 4 days ago
Australia

Is it possible to reduce flanking on both sides (start and end) to a one-liner? Flank has only start parameter which is boolean of length 1. I suppose what I would like is something like flank(someRanges, where = "both", width = 1000).

GenomicRanges • 1.8k views
ADD COMMENT
0
Entering edit mode

You might provide an example of what you are after. It's not clear (to me at least) what 'reduce flanking' means in this context, given that flank isn't meant to reduce anything.

ADD REPLY
0
Entering edit mode

Sorry about the ambiguity in the sentence above. I meant reduce to a one-liner the operation of flanking both sides of a range. So, if the input range was chr1 10000 20000 and the width parameter was 1000, I am interested in obtaining the resulting range chr1 9000 21000. I can do it in a couple of lines, but I was wondering if there was an obscure combination of function parameters that would allow it to be computed in a single invocation of flank.

ADD REPLY
1
Entering edit mode

Personally I would have no idea what something like flank(someRanges, where = "both", width = 1000) does, unless I spend some time reading the man page (if I manage to find it ;-) ) Also I wouldn't necessarily see this operation as a flanking operation. It's more like the opposite of narrow(). So maybe we could use a new generic for that e.g. widen()?

ADD REPLY
3
Entering edit mode
@james-w-macdonald-5106
Last seen 14 minutes ago
United States

You are confusing flank, which gives you the flanking range, with resize, which is intended to, uh, resize the range.

> library(GenomicRanges)

> gr <- GRanges("chr1:10000-20000")
> gr
GRanges object with 1 range and 0 metadata columns:
      seqnames      ranges strand
         <Rle>   <IRanges>  <Rle>
  [1]     chr1 10000-20000      *
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
## get the 1000 nt flanking region
## e.g., the 1000 nt genomic region preceding the GRanges
> flank(gr, 1000)
GRanges object with 1 range and 0 metadata columns:
      seqnames    ranges strand
         <Rle> <IRanges>  <Rle>
  [1]     chr1 9000-9999      *
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths

## resize the GRanges to add 1000 nt to the start and end
> resize(gr, width(gr) + 2000, "center")
GRanges object with 1 range and 0 metadata columns:
      seqnames     ranges strand
         <Rle>  <IRanges>  <Rle>
  [1]     chr1 9000-21000      *
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths
ADD COMMENT

Login before adding your answer.

Traffic: 851 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6