def perform_gender_filtering(maf_df, cli_df, filter_type):
    """Keep only samples in clinical_df in which the patient's gender matches
    the specified filter.

    Notes
    -----
    - If filter_type is "EXCLUDE_MALE", then exclude all 'Male' samples. Retain
     'Famale' and 'Unknown' Gender samples.
    """
    if filter_type == "EXCLUDE_MALE":
        keep_samples = set(cli_df[cli_df['Gender'] != "Male"]['Tumor_Sample_Barcode'].unique())

        cli_df = cli_df[cli_df['Tumor_Sample_Barcode'].isin(keep_samples)]
        maf_df = maf_df[maf_df['Tumor_Sample_Barcode'].isin(keep_samples)]

    else:
        raise Exception("Invalid filter_type: %s" % filter_type)

    return maf_df, cli_df