Commit 6e1b2fb0 by Hanna JULIENNE

### improved docstring in stat.py

parent 9a9b371c
 """ function for SNP imputation This module contain the statistical library for imputation. Notation style of matrices subset and vectors are based on the publication: Bogdan Pasaniuc, Noah Zaitlen, Huwenbo Shi, Gaurav Bhatia, Alexander Gusev, Joseph Pickrell, Joel Hirschhorn, David P. Strachan, Nick Patterson, Alkes L. Price; Fast and accurate imputation of summary statistics enhances evidence of functional enrichment, Bioinformatics, Volume 30, Issue 20, 15 October 2014, Pages 2906–2914 Todo: * add better docstring """ import numpy as np import scipy as sc import scipy.linalg def compute_mu(sig_i_t, sig_t_inv, zt): """ Compute the estimation of z-score from neighborring snp Args: sig_i_t """ return np.dot(sig_i_t, np.dot(sig_t_inv, zt)) def compute_var(sig_i_t, sig_t_inv, lamb, batch=True): ... ... @@ -37,7 +55,7 @@ def var_in_boundaries(var,lamb): def impg_model(zt, sig_t, sig_i_t, lamb=0.01, rcond=0.01, batch=True): """ Argument: Args: zt : (vector) the vector of known Z scores """ sig_t = sig_t.values ... ... @@ -52,15 +70,12 @@ def impg_model(zt, sig_t, sig_i_t, lamb=0.01, rcond=0.01, batch=True): correct_inversion = check_inversion(sig_t, sig_t_inv) var, ld_score = compute_var(sig_i_t, sig_t_inv, lamb, batch) mu = compute_mu(sig_i_t, sig_t_inv, zt) if np.any(mu > 30): print("ABERANT SNP SNiP") var_norm = var_in_boundaries(var, lamb) R2 = (1-var_norm) R2 = ((1+lamb)-var_norm) mu = mu / np.sqrt(R2) return({"var" : var, "mu" : mu, "ld_score" : ld_score, "condition_number" : condition_number, "correct_inversion":correct_inversion })
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!