pcrsim

3xNews

05.02.2022: Added section "Papers citing pcrsim" and added code examples under "Get started" (kudos to Peter Green)

16.01.2022: Development version 1.0.2.9000 migrated to gWidgets2. Updated sections "Download pcrsim" and "Get started"

11.01.2020: Added latest download statistics. Added section "Work in progress".

Introduction

pcrsim was created by Oskar Hansson as part of his PhD at the Norwegian Institute of Public Health (NIPH), Department of Forensic Biology. The work has received external funding from the European Union seventh Framework Programme (FP7/2007-2013) under grant agreement n° 285487 (EUROFORGEN-NoE)

pcrsim is a package for simulation of the forensic DNA process. The package was developed based on the simulation functions in forensim, which is an implementation of A graphical simulation model of the entire DNA process, but expanded to include simulation of entire profiles and mixtures. In addition pcrsim is able to simulate inter-locus balance, stutters, and degradation. The graphical user interface give access to function parameters organised into tabs for the respective subprocess. Simulation is performed and the result for each step can be viewed as a table within the GUI or plotted as an electropherogram (EPG). Effort has been made to mimic each step of the real process as closely as possible - consequently, due to performance, it is not well suited for very large simulations. For realistic simulations pcrsim must be calibrated to the quantification method used and for each capillary electrophoresis instrument.

PhD material

pcrsim was developed as part of my PhD project. Download the thesis Development of computer software to characterise and simulate molecular biology processes used in forensic DNA profiling assays (ISBN 978-82-8377-319-4) or view the short popular scientific presentation and the trial lecture Epigenetics in forensics.

Work in progress

There is no development since 2017. However, contribution to the pcrsim R package is more than welcome. Do not hesitate to contact the developer to contribute with improvements like implementation of new functions, better manuals or tutorials.

Download statistics

RStudio CRAN mirror download statistics. The actual number of downloads over all CRAN mirrors is unknown, which mean that the counts are likely an underestimate.

Download pcrsim

The current version have been verified to work with R version up to 4.1.1. The pcrsim package is no longer available on CRAN. The package was removed from the CRAN repository (archived) on 2020-05-20 as requires 'gWidgets'. This was fixed in developer version 1.0.2.9000, 16.01.2022. However, there are currently no plans to re-release pcrsim to CRAN. The developer version can easily be installed from GitHub from within R by typing this into the command window:

devtools::install_github("oskarhansson/strvalidator")

You may need to install devtools to make it work:

install.packages("devtools", dependencies=TRUE)

Archived versions can also be downloaded from the CRAN website:

https://cran.r-project.org/web/packages/pcrsim/index.html.

Get started

Load the package

After installing the pcrsim package (see Download section), type the following commands to load pcrsim and open the graphical user interface:

library(pcrsim)

pcrsim()

If you get one of the following error messages:

Error in (function (classes, fdef, mtable) :

unable to find an inherited method for function ‘.gwindow’ for signature ‘"NULL"’

In addition: Warning message:

In guiToolkit() : No toolkits installed

or

Loading required package: gWidgetsRGtk2

Error in (function (classes, fdef, mtable) :

unable to find an inherited method for function ‘.gwindow’ for signature ‘"guiWidgetsToolkitRGtk2"’

In addition: Warning message:

In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :

there is no package called ‘gWidgetsRGtk2’

Then the correct gui toolkit is missing. Install the missing package by the following command:

install.packages("gWidgets2RGtk2", dependencies=TRUE)

Note: Package gWidgets2RGtk2 was removed from the CRAN repository (archived) on 2021-11-08 as requires orphaned package RGtk2. Use instead the gWidgets2tcltk package (however, there may be some glitches since pcrsim was developed using the ‘gWidgets2RGtk2’ package).

install.packages("gWidgets2tcltk", dependencies=TRUE)

Simulate your first profile

  1. Select the Projects tab and browse to the folder extdata likely located in your document folder e.g. ...\Documents\R\win-library\3.5\pcrsim\[inst]\extdata. Click the OK button.

  2. Select the project tutorial_pcrsim_project.RData, and click the Open button. This opens the Workspace tab to show the loaded project. You may need to click the Refresh button to show the content of the loaded file.

  3. Select the simulation template template_tutorial_sgm_1 and click the Load simulation template button (not the load project workspace button). This will populate the simulation parameters.

  4. Select the Profile tab. The template is set up to simulate profiles using the typing kit SGMPlus with settings from method Tutorial1. Change the option to create profile by Generate a random profile for each simulation using the population database SGM Norway.

  5. Select the Sample tab. Change the sample name to 'my first sample'. Set the number of cells to 250 (approximately 1.5 ng in the tube).

  6. Select the Extraction tab. The extraction efficiency is set to 1, emulating a one-tube extraction. Change the extraction volume to 100 (ca. 0.015 ng/ul).

  7. Select the PCR tab. The aliquot for PCR is set to 20 (which gives approximately 300 pg in the reaction) and the number of PCR cycles is set to 28.

  8. Select the Simulation tab. Change the name for result to 'test'. Uncheck the Set random seed option to allow variability between simulations. Click the Simulate button.

  9. The generated EPG should be visible in the plot window. Click the Simulate button again to simulate another profile.

Simulate your first mixture profile

  1. Perform the steps in the previous section 'Simulate your first profile'.

  2. Select the Simulation tab. Set the Number of simulations or contributors to 2.

  3. Select the Sample tab. Check the Simulate a mixture with 2 contributors option. Change the number of cells to '1500,300' (major/minor) and the Haplotype flag to 'F,T' to simulate a diploid major (ca. 10 ng in the tube) and a haploid minor (ca. 1 ng in the tube).

  4. Select the Simulation tab. Click the Simulate button. Click the Simulate button again to simulate another mixture profile.

  5. The generated EPG should be visible in the plot window. Use the two buttons View result of the DNA process and View result after capillary electrophoresis to view details like true profiles and peak heights.

Code examples mixture of two fixed contributors

Code examples kindly provided by Peter Green in GitHub discussion.

require(pcrsim)

# profile and sample for 2-contributor mixture, different fixed profile for each


# Create data frames with DNA profiles.

df1 <- data.frame(Marker=rep(c("D3S1358","D8S1179","FGA"), each=2),Allele=c(15,18,11,12,25,25),stringsAsFactors=FALSE)

df2 <- data.frame(Marker=rep(c("D3S1358","D8S1179","FGA"), each=2),Allele=c(11,13,14,14,18,20),stringsAsFactors=FALSE)


# Simulate profiles.

prof1 <- simProfile(data=df1, name="Test")

prof2 <- simProfile(data=df2, name="Test")


# Simulate mixture of diploid sample types of two concentrations.

res1 <- simSample(data=prof1, cells=1000)

res2 <- simSample(data=prof2, cells=500)

res0<-rbind(res1,res2)


print(res0[,c('Marker','Allele','Sample.Cells')])


# Simulate extraction.

res1 <- simExtraction(data=res0, vol.ex=100, sd.vol=0, prob.ex=1.0, sd.prob=0)


# Simulate PCR

res2 <- simPCR(data=res1, pcr.prob=1, pcr.cyc=28, stutter=TRUE, vol.aliq=20,

sd.vol.aliq=0, vol.pcr=50, sd.vol.pcr=1)


res3<-compactStutter(res2, targetcol = 'PCR.Amplicon', stutterin = "PCR.Stutter.", debug = FALSE)


res4<-compact(res3, per.sample = FALSE, col = "PCR.Amplicon", sim = TRUE, debug = FALSE)


# Simulate CE

res <- simCE(data=res4, vol=1, sd.vol=0)

print(res[,c('Marker','Allele','Height')])


generateEPG(res,kit='SGMPlus')


Code examples mixture of two random contributors

Code examples kindly provided by Peter Green in GitHub discussion.

require(pcrsim)

# profile and sample for 2-contributor mixture, sampling inds from database


db<-getDb("SGM Norway")


# Simulate profiles

prof <- simProfile(db=db, sim=2, name="Test")

prof


# Simulate mixture of diploid sample types of two concentrations.

res0 <- simSample(data=prof, cells=c(1000,500))


print(res0[,c('Marker','Allele','Sample.Cells')])


# Simulate extraction.

res1 <- simExtraction(data=res0, vol.ex=100, sd.vol=0, prob.ex=1.0, sd.prob=0)


# Simulate PCR

res2 <- simPCR(data=res1, pcr.prob=1, pcr.cyc=28, stutter=TRUE, vol.aliq=20,

sd.vol.aliq=0, vol.pcr=50, sd.vol.pcr=1)


res3<-compactStutter(res2, targetcol = 'PCR.Amplicon', stutterin = "PCR.Stutter.", debug = FALSE)


res4<-compact(res3, per.sample = FALSE, col = "PCR.Amplicon", sim = TRUE, debug = FALSE)


# Simulate CE

res <- simCE(data=res4, vol=1, sd.vol=0)

print(res[,c('Marker','Allele','Height')])


generateEPG(res,kit='SGMPlus')

Report bugs

Please report bugs at GitHub (direct link). Remember to provide a reproducible example if possible.

Source code

The source code is hosted at GitHub: https://github.com/OskarHansson/pcrsim.

Papers citing pcrsim

2021

Publications

Characterization of degradation and heterozygote balance by simulation of the forensic DNA analysis process, International Journal of Legal Medicine

Version history (main features)

1.0.2 - Minor bug fix and new method used in the paper [18.03.2017]

1.0.1 - Updated for compatibility with strvalidator 1.8. [10.03.2016]

1.0.0 - Re-released on CRAN with a new module based simulation structure. [21.04.2016]

0.1.1 - The package was archived 07.02.2014 due to need of restructuring.

0.1.1 - Updated for compatibility with strvalidator version 0.2.0 [23.05.2013]

0.1.0 - Initial release on CRAN [06.04.2013]

Screen shots

The profile tab

The Profile tab.

The sample tab.

The Sample tab.

The degradation tab

The Degradation tab.

The extraction tab.

The Extraction tab.

The normalization tab.

The Normalization tab.

The pcr tab.

The PCR tab.

The ce tab.

The CE tab.

The simulation tab.

The simulation tab.

A simulated profile.

A simulated profile.