File: sort.rst

package info (click to toggle)
bedtools 2.26.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 55,328 kB
  • sloc: cpp: 37,989; sh: 6,930; makefile: 2,225; python: 163
file content (83 lines) | stat: -rwxr-xr-x 2,889 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
.. _sort:

###############
*sort*
###############
**sortBed** sorts a feature file by chromosome and other criteria.

==========================================================================
Usage and option summary
==========================================================================
Usage:

::
  sortBed [OPTIONS] -i <BED/GFF/VCF>

===========================      ===============================================================================================================================================================================================================
 Option                           Description
===========================      ===============================================================================================================================================================================================================
**-sizeA**				         Sort by feature size in ascending order.					 
**-sizeD**					     Sort by feature size in descending order.
**-chrThenSizeA**                Sort by chromosome, then by feature size (asc).
**-chrThenSizeD**                Sort by chromosome, then by feature size (desc).
**-chrThenScoreA**               Sort by chromosome, then by score (asc).
**-chrThenScoreD**               Sort by chromosome, then by score (desc).
===========================      ===============================================================================================================================================================================================================



==========================================================================
Default behavior
==========================================================================
By default, **sortBed** sorts a BED file by chromosome and then by start position in ascending order.

For example:

::
  cat A.bed
  chr1 800 1000
  chr1 80  180
  chr1 1   10
  chr1 750 10000

  sortBed -i A.bed
  chr1 1   10
  chr1 80  180
  chr1 750 10000
  chr1 800 1000


  
  
==========================================================================
Optional sorting behavior
==========================================================================
**sortBed** will also sorts a BED file by chromosome and then by other criteria.

For example, to sort by chromosome and then by feature size (in descending order):

::
  cat A.bed
  chr1 800 1000
  chr1 80  180
  chr1 1   10
  chr1 750 10000

  sortBed -i A.bed -sizeD
  chr1 750 10000
  chr1 800 1000
  chr1 80  180
  chr1 1   10
  

**Disclaimer:** it should be noted that **sortBed** is merely a convenience utility, as the UNIX sort utility
will sort BED files more quickly while using less memory. For example, UNIX sort will sort a BED file
by chromosome then by start position in the following manner:

::
  sort -k 1,1 -k2,2n a.bed
  chr1 1   10
  chr1 80  180
  chr1 750 10000
  chr1 800 1000