diff --git a/jass_preprocessing/__pycache__/__main__.cpython-311.pyc b/jass_preprocessing/__pycache__/__main__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7d78df709c338e0890b17ec874d692c45bc347f5 Binary files /dev/null and b/jass_preprocessing/__pycache__/__main__.cpython-311.pyc differ diff --git a/jass_preprocessing/compute_score.py b/jass_preprocessing/compute_score.py index 8bca34d95fc91806f04cffe67ef7e2ef7988687f..7e026c0ef2e9448eecc38280851a94080eb7a69f 100644 --- a/jass_preprocessing/compute_score.py +++ b/jass_preprocessing/compute_score.py @@ -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' 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