Skip to main content

Neural network sequence error correction.

Project description

Oxford Nanopore Technologies logo


Build Status

install with bioconda

medaka is a tool to create consensus sequences and variant calls from nanopore sequencing data. This task is performed using neural networks applied a pileup of individual sequencing reads against a draft assembly. It outperforms graph-based methods operating on basecalled data, and can be competitive with state-of-the-art signal-based methods whilst being much faster.

© 2018- Oxford Nanopore Technologies Ltd.


  • Requires only basecalled data. (.fasta or .fastq)
  • Improved accurary over graph-based methods (e.g. Racon).
  • 50X faster than Nanopolish (and can run on GPUs).
  • Benchmarks are provided here.
  • Includes extras for implementing and training bespoke correction networks.
  • Works on Linux and MacOS.
  • Open source (Mozilla Public License 2.0).

For creating draft assemblies we recommend Flye.

Documentation can be found at


Medaka can be installed in one of several ways.

Installation with conda

Perhaps the simplest way to start using medaka is through conda; medaka is available via the bioconda channel:

conda create -n medaka -c conda-forge -c bioconda medaka

Occasionally the conda releases lag behind the source code and PyPI releases.

Installation with pip

For those who prefer Python's native pacakage manager, medaka is also available on pypi and can be installed using pip:

pip install medaka

On Linux platforms this will install a precompiled binary, on MacOS (and other) platforms this will fetch and compile a source distribution.

We recommend using medaka within a virtual environment, viz.:

virtualenv medaka --python=python3 --prompt "(medaka) "
. medaka/bin/activate
pip install medaka

Using this method requires the user to provide several binaries:

and place these within the PATH. samtools/bgzip/tabix version 1.11 and minimap2 version 2.17 are recommended as these are those used in development of medaka.

Installation from source

Medaka can be installed from its source quite easily on most systems.

Before installing medaka it may be required to install some prerequisite libraries, best installed by a package manager. On Ubuntu theses are:

bzip2 g++ zlib1g-dev libbz2-dev liblzma-dev libffi-dev libncurses5-dev
libcurl4-gnutls-dev libssl-dev curl make cmake wget python3-all-dev

In addition it is required to install and set up git LFS before cloning the repository.

A Makefile is provided to fetch, compile and install all direct dependencies into a python virtual environment. To set-up the environment run:

# Note: certain files are stored in git-lfs,,
#       which must therefore be installed first.
git clone
cd medaka
make install
. ./venv/bin/activate

Using this method both samtools and minimap2 are built from source and need not be provided by the user.

Using a GPU

Since version 1.1.0 medaka uses Tensorflow 2.2, prior versions used Tensorflow 1.4. For medaka 1.1.0 and higher installation from source or using pip can make immediate use of GPUs. However, note that the tensorflow package is compiled against specific versions of the NVIDIA CUDA and cuDNN libraries; users are directed to the tensorflow installation pages for further information. cuDNN can be obtained from the cuDNN Archive, whilst CUDA from the CUDA Toolkit Archive.

For medaka prior to version 1.1.0, to enable the use of GPU resource it is necessary to install the tensorflow-gpu package. Using the source code from github a working GPU-powered medaka can be configured with:

# Note: certain files are stored in git-lfs,,
#       which must therefore be installed first.
git clone
cd medaka
sed -i 's/tensorflow/tensorflow-gpu/' requirements.txt
make install

GPU Usage notes

Depending on your GPU, medaka may show out of memory errors when running. To avoid these the inference batch size can be reduced from the default value by setting the -b option when running medaka_consensus. A value -b 100 is suitable for 11Gb GPUs.

For users with RTX series GPUs it may be required to additionally set an environment variable to have medaka run without failure:


In this situation a further reduction in batch size may be required.

Using Docker

The source code repository contains a Dockerfile which can be used to create a GPU compatible Docker container image with the appropriate CUDA and cuDNN library versions for running medaka. The image is built on top of images provided by NVIDIA designed to run with the NVIDIA Container Toolkit. With the toolkit setup on your host computer the following command can be used to run the latest version of medaka:

docker run --rm --gpus 0 ontresearch/medaka:latest medaka --help

(The --gpus option can be amended as appropriate for your environment). Versioned tags are also available.


medaka can be run using its default settings through the medaka_consensus program. An assembly in .fasta format and basecalls in .fasta or .fastq formats are required. The program uses both samtools and minimap2. If medaka has been installed using the from-source method these will be present within the medaka environment, otherwise they will need to be provided by the user.

source ${MEDAKA}  # i.e. medaka/venv/bin/activate
medaka_consensus -i ${BASECALLS} -d ${DRAFT} -o ${OUTDIR} -t ${NPROC} -m r941_min_high_g303

The variables BASECALLS, DRAFT, and OUTDIR in the above should be set appropriately. For the selection of the model (-m r941_min_high_g303 in the example above) see the Model section following.

When medaka_consensus has finished running, the consensus will be saved to ${OUTDIR}/consensus.fasta.

Human variant calling

Variant calling on human samples can be performed with the medaka_variant workflow:

medaka_variant -f <REFERENCE.fasta> -i <reads.bam>

which requires simply a path to the human reference sequence, and a .bam file of reads aligned to the reference.

Bacterial (ploidy-1) variant calling

Variant calling for monoploid samples is enabled through the medaka_haploid_variant workflow:

medaka_haploid_variant <reads.fastq> <ref.fasta>

which requires the reads as a .fasta or .fastq and a reference sequence as a .fasta file.


For best results it is important to specify the correct model, -m in the above, according to the basecaller used. Allowed values can be found by running medaka tools list\_models.

Medaka models are named to indicate i) the pore type, ii) the sequencing device (MinION or PromethION), iii) the basecaller variant, and iv) the basecaller version, with the format:

{pore}_{device}_{caller variant}_{caller version}

For example the model named r941_min_fast_g303 should be used with data from MinION (or GridION) R9.4.1 flowcells using the fast Guppy basecaller version 3.0.3. By contrast the model r941_prom_hac_g303 should be used with PromethION data and the high accuracy basecaller (termed "hac" in Guppy configuration files). Where a version of Guppy has been used without an exactly corresponding medaka model, the medaka model with the highest version equal to or less than the guppy version should be selected.

Origin of the draft sequence

Medaka has been trained to correct draft sequences processed through racon with:

racon -m 8 -x -6 -g -8 -w 500 ...

Processing a draft sequence from alternative sources (e.g. the output of canu or wtdbg2) may lead to different results.

The documentation provides a discussion and some guidance on how to obtain a draft sequence.


We thank Joanna Pineda and Jared Simpson for providing htslib code samples which aided greatly development of the optimised feature generation code, and for testing the version 0.4 release candidates.

We thank Devin Drown for working through use of medaka with his RTX 2080 GPU.


Licence and Copyright

© 2018- Oxford Nanopore Technologies Ltd.

medaka is distributed under the terms of the Mozilla Public License 2.0.

Research Release

Research releases are provided as technology demonstrators to provide early access to features or stimulate Community development of tools. Support for this software will be minimal and is only provided directly by the developers. Feature requests, improvements, and discussions are welcome and can be implemented by forking and pull requests. However much as we would like to rectify every issue and piece of feedback users may have, the developers may have limited resource for support of this software. Research releases may be unstable and subject to rapid iteration by Oxford Nanopore Technologies.

Project details

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for medaka, version 1.4.4
Filename, size File type Python version Upload date Hashes
Filename, size medaka-1.4.4.tar.gz (25.6 MB) File type Source Python version None Upload date Hashes View
Filename, size medaka-1.4.4-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (28.5 MB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size medaka-1.4.4-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (28.5 MB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size medaka-1.4.4-cp36-cp36m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (28.9 MB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size medaka-1.4.4-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (28.5 MB) File type Wheel Python version cp36 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page