rflan: The distribution of mutant cell counts

Description Usage Arguments Details Value See Also Examples

View source: R/flan.R

Description

Density, distribution function, quantile function and random generation for mutant cell counts.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
  dflan(m, mutations = 1., fitness = 1., death = 0., plateff = 1.,
        model = c("LD", "H", "I"), muinf = +Inf)
  pflan(m, mutations = 1., fitness = 1., death = 0., plateff = 1.,
        model = c("LD", "H", "I"), muinf = +Inf, lower.tail = TRUE)
  qflan(p, mutations = 1., fitness = 1., death = 0., plateff = 1.,
        model = c("LD", "H", "I"), muinf = +Inf, lower.tail = TRUE)
  rflan(n, mutations = 1., mutprob = NULL, fitness = 1., death = 0., plateff = 1.,
        dist = list(name = "lnorm", meanlog = -0.3795851, sdlog = 0.3016223),
        distfn = NULL,
        mfn = 1e9, cvfn = 0,
        muih = list(mu = NULL, muinv0 = NULL),
        ...)

Arguments

m

vector of quantiles.

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

mutations

mean number of mutations: positive integer. Ignored if mutprob is non-empty.

mutprob

mutation probability: numeric between 0 and 1. By default empty. See details.

fitness

fitness parameter: numeric positive. By default 1.

death

death probability: numeric between 0 and 0.5. By default 0.

plateff

plating efficiency parameter: numeric number between 0 and 1. By default 1. See Details.

dist

lifetime distribution for mutant cells. See Details.

model

statistical lifetime model. Must be one of "LD" (default) for Luria-Delbrück model (exponential lifetimes), "H" for Haldane model (constant lifetimes), or "I" for Inhomogeneous model

distfn

final number of cells distribution. Must be one of "lnorm" (default if cvfn is positive) or "gamma".

mfn

mean final number of cells: numeric positive.

cvfn

coefficient of variation of final numbers of cells: numeric, default 0. If non-zero and if mutprob is empty, compute the sample with mutprob = mutations/mfn

muih

functions for inhomogeneous model. See details.

muinf

parameter used only if model is I. See details.

lower.tail

logical: if TRUE (default), probabilities are P[X <= x] otherwise, P[X > m].

...

Arguments to be passed for muih, such that hyperparameters.

Details

The argument dist is a list beginning with the distribution name followed by its parameters, and must be one the 4 following distributions: "dirac", "exp", "lnorm"(meanlog, sdlog), "gamma"(shape, scale). Note that the parameters related to the "dirac" and "exp" cases are directly computed with inputs fitness and death.

If muih$mu is non-empty, a time dependent growth model is performed. The function muih$mu is a bivariate function which represents roughly the mean growth of clone durig an time interval. The function muih$muinv0 is the inverse function of muih$mu(0,.). If muih$muinv0 is empty, it is approximated using muih$mu.

muinf corresponds to the cumulative division rate on the interval [0 ; +Inf). It is the limit as t tends to infinity of muih$mu(0,t). If model is I, muinf has to be finite, else model is set to "LD"

If mutprob is non-empty and if cvfn is zero, the sample of mutants is computed with mutations as the product of mutprob by mfn. If cvfn is positive, the final numbers of cells are generated with the log-normal (if distfn is "lnorm" or empty) or the gamma (if distfn is "gamma") distribution with mean mfn and coefficient of variation cvfn. The sample of mutants is then generated conditionally to the sample of final numbers of cells.

A plating efficiency plateff smaller than 1 can be taken into account in the dflan, pflan and qflan functions only under LD model.

If the plating efficiency plateff is smaller than 1 in the flan function, then each mutant count mc is replaced by a binomial number with parameters size = mc and prob = plateff.

Value

dflan gives the density, pflan gives the distribution function, qflan gives the quantile function, and rflan generates a random sample.

rflan returns a list with two arguments, each with length n: a vector of integers $mc (mutant counts), and a vector of numeric $fn (final numbers of cells).

See Also

link{draw.clone}

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#----------------------- distributions ----------------------------------

# Luria-Delbrück model, mean number of mutations 1, fitness parameter 1
dflan(0:10)
pflan(0:10)
qflan(c(0.95, 0.99))

# Luria-Delbrück model, mean number of mutations 2, fitness parameter 0.5
qflan(c(0.95, 0.99), mutations = 2, fitness = 0.5)

qflan(c(0.05, 0.01), mutations = 2, fitness = 0.5, lower.tail = FALSE)

# Haldane model, mean number of mutations 2, fitness parameter 0.5
qflan(c(0.95, 0.99), mutations = 2, fitness = 0.5, model = "H")

#---------------------- random samples ----------------------------------
# lognormal lifetime distribution, lognormal final numbers
X <- rflan(100, cvfn = 0.3)
X$mc              # mutant counts
X$fn              # final numbers

# lognormal lifetime distribution, gamma final numbers
X <- rflan(100, distfn = "gamma", cvfn = 0.3)
X$mc              # mutant counts
X$fn              # final numbers

# mean number of mutations 2, fitness parameter 0.5 (realistic model, but slow)

# lognormal lifetimes
rflan(1000, mutations = 2, fitness = 0.5)$mc
# gamma lifetimes
rflan(1000, mutations = 2, fitness = 0.5, dist = list(name = "gamma", shape = 10, scale = 0.05))$mc

# exponential lifetimes (Luria-Delbrück model, fast)
rflan(1000, mutations = 2, fitness = 0.5, dist = list("exp"))$mc

# constant lifetimes (Haldane model, fast)
rflan(1000, mutations = 2, fitness = 0.5, dist = "dirac")$mc

# specifying mutation probability and mean final number

rflan(1000, mutprob = 2e-9, mfn = 2e9, fitness = 0.5, dist = list("dirac"))$mc


# positive cell death probability
rflan(1000, mutprob = 2e-9, mfn = 2e9, death = 0.1, fitness = 0.5, dist = list("exp"))$mc

#------------- Inhomogeneous model ---------
f <- function(t,n0,nf) nf/(1+(nf/n0-1)*exp(-t))  # Logistic function: mean growth of a clone
finv <- function(s,n0,nf) -log((nf/s-1)/(nf/n0-1))  # Inverse function of f

mu <- function(s,t,n0,nf) log(f(t,n0,nf)/f(s,n0,nf))   # Definition of mu
muinv0 <- function(u,n0,nf) finv(f(0.,n0,nf)*exp(u),n0,nf)   # Inverse function of mu

rflan(1000, muih = list(mu = mu, muinv0 = muinv0), n0 = 1e2, nf = 1e6)$mc

flan documentation built on June 7, 2021, 9:07 a.m.