Learn R Programming

dpcR (version 0.3)

test_ratio: Rate ratio test

Description

The test for comparing ratio of two Poisson means: $r = \lambda_1/\lambda_2$.

Usage

test_ratio(dpcr1, dpcr2, alternative = c("two.sided", "less", "greater"), conf.level = 0.95)

Arguments

dpcr1
a (non-empty) numeric vector of data values of length 2 or more or an object of class adpcr or ddpcr. See Details.
dpcr2
a (non-empty) numeric vector of data values of length 2 or more or an object of class adpcr or ddpcr. See Details.
alternative
alternative hypothesis, must be one of: two.sided, greater or less.
conf.level
confidence level for the returned confidence interval.

Value

An object of class `htest' containing the following components:
p.value
the p-value of the test
estimate
a vector with the means (lambdas) of both experiments and their ratio
conf.int
confidence interval for ratio between two experiments.
alternative
type of alternative hypothesis
method
description of method
data.name
description of data

Details

Objects dpcr1 and dpcr2 can be:
  1. numeric vectors of length 2. The first element is assumed to be number of positive partitions and the second one to be the total number of partitions.
  2. numeric vectors of length greater than 2. The length of vector is assumed to represent total number of partitions. Every element of the vector with value bigger than 0 is assumed to be a positive partitions.
  3. adpcr objects with type tnp (total number of positive wells in panel) or nm (number of molecules per partition). ddpcr objects with type tnp (total number of positive droplets) or nm (number of molecules per droplet).
Both dpcr1 and dpcr2 must have the same class. See Examples.

The ratio_test is a wrapper around rateratio.test function with custom input and output tailored specifically for digital PCR experiments.

References

Fay M.P. Two-sided exact tests and matching confidence intervals for discrete data R Journal 2 (1), 2010.

See Also

See also poisson.test.

Examples

Run this code

# Input values are numeric vectors representing dPCR experiments
x1 <- rpois(765, 1.1)
x2 <- rpois(765, 1.1)
test_ratio(x1, x2)

# Input values represent only number of positive partitions and total 
# partitions
x3 <- sum(rpois(765, 1.1) > 0)
x4 <- sum(rpois(765, 1.1) > 0)
test_ratio(c(x3, 765), c(x4, 765))

# It is possible to mix different types of input as long as they have 
# the same class
test_ratio(c(x3, 765), x1)

# The same is true for adpcr and dpcr objects.
x5 <- sim_adpcr(400, 1600, 100, pos_sums = TRUE, n_panels = 1)
x6 <- sim_adpcr(400, 1600, 100, pos_sums = FALSE, n_panels = 1)
test_ratio(x5, x6)

x7 <- sim_ddpcr(400, 1600, 100, pos_sums = TRUE, n_exp = 1)
x8 <- sim_ddpcr(400, 1600, 100, pos_sums = FALSE, n_exp = 1)
test_ratio(x7, x8)

Run the code above in your browser using DataLab