I'm trying to use the bedtools closest function to compare a couple of datasets. It works fine however when trying to compare ranges from chromosomes with double digits, it seems not be able to make the comparison. For example:
chr9 222268 30116164 chr9 29909450 29909600 0
chr9 222268 30116164 chr9 29926499 29926649 0
chr9 222268 30116164 chr9 30050824 30050974 0
chr10 214399 8156391 . -1 -1 -1
chr15 19138465 20536973 . -1 -1 -1
chr15 83671081 100021943 . -1 -1 -1
Has anyone else had this problem and what can I do to fix it?
2 answers
In the absence of a test case to reproduce your problem it is hard to answer, but my gut feeling is that the files that you are using as input are not sorted in the same way. For instance, the order of chromosomes in one might be chr1, chr2, chr3, ..., chr10, chr11, ... in one file and chr1, chr10, chr11, ... chr19, chr2, chr3, ... in another one. The solution is then to sort all files the same way, for instance with sort -k1,1 -k2,2n.
Log in to answer this question.