Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • dietmar13
    Senior Member
    • Mar 2010
    • 107

    intersect (actually: filter) a gtf file with coordinates from a bed-file

    -- SOLVED -- bedtools intersect

    hello,

    does someone know a script which filters a gtf-file with coordinates from a bed file.

    i have a bed-file with regions and want filter out all features from a gtf file which overlap (completely or largely) with this regions. is there a script or program? bedtools intersect does not work?

    i know, an awk-script would not be very difficult, but why re-invent the wheel...

    thank you,

    dietmar
    Last edited by dietmar13; 04-25-2013, 09:37 PM.
  • kmcarr
    Senior Member
    • May 2008
    • 1181

    #2
    Originally posted by dietmar13 View Post
    bedtools intersect does not work?
    Why do you say this? Seems like bedtools intersect with the '-v' option is exactly what you are looking for.

    Comment

    • dietmar13
      Senior Member
      • Mar 2010
      • 107

      #3
      @kmcarr

      thank you - you are right. i was misled by all the examples where only bed and bam files were used for bedtools intersect examples...

      dietmar

      Comment

      • vishal.rossi
        Member
        • Apr 2013
        • 25

        #4
        Hi,

        I am comparing 2 different files. 1st file has 113 entries and the 2nd one has 88 entries.
        I use the following command to get the differences
        intersectBed -v -a 1.bed -b 2.bed or
        intersectBed -v -wa -wb -a 1.bed -b 2.bed

        But it shows that only 3 entries don't match in both the cases which is false.
        Does anyone has the idea why?

        Thanks

        Comment

        • syfo
          Just a member
          • Nov 2012
          • 103

          #5
          Originally posted by vishal.rossi View Post
          I am comparing 2 different files. [...] I use the following command to get the differences [...] only 3 entries don't match
          What are you looking for exactly?
          IntersectBed with the "-v" parameter will show you the intervals from "1.bed" that have nothing in common with the ones in "2.bed". Entries from "2.bed" are not supposed to be reported.
          Also, one common nucleotide is enough by default to define an overlap between two intervals. For a more stringent criteria you might want to consider "-f" and "-r".

          Comment

          • AlexReynolds
            Member
            • Feb 2013
            • 45

            #6
            Another option is BEDOPS bedops, which does set operations on BED data, and BEDOPS gtf2bed, which does a lossless conversion of GTF data into BED format, which can be used with BEDOPS tools.

            Let's assume that your regions-of-interest are in a file called myRegions.bed and your GTF-formatted annotations are in a file called myAnnotations.gtf.

            First, we sort myRegions.bed:

            $ sort-bed myRegions.bed > mySortedRegions.bed

            Next, we convert the annotations to BED format:

            $ gtf2bed < myAnnotations.gtf > myAnnotations.bed

            Finally, we apply a --not-element-of set operation to show elements of the annotations file which do not overlap mySortedRegions.bed, if there is one or more bases of overlap (i.e., any overlap at all):

            $ bedops --not-element-of -1 myAnnotations.bed mySortedRegions.bed > myAnswer.bed

            As the gtf2bed conversion step was lossless, it is easy to convert myAnswer.bed back to GTF:

            $ awk '{print $1"\t"$7"\t"$8"\t"($2+1)"\t"$3"\t"$5"\t"$6"\t"$9"\t"(substr($0, index($0,$10)))}' myAnswer.bed > myAnswer.gtf
            Last edited by AlexReynolds; 05-21-2013, 12:05 PM.

            Comment

            • eieneg
              Junior Member
              • Feb 2017
              • 5

              #7
              To intersect coordinates

              Just use GFF-Intersector

              An R program capable of intersecting .GFF files and large files containg genomic co-ordinates and visualising the genome wide data. - PriceJon/GFF_Intersector


              it can intersect GFF files with multiple other coordinates!! have you got R? if so just 2 commands and you don't have to worry about the visualisation issue

              Comment

              Latest Articles

              Collapse

              • GATTACAT
                Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                by GATTACAT
                Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                07-01-2026, 11:43 AM
              • SEQadmin2
                Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                by SEQadmin2


                I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

                Here are nine questions we think about, in roughly the order they matter, before...
                06-18-2026, 07:11 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 07-02-2026, 11:08 AM
              0 responses
              12 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-30-2026, 05:37 AM
              0 responses
              14 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-26-2026, 11:10 AM
              0 responses
              20 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-17-2026, 06:09 AM
              0 responses
              54 views
              0 reactions
              Last Post SEQadmin2  
              Working...