def subsample_region(df_in, region, threshold):
    """Subsample crosslinks to save memory and time while running."""
    if len(df_in) > threshold:
        print(
            f'Subsampling {region} crosslinks, {threshold} randomly selected crosslinks used.'
            )
        return df_in.sample(threshold, random_state=4242, axis=0)
    else:
        return df_in
