Sort

From BITS wiki
Jump to: navigation, search


sorting tabular text files

BED files often need top be sorted, if you use sortBed (from BEDTools), you may get chromosomes in a strange order like chr1, chr10, chr2 ...

To avoid this, you can instead sort naturally using GNU sort and ask for natural sorting for the chromosome column (1), then increasing numerical sorting for start and stop (2,3).

# The resulting command will look like this

sort -k 1V,1, -k 2n,2 -k 3n,3 unsorted.bed > sorted.bed



[ Main_Page ]