def handle_effect_results(permutation_result):
    """Takes in output from multiprocess_permutation function and converts to
    a better formatted dataframe.

    Parameters
    ----------
    permutation_result : list
        output from multiprocess_permutation

    Returns
    -------
    permutation_df : pd.DataFrame
        formatted output suitable to save
    """
    mycols = ['gene', 'num recurrent', 'num inactivating', 'entropy-on-effect',
              'entropy-on-effect p-value',
              'Total Mutations', 'Unmapped to Ref Tx']
    permutation_df = pd.DataFrame(sorted(permutation_result, key=lambda x: x[4] if x[4] is not None else 1.1),
                                  columns=mycols)

    # get benjamani hochberg adjusted p-values
    permutation_df['entropy-on-effect BH q-value'] = mypval.bh_fdr(permutation_df['entropy-on-effect p-value'])

    # order output
    permutation_df = permutation_df.set_index('gene', drop=False)  # make sure genes are indices
    permutation_df['num recurrent'] = permutation_df['num recurrent'].fillna(-1).astype(int)  # fix dtype isssue
    col_order = ['gene', 'Total Mutations', 'Unmapped to Ref Tx',
                 'num recurrent', 'num inactivating', 'entropy-on-effect',
                 'entropy-on-effect p-value', 'entropy-on-effect BH q-value']
    return permutation_df[col_order]
def handle_effect_results ( permutation_result ) : mycols = [ 'gene' , 'num recurrent' , 'num inactivating' , 'entropy-on-effect' , 'entropy-on-effect p-value' , 'Total Mutations' , 'Unmapped to Ref Tx' ] permutation_df = pd . DataFrame ( sorted ( permutation_result , key = lambda x : x [ 4 ] if x [ 4 ] is not None else 1.1 ) , columns = mycols ) permutation_df [ 'entropy-on-effect BH q-value' ] = mypval . bh_fdr ( permutation_df [ 'entropy-on-effect p-value' ] ) permutation_df = permutation_df . set_index ( 'gene' , drop = False ) permutation_df [ 'num recurrent' ] = permutation_df [ 'num recurrent' ] . fillna ( - 1 ) . astype ( int ) col_order = [ 'gene' , 'Total Mutations' , 'Unmapped to Ref Tx' , 'num recurrent' , 'num inactivating' , 'entropy-on-effect' , 'entropy-on-effect p-value' , 'entropy-on-effect BH q-value' ] return permutation_df [ col_order ]
Takes in output from multiprocess_permutation function and converts to
    a better formatted dataframe.

    Parameters
    ----------
    permutation_result : list
        output from multiprocess_permutation

    Returns
    -------
    permutation_df : pd.DataFrame
        formatted output suitable to save