Skip to main content

Neural network sequence error correction.

Project description

Oxford Nanopore Technologies logo

Medaka

Build Status

install with bioconda

medaka is a tool to create a consensus sequence from nanopore sequencing data. This task is performed using neural networks applied from 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.

Features

  • 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).

Tools to enable the creation of draft assemblies can be found in a sister project pomoxis.

Documentation can be found at https://nanoporetech.github.io/medaka/.

Installation

Medaka can be installed in one of several ways.

Installation with conda

Perhaps the simplest way to start using medaka on both Linux and MacOS is through conda; medaka is available via the bioconda channel:

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

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.9 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
  • gcc
  • zlib1g-dev
  • libbz2-dev
  • liblzma-dev
  • libffi-dev
  • libncurses5-dev
  • libcurl4-gnutls-dev
  • libssl-dev
  • curl
  • make
  • cmake
  • wget
  • python3-all-dev
  • python-virtualenv

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, https://git-lfs.github.com/,
#       which must therefore be installed first.
git-lfs before cloning the repository*
git clone https://github.com/nanoporetech/medaka.git
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

All installation methods will allow medaka to be used with CPU resource only. To enable the use of GPU resource it is necessary to install the tensorflow-gpu package. Unfortunately depending on your python version it may be necessary to modify the requirements of the medaka package for it to run without complaining. Using the source code from github a working GPU-powered medaka can be configured with:

git clone https://github.com/nanoporetech/medaka.git
cd medaka
sed -i 's/tensorflow/tensorflow-gpu/' requirements.txt
make install

However, note that The tensorflow-gpu GPU 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.

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:

export TF_FORCE_GPU_ALLOW_GROWTH=true

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

Usage

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
NPROC=$(nproc)
BASECALLS=basecalls.fa
DRAFT=draft_assm/assm_final.fa
OUTDIR=medaka_consensus
medaka_consensus -i ${BASECALLS} -d ${DRAFT} -o ${OUTDIR} -t ${NPROC} -m r941_min_high

The variables BASECALLS, DRAFT, and OUTDIR in the above should be set appropriately. When medaka_consensus has finished running, the consensus will be saved to ${OUTDIR}/consensus.fasta.

Models

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.

For guppy v3.0.3 models are named similarly to their basecalling counterparts with a "fast" and "high accuracy" model, for example r941_min_fast and r941_min_high. The medaka models are equal in computation performance regardless of basecaller speed/accuracy.

Origin of the draft sequence

Medaka has been trained to correct draft sequences processed through racon, specifically racon run four times iteratively 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.

Acknowledgements

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.

Help

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


Download files

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

Source Distribution

medaka-0.9.2.tar.gz (22.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

medaka-0.9.2-cp36-cp36m-manylinux1_x86_64.whl (24.5 MB view details)

Uploaded CPython 3.6m

medaka-0.9.2-cp35-cp35m-manylinux1_x86_64.whl (24.5 MB view details)

Uploaded CPython 3.5m

File details

Details for the file medaka-0.9.2.tar.gz.

File metadata

  • Download URL: medaka-0.9.2.tar.gz
  • Upload date:
  • Size: 22.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for medaka-0.9.2.tar.gz
Algorithm Hash digest
SHA256 c3dcf600cf91d571b04087c2ff6bccb452dade82ba017de1080fea40794f8b20
MD5 d5e696d4bf42e2581f3d407c8695729d
BLAKE2b-256 b84cd221b7d8f154dd93ab175150726bd3c31aa1fde0766c1644cfc3e8d3a3dd

See more details on using hashes here.

File details

Details for the file medaka-0.9.2-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: medaka-0.9.2-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 24.5 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for medaka-0.9.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 6d1cab47bd4d31e95f509fe2f722cb48b78b8253d7f2d3ac4bf20c14c5f6a846
MD5 ddc717a6bb326a5d301eccda2cf21f40
BLAKE2b-256 a02cc79769250ccc718928c0585df3684c0a17255c9044a0afe686a2a12309b4

See more details on using hashes here.

File details

Details for the file medaka-0.9.2-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

  • Download URL: medaka-0.9.2-cp35-cp35m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 24.5 MB
  • Tags: CPython 3.5m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for medaka-0.9.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 bbd3cdd1f8aa37c8bc543cf7135a6d485d94c5e07b606fcfecab3cd1ad9060e7
MD5 2eb22568d3d5935a43d90a2880442edf
BLAKE2b-256 8aea36fb21ee68fdbd5b6b6dcb10acdc264e549f24f5b3744c3e804541721d1e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page