forked from Bayer-Group/genie-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_panel_tested_positions_cache.py
42 lines (36 loc) · 1.11 KB
/
create_panel_tested_positions_cache.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
import os
import pandas as pd
from tqdm.auto import tqdm
import genie.genie as gd
# Where to find the GENIE data
genie_dir = os.path.join(os.environ.get("HOME"), "genie/Data/Original/genie-15.0/")
g = gd.Genie(genie_dir)
print("Loading re-annotations", end=" ... ", flush=True)
positions = (
pd.read_table(
g.config.get_aux_file_name("annot"),
low_memory=False,
usecols=["hgvsg", "chromosome", "begin", "end"],
)
.drop_duplicates()
.set_index("hgvsg", drop=True)
)
print("done.", flush=True)
print("Checking mutations versus panels.", flush=True)
cols = []
panels = g.panel_set.panels
for panel_id, panel in tqdm(panels.items(), total=len(panels)):
cols.append(
pd.Series(
positions.apply(
lambda x: panel.range_is_tested(x["chromosome"], x["begin"], x["end"]),
axis=1,
),
name=panel_id,
)
)
tested = pd.concat(cols, axis=1)
print("Writing parquet file", end=" ... ", flush=True)
file_name = g.config.get_aux_file_name("panel_mut_tested")
tested.to_parquet(file_name)
print("done.", flush=True)