-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrun_swing.py
37 lines (29 loc) · 1.07 KB
/
run_swing.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
import pandas as pd
from Swing import Swing
if __name__ == "__main__":
# Load data
gene_start_column = 1
time_label = "Time"
separator = "\t"
gene_end = None
file_path = "data/Ecoli_10_node/Ecoli10-1_dream4_timeseries.tsv"
gold_standard_file = "data/Ecoli_10_node/Ecoli10-1_goldstandard.tsv"
df = pd.read_csv(file_path, sep=separator)
# Set SWING parameters
k_min = 1
k_max = 3
w = 10
method = 'RandomForest'
trees = 10
# Initialize a SWING object
sg = Swing(file_path, gene_start_column, gene_end, time_label, separator, min_lag=k_min,
max_lag=k_max, window_width=w, window_type=method)
sg.zscore_all_data()
sg.create_windows()
sg.optimize_params()
sg.fit_windows(n_trees=trees, show_progress=False, n_jobs=-1)
sg.compile_edges(self_edges=False)
sg.make_static_edge_dict(self_edges=False, lag_method='mean_mean')
ranked_edges = sg.make_sort_df(sg.edge_dict)
roc_dict, pr_dict = sg.score(ranked_edges, gold_standard_file=gold_standard_file)
print(roc_dict['auroc'][-1])