Skip to content

Commit

Permalink
Merge pull request #4 from PMBio/master
Browse files Browse the repository at this point in the history
ups
  • Loading branch information
Bonder-MJ authored Jun 27, 2017
2 parents 0d93bd5 + 6031116 commit 6e6ccae
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions limix_QTL_pipeline/limix_QTL_pipeline/qtl_fdr_utilities.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import numpy as np
import scipy.stats

def estimate_beta_function_paras(top_pvalues_perm):
mean = np.mean(top_pvalues_perm)
variance = np.var(top_pvalues_perm)
alpha_para = mean * (mean * (1 - mean ) / variance - 1)
beta_para = alpha_para * (1 / mean - 1)
return alpha_para,beta_para

def calculate_corrected_pvalues(top_pvalues_perm,nominal_pvalues):
alpha_para,beta_para = estimate_beta_function_paras(top_pvalues_perm)
beta_dist = scipy.stats.beta(alpha_para,beta_para)
#apply correction to nominal p_values - potentially slow
corrected_pvalues = np.array([beta_dist.cdf(x) for x in nominal_pvalues])
return corrected_pvalues

0 comments on commit 6e6ccae

Please sign in to comment.