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"))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.
A numeric matrix with missing values coded NA.
The summary used to fill a feature:
The feature's observed mean.
The feature's observed median; preferable for a skewed feature, where the mean is pulled towards the tail.
The feature's observed minimum divided by \(\sqrt{2}\), the standard substitution for values below an assay's limit of detection. This is appropriate only for data on the original measurement scale, where the minimum stands in for the detection limit; on centred or standardised data the observed minimum is negative and dividing it by \(\sqrt{2}\) moves the filled value up, which is not what the convention intends.
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")))
Run the code above in your browser using DataLab