Bedtools Error: Type checker found wrong number of fields while tokenizing data line.
Hi,
I get an error for having an extra tab but removing the extra tab does not solve the error, has anybody run into this?
cat bed1.txt bed2.txt | sort -k1,1 -k2,2n | mergeBed -i stdin > merged.bed
Error: Type checker found wrong number of fields while tokenizing data line. Perhaps you have extra TAB at the end of your line? Check with "cat -t"
sed 's/\t$//' bed1.txt > bed1.corrected.txt
Doesn't work. I also tried to replace all spaces/tabs and then reformat into a tab-delimited, but I get the same error.
awk '{$1=$1};1' bed1.txt | sed 's/ /\t/g' > bed1.corrected.txt
• 9,188 views
•
link
1 answer
So long as inputs have at least three columns, the following use of BEDOPS tools should work on inputs with different numbers of columns (or lines with lone tabs at the end):
$ cat bed1.txt bed2.txt | sort-bed - | bedops --merge - > answer.bed
The merged output will only have three columns.
• 1 views
•
link
Log in to answer this question.
did you try this ?
Yes; but shouldn't the sed command get rid of them?
none of your commands above remove the trailing tabs.
try
Hi Pierre, thank you, I have tried that but I still get the same error after doing that to each bed file: cat bed1.corrected.txt bed2.corrected.txt | sort -k1,1 -k2,2n | mergeBed -i stdin > merged.bed