Coalescent simulations of k-mer spectra for testing k-mer genome profiling tools
- Set up (conda) environment, see example commands in
00setUpEnv - Activate the newly created environment, e.g.
conda activate CSKS - Run pipeline, e.g.:
bash 05delPipeCoalComplex.sh -t 0.01 -g 10000001 -p 2 --pdel 0.0 --error-profile errProfile - Check helpstring
bash 05delPipeCoalComplex.sh -hfor more options and details on parameters. - Adjust parameters and re-run if desired.
Simulating genetic data is not trivial. In the case of one diploid (i.e. two genomes), one can just throw in heterozygous sites according to the desired heterozygosity level (θ). If more than two genomes are simulated, the task becomes more complicated. This is because related genomes have a common ancestor and thus share mutations. A summary of the number of times different mutations are shared between genomes in a sample is called the site-frequency spectrum.
There are at the moment four steps that take place in a temporary directory. Only the final result, a k-mer spectrum, is stored in the working directory. The steps are:
- The simulation of genetic variants and storage of simulated genomes
- Generation of sequencing reads from the simulated genomes
- Generation of a or multiple KMC3 database(s)
- Generation of a k-mer spectrum or multiple spectra from the KMC3 database(s)
Below, these steps are descibed in more detail for the standard entry point, which currently the script 05delPipeCoalComplex.sh.
This is done by the script makeGenomes.py, which runs the coalescent simulator msprime to generate genetic variant data in a sample of n genomes (where n is the ploidy level specified). msprime generates information only for variant sites and so the invariant rest of the genome is made up separately.
The genomes are then written (concatenated) to a single-record FASTA file, genomes.fa, with a specific header format containing the genome size information: >genomes_p[ploidy]_s[haploid GS]_t[total GS].
This script can be modified to allow for allopolyploidy, genomic repeats, unequal sub-genomes, etc.
This is done by makeReadsLowComplex.py. This script slices reads out of the FASTA reference file. It can add sequencing errors based on a constant error rate (--error-prob) or based on a profile file listing one error rate for each position in the read (--error-profile). Only constand read length are supported ATM. The reads are written to reads.fa.
KMC3 is run on reads.fa with k-mer lengths ranging from 21 to 51 in steps of 3.
11 k-mer spectra are generated from the KMC DBs and the temporary files are deleted by default (can be kept with --keep).