findBgnd | R Documentation |
Find the fluorescent value between negative and positive cells
findBgnd(x, mult = 3, log = TRUE, crit = 0.1, ratio.limit = 1/10)
x |
fluorescent values to evaluate |
mult |
numeric multiplier applied to the standard deviation for a non-bimodal distributions, default value of 3 |
log |
a |
crit |
the critical p-value between 0 and 1 to distinguish bimodal from non-bimodal populations, default of 0.1 |
ratio.limit |
if the ratio of the first peak height to the second peak height exceeds this value (1/10), the population could be bimodal |
The modetest
function tests whether the values have
a bimodal (or multimodal) distribution. If the p-value from this test is less
than the critical value (crit
), the background value is considered
to be the value at the first "valley" in the kernel density distribution.
For such bimodal distributions, the mult
parameter is ignored.
If the distribution is not bimodal, the population is assumed to be a mixture
of values from a normal distribution of low values and a lognormal (or log)
distribution of high values. The maximum of low values is determined from a
kernel density estimate and the left half of the distribution is fit
to a Gaussian distribution with the fitdistr
function.
The value returned is the position of the peak + mult
times the
estimated standard deviation of the fitted distribution.
Because fluorescent values are typically log-transformed before analysis,
values are log-transformed by default. This can be turned
off with the log
parameter. Typically, the parameter mult
must be empirically determined for non-bimodal distributions. See the
examples for the impact of mult
on the return value. Note that with
mult = 0
, the peak value of a non-bimodal distribution will be
returned.
If the distribution is very heavily skewed to the left (mostly dark values), the standard deviation of the distribution will be estimated as 1.35x the interquartile range.
It may be helpful to discard exceptionally low values before finding an estimated background should the estimated background be absurdly low. The code currently discards the upper and lower 1 per cent of values before fitting to a normal (or lognormal) distribution.
For bimodally distributed values, the value at the valley between the two populations. For non-bimodally distributed values, the value of the most abundant value + mult * standard deviation of the estimated distribution.
getZero
getBgnd
dev.new(width = 6, height = 8)
set.seed(1234)
par(mfrow = c(2, 1))
x1 <- c(rlnorm(100), rlnorm(30, 4))
bg <- findBgnd(x1)
plot(density(log(x1)), main = "Bimodal ('mult' is ignored)")
abline(v = log(bg), col = 2) # background limit
x2 <- c(rlnorm(80), rlnorm(40, 6, sdlog = 5))
bg <- sapply(0:4, function(m) findBgnd(x2, mult = m))
plot(density(log(x2)), main = "Non-bimodal")
abline(v = log(bg), col = 1:5) # background limit
txt <- expression(mult %*% sd)
legend("topright", legend = 0:4, title = txt, lty = 1, col = 1:5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.