def impute_mean(genotypes_t):
    """Impute missing genotypes to mean"""
    m = genotypes_t == -1
    a = genotypes_t.sum(1)
    b = m.sum(1).float()
    mu = (a + b) / (genotypes_t.shape[1] - b)
    ix = m.nonzero()
    genotypes_t[m] = mu[ix[:, (0)]]
