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
e413b780
Commit
e413b780
authored
Mar 14, 2018
by
Hanna JULIENNE
Browse files
fix zero division
parent
d378743c
Changes
3
Hide whitespace changes
Inline
Side-by-side
impute_jass/impute_jass/imputation_launcher.py
View file @
e413b780
...
...
@@ -16,7 +16,6 @@ class ImputationLauncher(object):
"""
"""
ref_panel_file
=
"/mnt/atlas/PCMA/1._DATA/ImpG_refpanel/{0}.eur.1pct.bim"
.
format
(
chrom
)
#ref_panel = pd.read_csv(ref_panel_file, sep="\t", names=['chr', "nothing", 'pos', 'Ref_all', 'alt_all'], index_col = 1)
...
...
impute_jass/impute_jass/stat_models.py
View file @
e413b780
...
...
@@ -23,9 +23,6 @@ def impg_model(zt, sig_t, sig_i_t, lamb=0.01, batch=True):
sig_t_inv
=
np
.
linalg
.
pinv
(
sig_t
)
var
=
compute_var
(
sig_i_t
,
sig_t_inv
,
lamb
,
batch
)
#if var< 0:
# var=0
mu
=
compute_mu
(
sig_i_t
,
sig_t_inv
,
zt
)
mu
=
mu
/
(((
1
+
lamb
)
-
var
)
**
0.5
)
#
mu = mu / (((1+lamb)-var)**0.5)
return
({
"var"
:
var
,
"mu"
:
mu
})
impute_jass/impute_jass/windows.py
View file @
e413b780
...
...
@@ -11,7 +11,6 @@ from .ld_matrix import generate_sparse_matrix
import
pandas
as
pd
import
numpy
as
np
def
parse_region_position
(
ld_file
):
"""
Retrieve the region definition from a ld-file generated by impute_jass
...
...
@@ -51,7 +50,6 @@ def prepare_zscore_for_imputation(ref_panel, zscore):
zscore
=
zscore
.
loc
[
zscore
.
index
.
intersection
(
ref_panel
.
index
)]
return
zscore
def
in_region
(
pos_vector
,
start
,
end
):
return
((
start
<
pos_vector
)
&
(
pos_vector
<
end
))
...
...
@@ -103,11 +101,16 @@ def impg_like_imputation(ld_file, ref_panel, zscore, window_size, buffer, unknow
LD_mat
=
generate_sparse_matrix
(
ld_file
,
ref_panel
)
Nwindows
=
((
int
(
end_ld_block
))
-
(
int
(
start_ld_block
)))
//
window_size
# adapt window size to cover the LD block
window_resize
=
np
.
ceil
((
int
(
end_ld_block
)
-
(
int
(
start_ld_block
)))
/
Nwindows
)
if
Nwindows
>
0
:
window_resize
=
np
.
ceil
((
int
(
end_ld_block
)
-
(
int
(
start_ld_block
)))
/
Nwindows
)
else
:
Nwindows
=
1
window_resize
=
np
.
ceil
(
int
(
end_ld_block
)
-
(
int
(
start_ld_block
)))
all_unknowns
=
ref_panel
.
loc
[
ref_panel
.
index
.
difference
(
zscore
.
index
)]
#zscore = pd.read_csv(Zfile, index_col=0, sep="\t")
zscore
=
prepare_zscore_for_imputation
(
ref_panel
,
zscore
)
print
(
"### Imputation of {0} snps ###"
.
format
(
unknowns
.
shape
[
0
]))
print
(
"### Imputation of {0} snps ###"
.
format
(
all_
unknowns
.
shape
[
0
]))
for
i
in
range
(
Nwindows
):
# Boundary of the sliding_window
...
...
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