imputeKNN: k-nearest neighbor imputation

View source: R/imputeIntensity-functions.R

imputeKNNR Documentation

k-nearest neighbor imputation

Description

Performs k-nearest neighbor (kNN) imputation on a matrix-like object where rows represent features and columns represent samples. This function finds k-nearest neighbors using either Gower distance or Euclidean distance.

Usage

imputeKNN(
  x,
  k = 10,
  type = c("gower", "euclidean"),
  by = c("feature", "sample"),
  scale = FALSE,
  ...
)

Arguments

x

A matrix-like object.

k

An integer specifying the number of nearest neighbors to be used in imputation.

type

A string specifying the distance metric to be used. Either "gower" or "euclidean".

by

A string specifying whether the imputation is performed by k-nearest features or by k-nearest samples. Either "feature" or "sample".

scale

A logical specifying whether x needs to be standardized prior to the imputation when Euclidean distance is used. The imputed values are re-transformed so that they are on the original scales.

...

Arguments passed to VIM::kNN (Gower distance) or impute::impute.knn (Euclidean distance).

Details

The kNN imputation based on Euclidean distance typically requires standardization of input data to avoid variance-based weighting of variables (make variables on similar scales). When Gower distance is used, the imputation can be done with original units (would get the same result with the standardized input on a different scale). The type "gower" utilizes the VIM::kNN and "euclidean" uses the impute::impute.knn.

Value

A matrix of the same dimension as x containing the imputed intensities.

References

Trevor Hastie, Robert Tibshirani, Balasubramanian Narasimhan and Gilbert Chu (2021). impute: impute: Imputation for microarray data. R package version 1.66.0.

Alexander Kowarik, Matthias Templ (2016). Imputation with the R Package VIM. Journal of Statistical Software, 74(7), 1-16. doi:10.18637/jss.v074.i07

See Also

See imputeIntensity that provides a SummarizedExperiment-friendly wrapper for this function.

See VIM::kNN and missForest::missForest for the underlying functions that do work.

Examples


data(faahko_se)

m <- assay(faahko_se, "raw")
imputeKNN(m)


HimesGroup/qmtools documentation built on April 16, 2023, 8 p.m.