def dict_filter(posdict, filterset):
    """
    Applies a filter on the values of the input dictionary
    Values in the dictionary are lists whose elements that aren't present in
    the filterset are removed

    Parameters
    ----------
    posdict : dictionary of the format returned by search_multiPos_link()

    filterset : list containing positions in the format id_position or chr_position

    Returns
    -------
    return_dict : dictionary in the same format as postdict and preserved keys,
    with lists in the values filtered
    """
    return_dict = {}
    for key, value in posdict.items():
        filterlist = list((set(filterset).intersection(set(value))))
        for k in posdict:
            if k in filterlist:
                filterlist.remove(str(k))
        return_dict[key] = filterlist
    return return_dict