Welcome to the world of bioinformatics :-)
Hello,
I am trying to use bedtools subtract in the following way:
$ bedtools subtract -a A.bed -b B.bed
but I get the following error:
ERROR: file A.bed has non positional records, which are only valid for the groupBy tool
When I tried to Google the answer, none of the solutions provided seemed to help. Here is the head of A.bed:
$ head A.bed
chr1 1 249250621
chr2 1 243199373
chr3 1 198022430
chr4 1 191154276
chr5 1 180915260
chr6 1 171115067
chr7 1 159138663
chrX 1 155270560
chr8 1 146364022
chr9 1 141213431
The cross checked that the columns are tab delimited and the three important columns are in the right order. Additionally, there are no invisible characters after the final column that might throw off Bedtools.
Any insight into the problem would be greatly appreciated!
1 answer
I found the solution. I made A.bed in Windows and B.bed in Linux, so the two files had conflicting end characters. When I turned the Windows end characters into Linux end characters, Bedtools started working properly again
We learn...do not use Windows in Bioinformatics ;-D
Hi could you please help me how to do this removal of end line characters because I face the same issue
Have you tried googling it? You can replace Windows CRLF line endings (\r\n) with Linux LF line endings (\n) or vice versa.
This fixed it for me.
One of my files had trailing carriage return characters (\r or ^M).
The invisible characters can be displayed with
cat -e polluted.bed
chr1 0 248956422^M$
chr10 0 133797422^M$
chr11 0 135086622^M$
Stripped them out with
cat polluted.bed | tr -d '\r' > clean.bed
To give
cat -e clean.bed
chr1 0 248956422$
chr10 0 133797422$
chr11 0 135086622$
Then bedtools worked properly.
Log in to answer this question.
Are the delimiters the same in both files?
I just checked, and they are. But I found out that the end characters for A.bed are windows end characters and B.bed are Linux end characters. After I fixed this issue, the program worked.