Package: megalodon
MegalodonMegalodon is a research command line tool to extract high accuracy modified base and sequence variant calls from raw nanopore reads by anchoring the information rich basecalling neural network output to a reference genome/transcriptome.Raw nanopore reads are processed by a single command to produce basecalls (FASTA/Q), reference mappings (SAM/BAM/CRAM), modified base calls (per-read and bedgraph/bedmethyl/modVCF), sequence variant calls (per-read and VCF) and more.Detailed documentation for allmegalodoncommands and algorithms can be found on theMegalodon documentation page.PrerequisitesThe primary Megalodon run mode requires the Guppy basecaller (version >= 4.0).
See thecommunity page for download/installation instructions [login required].Megalodon is a python-based command line software package.
Given a python (version >= 3.6) installation, all other requirements are handled bypiporconda.Taiyakiis no longer required to run Megalodon, but installation is required for two specific run modes:output mapped signal files (for basecall model training)running the Taiyaki basecalling backend (for neural network designs including experimental layers)Theont-pyguppy-client-apidependency provides select release specifications, so compatible python versions and operating systems may be limited.Installationpipis recommended for Megalodon installation.pip install megalodoncondainstallation is available, but not fully supported.ont_pyguppy_client_libis not available on conda and thus must be installed withpip.conda install megalodon
pip install ont_pyguppy_client_libTo install from github source for development, the following commands can be run.git clone https://github.com/nanoporetech/megalodon
pip install -e megalodon/Getting StartedMegalodon must obtain the intermediate output from the basecall neural network.
Guppy (production nanopore basecalling software) is the recommended backend to obtain this output from raw nanopore signal (from FAST5 files).
Nanopore basecalling is compute intensive and thus it is highly recommended that GPU resources are specified (--devices) for optimal Megalodon performance.Megalodon is accessed via the command line interfacemegalodoncommand.# megalodon help (common args)
megalodon -h
# megalodon help (all args)
megalodon --help-long

# Example command to output basecalls, mappings, and CpG 5mC and 5hmC methylation in both per-read (``mod_mappings``) and aggregated (``mods``) formats
#   Compute settings: GPU devices 0 and 1 with 20 CPU cores
megalodon \
    raw_fast5s/ \
    --guppy-config dna_r9.4.1_450bps_fast.cfg \
    --remora-modified-bases dna_r9.4.1_e8 fast 0.0.0 5hmc_5mc CG 0 \
    --outputs basecalls mappings mod_mappings mods \
    --reference reference.fa \
    --devices 0 1 \
    --processes 20The above command uses the modified base model included in Remora.
For more details on Remora modified base settings see theRemora repository.This command produces themegalodon_resultsoutput directory containing all requested output files and logs.
The format for common outputs is described briefly below and in more detail in thefull documentationThe code below shows how to obtain and run the R9.4.1, MinION/GridION, 5mC CpG model (same model shipped with Guppy as of 4.5.2 release).# Obtain and run R9.4.1, MinION, 5mC CpG model from Rerio
git clone https://github.com/nanoporetech/rerio
rerio/download_model.py rerio/basecall_models/res_dna_r941_min_modbases_5mC_CpG_v001
megalodon \
    raw_fast5s/ \
    --guppy-params "-d ./rerio/basecall_models/" \
    --guppy-config res_dna_r941_min_modbases_5mC_CpG_v001.cfg \
    --outputs basecalls mappings mod_mappings mods \
    --reference reference.fa \
    --mod-motif m CG 0 \
    --devices 0 1 \
    --processes 20The path to theguppy_basecall_serverexecutable is required to run Megalodon.
By default, Megalodon assumes Guppy (Linux GPU) is installed in the current working directory (i.e../ont-guppy/bin/guppy_basecall_server).
Use the--guppy-server-pathargument to specify a different path.InputsRaw readsDirectory containing raw read FAST5 files (sub-directories recursively searched)ReferenceGenome or transcriptome sequence reference (FASTA or minimap2 index)Variants FileMegalodon requires a set of candidate variants for--outputsvariants(provide via--variant-filenameargument; VCF or BCF).OutputsAll Megalodon outputs are written into the directory specified with the--output-directoryoption with standard file names and extensions.BasecallsFormat: FASTQ (default) or FASTABasecall-anchored modified base scores are also available in hts-spec BAM format tags (--outputsmod_basecalls).MappingsFormat: SAM, BAM (default), or CRAMA tab-separated mapping text summary is also produced including per-read alignment statistics.Modified Base CallsThe basecalling model specifies the modified bases capable of being output. Seemegalodon_extras modified_bases describe_alphabet.Per-read modified base callsSQL DB containing per-read modified base scores at each covered reference locationReference-anchored per-read modified base calls is BAM format via theMmandMltags (seehts-spec specifications here).Aggregated callsFormat: bedgraph, bedmethyl (default), and/or modVCFIn order to restrict modified base calls to a specific motif(s) specify the--mod-motifargument. For example, to restrict calls to CpG sites specify--mod-motifZ CG 0.Sequence Variant CallsPer-read Variant CallsSQL DB containing per-read variant scores for each covered variantAggregated callsFormat: VCFDefault run mode is diploid. To run in haploid mode, set--haploidflag.For best results on a diploid genome see the variant phasing workflow on thefull documentation page.Live ProcessingMegalodon supports live run processing.
Activate live processing mode by simply adding the--live-processingargument and specifying the MinKNOW output directory as the Megalodon FAST5 input directory.
Megalodon will continue to search for FAST5s until thefinal_summary*file is created by MinKNOW, indicating data production has completed.Guppy Models and ParametersThe basecalling model defines the modified bases capable of being output by Megalodon.
Basecalling models must be trained to specifically detect a type or types of modified bases.
See theMegalodon documentation herefor instructions to construct modified base training data and train a new modified base model.By default, Megalodon uses thedna_r9.4.1_450bps_modbases_5mc_hac.cfgGuppy config (released in version4.5.2).
This config is compatible with DNA, R9.4.1, MinION/GridION reads and allows output of 5mC calls in all contexts.
Use the--guppy-configoption to specify a different guppy model config.
The appropriateRerio modelis recommended for the highest accuracy modified base calls.All configs can be used to outputbasecallsandmappings(as well assignal_mappingsandper_read_refsforbasecall training).
Modified base and sequence variant outputs require Megalodon calibration files.
To list configs with default calibration files, runmegalodon--list-supported-guppy-configs.
Seecalibration documentation herefor details on Megalodon model calibration.Only flip-flop configs/models are currently supported by Megalodon (this excludes k-mer based and RLE model types).In addition to the--guppy-configand--guppy-server-pathoptions, a number of additional arguments control the behavior of the guppy backend.
The--guppy-paramsargument will pass arguments directly to theguppy_basecall_serverinitialization call.
For example to optimize GPU usage, the following option might be specified:--guppy-params"--num_callers5--ipc_threads6"Finally the--guppy-timeoutarguments ensures that a run will not stall on few reads or with lower compute resources.
TheGuppy server unable to recieve readerror indicate that the Guppy server is overwhelmed.
Consider lowering the--processesand/or--guppy-concurrent-readsvalues to reduce these errors.
Finding the right balance for these parameters can help achieve optimal performance on a system.Disk Performance ConsiderationsThe status of the extract signal input queue and output queues is displayed by default (suppress with--suppress-queues-status).If theextract_signalinput queue is often empty, Megalodon is waiting on reading raw signal from FAST5 files.
If the input queue remains empty, increasing the--num-read-enumeration-threadsand/or--num-extract-signal-processesparameters (defaults8and2)) may improve performance.
Note that[--num-read-enumeration-threads]threads will be opened within each extract signal process.
Alternatively and if available, the input FAST5s disk location could be moved to faster I/O disk.If any output status bars indicate a full queue, Megalodon will stall waiting on that process to write data to disk.
Moving the--output-directoryaccordingly to a location with faster disk I/O performance should improve performance.
Per-read modified base and variant statistics are stored in an on-disk sqlite database, which can be very dependent on disk speed and configuration.High Quality Phased Variant CallsIn order to obtain the highest quality diploid sequence variant calls, the full variant phasing pipeline employingwhatshapshould be applied.
This pipeline is described in detail on thefull documentation page.
The default diploid variant settings are optimized for the full phasing pipeline and not the highest quality diploid calls directly from a single Megalodon call.High-Density VariantsWhen running Megalodon with a high density of variants (more than 1 variant per 100 reference bases), certain steps can be taken to increase performance.
Seevariant atomize documentationfor further details.RNAMegalodon supports processing direct RNA nanopore data.
In order to process an RNA sample specify the--rnaflag as well as an RNA model using the--guppy-configargument.Megalodon performs mapping using the standard minimap2 option,map-ont, and not thespliceoption, so a transcriptome reference must be provided.
The Megalodon code supports RNA modified base detection, but currently no RNA modified base basecalling models are released.Megalodon does not currently perform checking that a set of reads agree with the provided model or options specified (e.g.--rna).
Users should take care to ensure that the correct options are specified for each sample processed.License and Copyright© 2019-21 Oxford Nanopore Technologies Ltd.Megalodon is distributed under the terms of the Oxford Nanopore
Technologies, Ltd.  Public License, v. 1.0.  If a copy of the License
was not distributed with this file, You can obtain one athttp://nanoporetech.comResearch ReleaseResearch 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.