-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from PMBio/master
ups
- Loading branch information
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
limix_QTL_pipeline/limix_QTL_pipeline/qtl_fdr_utilities.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |