1 # Copyright (C) The Lightning Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
18 columns = numpy.load(os.path.join(input_path, 'onehot-columns.npy'))
20 # pvalue maps tag# => [pvalue1, pvalue2, ...] (one het p-value and one hom p-value for each tile variant)
22 for i in range(columns.shape[1]):
24 x = pvalue.get(tag, [])
25 x.append(pow(10, -columns[4,i] / 1000000))
28 # tilepos maps tag# => (chromosome, position)
30 for dirent in os.scandir(input_path):
31 if dirent.name.endswith('.annotations.csv'):
32 with open(dirent, 'rt', newline='') as annotations:
33 for annotation in csv.reader(annotations):
34 # 500000,0,2,=,chr1,160793649,,,
35 if annotation[3] == "=":
36 tilepos[int(annotation[0])] = (annotation[4], int(annotation[5]))
38 series = {"#CHROM": [], "POS": [], "P": []}
39 for tag, chrpos in sorted(tilepos.items(), key=lambda item: (item[1][0][-1] > '9', item[1][0].lstrip('chr').zfill(2), item[1][1])):
40 for p in pvalue.get(tag, []):
41 series["#CHROM"].append(chrpos[0])
42 series["POS"].append(chrpos[1])
45 qmplot.manhattanplot(data=pandas.DataFrame(series),
46 suggestiveline=2e-10, # Turn off suggestiveline
47 genomewideline=2e-11, # Turn off genomewidel
48 sign_line_cols=["#D62728", "#2CA02C"],
51 hline_kws={"linestyle": "--", "lw": 1.3},
52 title="Tile Variant Manhattan Plot",
53 # xtick_label_set=xtick,
55 ylabel=r"$-log_{10}{(P)}$",
56 xticklabel_kws={"rotation": "vertical"})
57 matplotlib.pyplot.savefig(output_path, bbox_inches="tight")