Skip to contents

Replaces missing values in each marker (column) with that marker's mean dosage (i.e. twice the estimated allele frequency). Simple and fast; for production work a model-based imputation upstream is preferable.

Usage

impute_markers(geno)

Arguments

geno

A numeric marker matrix (individuals x markers), 0/1/2, possibly with NAs.

Value

The matrix with NAs filled by column means. Columns that are entirely missing are filled with 0.

Examples

g <- matrix(c(0, 1, NA, 2, 2, 0), nrow = 3)
impute_markers(g)
#>      [,1] [,2]
#> [1,]  0.0    2
#> [2,]  1.0    2
#> [3,]  0.5    0