1 # Copyright (C) The Lightning Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
13 X = numpy.load(infile)
20 with open(sys.argv[2], 'rt', newline='') as samplelist:
21 for row in csv.reader(samplelist):
23 samples.append(sampleid)
24 phenotype_category_column = int(sys.argv[4])
25 phenotype_column = int(sys.argv[5])
26 if os.path.isdir(sys.argv[3]):
27 phenotype_files = os.scandir(sys.argv[3])
29 phenotype_files = [sys.argv[3]]
30 for phenotype_file in phenotype_files:
31 with open(phenotype_file, 'rt', newline='') as phenotype:
32 dialect = csv.Sniffer().sniff(phenotype.read(1024))
34 for row in csv.reader(phenotype, dialect):
36 label = row[phenotype_column]
37 for sampleid in samples:
39 labels[sampleid] = label
40 if phenotype_category_column >= 0 and row[phenotype_category_column] != '0':
41 category[sampleid] = True
75 '6': 'black', # unknown?
77 for sampleid in samples:
78 if (sampleid in labels) and (labels[sampleid] in labelcolors):
79 colors.append(labelcolors[labels[sampleid]])
81 colors.append('black')
83 from matplotlib.figure import Figure
84 from matplotlib.patches import Polygon
85 from matplotlib.backends.backend_agg import FigureCanvasAgg
87 ax = fig.add_subplot(111)
88 for marker in ['o', 'x']:
93 for i, sampleid in enumerate(samples):
94 if category.get(sampleid, False) == (marker == 'x'):
104 ax.scatter(x, y, c=c, s=60, marker=marker, alpha=0.5)
105 canvas = FigureCanvasAgg(fig)
106 canvas.print_figure(sys.argv[6], dpi=80)