Generate simulated reads¶
In brief¶
Simulate reads as a NanopolishComp like file from a fasta file and an inbuild model.
...
Import the package and plotting tools¶
from nanocompore.SimReads import SimReads # Ploting lib imports import matplotlib.pyplot as pl %matplotlib inline
Generate reads without modifications¶
SimReads ( fasta_fn="./references/simulated/ref.fa", ref_list=["ref_0000"], outpath="./results/", overwrite="True", plot=True, nreads_per_ref=100)
SimReads ( fasta_fn="./references/simulated/ref.fa", ref_list=["ref_0000"], outpath="./results/", overwrite="True", plot=True, mod_extend_context=3, nreads_per_ref=100, intensity_mod=5, dwell_mod=5, mod_reads_freq=0.5)
Generate a small dataset with both modified and unmodified conditions¶
# Options fasta = "./references/simulated/ref.fa" data_dir = "./eventalign_files/simulated/" for replicate, nreads in [(1, 55), (2, 60)]: # Generate non modified control SimReads ( fasta_fn=fasta, outpath=data_dir, outprefix=f"unmodified_rep_{replicate}", overwrite=True, nreads_per_ref= nreads) # Generate modified control SimReads ( fasta_fn=fasta, outpath=data_dir, outprefix=f"modified_rep_{replicate}", overwrite=True, nreads_per_ref= nreads, intensity_mod=3, dwell_mod=3, mod_reads_freq=0.9, mod_bases_freq = 0.25, pos_rand_seed=2)
Full CLI and API documentations¶
API documentation¶
API help can be obtained with conventional python methods (help or ?) or rendered nicely in Jupyter with the jhelp function from nanocompore
from nanocompore.SimReads import SimReads from nanocompore.common import jhelp jhelp(SimReads)
CLI documentation¶
nanocompore simreads --help
usage: nanocompore simreads [-h] --fasta FASTA [--intensity_mod INTENSITY_MOD]
[--dwell_mod DWELL_MOD]
[--mod_reads_freq MOD_READS_FREQ]
[--mod_bases_freq MOD_BASES_FREQ]
[--mod_bases_type {A,T,C,G}]
[--mod_extend_context MOD_EXTEND_CONTEXT]
[--min_mod_dist MIN_MOD_DIST]
[--run_type {RNA,DNA}]
[--nreads_per_ref NREADS_PER_REF]
[--pos_rand_seed POS_RAND_SEED] [--not_bound]
[--outpath OUTPATH] [--outprefix OUTPREFIX]
[--overwrite] [--log_level {warning,info,debug}]
[--progress]
Simulate reads as a NanopolishComp like file from a fasta file and an inbuild model
* Minimal example without model alteration
nanocompore simreads -f ref.fa -o results -n 50
* Minimal example with alteration of model intensity loc parameter for 50% of the reads
nanocompore simreads -f ref.fa -o results -n 50 --intensity_mod 2 --mod_reads_freq 0.5 --mod_bases_freq 0.2
optional arguments:
-h, --help show this help message and exit
Input options:
--fasta FASTA, -f FASTA
Fasta file containing references to use to generate
artificial reads
Signal modification options:
--intensity_mod INTENSITY_MOD
Fraction of intensity distribution SD by which to
modify the intensity distribution loc value (default:
0)
--dwell_mod DWELL_MOD
Fraction of dwell time distribution SD by which to
modify the intensity distribution loc value (default:
0)
--mod_reads_freq MOD_READS_FREQ
Frequency of reads to modify (default: 0)
--mod_bases_freq MOD_BASES_FREQ
Frequency of bases to modify in each read (if
possible) (default: 0.25)
--mod_bases_type {A,T,C,G}
Base for which to modify the signal (default: A)
--mod_extend_context MOD_EXTEND_CONTEXT
number of adjacent base affected by the signal
modification following an harmonic series (default: 2)
--min_mod_dist MIN_MOD_DIST
Minimal distance between 2 bases to modify (default:
6)
Other options:
--run_type {RNA,DNA} Define the run type model to import (default: RNA)
--nreads_per_ref NREADS_PER_REF, -n NREADS_PER_REF
Number of reads to generate per references (default:
100)
--pos_rand_seed POS_RAND_SEED
Define a seed for randon position picking to get a
deterministic behaviour (default: 42)
--not_bound Do not bind the values generated by the distributions
to the observed min and max observed values from the
model file (default: False)
Output options:
--outpath OUTPATH, -o OUTPATH
Path to the output folder (default: ./)
--outprefix OUTPREFIX, -p OUTPREFIX
text outprefix for all the files generated (default:
out)
--overwrite, -w Use --outpath even if it exists already (default:
False)
Verbosity options:
--log_level {warning,info,debug}
Set the log level (default: info)
--progress Display a progress bar during execution (default:
False)