@profile<EOL>def lfdr(p_values, pi0, trunc = True, monotone = True, transf = "<STR_LIT>", adj = <NUM_LIT>, eps = np.power(<NUM_LIT>,-<NUM_LIT:8>)):
p = np.array(p_values)<EOL>lfdr_out = p<EOL>rm_na = np.isfinite(p)<EOL>p = p[rm_na]<EOL>if (min(p) < <NUM_LIT:0> or max(p) > <NUM_LIT:1>):<EOL><INDENT>raise click.ClickException("<STR_LIT>")<EOL><DEDENT>elif (pi0 < <NUM_LIT:0> or pi0 > <NUM_LIT:1>):<EOL><INDENT>raise click.ClickException("<STR_LIT>")<EOL><DEDENT>if (transf == "<STR_LIT>"):<EOL><INDENT>p = np.maximum(p, eps)<EOL>p = np.minimum(p, <NUM_LIT:1>-eps)<EOL>x = scipy.stats.norm.ppf(p, loc=<NUM_LIT:0>, scale=<NUM_LIT:1>)<EOL>bw = bw_nrd0(x)<EOL>myd = KDEUnivariate(x)<EOL>myd.fit(bw=adj*bw, gridsize = <NUM_LIT>)<EOL>splinefit = sp.interpolate.splrep(myd.support, myd.density)<EOL>y = sp.interpolate.splev(x, splinefit)<EOL>lfdr = pi0 * scipy.stats.norm.pdf(x) / y<EOL><DEDENT>elif (transf == "<STR_LIT>"):<EOL><INDENT>x = np.log((p + eps) / (<NUM_LIT:1> - p + eps))<EOL>bw = bw_nrd0(x)<EOL>myd = KDEUnivariate(x)<EOL>myd.fit(bw=adj*bw, gridsize = <NUM_LIT>)<EOL>splinefit = sp.interpolate.splrep(myd.support, myd.density)<EOL>y = sp.interpolate.splev(x, splinefit)<EOL>dx = np.exp(x) / np.power((<NUM_LIT:1> + np.exp(x)),<NUM_LIT:2>)<EOL>lfdr = (pi0 * dx) / y<EOL><DEDENT>else:<EOL><INDENT>raise click.ClickException("<STR_LIT>")<EOL><DEDENT>if (trunc):<EOL><INDENT>lfdr[lfdr > <NUM_LIT:1>] = <NUM_LIT:1><EOL><DEDENT>if (monotone):<EOL><INDENT>lfdr = lfdr[p.ravel().argsort()]<EOL>for i in range(<NUM_LIT:1>,len(x)):<EOL><INDENT>if (lfdr[i] < lfdr[i - <NUM_LIT:1>]):<EOL><INDENT>lfdr[i] = lfdr[i - <NUM_LIT:1>]<EOL><DEDENT><DEDENT>lfdr = lfdr[scipy.stats.rankdata(p,"<STR_LIT>")-<NUM_LIT:1>]<EOL><DEDENT>lfdr_out[rm_na] = lfdr<EOL>return lfdr_out<EOL>
Estimate local FDR / posterior error probability from p-values according to bioconductor/qvalue