invert.pmultinom {pmultinom} | R Documentation |
Calculate the sample size such that the probability of a result is a given amount.
Description
Calculate the sample size such that the probability of a result is a given amount.
Usage
invert.pmultinom(lower = -Inf, upper = Inf, probs, target.prob, method)
Arguments
lower |
Vector of lower bounds. Lower bounds are excluded |
upper |
Vector of upper bounds. Upper bounds are included |
probs |
Cell probabilities |
target.prob |
The probability of the event, at the output sample size. |
method |
Method used for computation. Only method currently implemented is "exact" |
Details
If only lower is given, then the result is the smallest size such that pmultinom(lower=lower, size=size, probs=probs) >= target.prob. If only upper is given, then the result is the smallest size such that pmultinom(upper=upper, size=size, probs=probs) <= target.prob. Behavior when both lower and upper are given is not yet implemented.
Value
The sample size parameter at which the the target probability of the given event is achieved.
References
Casasent, A. K., Schalck, A., Gao, R., Sei, E., Long, A., Pangburn, W., ... & Navin, N. E. (2018). Multiclonal Invasion in Breast Tumors Identified by Topographic Single Cell Sequencing. Cell. doi:10.1016/j.cell.2017.12.007
See Also
Examples
# How many cells must be sequenced to have a 95% chance of
# observing at least 2 from each subclone of a tumor? (Data
# from Casasent et al (2018); see vignette("pmultinom") for
# details of this example)
# Input:
ncells <- 204
subclone.freqs <- c(43, 20, 82, 17, 5, 37)/ncells
target.number <- c(2, 2, 2, 2, 2, 0)
lower.bound <- target.number - 1
invert.pmultinom(lower=lower.bound, probs=subclone.freqs,
target.prob=.95, method="exact")
# Output:
# [1] 192