forked from atgu/ukbb_pan_ancestry
-
Notifications
You must be signed in to change notification settings - Fork 1
/
load_timings.py
48 lines (36 loc) · 1.75 KB
/
load_timings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
__author__ = 'konradk'
import sys
import argparse
import logging
logging.basicConfig(format="%(levelname)s (%(name)s %(lineno)s): %(message)s", level='INFO', filename='saige_pipeline.log')
from ukb_common import *
from ukbb_pan_ancestry import *
logger = logging.getLogger("saige_pan_ancestry")
logger.addHandler(logging.StreamHandler(sys.stderr))
def main(args):
hl.init(log=f'/tmp/saige_temp_hail.log')
hts = []
for pop in POPS:
ht = hl.import_table(get_results_timing_tsv_path('saige', pop), types={'saige_time': hl.tfloat64}, min_partitions=100)
ht = ht.annotate(locus=hl.parse_locus(ht.locus))
ht = ht.key_by('pop', 'trait_type', 'pheno', 'coding', 'locus')
hts.append(ht)
ht = hts[0].union(*hts[1:])
ht.write(get_results_timing_ht_path('saige'), True)
ht = hl.import_table(get_results_timing_tsv_path('null_model'), impute=True)
ht = ht.key_by('pop', trait_type=ht.trait, pheno=ht.pheno, coding=ht.coding)
ht.write(get_results_timing_ht_path('null_model'), True)
ht = hl.read_table(get_results_timing_ht_path('saige'))
ht = ht.group_by('pop', 'trait_type', 'pheno', 'coding').aggregate(saige_time=hl.agg.sum(ht.saige_time))
null_ht = hl.read_table(get_results_timing_ht_path('null_model'))
ht.annotate(**null_ht[ht.key]).write(get_results_timing_ht_path('full'), True)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--overwrite', help='Overwrite everything', action='store_true')
parser.add_argument('--slack_channel', help='Send message to Slack channel/user', default='@konradjk')
args = parser.parse_args()
if args.slack_channel:
try_slack(args.slack_channel, main, args)
else:
main(args)