bedtools like subtract in genomic ranges?
1
1
Entering edit mode
Jake ▴ 90
@jake-7236
Last seen 9 months ago
United States

Hi, I have two GenomicRanges lists. I was wondering if there is any way to subtract the ranges of one element from the ranges in another element exactly like bedtools subtract (http://bedtools.readthedocs.org/en/latest/content/tools/subtract.html)? Thanks

genomicranges • 2.4k views
ADD COMMENT
0
Entering edit mode
@martin-morgan-1513
Last seen 3 months ago
United States

For the two illustrated variations,

A = GRanges("A", IRanges(c(100, 200, 300), c(180, 220, 500)))
B = GRanges("A", IRanges(c(110, 320, 400), c(130, 350, 460)))

we have

> setdiff(A, B)
GRanges object with 6 ranges and 0 metadata columns:
      seqnames     ranges strand
         <Rle>  <IRanges>  <Rle>
  [1]        A [100, 109]      *
  [2]        A [131, 180]      *
  [3]        A [200, 220]      *
  [4]        A [300, 319]      *
  [5]        A [351, 399]      *
  [6]        A [461, 500]      *
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths

Or the -A option

> A[!A %over% B]
GRanges object with 1 range and 0 metadata columns:
      seqnames     ranges strand
         <Rle>  <IRanges>  <Rle>
  [1]        A [200, 220]      *
  -------
  seqinfo: 1 sequence from an unspecified genome; no seqlengths

These are for GRanges; if you have a GRangesList then it might help to show an example of the structures you're working with; psetdiff() might also be relevant.

ADD COMMENT

Login before adding your answer.

Traffic: 143 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