Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RAISS
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Statistical-Genetics
RAISS
Commits
80dae27d
Commit
80dae27d
authored
1 year ago
by
Hanna JULIENNE
Browse files
Options
Downloads
Patches
Plain Diff
change rcond to rtol : fixed lack of backward compatibility of scipy
parent
86c31e4f
No related branches found
No related tags found
1 merge request
!11
Dev
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
raiss/imputation_launcher.py
+4
-4
4 additions, 4 deletions
raiss/imputation_launcher.py
raiss/pipes.py
+1
-1
1 addition, 1 deletion
raiss/pipes.py
raiss/stat_models.py
+6
-6
6 additions, 6 deletions
raiss/stat_models.py
raiss/windows.py
+2
-2
2 additions, 2 deletions
raiss/windows.py
with
13 additions
and
13 deletions
raiss/imputation_launcher.py
+
4
−
4
View file @
80dae27d
...
@@ -15,7 +15,7 @@ class ImputationLauncher(object):
...
@@ -15,7 +15,7 @@ class ImputationLauncher(object):
Class to perform imputation of snp from summary statistic
Class to perform imputation of snp from summary statistic
"""
"""
def
__init__
(
self
,
window_size
=
10000
,
buf
=
2500
,
def
__init__
(
self
,
window_size
=
10000
,
buf
=
2500
,
lamb
=
0.01
,
pinv_r
cond
=
0.01
,
ld_type
=
"
plink
"
):
lamb
=
0.01
,
pinv_r
tol
=
0.01
,
ld_type
=
"
plink
"
):
"""
"""
Initialise the imputation object. Fix the windows size, the buffer size
Initialise the imputation object. Fix the windows size, the buffer size
and the kind of imputation employed
and the kind of imputation employed
...
@@ -26,14 +26,14 @@ class ImputationLauncher(object):
...
@@ -26,14 +26,14 @@ class ImputationLauncher(object):
imputation (relevant only for batch imputation)
imputation (relevant only for batch imputation)
lamb (float): size of the increment added to snp correlation
lamb (float): size of the increment added to snp correlation
matrices to make it less singular
matrices to make it less singular
pinv_r
cond
(float): the r
cond
scipy.linalg.pinv function argument.
pinv_r
tol
(float): the r
tol
scipy.linalg.pinv function argument.
The scipy.linalg.pinv is used to invert the correlation matrices
The scipy.linalg.pinv is used to invert the correlation matrices
"""
"""
self
.
window_size
=
window_size
self
.
window_size
=
window_size
self
.
buffer
=
buf
self
.
buffer
=
buf
self
.
lamb
=
lamb
self
.
lamb
=
lamb
self
.
r
cond
=
pinv_r
cond
self
.
r
tol
=
pinv_r
tol
self
.
ld_type
=
ld_type
self
.
ld_type
=
ld_type
def
chromosome_imputation
(
self
,
chrom
,
zscore
,
ref_panel
,
ld_folder
):
def
chromosome_imputation
(
self
,
chrom
,
zscore
,
ref_panel
,
ld_folder
):
...
@@ -63,7 +63,7 @@ class ImputationLauncher(object):
...
@@ -63,7 +63,7 @@ class ImputationLauncher(object):
def
imputer
(
ld_file
):
def
imputer
(
ld_file
):
return
impg_like_imputation
(
ld_file
,
ref_panel
,
zscore
,
return
impg_like_imputation
(
ld_file
,
ref_panel
,
zscore
,
self
.
window_size
,
self
.
buffer
,
self
.
window_size
,
self
.
buffer
,
self
.
lamb
,
self
.
r
cond
,
self
.
ld_type
)
self
.
lamb
,
self
.
r
tol
,
self
.
ld_type
)
ld_file_list
=
set
(
map
(
get_file_name
,
glob
.
glob
(
pattern
)))
ld_file_list
=
set
(
map
(
get_file_name
,
glob
.
glob
(
pattern
)))
for
ld_file
in
ld_file_list
:
for
ld_file
in
ld_file_list
:
...
...
This diff is collapsed.
Click to expand it.
raiss/pipes.py
+
1
−
1
View file @
80dae27d
...
@@ -28,7 +28,7 @@ def save_chromosome_imputation(gwas, chrom, window_size, buffer_size,
...
@@ -28,7 +28,7 @@ def save_chromosome_imputation(gwas, chrom, window_size, buffer_size,
print
(
"
Imputation of {0} gwas for chromosome {1}
"
.
format
(
gwas
,
chrom
))
print
(
"
Imputation of {0} gwas for chromosome {1}
"
.
format
(
gwas
,
chrom
))
# Imputer settings
# Imputer settings
imputer
=
ImputationLauncher
(
window_size
=
int
(
window_size
),
buf
=
int
(
buffer_size
),
lamb
=
float
(
l2_regularization
),
pinv_r
cond
=
float
(
eigen_threshold
),
ld_type
=
ld_type
)
imputer
=
ImputationLauncher
(
window_size
=
int
(
window_size
),
buf
=
int
(
buffer_size
),
lamb
=
float
(
l2_regularization
),
pinv_r
tol
=
float
(
eigen_threshold
),
ld_type
=
ld_type
)
# Reading of inputs
# Reading of inputs
z_file
=
"
{0}/z_{1}_{2}.txt
"
.
format
(
zscore_folder
,
gwas
,
chrom
)
z_file
=
"
{0}/z_{1}_{2}.txt
"
.
format
(
zscore_folder
,
gwas
,
chrom
)
zscore
=
pd
.
read_csv
(
z_file
,
index_col
=
0
,
sep
=
"
\t
"
)
zscore
=
pd
.
read_csv
(
z_file
,
index_col
=
0
,
sep
=
"
\t
"
)
...
...
This diff is collapsed.
Click to expand it.
raiss/stat_models.py
+
6
−
6
View file @
80dae27d
...
@@ -68,15 +68,15 @@ def var_in_boundaries(var,lamb):
...
@@ -68,15 +68,15 @@ def var_in_boundaries(var,lamb):
return
var
return
var
def
invert_sig_t
(
sig_t
,
lamb
,
r
cond
):
def
invert_sig_t
(
sig_t
,
lamb
,
r
tol
):
try
:
try
:
np
.
fill_diagonal
(
sig_t
.
values
,
(
1
+
lamb
))
np
.
fill_diagonal
(
sig_t
.
values
,
(
1
+
lamb
))
sig_t_inv
=
scipy
.
linalg
.
pinv
(
sig_t
,
r
cond
=
rcond
)
sig_t_inv
=
scipy
.
linalg
.
pinv
(
sig_t
,
r
tol
=
rtol
,
atol
=
0
)
return
(
sig_t_inv
)
return
(
sig_t_inv
)
except
np
.
linalg
.
LinAlgError
:
except
np
.
linalg
.
LinAlgError
:
invert_sig_t
(
sig_t
,
lamb
*
1.1
,
r
cond
*
1.1
)
invert_sig_t
(
sig_t
,
lamb
*
1.1
,
r
tol
*
1.1
)
def
raiss_model
(
zt
,
sig_t
,
sig_i_t
,
lamb
=
0.01
,
r
cond
=
0.01
,
batch
=
True
):
def
raiss_model
(
zt
,
sig_t
,
sig_i_t
,
lamb
=
0.01
,
r
tol
=
0.01
,
batch
=
True
):
"""
"""
Compute the variance
Compute the variance
Args:
Args:
...
@@ -85,10 +85,10 @@ def raiss_model(zt, sig_t, sig_i_t, lamb=0.01, rcond=0.01, batch=True):
...
@@ -85,10 +85,10 @@ def raiss_model(zt, sig_t, sig_i_t, lamb=0.01, rcond=0.01, batch=True):
correlation
correlation
sig_i_t (np.ndarray): correlation matrix of known matrix
sig_i_t (np.ndarray): correlation matrix of known matrix
lamb (float): regularization term added to the diagonal of the sig_t matrix
lamb (float): regularization term added to the diagonal of the sig_t matrix
r
cond
(float): threshold to filter eigenvector with a eigenvalue under r
cond
r
tol
(float): threshold to filter eigenvector with a eigenvalue under r
tol
make inversion biased but much more numerically robust
make inversion biased but much more numerically robust
"""
"""
sig_t_inv
=
invert_sig_t
(
sig_t
,
lamb
,
r
cond
)
sig_t_inv
=
invert_sig_t
(
sig_t
,
lamb
,
r
tol
)
if
sig_t_inv
is
None
:
if
sig_t_inv
is
None
:
return
None
return
None
else
:
else
:
...
...
This diff is collapsed.
Click to expand it.
raiss/windows.py
+
2
−
2
View file @
80dae27d
...
@@ -133,7 +133,7 @@ def empty_imputed_dataframe():
...
@@ -133,7 +133,7 @@ def empty_imputed_dataframe():
def
impg_like_imputation
(
ld_file
,
ref_panel
,
zscore
,
window_size
,
buffer
,
lamb
,
def
impg_like_imputation
(
ld_file
,
ref_panel
,
zscore
,
window_size
,
buffer
,
lamb
,
r
cond
,
ld_file_type
=
"
plink
"
):
# unknowns=pd.Series([])):
r
tol
,
ld_file_type
=
"
plink
"
):
# unknowns=pd.Series([])):
"""
"""
Each missing Snp is imputed by known snps found in a window
Each missing Snp is imputed by known snps found in a window
Argument.
Argument.
...
@@ -175,7 +175,7 @@ def impg_like_imputation(ld_file, ref_panel, zscore, window_size, buffer, lamb,
...
@@ -175,7 +175,7 @@ def impg_like_imputation(ld_file, ref_panel, zscore, window_size, buffer, lamb,
if
(
len
(
known
)
>
0
):
if
(
len
(
known
)
>
0
):
print
(
"
Imputation for window {0} - {1}
"
.
format
(
start_windows
,
end_windows
))
print
(
"
Imputation for window {0} - {1}
"
.
format
(
start_windows
,
end_windows
))
imp
=
raiss_model
(
zt
,
sig_t
,
sig_i_t
,
lamb
=
lamb
,
r
cond
=
rcond
,
batch
=
True
)
imp
=
raiss_model
(
zt
,
sig_t
,
sig_i_t
,
lamb
=
lamb
,
r
tol
=
rtol
,
batch
=
True
)
try
:
try
:
batch_df
=
format_result_df
(
imp
,
ref_panel
,
known
,
unknowns
)
batch_df
=
format_result_df
(
imp
,
ref_panel
,
known
,
unknowns
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment