Skip to content
Snippets Groups Projects
Commit 1497e1fc authored by Hanna  JULIENNE's avatar Hanna JULIENNE
Browse files

Merge branch 'hjulienn-805f2f78-patch-74c6' into 'master'

Hjulienn 805f2f78 patch 74c6

See merge request !6
parents 57ee2dfb b13fe091
No related branches found
No related tags found
No related merge requests found
File added
......@@ -12,18 +12,36 @@ def compute_z_score(mgwas):
"""
Compute zscore value and sign1
add the corresponding column to the mgwas dataframe
the smallest positive value of float
sys.float_info.min
2.2250738585072014e-308
the biggest Z score
np.sqrt(ss.chi2.isf(sys.float_info.min, 1))
37.537836095576054
"""
print(mgwas.columns)
mgwas["computed_z"] = np.sqrt(ss.chi2.isf(mgwas['pval'], 1))
if 'z' in mgwas.columns:
sign_vect = np.sign(mgwas.z)
mgwas.loc[mgwas["computed_z"].isin([np.inf]), 'computed_z'] = mgwas["z"]
if 'beta_or_Z' in mgwas.columns:
sign_vect = np.sign(mgwas.beta_or_Z)
elif 'beta_or_Z' in mgwas.columns:
sign_vect = np.sign(mgwas.beta)
mgwas["computed_z"] = mgwas["computed_z"].replace(np.inf, 37.537836095576054)
else:
if "OR" in mgwas.columns:
sign_vect = np.sign(mgwas["OR"] - 1.0 + 10**(-8))
mgwas["computed_z"] = mgwas["computed_z"].replace(np.inf, 37.537836095576054)
else:
raise ValueError(
'The gwas data frame doesn"t contain effect column')
mgwas["computed_z"] = np.sqrt(ss.chi2.isf(mgwas['pval'], 1)) * sign_vect * mgwas["sign_flip"]
mgwas["computed_z"] = mgwas["computed_z"] * sign_vect * mgwas["sign_flip"]
return mgwas
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment