View source: R/imputeIntensity-functions.R
imputeKNN | R Documentation |
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.
imputeKNN(
x,
k = 10,
type = c("gower", "euclidean"),
by = c("feature", "sample"),
scale = FALSE,
...
)
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 |
... |
Arguments passed to VIM::kNN (Gower distance) or impute::impute.knn (Euclidean distance). |
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.
A matrix of the same dimension as x
containing the imputed
intensities.
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 imputeIntensity that provides a SummarizedExperiment-friendly wrapper for this function.
See VIM::kNN and missForest::missForest for the underlying functions that do work.
data(faahko_se)
m <- assay(faahko_se, "raw")
imputeKNN(m)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.