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
c1134860
Commit
c1134860
authored
Mar 06, 2018
by
Hanna JULIENNE
Browse files
Checked statistic computation on correctly indexed matrices
parent
15f2105f
Changes
1
Hide whitespace changes
Inline
Side-by-side
impute_jass/impute_jass/stat_models.py
View file @
c1134860
...
...
@@ -11,14 +11,15 @@ def ImpG_model_batch(Zt, Sig_t, Sig_i_t):
"""
np
.
fill_diagonal
(
Sig_t
.
values
,
1.01
)
Sig_t
.
fillna
(
0
,
inplace
=
True
)
#
np.fill_diagonal(Sig_t.values, 1.01)
#
Sig_t.fillna(0, inplace=True)
Sig_t_inv
=
np
.
linalg
.
inv
(
Sig_t
)
Var
=
np
.
diag
(
Sig_t
)[
0
]
-
np
.
einsum
(
'ij,jk,ki->i'
,
Sig_i_t
,
Sig_t_inv
,
Sig_i_t
.
transpose
())
mu
=
np
.
dot
(
Sig_i_t
,
np
.
dot
(
Sig_t_inv
,
Zt
))
return
({
"Var"
:
Var
,
"mu"
:
mu
})
...
...
@@ -28,14 +29,13 @@ def ImpG_model_snp(Zt, Sig_t, Sig_i_t):
Zt : (vector) the vector of known Z scores
"""
np
.
fill_diagonal
(
Sig_t
.
values
,
1.01
)
Sig_t
.
fillna
(
0
,
inplace
=
True
)
#np.fill_diagonal(Sig_t.values, 1.01)
#Sig_t.fillna(0, inplace=True)
Sig_t_inv
=
np
.
linalg
.
inv
(
Sig_t
)
Var
=
np
.
diag
(
Sig_t
)[
0
]
-
np
.
dot
(
Sig_i_t
,
np
.
dot
(
Sig_t_inv
,
Sig_i_t
.
transpose
()))
#np.einsum('ij,jk,ki->i', Sig_i_t, Sig_t_inv ,Sig_i_t.transpose())
mu
=
np
.
dot
(
Sig_i_t
,
np
.
dot
(
Sig_t_inv
,
Zt
))
mu
=
mu
/
((
1
-
Var
)
**
0.5
)
return
({
"Var"
:
Var
,
"mu"
:
mu
})
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