
NanoSim is a fast and scalable read simulator that captures the technology-specific features of ONT data, and allows for adjustments upon improvement of nanopore sequencing technology.
The second version of NanoSim (v2.0.0) uses minimap2 as default aligner to align long genomic ONT reads to reference genome. It leads to much faster alignment step and reduces the overall runtime of NanoSim. We also utilize HTSeq, a python package, to read SAM alignment files efficiently.
NanoSim (v2.5) is able to simulate ONT transcriptome reads (cDNA / direct RNA) as well as genomic reads. It also models features of the library preparation protocols used, including intron retention (IR) events in cDNA and directRNA reads. Further, it has stand-alone modes which profiles transcript expression patterns and detects IR events in custom datasets. Additionally, we improved the homopolymer simulation option which simulates homopolymer expansion and contraction events with respect to chosen basecaller. Multiprocessing option allows for faster runtime for large library simulation.
NanoSim (v2.6) is able to simulate ONT reads in fastq format. The base quality information is simulated with truncated log-normal distributions, learnt separately from match bases, mismatch bases, insertion bases, deletion bases, and unaligned bases, each from different basecaller and read type.
NanoSim (v3.0) is able to simulate ONT metagenome reads. It quantifies metagenome abundance in the characterization stage, and accomodates for chimeric reads. In the simulation stage, it simulates both features as well. In addition, the simulation of chimeric reads is available in genome mode too. Some pre-trained models are re-trained for compatibility issues.
NOTE:
We usually add new pre-trained models and make them available through the latest releases! Users can choose to download the whole package or only scripts without models to speed it up. Please check the downloads section for more information regarding the pre-trained models.
If you use NanoSim to simulate genomic reads, please cite the following paper:
NanoSim
Yang C, Chu J, Warren RL, Birol I. NanoSim: nanopore sequence read simulator based on statistical characterization. Gigascience. 2017 Apr 1;6(4):1-6. doi: 10.1093/gigascience/gix010. PMID: 28327957; PMCID: PMC5530317.
If you use NanoSim to simulate transcriptomic reads, please cite the following paper:
Trans-NanoSim
Hafezqorani S, Yang C, Lo T, Nip KM, Warren RL, Birol I. Trans-NanoSim characterizes and simulates nanopore RNA-sequencing data. Gigascience. 2020 Jun 1;9(6):giaa061. doi: 10.1093/gigascience/giaa061. PMID: 32520350; PMCID: PMC7285873.
If you use NanoSim to simulate metagenomic reads, please cite the following paper:
Meta-NanoSim
Yang C, Lo T, Nip KM, Hafezqorani S, Warren RL, Birol I. Characterization and simulation of metagenomic nanopore sequencing data with Meta-NanoSim. Gigascience. 2023 Mar 20;12:giad013. doi: 10.1093/gigascience/giad013. PMID: 36939007; PMCID: PMC10025935.
Dependencies
NOTE: Please kindly note that the pretrained models in NanoSim (v3.0.2) were made using an older version of scikit-learn (e.g. <=0.22.1). If you have to use these models (instead of creating your own models), then you must use scikit-learn=0.22.1 but not the newer versions. If you have a newer version of scikit-learn installed, then you will get the error for No module named 'sklearn.neighbors.kde'. If you would like to create your own models (instead of using the pretrained models), then NanoSim should work just fine with scikit-learn=1.0.2 from our experience. For future releases of NanoSim, we will try to include newly pre-trained models with the updated versions of required packages in order to solve the incompatibility issues.
Python packages:
- HTSeq (Tested with version 0.11.2)
- joblib (Tested with version 0.14.1)
- numpy (Tested with version 1.17.2)
- pybedtools (Tested with version 0.8.2)
- pysam (Tested with version 0.13 or above)
- scikit-learn (Tested with version 0.21.3)
- scipy (Tested with verson 1.4.1)
- six (Tested with version 1.16.0)
- piecewise-regression (Tested with version 1.1.2)
External programs:
Installation
Before you begin, make sure that your conda channels are configured properly for bioconda.
Option 1. Install the latest release through bioconda:
conda install -c bioconda nanosim
Option 2. Install the development code in our repo:
git clone https://github.com/BirolLab/NanoSim.git
conda create --name nanosim python=3.7
conda activate nanosim
conda install --file requirements.txt -c conda-forge -c bioconda
NOTE: If you have difficulty with installing all the dependent packages with conda. We strongly recommend that you create a dedicated environment for running NanoSim. If you have issues with conda install being eternally stuck, use mamba instead of conda to install your conda packages: https://github.com/mamba-org/mamba .
So, integrating all these together:
conda create -n nanosim_env
conda activate nanosim_env
mamba install scikit-learn=0.22.1 six samtools pysam pybedtools minimap2 joblib htseq genometools-genometools
Note that here we only specified the version for scikit-learn but not for the other packages. mamba should be able to pick the appropriate versions for the specified packages, python, and numpy, etc.
Downloads
Some ONT read profiles are ready to use for users. With the profiles, users can run the simulation tool directly.
For releases before v2.2.0, we provide profiles trained for E. coli or S. cerevisiae datasets. Flowcell chemistry is R7.3 and R9, and they were basecalled by Metrichor. They can be downloaded from our ftp site
For release v2.5.0 and onwards, we provide profiles trained for H. sapiens NA12878 gDNA, cDNA 1D2, and directRNA datasets, Mus. musculus cDNA dataset, and the ZymoBIOMICS mock community datasets with 10 species and two abundance levels. Flowcell chemistry is R9.4 for all datasets. NA12878 gDNA and directRNA were basecalled by Guppy 3.1.5; NA12878 cDNA 1D2 was basecalled by Albacore 2.3.1; mouse cDNA was basecalled by Metrichor. These models are available within pre-trained_models folder.
For release v3.1.1, we provide a trained model for H. sapiens NA24385 - AshkenazimTrio - Son (hg002) which is sequenced using Kit v14 (R10 chemistry) and basecalled by dorado. You may find the trained model on 1 Million subsampled reads on the GitHub page (available along with the other models at pre-trained_models folder). If you are interested in the trained model based on the whole dataset, you can get it through Zenodo - DOI: 10.5281/zenodo.10064740. The model is trained using NanoSim v3.0.2 with scikit-learn v0.23.2 and python v3.7.10.
For release v3.2.1, we provide a trained model for H. sapiens NA24385 - AshkenazimTrio - Son (hg002) which is sequenced using Kit v14 (R10 chemistry) and basecalled by dorado (human_giab_hg002_sub1M_kitv14_dorado_v3.2.1.tar.gz). The model is trained using NanoSim v3.2.1 with python 3.7 and scikit-learn v0.23.2.
For release v3.2.2, we provide trained models for the ZymoBIOMICS mock community datasets with 10 species and two abundance levels. We also provide a trained model for H. sapiens NA12878 cDNA (rel2 release, base-called using guppy v4.2.2) ONT data on Zenodo. The models are trained using NanoSim v3.2.2 with python 3.7 and scikit-learn v0.23.2.
If you have any issues using the pre-trained models, check the dependencies section for some information and tips.
Usage
NanoSim is implemented using Python for error model fitting, read length analysis, and simulation. The first step of NanoSim is read characterization, which provides a comprehensive alignment-based analysis, and generates a set of read profiles serving as the input to the next step, the simulation stage. The simulation tool uses the model built in the previous step to produce in silico reads for a given reference genome/transcriptome. It also outputs a list of introduced errors, consisting of the position on each read, error type and reference bases.
1. Characterization stage
Characterization stage runs in five mode: genome, transcriptome, metagenome, quantify, and detect_ir. Below you may see the general usage of this code. We will explain each mode separately as well.
Characterization step general usage:
usage: read_analysis.py [-h] [-v]
{genome,transcriptome,metagenome,quantify,detect_ir} ...
Read characterization step
-----------------------------------------------------------
Given raw ONT reads, reference genome, metagenome, and/or
transcriptome, learn read features and output error profiles
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
subcommands:
There are five modes in read_analysis.
For detailed usage of each mode:
read_analysis.py mode -h
-------------------------------------------------------
{genome,transcriptome,metagenome,quantify,detect_ir}
genome Run the simulator on genome mode
transcriptome Run the simulator on transcriptome mode
metagenome Run the simulator on metagenome mode
quantify Quantify transcriptome expression or metagenome abundance
detect_ir Detect Intron Retention events using the alignment file
genome mode
If you are interested in simulating ONT genomic reads, you need to run the characterization stage in "genome" mode with following options. It takes a reference genome and a training read set in FASTA or FASTQ format as input and aligns these reads to the reference using minimap2 (default) or LAST aligner. User can also provide their own alignment file in SAM/BAM formats. If a SAM/BAM file is provided, make sure the alignments contain the cs tag (See minimap2) and MD flag. The output of this is a bunch of profiles which you should use in simulation stage.
genome mode usage: