Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Statistical-Genetics
RAISS
Commits
ed934570
Commit
ed934570
authored
Apr 12, 2018
by
Hanna JULIENNE
Browse files
add Zscore variance normalisation
parent
9fcdbbb9
Changes
1
Hide whitespace changes
Inline
Side-by-side
impute_jass/impute_jass/stat_models.py
View file @
ed934570
...
...
@@ -22,6 +22,19 @@ def compute_var(sig_i_t, sig_t_inv, lamb, batch=True):
def
check_inversion
(
sig_t
,
sig_t_inv
):
return
np
.
allclose
(
sig_t
,
np
.
dot
(
sig_t
,
np
.
dot
(
sig_t_inv
,
sig_t
)))
def
var_in_boundaries
(
var
,
lamb
):
"""
Forces the variance to be in the 0 to 1+lambda boundary
theoritically we shouldn't have to do that
"""
id_neg
=
np
.
where
(
var
<
0
)
var_norm
=
var
var
[
id_neg
]
=
0
id_inf
=
np
.
where
(
var
>
(
1
+
lamb
))
var
[
id_inf
]
=
1
+
lamb
return
var
def
impg_model
(
zt
,
sig_t
,
sig_i_t
,
lamb
=
0.01
,
rcond
=
0.01
,
batch
=
True
):
"""
Argument:
...
...
@@ -39,8 +52,14 @@ 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 "
)
#mu = mu / (((1+lamb)-var)**0.5)
print
(
"ABERANT SNP SNiP"
)
var_norm
=
var_in_boundaries
(
var
,
lamb
)
mu
=
mu
/
np
.
sqrt
(
var_norm
)
return
({
"var"
:
var
,
"mu"
:
mu
,
"ld_score"
:
ld_score
,
"condition_number"
:
condition_number
,
"correct_inversion"
:
correct_inversion
})
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment