def gene_sample_count(insertions, name='n_samples'):
    """Calculates the number of samples with insertions for each gene.

    Parameters
    ----------
    insertions : pd.DataFrame
        Insertion dataframe.
    name : str
        Name to use for the returned series.

    Returns
    -------
    pd.Series
        Gene sample counts for the given insertion set.
    """

    count = insertions.groupby('gene_name')['sample'].nunique()
    count.name = name
    return count