seq2squiggle is a deep learning-based tool for generating artifical nanopore signals from DNA sequence data.
Please cite the following publication if you use seq2squiggle in your work:
Beslic D, Kucklick M, Engelmann S, Fuchs S, Renard BY, Körber N. End-to-end simulation of nanopore sequencing signals with feed-forward transformers. Bioinformatics. 2024; btae744. doi:10.1093/bioinformatics/btae744
Installation
Dependencies
seq2squiggle requires Python >= 3.10.
We recommend to run seq2squiggle in a separate conda / mamba environment. This keeps the tool and its dependencies isolated from your other Python environments.
This samples n total signals by selecting input reads without splitting them.
It’s not simulating n signals per read, but rather simulating n signals across the input reads.
This hybrid approach is useful when:
You want to simulate larger datasets from real reads without generating synthetic sequences.
You want to preserve real read characteristics while exploring noise or signal variability.
Notes
Output format
By default, the output is in SLOW5/BLOW5 format. Exporting to the new POD5 format is also supported, though BLOW5 is preferred for its stability. You will need to specify the path to the model through the configuration file.
Performance tips
For optimal performance, running seq2squiggle on a GPU is recommended, especially to speed up inference for a high number of samples. However, the tool also works on CPU-only systems, though at a slower inference speed.
Noise options
Signal generation can be customized with:
Noise Sampler: predicts per-k-mer signal amplitude variation
Duration Sampler: predicts per-k-mer dwell time (event length) variation
You can disable either or both to use static distributions instead.
Examples using different noise options
# Default configuration (noise sampler and duration sampler enabled)
seq2squiggle predict example.fasta -o example.blow5
# Using the noise sampler with increased noise standard deviation and the duration sampler
seq2squiggle predict example.fasta -o example.blow5 --noise-std 1.5
# Using a static normal distribution for the amplitude noise and the duration sampler
seq2squiggle predict example.fasta -o example.blow5 --noise-std 1.0 --noise-sampling False
# Using the noise sampler and a static normal distribution for event durations
seq2squiggle predict example.fasta -o example.blow5 --duration-sampling False --dwell-std 4.0
# Using the noise sampler with ideal event lengths (each k-mer event will have a length of 10):
seq2squiggle predict example.fasta -o example.blow5 --duration-sampling False --dwell-mean 10.0 --dwell-std 0.0
# Using a static normal distribution for amplitude noise and ideal event lengths:
seq2squiggle predict example.fasta -o example.blow5 --duration-sampling False --dwell-mean 10.0 --dwell-std 0.0 --noise-sampling False --noise-std 1.0
# Generating reads with no amplitude noise and ideal event lengths:
seq2squiggle predict example.fasta -o example.blow5 --duration-sampling False --dwell-mean 10.0 --dwell-std 0.0 --noise-sampling False --noise-std 0.0
Train a new model
seq2squiggle can be trained using segmented sequence and signal data obtained from a signal-to-reference alignment. These alignments can be generated using uncalled4 or f5c, which produce an eventalign table mapping raw signals to their corresponding reference sequences.
1. Generate training data with uncalled4 or f5c
You need event-level signal alignments as training data. These can be generated using either uncalled4 or f5c.
Since uncalled4 version 4.1.0, it no longer outputs scaled pA values directly. Instead, it outputs the normalized pore model values, which have a mean of 0 and a standard deviation of 1. seq2squiggle requires the signals to be in pA, so they must be converted back.
To denormalize signals, you first need to compute the average mean and average standard deviation of the pA values from your data. This can be done using sigtk:
Before training, the eventalign table needs to be preprocessed into .npy chunks. It is recommended to first split the data into training and validation sets. This can be done based on chromosome regions (e.g., using chromosome 1 for training and chromosome 21 for validation) or by applying a random split with a specified fraction.
For a detailed explanation of the configuration parameters, see CONFIG.md
Acknowledgement
The model is based on xcmyz’s implementation of FastSpeech. Some code snippets for preprocessing DNA-signal chunks have been taken from bonito. We also incorporated code snippets from Casanovo for different functionalities, including downloading weights, logging, and the design of the main function.
Additionally, we used parameter profiles from squigulator for various chemistries to set digitisation, sample-rate, range, median_before, and other signal parameters. These profiles are detailed in squigulator’s documentation.
seq2squiggle
seq2squiggleis a deep learning-based tool for generating artifical nanopore signals from DNA sequence data.Please cite the following publication if you use
seq2squigglein your work:Installation
Dependencies
seq2squigglerequires Python >= 3.10.We recommend to run
seq2squigglein a separate conda / mamba environment. This keeps the tool and its dependencies isolated from your other Python environments.Install with pip
Install with conda or mamba
Install from source
Download training data and model weights
seq2squigglerequires compatible pretrained model weights to make predictions, which can be specified using the--modelcommand-line parameter.If you do not provide a model file,
seq2squigglewill automatically attempt to download a compatible model file to ensure predictions can be made.Predict signals from FASTA/Q file
seq2squigglesimulates artificial signals based on an input FASTA or FASTQ file. It supports two main simulation modes.Reference mode (default)
Input: FASTA file (e.g. genome or transcriptome reference)
Goal: Generate synthetic reads and simulate corresponding signals.
How it works
-n,-c, or-rto control number, coverage, or average read length.--distrto specify the read length distribution.Example:
Read mode (–read-input)
Input: FASTA or FASTQ file containing pre-existing reads (e.g. basecalled reads)
Goal: Simulates signals directly from input reads - no additional fragmentation
There are two behaviors within Read Mode:
One signal per input read
This generates exactly one signal per input read (1:1 mapping).
Multiple signals based on input reads (-n)
This samples n total signals by selecting input reads without splitting them. It’s not simulating n signals per read, but rather simulating n signals across the input reads.
This hybrid approach is useful when:
Notes
Output format
By default, the output is in SLOW5/BLOW5 format. Exporting to the new POD5 format is also supported, though BLOW5 is preferred for its stability. You will need to specify the path to the model through the configuration file.
Performance tips
For optimal performance, running
seq2squiggleon a GPU is recommended, especially to speed up inference for a high number of samples. However, the tool also works on CPU-only systems, though at a slower inference speed.Noise options
Signal generation can be customized with:
You can disable either or both to use static distributions instead.
Examples using different noise options
Train a new model
seq2squigglecan be trained using segmented sequence and signal data obtained from a signal-to-reference alignment. These alignments can be generated using uncalled4 or f5c, which produce an eventalign table mapping raw signals to their corresponding reference sequences.1. Generate training data with
uncalled4orf5cYou need event-level signal alignments as training data. These can be generated using either
uncalled4orf5c.Using uncalled4
Run the following command to align reads and extract event-level signals:
Using f5c
Alternatively, you can use f5c to perform the alignment:
2. Filter and transform into pA values (optional)
Since
uncalled4version 4.1.0, it no longer outputs scaled pA values directly. Instead, it outputs the normalized pore model values, which have a mean of 0 and a standard deviation of 1.seq2squigglerequires the signals to be in pA, so they must be converted back.To denormalize signals, you first need to compute the average mean and average standard deviation of the pA values from your data. This can be done using sigtk:
The sigtk.txt will look like this
Once you have the sigtk.txt file, you can run the
standardize-events.pyscript to denormalize the signal values:3. Preprocess the event table to .npy chunks
Before training, the eventalign table needs to be preprocessed into .npy chunks. It is recommended to first split the data into training and validation sets. This can be done based on chromosome regions (e.g., using chromosome 1 for training and chromosome 21 for validation) or by applying a random split with a specified fraction.
Once the data is split, preprocess each subset:
4. Train
Once preprocessing is complete, you can start training:
For a detailed explanation of the configuration parameters, see CONFIG.md
Acknowledgement
The model is based on xcmyz’s implementation of FastSpeech. Some code snippets for preprocessing DNA-signal chunks have been taken from bonito. We also incorporated code snippets from Casanovo for different functionalities, including downloading weights, logging, and the design of the main function. Additionally, we used parameter profiles from squigulator for various chemistries to set digitisation, sample-rate, range, median_before, and other signal parameters. These profiles are detailed in squigulator’s documentation.