Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Obtain unique no overlapping region of bed file

    Hello. I have a bed file that contains exons of all mouse ensembl genes. I am trying to get UNIQUE regions which have no overlapping with other ensembl genes. I thought there should be some tools for this, but I haven't been able find one that works. All the tools I found do not remove overlapping regions. Here is a simple example

    chr1 10 20 gene1
    chr1 15 22 gene2
    chr1 20 25 gene3

    the result should be
    chr1 10 14 gene1
    chr1 23 25 gene3

    I think this is possible with algorithm using bedtools subtract. But if anyone knows there is a simpler way to do it, I highly appreciate!

    Thanks,

    RK

  • #2
    An example in R:
    Code:
    library(GenomicRanges)
    gr <- GRanges(seqnames=c(rep("1",5)), ranges=IRanges(start=c(10,15,20,25,30), end=c(20,21,30,40,35)))
    dis <- disjoin(gr) #Make disjoint ranges
    res <- dis[countOverlaps(dis,gr)==1] #subset by those bins overlapping only 1 original entry
    In case you're wondering, the input data ("gr") looks like this:
    Code:
          seqnames    ranges strand
             <Rle> <IRanges>  <Rle>
      [1]        1  [10, 20]      *
      [2]        1  [15, 21]      *
      [3]        1  [20, 30]      *
      [4]        1  [25, 40]      *
      [5]        1  [30, 35]      *
    The disjoint bins ("dis") are then:
    Code:
             <Rle> <IRanges>  <Rle>
      [1]        1  [10, 14]      *
      [2]        1  [15, 19]      *
      [3]        1  [20, 20]      *
      [4]        1  [21, 21]      *
      [5]        1  [22, 24]      *
      [6]        1  [25, 29]      *
      [7]        1  [30, 30]      *
      [8]        1  [31, 35]      *
      [9]        1  [36, 40]      *
    So the results ("res") are:
    Code:
             <Rle> <IRanges>  <Rle>
      [1]        1  [10, 14]      *
      [2]        1  [22, 24]      *
      [3]        1  [36, 40]      *
    bedtools is very likely faster, but it's often nice to use R since it's convenient for debugging.

    Comment


    • #3
      Excellent. I split original bed files by chromosome names, then run the script.
      After that I concatenate the resulting uniq exon bed files into one.
      bedtools intersect with original bed file allows to add gene annotation.

      Thanks you so much.

      Comment

      Latest Articles

      Collapse

      • seqadmin
        Strategies for Sequencing Challenging Samples
        by seqadmin


        Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
        03-22-2024, 06:39 AM
      • seqadmin
        Techniques and Challenges in Conservation Genomics
        by seqadmin



        The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

        Avian Conservation
        Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
        03-08-2024, 10:41 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, 03-27-2024, 06:37 PM
      0 responses
      12 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 03-27-2024, 06:07 PM
      0 responses
      11 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 03-22-2024, 10:03 AM
      0 responses
      53 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 03-21-2024, 07:32 AM
      0 responses
      69 views
      0 likes
      Last Post seqadmin  
      Working...
      X