def cal_fdp_power(selected, non_zero_index, r_index=False):
    """ Calculate power and False Discovery Proportion

    Parameters
    ----------
    selected: list index (in R format) of selected non-null variables
    non_zero_index: true index of non-null variables
    r_index : True if the index is taken from rpy2 inference

    Returns
    -------
    fdp: False Discoveries Proportion
    power: percentage of correctly selected variables over total number of
        non-null variables

    """
    # selected is the index list in R and will be different from index of
    # python by 1 unit

    if selected.size == 0:
        return 0.0, 0.0

    if r_index:
        selected = selected - 1

    true_positive = [i for i in selected if i in non_zero_index]
    false_positive = [i for i in selected if i not in non_zero_index]
    fdp = len(false_positive) / max(1, len(selected))
    power = len(true_positive) / len(non_zero_index)

    return fdp, power