Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jass
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Statistical-Genetics
jass
Commits
327e6e63
Commit
327e6e63
authored
7 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
first corrections on the init table
parent
92b50252
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
jass/models/worktable.py
+12
-10
12 additions, 10 deletions
jass/models/worktable.py
with
12 additions
and
10 deletions
jass/models/worktable.py
+
12
−
10
View file @
327e6e63
...
@@ -117,13 +117,13 @@ def create_inittable_file(input_data_path: str, init_covariance_path: str, regio
...
@@ -117,13 +117,13 @@ def create_inittable_file(input_data_path: str, init_covariance_path: str, regio
# Read summary statistics
# Read summary statistics
covariance
=
read_csv
(
init_covariance_path
,
sep
=
'
\t
'
,
index_col
=
0
)
covariance
=
read_csv
(
init_covariance_path
,
sep
=
'
\t
'
,
index_col
=
0
)
# Read description file
# Read description file
description
=
read_csv
(
description_file_path
,
sep
=
'
\t
'
,
index_col
=
0
)
description
=
read_csv
(
description_file_path
,
sep
=
'
\t
'
)
# gwas_list = list(set([os.path.basename(x).split("_")[0] for x in glob.glob(input_data_path)]))
# gwas_list = list(set([os.path.basename(x).split("_")[0] for x in glob.glob(input_data_path)]))
gwas_dict
=
{}
gwas_dict
=
{}
for
x
in
glob
.
glob
(
input_data_path
)
])
:
for
x
in
glob
.
glob
(
input_data_path
):
gwas_name
=
os
.
path
.
basename
(
x
).
split
(
"
_
"
)[
0
]
gwas_name
=
os
.
path
.
basename
(
x
).
split
(
"
_
"
)[
0
]
if
gwas_name
in
gwas_dict
:
if
gwas_name
in
gwas_dict
:
gwas_dict
[
gwas_name
].
append
(
x
)
gwas_dict
[
gwas_name
].
append
(
x
)
...
@@ -134,18 +134,20 @@ def create_inittable_file(input_data_path: str, init_covariance_path: str, regio
...
@@ -134,18 +134,20 @@ def create_inittable_file(input_data_path: str, init_covariance_path: str, regio
for
meta_index
,
meta_row
in
description
.
iterrows
():
# READ GWAS
for
meta_index
,
meta_row
in
description
.
iterrows
():
# READ GWAS
print
(
meta_row
.
keys
())
# create an ID from the GWAS consortia + outcome columns
# create an ID from the GWAS consortia + outcome columns
study_name
=
'
z_
'
+
meta_row
[
'
c
onsorti
a
'
].
upper
()
+
'
_
'
+
meta_row
[
'
o
utcome
'
].
upper
()
study_name
=
'
z_
'
+
meta_row
[
'
C
onsorti
um
'
].
upper
()
+
'
_
'
+
meta_row
[
'
O
utcome
'
].
upper
()
print
(
'
**** PARSING %s ******
'
%
my_
study
)
print
(
'
**** PARSING %s ******
'
%
study
_name
)
for
gwas_file_chri
in
gwas_dict
[
meta_row
[
'
o
utcome
'
]]:
for
gwas_file_chri
in
gwas_dict
[
meta_row
[
'
O
utcome
'
]]:
print
(
gwas_file_chri
)
chrom
=
int
(
os
.
path
.
splitext
(
os
.
path
.
basename
(
gwas_file_chri
[
0
]
))[
0
].
split
(
"
_chr
"
)[
1
])
chrom
=
int
(
os
.
path
.
splitext
(
os
.
path
.
basename
(
gwas_file_chri
))[
0
].
split
(
"
_chr
"
)[
1
])
print
(
'
Working on Chromosome %d
'
%
chrom
)
print
(
'
Working on Chromosome %d
'
%
chrom
)
# Load summary statistics file for CHR i
# Load summary statistics file for CHR i
z_gwas
=
read_csv
(
gwas_file_chri
,
sep
=
"
\t
"
,
index_col
=
[
0
,
1
,
4
])
z_gwas
=
read_csv
(
gwas_file_chri
,
sep
=
"
\t
"
,
usecols
=
[
0
,
1
,
4
])
print
(
z_gwas
.
columns
)
z_gwas
.
columns
=
[
'
snp_ids
'
,
'
position
'
,
'
z_score
'
]
z_gwas
.
columns
=
[
'
snp_ids
'
,
'
position
'
,
'
z_score
'
]
# CAUTION: handle duplicates (whenever there are multiple values for a single SNP)
# CAUTION: handle duplicates (whenever there are multiple values for a single SNP)
z_gwas
=
z_gwas
[
~
z_gwas
.
index
.
duplicated
(
keep
=
'
first
'
)]
z_gwas
=
z_gwas
[
~
z_gwas
.
index
.
duplicated
(
keep
=
'
first
'
)]
...
@@ -155,7 +157,7 @@ def create_inittable_file(input_data_path: str, init_covariance_path: str, regio
...
@@ -155,7 +157,7 @@ def create_inittable_file(input_data_path: str, init_covariance_path: str, regio
# Add chromosome and study name columns
# Add chromosome and study name columns
z_gwas
[
'
CHR
'
]
=
[
chrom
]
*
N
z_gwas
[
'
CHR
'
]
=
[
chrom
]
*
N
merge_GWAS
[
'
study_name
'
]
=
[
study_name
]
*
N
z_gwas
[
'
study_name
'
]
=
[
study_name
]
*
N
# Add region and middle position columns
# Add region and middle position columns
z_gwas
[
'
Region
'
]
=
np
.
zeros
(
len
(
z_gwas
),
dtype
=
np
.
int
)
z_gwas
[
'
Region
'
]
=
np
.
zeros
(
len
(
z_gwas
),
dtype
=
np
.
int
)
...
...
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