View source: R/missing_data_diagnostics.R
| safe_impute | R Documentation |
Fills missing entries feature by feature with a single summary of that feature's observed values. This is a starting point for the EM algorithm, not a substitute for it: LUCID's own E-step imputes missing omics values under the fitted cluster model (an internal EM detail, not part of the public API), and single-value filling here only has to be finite and roughly located.
Unlike a bare mean(x, na.rm = TRUE), a feature with no observed
value does not yield NaN: it falls back to the mean over the whole
matrix and warns. Note that this fallback uses the mean whichever
method was requested, since a median or limit of detection is not
defined for a feature with nothing observed.
safe_impute(Z, method = c("mean", "median", "lod"))
Z |
A numeric matrix with missing values coded |
method |
The summary used to fill a feature:
|
A matrix of the same dimensions as Z with no missing values,
unless every value of Z is missing, in which case Z is
returned unchanged with a warning.
check_imputation_quality to check the result, and the
init_impute argument of estimate_lucid for the
imputation LUCID applies internally.
Z <- matrix(rnorm(100), nrow = 10)
Z[2:4, 2] <- NA
colMeans(is.na(safe_impute(Z, method = "median")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.