Tutorial

Find where coverage drops

Measure how much of a genome your reads cover, and list the exact regions where coverage drops, with samtools and a one-line gawk program. All in your browser.

What you will learn

  • Summarise coverage with samtools coverage
  • Get the depth at every position with samtools depth
  • Turn a long table into a short answer with gawk
  • Spot an amplicon that failed

The data

A simulated amplicon run over bacteriophage PhiX174 (NC_001422.1): 1,000 reads of 150 bp from 25 of the 26 amplicons used in the amplicon tutorial. Amplicon 12 (positions 2251–2500) failed, as happens in real runs, and you will find where.

Tools in this tutorial

minimap2
Aligns DNA sequences, from short reads to whole genomes, against a reference. It writes SAM for downstream tools or PAF, a plain table of where each sequence matches.
samtools
Works with alignment files (SAM, BAM): sorts them and reports mapping statistics, coverage and per-position read counts.
gawk
GNU awk: a small language for filtering and summarising text tables line by line.

Watch it first

The whole tutorial in under 3 minutes, recorded in the live app. The run is sped up.

Steps

  1. 01

    Load the reads

    Open the Workflow Builder at biochef.app. In File manager, upload run2-reads.fastq and phix174.fasta, and tick the reads for the Input node. New to the editor? The map reads tutorial shows each move with screenshots.

  2. 02

    Map and sort

    Add Align (minimap2) with the reads in reads and a second Input with phix174.fasta in ref, switch on sam_output, then add Sort (samtools).

  3. 03

    Get the overall coverage

    Select Sort and add Coverage (samtools) with an Output. It gives one summary line per sequence: reads, bases covered, percentage covered and mean depth.

  4. 04

    Get the depth at every position

    Select Sort again and add Depth (samtools). Switch on all_positions so that positions with no reads are listed too, with depth 0. The output has one line per position: sequence name, position, depth.

  5. 05

    List the low-coverage regions

    After Depth, add Script (gawk) and, in its required program field, paste:
    $3 < 10 { if (!s) s = $2; e = $2; next } s { print $1, s, e; s = 0 } END { if (s) print $1, s, e }
    For each run of positions with depth below 10, it prints where the run starts and ends. Add an Output and press ▶.

    Script (gawk) settings with the program that reports runs of positions with depth below 10.
  6. 06

    Read both results

    Click the two Outputs: the coverage summary, and the list of low-coverage regions.

    Workflow: reads and reference into minimap2, Sort, then Coverage (samtools) with an Output and Depth (samtools), Script (gawk) with an Output.

What you should see

#rname       startpos endpos numreads covbases coverage meandepth
NC_001422.1  1        5386   1000     5100     94.6899  27.8455

NC_001422.1 1 50
NC_001422.1 2301 2450
NC_001422.1 5301 5386

Reads cover 5,100 of 5,386 bases (94.7%), at a mean depth of 27.8. Three regions fall below 10 reads. Positions 1–50 and 5301–5386 lie outside the first and last amplicons. Positions 2301–2450 are the gap left by the failed amplicon: the neighbouring amplicons overlap it only at its edges.

Use the finished workflow

Import the finished workflow, data included, and press ▶. Remember that an exported workflow contains the data loaded in its Input nodes.

Exercise: draw the coverage

On Coverage (samtools), switch on histogram and run again. samtools draws the coverage along the genome in text. The output panel is narrow and wraps long lines, so the drawing is easier to read below. The gap near 2.3 kb shows up as a hole.

Show the solution
NC_001422.1 (5.4Kbp)
>  90.00% │ ████████████████  ████████████████████ │ Number of reads: 1000
>  80.00% │ ████████████████  ████████████████████ │
>  70.00% │ ████████████████ ▁████████████████████ │ Covered bases:   5.1Kbp
>  60.00% │▂████████████████ █████████████████████ │ Percent covered: 94.69%
>  50.00% │█████████████████ █████████████████████▄│ Mean coverage:   27.8x
>  40.00% │█████████████████ ██████████████████████│ Mean baseQ:      38.5
>  30.00% │█████████████████ ██████████████████████│ Mean mapQ:       60
>  20.00% │█████████████████ ██████████████████████│
>  10.00% │█████████████████▅██████████████████████│ Histo bin width: 134bp
>   0.00% │████████████████████████████████████████│ Histo max bin:   100%
          1        1.3K      2.7K      4.0K       5.4K

From a test to a full run

The browser is the place to build and test a workflow on small data like this. For full datasets, the same workflow file is meant to run next to the data with the BioChef agent, which is in development. See Workflows for how the two fit together.

More tutorials: all BioChef tutorials.

This tutorial is licensed under CC BY 4.0. If you use BioChef in your work, please cite Rosa et al., BMC Bioinformatics 2026. BioChef is listed in bio.tools as biotools:biochef.