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
        Essential Discoveries and Tools in Epitranscriptomics
        by seqadmin




        The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
        04-22-2024, 07:01 AM
      • seqadmin
        Current Approaches to Protein Sequencing
        by seqadmin


        Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
        04-04-2024, 04:25 PM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, Yesterday, 08:47 AM
      0 responses
      16 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-11-2024, 12:08 PM
      0 responses
      60 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 10:19 PM
      0 responses
      60 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 09:21 AM
      0 responses
      54 views
      0 likes
      Last Post seqadmin  
      Working...
      X