-
Notifications
You must be signed in to change notification settings - Fork 4
/
prepare_feature.py
51 lines (41 loc) · 1.6 KB
/
prepare_feature.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
""" Prepare and preprocess various feature types: survival, clinical, driver,
two-node and multi-node.
"""
import pickle
from utils_feature import (Survival_Data_Processor, get_clinical_feature,
get_driver_feature, get_twonode_feature, get_multinode_feature)
print("Extracting OS/DFS time of sampes...")
for cancer in ["BRCA", "LUAD", "LUSC"]:
sdp = Survival_Data_Processor("", cancer)
refined = sdp.run()
refined.to_csv(
"data/survival/"+cancer.lower()+".csv",
sep=",", header=True)
print("Extracting clinical feature of samples...")
for cancer in ["BRCA", "lung"]:
data, feature_lut = get_clinical_feature("", cancer)
data.to_csv(
"data/clinical/"+cancer.lower()+".csv",
sep=",", header=True)
pickle.dump(feature_lut, open("data/clinical/"+cancer.lower()+".pkl","wb"), protocol=2)
# Below is for feature extraction of ICGC data: driver, two-node and multi-node feature.
# TCGA data is similar with minor revisions.
# Specifically, TCGA uses hg38 instead of hg19.
print("Extracting driver feature of samples...")
for cancer in ["BRCA", "lung"]:
data = get_driver_feature(cancer)
data.to_csv(
"data/driver/"+cancer.lower()+".csv",
sep=",", header=True)
print("Extracting two-node feature of samples...")
for cancer in ["BRCA", "lung"]:
data = get_twonode_feature(cancer)
data.to_csv(
"data/twonode/"+cancer.lower()+".csv",
sep=",", header=True)
print("Extracting multi-node feature of samples...")
for cancer in ["BRCA", "lung"]:
data = get_multinode_feature(cancer)
data.to_csv(
"data/multinode/"+cancer.lower()+".csv",
sep=",", header=True)