# odgi sort¶

sort a variation graph

## SYNOPSIS¶

**odgi sort** [**-i, –idx**=*FILE*] [**-o, –out**=*FILE*]
[*OPTION*]…

## DESCRIPTION¶

The odgi sort(1) command sorts a succinct variation graph. Odgi sort offers a diverse palette of sorting algorithms to determine the node order:

A topological sort: A graph can be sorted via breadth-first search (BFS) or depth-first search (DFS). Optionally, a chunk size specifies how much of the graph to grab at once in each topological sorting phase. The sorting algorithm will continue the sort from the next node in the prior graph order that has not been sorted, yet. The cycle breaking algorithm applies a DFS sort until a cycle is found. We break and start a new DFS sort phase from where we stopped.

A random sort: The graph is randomly sorted. The node order is randomly shuffled from Mersenne Twister pseudo-random generated numbers.

A 1D linear SGD sort: Odgi implements a 1D linear, variation graph adjusted, multi-threaded version of the Graph Drawing by Stochastic Gradient Descent algorithm. The force-directed graph drawing algorithm minimizes the graph’s energy function or stress level. It applies stochastic gradient descent (SGD) to move a single pair of nodes at a time.

A path guided, 1D linear SGD sort: Odgi implements a 1D linear, variation graph adjusted, multi-threaded version of the Graph Drawing by Stochastic Gradient Descent algorithm. The force-directed graph drawing algorithm minimizes the graph’s energy function or stress level. It applies stochastic gradient descent (SGD) to move a single pair of nodes at a time. The path index is used to pick the terms to move stochastically. If ran with 1 thread only, the resulting order of the graph is deterministic. The seed is adjustable.

Sorting the paths in a graph my refine the sorting process. For the users’ convenience, it is possible to specify a whole pipeline of sorts within one parameter.

## OPTIONS¶

### Graph Files IO¶

**-i, –idx**=

*FILE*

*.og*.

**-o, –out**=

*FILE*

*.og*is recommended.

**-s, –sort-order**=

*FILE*

### Topological Sorts¶

**-b, –breadth-first**

**-B, –breadth-first-chunk**=

*N*

**-z, –depth-first**

**-Z, –depth-first-chunk**=

*N*

**-w, –two-way**

**-n, –no-seeds**

**-c, –cycle-breaking**

### Random Sort¶

**-r, –random**

### Path Guided 1D Linear SGD Sort¶

**-Y, –path-sgd**

**-X, –path-index**=

*FILE*

*FILE*.

**-f, –path-sgd-use-paths**=FILE

*all paths*.

**-G, –path-sgd-min-term-updates-paths**=

*N*

*1.0*. Can be overwritten by

*-U, -path-sgd-min-term-updates-nodes=N*.

**-U, –path-sgd-min-term-updates-nodes**=

*N*

*-G, path-sgd-min-term-updates-paths=N*is used).

**-j, –path-sgd-delta**=

*N*

*0.0*.

**-g, –path-sgd-eps**=

*N*

*0.01*.

**-v, –path-sgd-eta-max**=

*N*

*squared steps of longest path in graph*.

**-a, –path-sgd-zipf-theta**=

*N*

*0.99*.

**-x, –path-sgd-iter-max**=

*N*

*30*.

**-F, –iteration-max-learning-rate**=

*N*

*0*.

**-k, –path-sgd-zipf-space**=

*N*

*longest path length*.

**-I, –path-sgd-zipf-space-max**=

*N*

*100*.

**-l, –path-sgd-zipf-space-quantization-step**=

*N*

*100*.

**-y, –path-sgd-zipf-max-num-distributions**=

*N*

*100*.

**-q, –path-sgd-seed**=

*N*

*pangenomic!*.

**-u, –path-sgd-snapshot**=

*STRING*

*-Y, –path-sgd*was specified. Not applicable in a pipeline of sorts.

### Path Sorting Options¶

**-L, –paths-min**

**-M, –paths-max**

**-A, –paths-avg**

**-R, –paths-avg-rev**

**-D, –path-delim**=

*path-delim*

### Pipeline Sorting¶

**-p, –pipeline**=

*STRING*

*s*. The reverse sort would be specified via

*f*.

### Additional Parameters¶

**-d, –dagify-sort**

**-O, –Optimize**

### Threading¶

**-t, –threads**=

*N*

### Processing Information¶

**-P, –progress**

### Program Information¶

**-h, –help**

**odgi sort**.