return function that filters by missing values
    (takes maximum fraction of missing values, default is 0.01)

def filter_by_missing(max_miss=0.01):
    """
    return function that filters by missing values
    (takes maximum fraction of missing values, default is 0.01)
    """

    def f(G, bim):
        Isnp = sp.isnan(G).mean(0) < max_miss
        G_out = G[:, Isnp]
        bim_out = bim[Isnp]
        return G_out, bim_out

    return f