def filter_repeatlist(tr_list, pvalue_threshold=0.05, divergence_threshold=0.1, n_threshold=2.5):
    """Filter a list of tandem repeats based on specified criteria

    Parameters
    tr_list (tral.repeat_list.RepeatList):
                            List of repeats to filter
    pvalue_threshold (float):
                            P value cutoff for filter
    divergence_threshold (float):
                            Divergence cutoff for filter
    n_threshold (float):    Minimum number of repeat unit repetitions for repeat to be kept

    Returns
    tr_list_filtered (RepeatList):
                            Filtered list of repeats
    """

    # filtering for pvalue
    tr_list_filtered = tr_list.filter(
        "pvalue",
        "phylo_gap01",
        pvalue_threshold)

    # filtering for divergence
    tr_list_filtered = tr_list_filtered.filter(
        "divergence",
        "phylo_gap01",
        divergence_threshold)

    # filtering for number of repeat units
    tr_list_filtered = tr_list_filtered.filter(
        "attribute",
        "n_effective",
        "min",
        n_threshold)

    return tr_list_filtered