Question: Bedtools intersect with header file
0
gravatar for irfanwustl
10 months ago by
irfanwustl10
irfanwustl10 wrote:

I have two bedgraph files(a_h.bedgraph and b_h.bedgraph) with header. And I am running the following command:

bedtools intersect -header -wa -a a_h.bedgraph -b b_h.bedgraph

However I am getting the following error:

Error: unable to open file or unable to determine types for file a_h.bedgraph Please ensure that your file is TAB delimited (e.g., cat -t FILE). - Also ensure that your file has integer chromosome coordinates in the expected columns (e.g., cols 2 and 3 for BED).

When I remove the header from a_h.bedgraph and b_h.bedgraph, it works. Is there any way to keep the header after the intersection?

bedtools • 541 views
ADD COMMENTlink modified 4 months ago by Alex Reynolds31k • written 10 months ago by irfanwustl10

I am reasonably sure headers have to be indicated by #, is that the case with your file?

ADD REPLYlink modified 10 months ago • written 10 months ago by ATpoint40k

I have the same problem, have you resolved?

ADD REPLYlink written 8 months ago by User000400

Do you have headers? Did you make sure everything is tab-separated?

ADD REPLYlink written 8 months ago by ATpoint40k

Sorry for my late response. Actually, I could not resolve it. Is it a bug?

ADD REPLYlink modified 4 months ago • written 4 months ago by irfanwustl10

People, User000 and irfanwustl, simply saying "it does not work" is not an adequate error description. As asked twice now above, did you make sure your file is properly tab-separated and headers are indicated by a '#'? I am 99.99% sure this is not a bug and a problem with your files.

ADD REPLYlink written 4 months ago by ATpoint40k

Got it. Yes, the header was not indicated by '#'

ADD REPLYlink written 4 months ago by irfanwustl10

I actually solved the problem 4 months ago I guess, so I do not remember now what was the problem, but it was pretty easy at the end :) and I never said it does not work

ADD REPLYlink written 4 months ago by User000400
0
gravatar for Alex Reynolds
4 months ago by
Alex Reynolds31k
Seattle, WA USA
Alex Reynolds31k wrote:

If you use bash, one option is to use tools that support Unix streams:

$ bedops --intersect <(sort-bed A.txt) <(sort-bed B.txt) | cat <(head -1 A.txt) - > answer.bed

Replace head -1 with adjustments from -1 to whatever number of header lines you have in A.txt.

ADD COMMENTlink modified 4 months ago • written 4 months ago by Alex Reynolds31k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1956 users visited in the last hour