Build Status ## Getting Started

Table of Contents

Introduction

Minigraph is a sequence-to-graph mapper and graph constructor. It finds approximate locations of a query sequence in a sequence graph and incrementally augments an existing graph with long query subsequences diverged from the graph. The figure on the right briefly explains the procedure.

Minigraph borrows many ideas and code from minimap2. It is fairly efficient and can construct a graph from 40 human assemblies in half a day using 24 CPU cores. Partly due to the lack of base alignment, minigraph may produce suboptimal mappings and local graphs. Please read the Limitations section of this README for more information.

Users’ Guide

Installation

To install minigraph, type make in the source code directory. The only non-standard dependency is zlib.

Sequence-to-graph mapping

To map sequences against a graph, you should prepare the graph in the GFA format, or preferrably the rGFA format. If you don’t have a graph, you can generate a graph from multiple samples (see the Graph generation section below). The typical command line for mapping is You may choose the right preset option -x according to input. Minigraph output mappings in the GAF format, which is a strict superset of the PAF format. The only visual difference between GAF and PAF is that the 6th column in GAF may encode a graph path like >MT_human:0-4001<MT_orang:3426-3927 instead of a contig/chromosome name.

The minigraph GFA parser seamlessly parses FASTA and converts it to GFA internally, so you can also provide sequences in FASTA as the reference. In this case, minigraph will behave like minimap2 but without base-level alignment.

Graph generation

The following command-line generates a graph in rGFA: which is equivalent to File ref.fa is typically the reference genome (e.g. GRCh38 for human). It can also be replaced by a graph in rGFA. Minigraph assumes sample1.fa to be the whole-genome assembly of an individual. This is an important assumption: minigraph only considers 1-to-1 orthogonal regions between the graph and the individual FASTA. If you use raw reads or put multiple individual genomes in one file, minigraph will filter out most alignments as they cover the input graph multiple times.

The output rGFA can be converted to a FASTA file with gfatools: The output out.stable.fa will always include the initial reference ref.fa and may additionally add new segments diverged from the initial reference.

Calling structural variations

A minigraph graph is composed of chains of bubbles with the reference as the backbone. Each bubble represents a structural variation. It can be multi-allelic if there are multiple paths through the bubble. You can extract these bubbles with The output is a BED-like file. The first three columns give the position of a bubble/variation and the rest of columns are:

Given an assembly, you can find the path/allele of this assembly in each bubble with On each line in the BED-like output, the last colon separated field gives the alignment path through the bubble, the path length in the graph, the mapping strand of sample contig, the contig name, the approximate contig start and contig end. The number of lines in the file is the same as the number of lines in the output of gfatools bubble. You can use the paste Unix command to piece multiple samples together.

Prebuilt graphs

Prebuilt human graphs in the rGFA format can be found at ftp://ftp.dfci.harvard.edu/pub/hli/minigraph.

Algorithm overview

In the following, minigraph command line options have a dash ahead and are highlighted in bold. The description may help to tune minigraph parameters.

  1. Read all reference bases, extract (-k,-w)-minimizers and index them in a hash table.

  2. Read -K [=500M] query bases in the mapping mode, or read all query bases in the graph construction mode. For each query sequence, do step 3 through 5:

  3. Find colinear minimizer chains using the minimap2 algorithm, assuming segments in the graph are disconnected. These are called linear chains.

  4. Perform another round of chaining, taking each linear chain as an anchor. For a pair of linear chains, minigraph finds up to 15 shortest paths between them and chooses the path of length closest to the distance on the query sequence. Minigraph checks the base sequences, but doesn’t perform thorough graph alignment. Chains found at this step are called graph chains.

  5. Identify primary chains and estimate mapping quality with a method similar to the one used in minimap2.

  6. In the graph construction mode, collect all mappings longer than -d [=10k] and keep their query and graph segment intervals in two lists, respectively.

  7. For each mapping longer than -l [=50k], finds poorly aligned regions. A region is filtered if it overlaps two or more intervals collected at step

  8. Insert the remaining poorly aligned regions into the input graph. This constructs a new graph.

Limitations