def iqr(data, channels=None):
    """
    Calculate the Interquartile Range of the events in an FCSData object.

    Parameters
    ----------
    data : FCSData or numpy array
        NxD flow cytometry data where N is the number of events and D is
        the number of parameters (aka channels).
    channels : int or str or list of int or list of str, optional
        Channels on which to calculate the statistic. If None, use all
        channels.

    Returns
    -------
    float or numpy array
        The Interquartile Range of the events in the specified channels of
        `data`.

    Notes
    -----
    The Interquartile Range (IQR) of a dataset is defined as the interval
    between the 25% and the 75% percentiles of such dataset.

    """
    # Slice data to take statistics from
    if channels is None:
        data_stats = data
    else:
        data_stats = data[:, channels]

    # Calculate and return statistic
    q75, q25 = np.percentile(data_stats, [75 ,25], axis=0)
    return q75 - q25
Calculate the Interquartile Range of the events in an FCSData object.

    Parameters
    ----------
    data : FCSData or numpy array
        NxD flow cytometry data where N is the number of events and D is
        the number of parameters (aka channels).
    channels : int or str or list of int or list of str, optional
        Channels on which to calculate the statistic. If None, use all
        channels.

    Returns
    -------
    float or numpy array
        The Interquartile Range of the events in the specified channels of
        `data`.

    Notes
    -----
    The Interquartile Range (IQR) of a dataset is defined as the interval
    between the 25% and the 75% percentiles of such dataset.