Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rkawa
    Junior Member
    • Jan 2014
    • 5

    #1

    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
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #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

    • rkawa
      Junior Member
      • Jan 2014
      • 5

      #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

      • SEQadmin2
        16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
        by SEQadmin2




        NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification, detection...
        Today, 06:46 AM
      • SEQadmin2
        Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
        by SEQadmin2



        Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

        Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
        ...
        10-14-2026, 09:55 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, 10-28-2026, 09:57 AM
      0 responses
      24 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-28-2026, 09:51 AM
      0 responses
      15 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-22-2026, 11:13 AM
      0 responses
      68 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-22-2026, 10:48 AM
      0 responses
      48 views
      0 reactions
      Last Post SEQadmin2  
      Working...