Bedtools intersect with header file
1
0
Entering edit mode
4.4 years ago
irfanwustl ▴ 80

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 • 3.8k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

I have the same problem, have you resolved?

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
3.9 years ago

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 COMMENT

Login before adding your answer.

Traffic: 1797 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6