Question: Bedtools intersect with header file
0
gravatar for irfanwustl
8 months ago by
irfanwustl0
irfanwustl0 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 • 425 views
ADD COMMENTlink modified 8 weeks ago by Alex Reynolds30k • written 8 months ago by irfanwustl0

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

ADD REPLYlink modified 8 months ago • written 8 months ago by ATpoint36k

I have the same problem, have you resolved?

ADD REPLYlink written 6 months ago by User000380

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

ADD REPLYlink written 6 months ago by ATpoint36k

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

ADD REPLYlink modified 8 weeks ago • written 8 weeks ago by irfanwustl0

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 8 weeks ago by ATpoint36k

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

ADD REPLYlink written 8 weeks ago by irfanwustl0

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 8 weeks ago by User000380
0
gravatar for Alex Reynolds
8 weeks ago by
Alex Reynolds30k
Seattle, WA USA
Alex Reynolds30k 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 8 weeks ago • written 8 weeks ago by Alex Reynolds30k
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: 1363 users visited in the last hour