Replace missing values with a proportion of the row minimum
Source:R/functions-imputation.R
imputeRowMin.Rd
imputeRowMin
imputes missing values in x
by replacing NA
s in each row
with a proportion of the minimal value for that row (i.e.
min_fraction * min(x[i, ])
).
Arguments
- x
matrix
with abundances, rows being features/metabolites and columns samples.- min_fraction
numeric(1)
with the fraction of the row minimum that should be used to replaceNA
values in that row.
See also
imputeLCMD
package for more left censored imputation functions.
Other imputation functions:
imputeRowMinRand()
Examples
library(MSnbase)
library(faahKO)
data("faahko")
xset <- group(faahko)
mat <- groupval(xset, value = "into")
mat_imp <- imputeRowMin(mat)
head(mat)
#> ko15 ko16 ko18 ko19 ko21 ko22
#> 200.1/2926 147887.5 451600.7 65290.38 NA 91635.45 162012.4
#> 205/2791 1778568.9 1567038.1 1482796.38 1039129.8 1223132.35 1072037.7
#> 206/2790 237993.6 269714.0 201393.42 150107.3 176989.65 156797.0
#> 207.1/2719 380873.0 460629.7 351750.14 219288.0 286848.56 235022.6
#> 219.1/2525 235544.9 173623.4 NA NA 185792.43 174458.8
#> 231/2517 NA NA 222609.07 286232.1 435094.49 NA
#> wt15 wt16 wt18 wt19 wt21 wt22
#> 200.1/2926 175177.1 82619.48 NA 69198.22 153273.5 98144.28
#> 205/2791 1950287.5 1466780.60 1572679.16 1275312.76 1356014.3 1231442.16
#> 206/2790 276541.8 222366.15 211717.71 186850.88 188285.9 172348.76
#> 207.1/2719 417169.6 324892.46 277990.70 220972.35 252874.0 236728.16
#> 219.1/2525 244584.5 161184.05 72029.38 NA 238194.4 173829.95
#> 231/2517 NA NA NA 240261.21 201316.2 179437.72
head(mat_imp)
#> ko15 ko16 ko18 ko19 ko21 ko22
#> 200.1/2926 147887.53 451600.71 65290.38 32645.19 91635.45 162012.44
#> 205/2791 1778568.94 1567038.14 1482796.38 1039129.82 1223132.35 1072037.70
#> 206/2790 237993.62 269713.98 201393.42 150107.31 176989.65 156797.04
#> 207.1/2719 380873.05 460629.74 351750.14 219287.97 286848.56 235022.63
#> 219.1/2525 235544.92 173623.38 36014.69 36014.69 185792.43 174458.77
#> 231/2517 89718.86 89718.86 222609.07 286232.15 435094.49 89718.86
#> wt15 wt16 wt18 wt19 wt21 wt22
#> 200.1/2926 175177.08 82619.48 32645.19 69198.22 153273.5 98144.28
#> 205/2791 1950287.49 1466780.60 1572679.16 1275312.76 1356014.3 1231442.16
#> 206/2790 276541.85 222366.15 211717.71 186850.88 188285.9 172348.76
#> 207.1/2719 417169.58 324892.46 277990.70 220972.35 252874.0 236728.16
#> 219.1/2525 244584.47 161184.05 72029.38 36014.69 238194.4 173829.95
#> 231/2517 89718.86 89718.86 89718.86 240261.21 201316.2 179437.72
## Replace with 1/8 of the row mimimum
head(imputeRowMin(mat, min_fraction = 1/8))
#> ko15 ko16 ko18 ko19 ko21 ko22
#> 200.1/2926 147887.53 451600.71 65290.385 8161.298 91635.45 162012.44
#> 205/2791 1778568.94 1567038.14 1482796.385 1039129.818 1223132.35 1072037.70
#> 206/2790 237993.62 269713.98 201393.415 150107.310 176989.65 156797.04
#> 207.1/2719 380873.05 460629.74 351750.138 219287.968 286848.56 235022.63
#> 219.1/2525 235544.92 173623.38 9003.672 9003.672 185792.43 174458.77
#> 231/2517 22429.72 22429.72 222609.068 286232.146 435094.49 22429.72
#> wt15 wt16 wt18 wt19 wt21 wt22
#> 200.1/2926 175177.08 82619.48 8161.298 69198.222 153273.5 98144.28
#> 205/2791 1950287.49 1466780.60 1572679.161 1275312.758 1356014.3 1231442.16
#> 206/2790 276541.85 222366.15 211717.713 186850.878 188285.9 172348.76
#> 207.1/2719 417169.58 324892.46 277990.701 220972.352 252874.0 236728.16
#> 219.1/2525 244584.47 161184.05 72029.378 9003.672 238194.4 173829.95
#> 231/2517 22429.72 22429.72 22429.715 240261.212 201316.2 179437.72