Skip to contents

A function to replace NA in the data frame using metabolomic Non-negative Matrix Factorization.

Usage

impute_mnmf(missdf, kgroup = NULL, initialType = "mean")

Arguments

missdf

a data frame with missing values to be imputed containing features in columns and samples in rows.

kgroup

the range of k value.

initialType

type of pre-imputation. Possible values are: mean, median, and zero.

Value

A data.frame with imputed values by mNMF.

k

If k is not defined, it becomes a range between 1 and the minimum of number of columns and number of rows of missdf as advised in the original article (see References).

Original implementation

This function was adapted from https://github.com/freeoliver-jing/NMF.

References

Xu J, Wang Y, Xu X, Cheng K, Raftery D, Dong J (2021). “NMF-Based Approach for Missing Values Imputation of Mass Spectrometry Metabolomics Data.” Molecules, 26(19), 5787. ISSN 1420-3049, doi:10.3390/molecules26195787 .

Examples

data(sim_miss)
impute_mnmf(sim_miss + 100)
#>          X1       X2       X3       X4       X5       X6
#> 1  100.1551 100.8812 100.4637 100.1195 100.6004 100.5534
#> 2  100.9684 100.6075 100.6338 100.6181 100.0081 100.7521
#> 3  100.4683 100.5745 100.2476 100.2983 100.3701 100.5832
#> 4  100.7768 100.8031 100.5513 100.1460 100.7242 100.8478
#> 5  100.4079 100.7991 100.2348 100.1897 100.4183 100.7087
#> 6  100.5388 100.8019 100.2586 100.5755 100.2382 100.4700
#> 7  100.8301 100.7521 100.9529 100.0002 100.8879 100.4883
#> 8  100.1871 100.5755 100.8569 100.3283 100.5778 100.3472
#> 9  100.7800 100.9442 100.6595 100.0783 100.7400 100.2030
#> 10 100.1939 100.2190 100.5545 100.6042 100.1607 100.7400
#> 11 100.4342 100.4780 100.8769 100.3268 100.5296 100.8937
#> 12 100.0023 100.0447 100.8019 100.7905 100.5745 100.5745
#> 13 100.8347 100.1685 100.5467 100.8301 100.9601 100.0844
#> 14 100.7042 100.3683 100.2328 100.8101 100.3986 100.1483
#> 15 100.9570 100.5633 100.6023 100.2028 100.4085 100.3703
#> 16 100.9485 100.7202 100.7125 100.5060 100.6133 100.8612
#> 17 100.6007 100.7343 100.6489 100.5207 100.7066 100.8367
#> 18 100.2618 100.7037 100.1876 100.0843 100.7991 100.7405
#> 19 100.6430 100.7368 100.2384 100.2688 100.1613 100.9858
#> 20 100.5262 100.5922 100.7671 100.8147 100.8859 100.0321