A function that simulates results of a droplet digital PCR.

sim_dpcr(m, n, times, n_exp = 1, dube = FALSE, pos_sums = FALSE,
  fluo = NULL)

Arguments

m
the total number of template molecules used in the expertiment. Must be a positive integer.
n
the number of droplets per experiment. Must be a positive integer.
times
number of repetitions (see Details).
n_exp
the number of experiments that are simulated by the function. Cannot have higher value than the times argument.
dube
if TRUE, the function is strict implementation of digital PCR simulation (as in Dube et al., 2008). If FALSE, the function calculates only approximation of Dube's experiment. See Details and References.
pos_sums
if TRUE, function returns only the total number of positive (containing at least one molecule) chamber per panel. If FALSE, the functions returns a vector of length equal to the number of chambers. Each element of the vector represents the number of template molecules in a given chamber.
fluo
if NULL, the function calculates number of molecules per well or total number of positive droplets. If list of two, the first argument defines smoothness of the fluorescence curve and second space between two consecutive measured droplets. Space must be a vector containing positive integers of the length n or 1.

Value

If the pos_sums argument has value FALSE, the function returns matrix with \(n\) rows and \(n_panels\) columns. Each column represents one plate. The type of such simulation would be "nm". If the pos_sums argument has value TRUE, the function return matrix with one row and \(n_panels\) columns. Each column contains the total number of positive chambers in each plate and type of simulation would be set as "tnp".

In each case the value is an object of the dpcr class.

Details

The function contains two implementations of the array digital PCR simulation. First one was described in Dube at. al (2008). This method is based on random distributing \(m \times times\) molecules between \(n \times times\) chambers. After this step, the required number of plates is created by the random sampling of chambers without replacement. The above method is used, when the dube argument has value TRUE.

The higher the value of the argument times, the simulation result is closer to theoretical calculations.

Note

Although Dube's simulation of digital PCR was developed for array digital PCR, it's also viable for simulating droplet-based methods.

See also

sim_adpcr.

Examples

#simulate fluorescence data tmp_VIC <- sim_dpcr(m = 7, n = 20, times = 5, fluo = list(0.1, 0)) tmp_FAM <- sim_dpcr(m = 15, n = 20, times = 5, fluo = list(0.1, 0)) par(mfrow = c(2,1)) plot(tmp_VIC, col = "green", type = "l") plot(tmp_FAM, col = "blue", type = "l")
summary(tmp_FAM)
#> #> Number of positive partitions: 11 #> Total number of partitions: 20 #> #> Number of runs: 1 #> Number of experiments: 1 #> #> experiment replicate assay method lambda lambda.low lambda.up m #> Experiment1 1 Unknown dube 0.7985077 0.4034189 1.461157 15.97015 #> Experiment1 1 Unknown bhat 0.7985077 0.5513011 1.045714 15.97015 #> m.low m.up c c.low c.up k n #> 8.068377 29.22314 0.7985077 0.4034189 1.461157 11 20 #> 11.026022 20.91429 0.7985077 0.5513011 1.045714 11 20
summary(sim_dpcr(m = 7, n = 20, times = 5, n_exp = 5))
#> The assumed volume of partitions in each run is equal to 1.
#> The assumed volume uncertainty in each run is equal to 0.
#> #> Number of positive partitions: 5, 5, 6, 5, ... #> Total number of partitions: 20, 20, 20, 20, ... #> #> Number of runs: 5 #> Number of experiments: 1 #> #> experiment replicate assay method lambda lambda.low lambda.up m #> Experiment1 1 Unknown dube 0.2876821 0.06211724 0.5794127 5.753641 #> Experiment1 1 Unknown bhat 0.2876821 0.15858263 0.4167815 5.753641 #> Experiment1 2 Unknown dube 0.2876821 0.06211724 0.5794127 5.753641 #> Experiment1 2 Unknown bhat 0.2876821 0.15858263 0.4167815 5.753641 #> Experiment1 3 Unknown dube 0.3566749 0.10443145 0.6948217 7.133499 #> Experiment1 3 Unknown bhat 0.3566749 0.21028993 0.5030600 7.133499 #> Experiment1 4 Unknown dube 0.2876821 0.06211724 0.5794127 5.753641 #> Experiment1 4 Unknown bhat 0.2876821 0.15858263 0.4167815 5.753641 #> Experiment1 5 Unknown dube 0.4307829 0.15194293 0.8187950 8.615658 #> Experiment1 5 Unknown bhat 0.4307829 0.26670039 0.5948654 8.615658 #> m.low m.up c c.low c.up k n #> 1.242345 11.58825 0.2876821 0.06211724 0.5794127 5 20 #> 3.171653 8.33563 0.2876821 0.15858263 0.4167815 5 20 #> 1.242345 11.58825 0.2876821 0.06211724 0.5794127 5 20 #> 3.171653 8.33563 0.2876821 0.15858263 0.4167815 5 20 #> 2.088629 13.89643 0.3566749 0.10443145 0.6948217 6 20 #> 4.205799 10.06120 0.3566749 0.21028993 0.5030600 6 20 #> 1.242345 11.58825 0.2876821 0.06211724 0.5794127 5 20 #> 3.171653 8.33563 0.2876821 0.15858263 0.4167815 5 20 #> 3.038859 16.37590 0.4307829 0.15194293 0.8187950 7 20 #> 5.334008 11.89731 0.4307829 0.26670039 0.5948654 7 20