return function that filters by maf
    (takes minimum maf, default is 0.01)

def filter_by_maf(min_maf=0.01):
    """
    return function that filters by maf
    (takes minimum maf, default is 0.01)
    """

    def f(G, bim):
        maf = 0.5 * G.mean(0)
        maf[maf > 0.5] = 1.0 - maf[maf > 0.5]
        Isnp = maf > min_maf
        G_out = G[:, Isnp]
        bim_out = bim[Isnp]
        return G_out, bim_out

    return f