forked from soondubu137/Cytometry_PreGating
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Validation_Recon_Plot_Single.py
66 lines (52 loc) · 1.93 KB
/
Validation_Recon_Plot_Single.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import os
import argparse
def plot_one(gate, x_axis, y_axis, subject):
substring = f"./Data_{gate}/Raw_Numpy/"
subject = subject.split(substring)[1]
substring = ".npy"
subject = subject.split(substring)[0]
data_table = pd.read_csv(f'./Pred_Results_gate2_cd45/Pred_Results_{subject}')
if x_axis != 'Event_length':
x_axis = x_axis + '_backup'
if y_axis != 'Event_length':
y_axis = y_axis + '_backup'
gate_pred = gate + '_pred'
fig, axs = plt.subplots(2, 1, figsize=(5, 10))
#plot raw:
data = data_table.copy()
x = data[x_axis]
y = data[y_axis]
axs[0].plot(x, y, 'o', color='black', markersize = 3)
data = data[data[gate]==1]
x = data[x_axis]
y = data[y_axis]
axs[0].plot(x, y, 'o', color='blue', markersize = 3)
axs[0].set_title("Raw Gate Plot")
axs[0].set_xlim([0, 10])
data = data_table.copy()
x = data[x_axis]
y = data[y_axis]
axs[1].plot(x, y, 'o', color='black', markersize = 3)
data = data[data[gate_pred]==1]
x = data[x_axis]
y = data[y_axis]
axs[1].plot(x, y, 'o', color='blue', markersize = 3)
axs[1].set_title("Reconstructed Gate Plot")
axs[1].set_xlim([0, 10])
plt.savefig(f'./Figure_{gate}/Recon_Single_{subject}.png')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="cytometry autogating")
parser.add_argument("--g", default='gate2_cd45', help = 'gate')
parser.add_argument("--x", default='Ir193Di___193Ir_DNA2', help = 'x axis measurement')
parser.add_argument("--y", default='Y89Di___89Y_CD45', help = 'y axis measurement')
args = parser.parse_args()
gate = args.g
x_axis = args.x
y_axis = args.y
path_val = pd.read_csv(f"./Data_{gate}/Train_Test_Val/Val.csv")
# find path for raw tabular data
for subject in path_val.Image:
plot_one(gate, x_axis, y_axis, subject)