1 Introduction

A two-step approach to imputing missing data in metabolomics. Step 1 uses a random forest classifier to classify missing values as either Missing Completely at Random/Missing At Random (MCAR/MAR) or Missing Not At Random (MNAR). MCAR/MAR are combined because it is often difficult to distinguish these two missing types in metabolomics data. Step 2 imputes the missing values based on the classified missing mechanisms, using the appropriate imputation algorithms. Imputation algorithms tested and available for MCAR/MAR include Bayesian Principal Component Analysis (BPCA), Multiple Imputation No-Skip K-Nearest Neighbors (Multi_nsKNN), and Random Forest. Imputation algorithms tested and available for MNAR include nsKNN and a single imputation approach for imputation of metabolites where left-censoring is present.

2 Installation

The following code chunk depicts how to install MAI from Bioconductor

3 Using MAI when your data is a data.frame or matrix

## Estimating pattern of missingness
## Imposing missingness
## Generating features
## Training
## Predicting
## Imputing
##          [,1]     [,2]     [,3]     [,4]     [,5]
## [1,] 12.87164 12.70516 12.11793 12.07897 11.18725
## [2,] 12.10813 12.36043 12.08463 12.07897 14.30504
## [3,] 12.10813 11.16815 12.08463 12.07897 11.79195
## [4,] 12.01395 12.28791 12.12017 12.07897 10.05397
## [5,] 11.32825 12.55314 12.23772 11.31292 12.28869
## $Alpha
## [1] 20
## 
## $Beta
## [1] 80
## 
## $Gamma
## [1] 60

These parameters estimate the ratio of MCAR/MAR to MNAR in the data. The parameters \(\alpha\) and \(\beta\) separate high, medium, and low average abundance metabolites, while the parameter \(\gamma\) is used to impose missingness in the medium and low abundance metabolites. A smaller \(\alpha\) corresponds to more MCAR/MAR being present, while larger \(\beta\) and \(\gamma\) values imply more MNAR values being present. The returned estimated parameters are then used to impose known missingness in the complete subset of the input data. Subsequently, a random forest classifier is trained to classify the known missingness in the complete subset of the input data. Once the classifier is established it is applied to the unknown missingness of the full input data to predict the missingness. Finally, the missing values are imputed using a specific algorithm, chosen by the user, according to the predicted missingness mechanism.

4 Using MAI when your data is a SummarizedExperiment (SE) class

## Estimating pattern of missingness
## Imposing missingness
## Generating features
## Training
## Predicting
## Imputing
##          [,1]     [,2]     [,3]     [,4]     [,5]
## [1,] 12.87164 12.70516 12.11793 12.07897 11.18725
## [2,] 12.10813 12.36043 12.08463 12.07897 14.30504
## [3,] 12.10813 11.16815 12.08463 12.07897 11.79195
## [4,] 12.01395 12.28791 12.12017 12.07897 10.05397
## [5,] 11.32825 12.55314 12.23772 11.31292 12.28869
## $Alpha
## [1] 20
## 
## $Beta
## [1] 80
## 
## $Gamma
## [1] 60

5 Session Information

## R Under development (unstable) (2021-10-19 r81077)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 20.04.3 LTS
## 
## Matrix products: default
## BLAS:   /home/biocbuild/bbs-3.15-bioc/R/lib/libRblas.so
## LAPACK: /home/biocbuild/bbs-3.15-bioc/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=en_GB              LC_COLLATE=C              
##  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats4    stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] SummarizedExperiment_1.25.0 Biobase_2.55.0             
##  [3] GenomicRanges_1.47.1        GenomeInfoDb_1.31.0        
##  [5] IRanges_2.29.0              S4Vectors_0.33.0           
##  [7] BiocGenerics_0.41.0         MatrixGenerics_1.7.0       
##  [9] matrixStats_0.61.0          caret_6.0-90               
## [11] lattice_0.20-45             ggplot2_3.3.5              
## [13] MAI_1.1.0                   BiocStyle_2.23.0           
## 
## loaded via a namespace (and not attached):
##   [1] colorspace_2.0-2       ellipsis_0.3.2         class_7.3-19          
##   [4] XVector_0.35.0         fs_1.5.0               proxy_0.4-26          
##   [7] listenv_0.8.0          prodlim_2019.11.13     fansi_0.5.0           
##  [10] lubridate_1.8.0        xml2_1.3.2             codetools_0.2-18      
##  [13] splines_4.2.0          doParallel_1.0.16      knitr_1.36            
##  [16] itertools_0.1-3        jsonlite_1.7.2         pROC_1.18.0           
##  [19] broom_0.7.9            dbplyr_2.1.1           missForest_1.4        
##  [22] BiocManager_1.30.16    readr_2.0.2            compiler_4.2.0        
##  [25] httr_1.4.2             backports_1.3.0        assertthat_0.2.1      
##  [28] Matrix_1.3-4           fastmap_1.1.0          htmltools_0.5.2       
##  [31] tools_4.2.0            gtable_0.3.0           glue_1.4.2            
##  [34] GenomeInfoDbData_1.2.7 reshape2_1.4.4         dplyr_1.0.7           
##  [37] Rcpp_1.0.7             cellranger_1.1.0       jquerylib_0.1.4       
##  [40] vctrs_0.3.8            nlme_3.1-153           iterators_1.0.13      
##  [43] timeDate_3043.102      gower_0.2.2            xfun_0.27             
##  [46] stringr_1.4.0          globals_0.14.0         rvest_1.0.2           
##  [49] lifecycle_1.0.1        future_1.22.1          MASS_7.3-54           
##  [52] zlibbioc_1.41.0        scales_1.1.1           ipred_0.9-12          
##  [55] pcaMethods_1.87.0      hms_1.1.1              parallel_4.2.0        
##  [58] tidyverse_1.3.1        yaml_2.2.1             sass_0.4.0            
##  [61] rpart_4.1-15           stringi_1.7.5          randomForest_4.6-14   
##  [64] foreach_1.5.1          e1071_1.7-9            lava_1.6.10           
##  [67] rlang_0.4.12           pkgconfig_2.0.3        bitops_1.0-7          
##  [70] evaluate_0.14          purrr_0.3.4            recipes_0.1.17        
##  [73] tidyselect_1.1.1       parallelly_1.28.1      plyr_1.8.6            
##  [76] magrittr_2.0.1         bookdown_0.24          R6_2.5.1              
##  [79] generics_0.1.1         DelayedArray_0.21.0    DBI_1.1.1             
##  [82] pillar_1.6.4           haven_2.4.3            withr_2.4.2           
##  [85] survival_3.2-13        RCurl_1.98-1.5         nnet_7.3-16           
##  [88] tibble_3.1.5           future.apply_1.8.1     modelr_0.1.8          
##  [91] crayon_1.4.1           utf8_1.2.2             tzdb_0.2.0            
##  [94] rmarkdown_2.11         grid_4.2.0             readxl_1.3.1          
##  [97] data.table_1.14.2      forcats_0.5.1          ModelMetrics_1.2.2.2  
## [100] reprex_2.0.1           digest_0.6.28          tidyr_1.1.4           
## [103] munsell_0.5.0          bslib_0.3.1

6 References