replNAbyLow {wrMisc} | R Documentation |
Replace NAs by low values
Description
With several screening techniques used in hight-throughput biology values at/below detection limit are returned as NA
.
However, the resultant NA
-values may be difficult to analyse properly, simply ignoring NA
-values mat not be a good choice.
When (technical) replicate measurements are available, one can look for cases where one gave an NA
while the other did not
with the aim of investigating such 'NA-neighbours'.
replNAbyLow
locates and replaces NA
values by (random) values from same line & same group 'grp'.
The origin of NAs should be predominantly absence of measure (quantitation) due to signal below limit of detection
and not saturation at upper detection limit or other technical problems.
Note, this approach may be not optimal if the number of NA-neighbours is very low.
Replacamet is done -depending on agrument 'unif'- by Gaussian random model based on neighbour values (within same group),
using their means and sd, or a uniform random model (min and max of neighbour values) .
Then numeric matrix (same dim as 'x') with NA
replaced is returned.
Usage
replNAbyLow(
x,
grp,
quant = 0.8,
signific = 3,
unif = TRUE,
absOnly = FALSE,
seed = NULL,
silent = FALSE,
callFrom = NULL
)
Arguments
x |
(numeric matrix or data.frame) main input |
grp |
(factor) to organize replicate columns of (x) |
quant |
(numeric) quantile form 'neighbour' values to use as upper limit for random values |
signific |
number of signif digits for random values |
unif |
(logical) toggle between uniform and Gaussian random values |
absOnly |
(logical) if TRUE, make negative NA-replacment values positive as absolute values |
seed |
(integer) for use with set.seed for reproducible output |
silent |
(logical) suppress messages |
callFrom |
(character) allow easier tracking of message(s) produced |
Value
numeric matrix (same dim as 'x') with NA
replaced
See Also
Examples
dat <- matrix(round(rnorm(30),2),ncol=6); grD <- gl(2,3)
dat[sort(sample(1:30,9,repl=FALSE))] <- NA
dat; replNAbyLow(dat,gr=grD)