Simulate Next-Generation Sequencing Data

David Gerard



We demonstrate how to simulate NGS data under various genotype distributions, then fit these data using flexdog.


Let’s suppose that we have 100 hexaploid individuals, with varying levels of read-depth.

nind    <- 100
ploidy  <- 6
sizevec <- round(stats::runif(n   = nind, 
                              min = 50, 
                              max = 200))

We can simulate their read-counts under various genotype distributions, allele biases, overdispersions, and sequencing error rates using the rgeno and rflexdog functions.

F1 Population

Suppose these individuals are all siblings where the first parent has 4 copies of the reference allele and the second parent has 5 copies of the reference allele. Then the following code, using rgeno, will simulate the individuals’ genotypes.

Once we have their genotypes, we can simulate their read-counts using rflexdog. Let’s suppose that there is a moderate level of allelic bias (0.7) and a small level of overdispersion (0.005). Generally, in the real data that I’ve seen, the bias will range between 0.5 and 2 and the overdispersion will range between 0 and 0.02, with only a few extremely overdispersed SNPs above 0.02.

When we plot the data, it looks realistic

We can test flexdog on these data

flexdog gives us reasonable genotyping, and it accurately estimates the proportion of individuals mis-genotyped.

HWE Population

Now run the same simulations assuming the individuals are in Hardy-Weinberg population with an allele frequency of 0.75.


Gerard, David, Luis Felipe Ventorim Ferrão, Antonio Augusto Franco Garcia, and Matthew Stephens. 2018. “Harnessing Empirical Bayes and Mendelian Segregation for Genotyping Autopolyploids from Messy Sequencing Data.” bioRxiv. Cold Spring Harbor Laboratory.