Liu-Hy commited on
Commit
324058b
·
verified ·
1 Parent(s): a0b62f5

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +40 -0
  2. p3/preprocess/Anxiety_disorder/gene_data/GSE119995.csv +3 -0
  3. p3/preprocess/Anxiety_disorder/gene_data/GSE61672.csv +3 -0
  4. p3/preprocess/Anxiety_disorder/gene_data/GSE68526.csv +3 -0
  5. p3/preprocess/Arrhythmia/GSE182600.csv +3 -0
  6. p3/preprocess/Arrhythmia/GSE235307.csv +3 -0
  7. p3/preprocess/Arrhythmia/gene_data/GSE115574.csv +3 -0
  8. p3/preprocess/Arrhythmia/gene_data/GSE136992.csv +3 -0
  9. p3/preprocess/Arrhythmia/gene_data/GSE182600.csv +3 -0
  10. p3/preprocess/Arrhythmia/gene_data/GSE235307.csv +3 -0
  11. p3/preprocess/Arrhythmia/gene_data/GSE47727.csv +3 -0
  12. p3/preprocess/Arrhythmia/gene_data/GSE55231.csv +3 -0
  13. p3/preprocess/Asthma/GSE182797.csv +3 -0
  14. p3/preprocess/Asthma/GSE182798.csv +3 -0
  15. p3/preprocess/Asthma/GSE185658.csv +3 -0
  16. p3/preprocess/Asthma/GSE270312.csv +0 -0
  17. p3/preprocess/Asthma/code/GSE123086.py +240 -0
  18. p3/preprocess/Asthma/code/GSE123088.py +283 -0
  19. p3/preprocess/Asthma/code/GSE182797.py +185 -0
  20. p3/preprocess/Asthma/code/GSE182798.py +178 -0
  21. p3/preprocess/Asthma/code/GSE184382.py +66 -0
  22. p3/preprocess/Asthma/code/GSE185658.py +174 -0
  23. p3/preprocess/Asthma/code/GSE188424.py +146 -0
  24. p3/preprocess/Asthma/code/GSE205151.py +153 -0
  25. p3/preprocess/Asthma/code/GSE230164.py +144 -0
  26. p3/preprocess/Asthma/code/GSE270312.py +149 -0
  27. p3/preprocess/Asthma/code/TCGA.py +34 -0
  28. p3/preprocess/Asthma/gene_data/GSE123086.csv +1 -0
  29. p3/preprocess/Asthma/gene_data/GSE123088.csv +1 -0
  30. p3/preprocess/Asthma/gene_data/GSE182797.csv +3 -0
  31. p3/preprocess/Asthma/gene_data/GSE182798.csv +3 -0
  32. p3/preprocess/Asthma/gene_data/GSE185658.csv +3 -0
  33. p3/preprocess/Asthma/gene_data/GSE188424.csv +3 -0
  34. p3/preprocess/Asthma/gene_data/GSE205151.csv +0 -0
  35. p3/preprocess/Asthma/gene_data/GSE230164.csv +3 -0
  36. p3/preprocess/Asthma/gene_data/GSE270312.csv +0 -0
  37. p3/preprocess/Atrial_Fibrillation/GSE115574.csv +3 -0
  38. p3/preprocess/Atrial_Fibrillation/GSE143924.csv +0 -0
  39. p3/preprocess/Atrial_Fibrillation/GSE235307.csv +3 -0
  40. p3/preprocess/Atrial_Fibrillation/GSE41177.csv +0 -0
  41. p3/preprocess/Atrial_Fibrillation/clinical_data/GSE115574.csv +2 -0
  42. p3/preprocess/Atrial_Fibrillation/clinical_data/GSE143924.csv +2 -0
  43. p3/preprocess/Atrial_Fibrillation/clinical_data/GSE235307.csv +4 -0
  44. p3/preprocess/Atrial_Fibrillation/clinical_data/GSE41177.csv +4 -0
  45. p3/preprocess/Atrial_Fibrillation/clinical_data/GSE47727.csv +4 -0
  46. p3/preprocess/Atrial_Fibrillation/code/GSE115574.py +150 -0
  47. p3/preprocess/Atrial_Fibrillation/code/GSE143924.py +133 -0
  48. p3/preprocess/Atrial_Fibrillation/code/GSE235307.py +169 -0
  49. p3/preprocess/Atrial_Fibrillation/code/GSE41177.py +152 -0
  50. p3/preprocess/Atrial_Fibrillation/code/GSE47727.py +97 -0
.gitattributes CHANGED
@@ -1477,3 +1477,43 @@ p3/preprocess/Anxiety_disorder/gene_data/GSE94119.csv filter=lfs diff=lfs merge=
1477
  p3/preprocess/Arrhythmia/GSE136992.csv filter=lfs diff=lfs merge=lfs -text
1478
  p3/preprocess/Arrhythmia/GSE115574.csv filter=lfs diff=lfs merge=lfs -text
1479
  p3/preprocess/Anxiety_disorder/gene_data/GSE60491.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1477
  p3/preprocess/Arrhythmia/GSE136992.csv filter=lfs diff=lfs merge=lfs -text
1478
  p3/preprocess/Arrhythmia/GSE115574.csv filter=lfs diff=lfs merge=lfs -text
1479
  p3/preprocess/Anxiety_disorder/gene_data/GSE60491.csv filter=lfs diff=lfs merge=lfs -text
1480
+ p3/preprocess/Anxiety_disorder/gene_data/GSE119995.csv filter=lfs diff=lfs merge=lfs -text
1481
+ p3/preprocess/Arrhythmia/GSE182600.csv filter=lfs diff=lfs merge=lfs -text
1482
+ p3/preprocess/Anxiety_disorder/gene_data/GSE68526.csv filter=lfs diff=lfs merge=lfs -text
1483
+ p3/preprocess/Arrhythmia/gene_data/GSE115574.csv filter=lfs diff=lfs merge=lfs -text
1484
+ p3/preprocess/Arrhythmia/GSE235307.csv filter=lfs diff=lfs merge=lfs -text
1485
+ p3/preprocess/Asthma/GSE182797.csv filter=lfs diff=lfs merge=lfs -text
1486
+ p3/preprocess/Anxiety_disorder/gene_data/GSE61672.csv filter=lfs diff=lfs merge=lfs -text
1487
+ p3/preprocess/Arrhythmia/gene_data/GSE136992.csv filter=lfs diff=lfs merge=lfs -text
1488
+ p3/preprocess/Arrhythmia/gene_data/GSE182600.csv filter=lfs diff=lfs merge=lfs -text
1489
+ p3/preprocess/Asthma/GSE185658.csv filter=lfs diff=lfs merge=lfs -text
1490
+ p3/preprocess/Arrhythmia/gene_data/GSE47727.csv filter=lfs diff=lfs merge=lfs -text
1491
+ p3/preprocess/Asthma/GSE182798.csv filter=lfs diff=lfs merge=lfs -text
1492
+ p3/preprocess/Arrhythmia/gene_data/GSE235307.csv filter=lfs diff=lfs merge=lfs -text
1493
+ p3/preprocess/Asthma/gene_data/GSE182797.csv filter=lfs diff=lfs merge=lfs -text
1494
+ p3/preprocess/Arrhythmia/gene_data/GSE55231.csv filter=lfs diff=lfs merge=lfs -text
1495
+ p3/preprocess/Asthma/gene_data/GSE185658.csv filter=lfs diff=lfs merge=lfs -text
1496
+ p3/preprocess/Atrial_Fibrillation/GSE115574.csv filter=lfs diff=lfs merge=lfs -text
1497
+ p3/preprocess/Asthma/gene_data/GSE188424.csv filter=lfs diff=lfs merge=lfs -text
1498
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/GSE285666.csv filter=lfs diff=lfs merge=lfs -text
1499
+ p3/preprocess/Asthma/gene_data/GSE230164.csv filter=lfs diff=lfs merge=lfs -text
1500
+ p3/preprocess/Asthma/gene_data/GSE182798.csv filter=lfs diff=lfs merge=lfs -text
1501
+ p3/preprocess/Atrial_Fibrillation/GSE235307.csv filter=lfs diff=lfs merge=lfs -text
1502
+ p3/preprocess/Atrial_Fibrillation/gene_data/GSE115574.csv filter=lfs diff=lfs merge=lfs -text
1503
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/GSE57802.csv filter=lfs diff=lfs merge=lfs -text
1504
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/GSE89594.csv filter=lfs diff=lfs merge=lfs -text
1505
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/GSE87847.csv filter=lfs diff=lfs merge=lfs -text
1506
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/GSE65106.csv filter=lfs diff=lfs merge=lfs -text
1507
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/GSE111175.csv filter=lfs diff=lfs merge=lfs -text
1508
+ p3/preprocess/Atrial_Fibrillation/gene_data/GSE235307.csv filter=lfs diff=lfs merge=lfs -text
1509
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/gene_data/GSE285666.csv filter=lfs diff=lfs merge=lfs -text
1510
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/gene_data/GSE57802.csv filter=lfs diff=lfs merge=lfs -text
1511
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/GSE42133.csv filter=lfs diff=lfs merge=lfs -text
1512
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/gene_data/GSE87847.csv filter=lfs diff=lfs merge=lfs -text
1513
+ p3/preprocess/Bile_Duct_Cancer/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1514
+ p3/preprocess/Autoinflammatory_Disorders/gene_data/GSE43553.csv filter=lfs diff=lfs merge=lfs -text
1515
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/gene_data/GSE89594.csv filter=lfs diff=lfs merge=lfs -text
1516
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/gene_data/GSE111175.csv filter=lfs diff=lfs merge=lfs -text
1517
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/GSE148450.csv filter=lfs diff=lfs merge=lfs -text
1518
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/gene_data/GSE65106.csv filter=lfs diff=lfs merge=lfs -text
1519
+ p3/preprocess/Autism_spectrum_disorder_(ASD)/gene_data/GSE42133.csv filter=lfs diff=lfs merge=lfs -text
p3/preprocess/Anxiety_disorder/gene_data/GSE119995.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d983eb4554c44401d90639f27d35921438e6834763bb95f6e41c2857edb80d0
3
+ size 24675188
p3/preprocess/Anxiety_disorder/gene_data/GSE61672.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc3ec7db3721c2df4aee7f88f4d34dde6e8caea3f63df7c671a696f04352165c
3
+ size 33639737
p3/preprocess/Anxiety_disorder/gene_data/GSE68526.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2c9a9241160207e9a394dbaaf17432cb8e0496dc65b91c7cf71a6086944bb8d
3
+ size 22640965
p3/preprocess/Arrhythmia/GSE182600.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e3028b35f41eec7560aae712dba747f1265e5c43f2c731c30dc0f67f9ef771f1
3
+ size 26036063
p3/preprocess/Arrhythmia/GSE235307.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2cf113791094ff855418534fa67eb3c91e47e904abdceb7c4c9cfa1210f5453a
3
+ size 30127837
p3/preprocess/Arrhythmia/gene_data/GSE115574.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:456a00d22351d374c6e573fb5f8cd9aee06d8e578a5597254ec39e90ed25195d
3
+ size 15534388
p3/preprocess/Arrhythmia/gene_data/GSE136992.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed81b86668c87698a45486ae46c9cf45f0ddb2f1f27a6dc91aef2b9c912199a4
3
+ size 15435596
p3/preprocess/Arrhythmia/gene_data/GSE182600.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8ab10642973a2c6ae075b4608278a038bc9bf2ff5fa8d444a21b081ea4467056
3
+ size 26035031
p3/preprocess/Arrhythmia/gene_data/GSE235307.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d40bfec5aee125dd279e5a4a5b658d3b8c0ce73e2f05846a13e621756e1927e
3
+ size 30126272
p3/preprocess/Arrhythmia/gene_data/GSE47727.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3911e4ca8b0d9286bd33dfe6347f7ca16dd00f295d016d279eaaebc43067913c
3
+ size 28462595
p3/preprocess/Arrhythmia/gene_data/GSE55231.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b05c392547040100a06721962e4878fff3bdc6f2c40aa5be3c134f076694bae6
3
+ size 33169173
p3/preprocess/Asthma/GSE182797.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:10310e4a264b00ba4b02c68bacddfd0ae248d72dde5d36e0e313fbad6870af47
3
+ size 10668389
p3/preprocess/Asthma/GSE182798.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4c719f379a878f7a60438885fda54bd1243bb460efddd5941a5caff4ad0ac96
3
+ size 23669788
p3/preprocess/Asthma/GSE185658.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a0f4701bf03a9cb4bbdea1cd852e582f02750f21cbe77b82919965ff92d85b6
3
+ size 18243246
p3/preprocess/Asthma/GSE270312.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Asthma/code/GSE123086.py ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE123086"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE123086"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE123086.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE123086.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE123086.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # Yes, this dataset contains gene expression data from CD4+ T cells using microarray
38
+ is_gene_available = True
39
+
40
+ # 2.1 Data Availability
41
+ # Trait is in Feature 1 (primary diagnosis), values include ASTHMA and others
42
+ trait_row = 1
43
+
44
+ # Gender is in Feature 2 and 3 (Sex appears in both)
45
+ gender_row = 2
46
+
47
+ # Age appears in Features 3 and 4
48
+ age_row = 3
49
+
50
+ # 2.2 Data Type Conversion Functions
51
+
52
+ def convert_trait(value: str) -> int:
53
+ """Convert trait values to binary (0 for control, 1 for case)"""
54
+ if not isinstance(value, str):
55
+ return None
56
+ value = value.split(': ')[-1].upper()
57
+ if 'ASTHMA' in value:
58
+ return 1
59
+ elif value == 'HEALTHY_CONTROL':
60
+ return 0
61
+ return None
62
+
63
+ def convert_age(value: str) -> float:
64
+ """Convert age values to continuous numeric"""
65
+ if not isinstance(value, str):
66
+ return None
67
+ if not value.startswith('age: '):
68
+ return None
69
+ try:
70
+ return float(value.split(': ')[-1])
71
+ except:
72
+ return None
73
+
74
+ def convert_gender(value: str) -> int:
75
+ """Convert gender values to binary (0 for female, 1 for male)"""
76
+ if not isinstance(value, str):
77
+ return None
78
+ if not value.startswith('Sex: '):
79
+ return None
80
+ value = value.split(': ')[-1].upper()
81
+ if value == 'FEMALE':
82
+ return 0
83
+ elif value == 'MALE':
84
+ return 1
85
+ return None
86
+
87
+ # 3. Save Metadata
88
+ is_trait_available = trait_row is not None
89
+ validate_and_save_cohort_info(is_final=False, cohort=cohort, info_path=json_path,
90
+ is_gene_available=is_gene_available,
91
+ is_trait_available=is_trait_available)
92
+
93
+ # 4. Clinical Feature Extraction
94
+ if trait_row is not None:
95
+ clinical_features = geo_select_clinical_features(
96
+ clinical_df=clinical_data,
97
+ trait=trait,
98
+ trait_row=trait_row,
99
+ convert_trait=convert_trait,
100
+ age_row=age_row,
101
+ convert_age=convert_age,
102
+ gender_row=gender_row,
103
+ convert_gender=convert_gender
104
+ )
105
+
106
+ print("Preview of extracted clinical features:")
107
+ print(preview_df(clinical_features))
108
+
109
+ # Save clinical features
110
+ clinical_features.to_csv(out_clinical_data_file)
111
+ # Get file paths
112
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
113
+
114
+ # Extract gene expression data from matrix file
115
+ gene_data = get_genetic_data(matrix_file)
116
+
117
+ # Print first 20 row IDs and shape of data to help debug
118
+ print("Shape of gene expression data:", gene_data.shape)
119
+ print("\nFirst few rows of data:")
120
+ print(gene_data.head())
121
+ print("\nFirst 20 gene/probe identifiers:")
122
+ print(gene_data.index[:20])
123
+
124
+ # Inspect a snippet of raw file to verify identifier format
125
+ import gzip
126
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
127
+ lines = []
128
+ for i, line in enumerate(f):
129
+ if "!series_matrix_table_begin" in line:
130
+ # Get the next 5 lines after the marker
131
+ for _ in range(5):
132
+ lines.append(next(f).strip())
133
+ break
134
+ print("\nFirst few lines after matrix marker in raw file:")
135
+ for line in lines:
136
+ print(line)
137
+ requires_gene_mapping = True
138
+ # Get file paths
139
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
140
+
141
+ # Extract gene annotation from SOFT file
142
+ gene_annotation = get_gene_annotation(soft_file)
143
+
144
+ # Preview annotation dataframe structure
145
+ print("Gene Annotation Preview:")
146
+ print("Column names:", gene_annotation.columns.tolist())
147
+ print("\nFirst few rows as dictionary:")
148
+ print(preview_df(gene_annotation))
149
+ # The IDs in gene annotation correspond to the row IDs in gene expression data
150
+ # The ENTREZ_GENE_ID contains IDs that we first map to
151
+ mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='ENTREZ_GENE_ID')
152
+
153
+ # Apply the mapping to convert probe expression to gene expression
154
+ entrez_data = apply_gene_mapping(gene_data, mapping_df)
155
+
156
+ # Convert Entrez IDs to gene symbols using NCBI synonym database
157
+ gene_data = normalize_gene_symbols_in_index(entrez_data)
158
+
159
+ # Save the gene expression data
160
+ gene_data.to_csv(out_gene_data_file)
161
+ # Load previously saved data
162
+ gene_data = pd.read_csv(out_gene_data_file, index_col=0)
163
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
164
+
165
+ # Inspect data alignment
166
+ print("Clinical data shape:", clinical_data.shape)
167
+ print("Gene data shape:", gene_data.shape)
168
+ print("Clinical data columns:", clinical_data.columns[:5])
169
+ print("Gene data columns:", gene_data.columns[:5])
170
+
171
+ # Transpose data to get samples in rows, genes in columns
172
+ clinical_data = clinical_data.T
173
+ gene_data = gene_data.T
174
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
175
+
176
+ # 3. Handle missing values
177
+ linked_data = handle_missing_values(linked_data, 'Asthma')
178
+
179
+ # 4. Evaluate bias
180
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, 'Asthma')
181
+
182
+ # 5. Validate and save cohort info
183
+ is_usable = validate_and_save_cohort_info(
184
+ is_final=True,
185
+ cohort=cohort,
186
+ info_path=json_path,
187
+ is_gene_available=True,
188
+ is_trait_available=True,
189
+ is_biased=is_biased,
190
+ df=linked_data,
191
+ note="Dataset contains gene expression data from CD4+ T cells comparing asthma patients with healthy controls."
192
+ )
193
+
194
+ # 6. Save linked data if usable
195
+ if is_usable:
196
+ linked_data.to_csv(out_data_file)
197
+ # Load previously saved data
198
+ gene_data = pd.read_csv(out_gene_data_file, index_col=0)
199
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
200
+
201
+ # Verify data validity
202
+ if gene_data.empty:
203
+ print("Gene expression data is empty. Previous preprocessing steps likely failed.")
204
+ is_gene_available = False
205
+ is_trait_available = True
206
+ validate_and_save_cohort_info(
207
+ is_final=True,
208
+ cohort=cohort,
209
+ info_path=json_path,
210
+ is_gene_available=is_gene_available,
211
+ is_trait_available=is_trait_available,
212
+ is_biased=False, # Set a definite value
213
+ df=clinical_data, # Provide the clinical data
214
+ note="Gene expression data processing failed, resulting in empty data."
215
+ )
216
+ else:
217
+ # Link clinical and genetic data
218
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
219
+
220
+ # Handle missing values
221
+ linked_data = handle_missing_values(linked_data, trait)
222
+
223
+ # Evaluate bias
224
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
225
+
226
+ # Validate and save cohort info
227
+ is_usable = validate_and_save_cohort_info(
228
+ is_final=True,
229
+ cohort=cohort,
230
+ info_path=json_path,
231
+ is_gene_available=True,
232
+ is_trait_available=True,
233
+ is_biased=is_biased,
234
+ df=linked_data,
235
+ note="Dataset contains gene expression data from CD4+ T cells comparing asthma patients with healthy controls."
236
+ )
237
+
238
+ # Save linked data if usable
239
+ if is_usable:
240
+ linked_data.to_csv(out_data_file)
p3/preprocess/Asthma/code/GSE123088.py ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE123088"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE123088"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE123088.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE123088.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE123088.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # CD4+ T cells data likely contains gene expression, not just miRNA or methylation
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # 2.1 Data Availability
42
+ trait_row = 1 # 'primary diagnosis' contains trait info
43
+ age_row = 3 # 'age' data starts at feature 3 and continues in feature 4
44
+ gender_row = 2 # 'Sex' info is in feature 2
45
+
46
+ # 2.2 Data Type Conversion Functions
47
+ def convert_trait(value):
48
+ if pd.isna(value):
49
+ return None
50
+ value = value.split(': ')[1]
51
+ # Convert values to binary (0: control, 1: asthma)
52
+ if value in ['HEALTHY_CONTROL', 'Control']:
53
+ return 0
54
+ elif value in ['ASTHMA']:
55
+ return 1
56
+ return None
57
+
58
+ def convert_age(value):
59
+ if pd.isna(value):
60
+ return None
61
+ try:
62
+ # Extract numeric age value after colon
63
+ age = int(value.split(': ')[1])
64
+ return age
65
+ except:
66
+ return None
67
+
68
+ def convert_gender(value):
69
+ if pd.isna(value):
70
+ return None
71
+ if not value.startswith('Sex:'):
72
+ return None
73
+ value = value.split(': ')[1]
74
+ # Convert to binary (0: female, 1: male)
75
+ if value.upper() == 'FEMALE':
76
+ return 0
77
+ elif value.upper() == 'MALE':
78
+ return 1
79
+ return None
80
+
81
+ # 3. Save Metadata
82
+ validate_and_save_cohort_info(
83
+ is_final=False,
84
+ cohort=cohort,
85
+ info_path=json_path,
86
+ is_gene_available=is_gene_available,
87
+ is_trait_available=trait_row is not None
88
+ )
89
+
90
+ # 4. Clinical Feature Extraction
91
+ if trait_row is not None:
92
+ selected_clinical = geo_select_clinical_features(
93
+ clinical_df=clinical_data,
94
+ trait=trait,
95
+ trait_row=trait_row,
96
+ convert_trait=convert_trait,
97
+ age_row=age_row,
98
+ convert_age=convert_age,
99
+ gender_row=gender_row,
100
+ convert_gender=convert_gender
101
+ )
102
+
103
+ # Preview the processed clinical data
104
+ preview = preview_df(selected_clinical)
105
+ print("Preview of processed clinical data:")
106
+ print(preview)
107
+
108
+ # Save to CSV
109
+ selected_clinical.to_csv(out_clinical_data_file)
110
+ # Get file paths
111
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
112
+
113
+ # Extract gene expression data from matrix file
114
+ gene_data = get_genetic_data(matrix_file)
115
+
116
+ # Print first 20 row IDs and shape of data to help debug
117
+ print("Shape of gene expression data:", gene_data.shape)
118
+ print("\nFirst few rows of data:")
119
+ print(gene_data.head())
120
+ print("\nFirst 20 gene/probe identifiers:")
121
+ print(gene_data.index[:20])
122
+
123
+ # Inspect a snippet of raw file to verify identifier format
124
+ import gzip
125
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
126
+ lines = []
127
+ for i, line in enumerate(f):
128
+ if "!series_matrix_table_begin" in line:
129
+ # Get the next 5 lines after the marker
130
+ for _ in range(5):
131
+ lines.append(next(f).strip())
132
+ break
133
+ print("\nFirst few lines after matrix marker in raw file:")
134
+ for line in lines:
135
+ print(line)
136
+ # The identifiers appear to be numeric IDs from 1-24166
137
+ # These are not gene symbols and will need mapping
138
+ requires_gene_mapping = True
139
+ # Get file paths
140
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
141
+
142
+ # Extract platform info from SOFT file line by line
143
+ import gzip
144
+ import re
145
+ platform_lines = []
146
+ gene_symbol_lines = []
147
+ with gzip.open(soft_file, 'rt') as f:
148
+ in_platform_block = False
149
+ for line in f:
150
+ if line.startswith('!Platform_'):
151
+ platform_lines.append(line.strip())
152
+ if 'table_begin' in line:
153
+ in_platform_block = True
154
+ # Skip header line
155
+ next(f)
156
+ continue
157
+ elif 'table_end' in line:
158
+ in_platform_block = False
159
+ continue
160
+ elif in_platform_block:
161
+ gene_symbol_lines.append(line.strip())
162
+
163
+ # Parse platform annotation table
164
+ import pandas as pd
165
+ import io
166
+
167
+ platform_table = pd.read_csv(io.StringIO('\n'.join(gene_symbol_lines)), sep='\t')
168
+
169
+ # Preview annotation data
170
+ print("Platform Information:")
171
+ for line in platform_lines[:5]:
172
+ print(line)
173
+
174
+ print("\nPlatform Annotation Table Preview:")
175
+ print("Column names:", platform_table.columns.tolist())
176
+ print("\nFirst few rows:")
177
+ print(preview_df(platform_table))
178
+ # Get file paths
179
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
180
+
181
+ # Look through entire SOFT file for gene symbol information
182
+ import gzip
183
+ platform_lines = []
184
+ gene_table_lines = []
185
+ with gzip.open(soft_file, 'rt') as f:
186
+ in_gene_table = False
187
+ table_found = False
188
+ for line in f:
189
+ # Keep track of platform lines for debugging
190
+ if line.startswith('!Platform_'):
191
+ platform_lines.append(line.strip())
192
+ if 'table_begin' in line:
193
+ in_gene_table = True
194
+ # Get header line
195
+ header = next(f).strip()
196
+ gene_table_lines.append(header)
197
+ continue
198
+ elif 'table_end' in line:
199
+ in_gene_table = False
200
+ elif in_gene_table and ('gene_symbol' in line.lower() or 'gene_name' in line.lower() or
201
+ 'symbol' in line.lower() or 'gene_assignment' in line.lower()):
202
+ table_found = True
203
+ gene_table_lines.append(line.strip())
204
+
205
+ print("Platform information:")
206
+ for line in platform_lines[:10]:
207
+ print(line)
208
+
209
+ print("\nFirst few gene table lines (if gene symbols found):")
210
+ if gene_table_lines:
211
+ for line in gene_table_lines[:5]:
212
+ print(line)
213
+
214
+ print("\nSearching for alternative annotation fields...")
215
+ # Extract gene annotation trying both methods
216
+ gene_annotation = get_gene_annotation(soft_file)
217
+
218
+ # Preview annotation dataframe structure
219
+ print("\nGene Annotation Preview:")
220
+ print("Column names:", gene_annotation.columns.tolist())
221
+ print("\nFirst few rows as dictionary (showing all columns):")
222
+ pd.set_option('display.max_columns', None)
223
+ print(gene_annotation.head().to_dict('records'))
224
+ # Create mapping dataframe using platform's annotation
225
+ mapping_data = gene_annotation.loc[:, ['ID', 'ENTREZ_GENE_ID']].dropna()
226
+
227
+ # Create a list of genes for the Gene column, single gene ID per row
228
+ mapping_data['Gene'] = mapping_data['ENTREZ_GENE_ID'].map(lambda x: [str(int(float(x)))] if pd.notnull(x) and float(x) > 0 else [])
229
+ mapping_data = mapping_data.drop(columns=['ENTREZ_GENE_ID'])
230
+
231
+ # Apply gene mapping to transform probe-level data to gene-level data
232
+ gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_data)
233
+
234
+ # Normalize gene symbols to consistent format
235
+ gene_data = normalize_gene_symbols_in_index(gene_data)
236
+
237
+ # Save gene expression data
238
+ gene_data.to_csv(out_gene_data_file)
239
+ # Get file paths and read data
240
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
241
+
242
+ # Get gene annotation and expression data
243
+ gene_annotation = get_gene_annotation(soft_file)
244
+ gene_data = get_genetic_data(matrix_file)
245
+
246
+ # Clean and create mapping dataframe
247
+ gene_annotation = gene_annotation[gene_annotation['ENTREZ_GENE_ID'].str.isnumeric().fillna(False)]
248
+ mapping_data = gene_annotation.loc[:, ['ID', 'ENTREZ_GENE_ID']].dropna()
249
+ mapping_data['Gene'] = mapping_data['ENTREZ_GENE_ID'].map(lambda x: [str(int(float(x)))] if pd.notnull(x) and float(x) > 0 else [])
250
+ mapping_data = mapping_data.drop(columns=['ENTREZ_GENE_ID'])
251
+
252
+ # Apply gene mapping to transform probe-level data to gene-level data
253
+ gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_data)
254
+
255
+ # Normalize gene symbols
256
+ gene_data = normalize_gene_symbols_in_index(gene_data)
257
+ gene_data.to_csv(out_gene_data_file)
258
+
259
+ # Link clinical and genetic data
260
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
261
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
262
+
263
+ # Handle missing values
264
+ linked_data = handle_missing_values(linked_data, trait)
265
+
266
+ # Evaluate bias
267
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
268
+
269
+ # Validate and save cohort info
270
+ is_usable = validate_and_save_cohort_info(
271
+ is_final=True,
272
+ cohort=cohort,
273
+ info_path=json_path,
274
+ is_gene_available=True,
275
+ is_trait_available=True,
276
+ is_biased=is_biased,
277
+ df=linked_data,
278
+ note="Dataset contains gene expression data from CD4+ T cells."
279
+ )
280
+
281
+ # Save linked data if usable
282
+ if is_usable:
283
+ linked_data.to_csv(out_data_file)
p3/preprocess/Asthma/code/GSE182797.py ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE182797"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE182797"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE182797.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE182797.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE182797.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # Based on series title and overall design, this dataset contains transcriptomic data from nasal biopsies
38
+ is_gene_available = True
39
+
40
+ # 2.1 Data Availability
41
+ # trait data is in Feature 0 (diagnosis)
42
+ trait_row = 0
43
+
44
+ # gender data is in Feature 1 but only contains females
45
+ gender_row = None # Not useful since all subjects are female
46
+
47
+ # age data is in Feature 2
48
+ age_row = 2
49
+
50
+ # 2.2 Data Type Conversion Functions
51
+ def convert_trait(x):
52
+ if not isinstance(x, str):
53
+ return None
54
+ value = x.split(': ')[-1].lower()
55
+ if 'adult-onset asthma' in value:
56
+ return 1
57
+ elif 'healthy' in value:
58
+ return 0
59
+ return None
60
+
61
+ def convert_age(x):
62
+ if not isinstance(x, str):
63
+ return None
64
+ try:
65
+ value = x.split(': ')[-1]
66
+ return float(value)
67
+ except:
68
+ return None
69
+
70
+ def convert_gender(x):
71
+ # This function won't be used but included for completeness
72
+ if not isinstance(x, str):
73
+ return None
74
+ value = x.split(': ')[-1].lower()
75
+ if 'female' in value:
76
+ return 0
77
+ elif 'male' in value:
78
+ return 1
79
+ return None
80
+
81
+ # 3. Save Metadata
82
+ is_trait_available = trait_row is not None
83
+ validate_and_save_cohort_info(is_final=False,
84
+ cohort=cohort,
85
+ info_path=json_path,
86
+ is_gene_available=is_gene_available,
87
+ is_trait_available=is_trait_available)
88
+
89
+ # 4. Clinical Feature Extraction
90
+ # Since trait_row is not None, we need to extract clinical features
91
+ selected_clinical = geo_select_clinical_features(clinical_df=clinical_data,
92
+ trait=trait,
93
+ trait_row=trait_row,
94
+ convert_trait=convert_trait,
95
+ age_row=age_row,
96
+ convert_age=convert_age)
97
+
98
+ # Preview the extracted features
99
+ print("Preview of extracted clinical features:")
100
+ print(preview_df(selected_clinical))
101
+
102
+ # Save clinical data
103
+ selected_clinical.to_csv(out_clinical_data_file)
104
+ # Get file paths
105
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
106
+
107
+ # Extract gene expression data from matrix file
108
+ gene_data = get_genetic_data(matrix_file)
109
+
110
+ # Print first 20 row IDs and shape of data to help debug
111
+ print("Shape of gene expression data:", gene_data.shape)
112
+ print("\nFirst few rows of data:")
113
+ print(gene_data.head())
114
+ print("\nFirst 20 gene/probe identifiers:")
115
+ print(gene_data.index[:20])
116
+
117
+ # Inspect a snippet of raw file to verify identifier format
118
+ import gzip
119
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
120
+ lines = []
121
+ for i, line in enumerate(f):
122
+ if "!series_matrix_table_begin" in line:
123
+ # Get the next 5 lines after the marker
124
+ for _ in range(5):
125
+ lines.append(next(f).strip())
126
+ break
127
+ print("\nFirst few lines after matrix marker in raw file:")
128
+ for line in lines:
129
+ print(line)
130
+ # These are Agilent probe identifiers starting with A_19_P, NOT human gene symbols
131
+ requires_gene_mapping = True
132
+ # Get file paths
133
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
134
+
135
+ # Extract gene annotation from SOFT file
136
+ gene_annotation = get_gene_annotation(soft_file)
137
+
138
+ # Preview annotation dataframe structure
139
+ print("Gene Annotation Preview:")
140
+ print("Column names:", gene_annotation.columns.tolist())
141
+ print("\nFirst few rows as dictionary:")
142
+ print(preview_df(gene_annotation))
143
+ # 1. Based on the dataframes, 'ID' column contains probe identifiers, and 'GENE_SYMBOL' contains gene symbols
144
+ prob_col = 'ID'
145
+ gene_col = 'GENE_SYMBOL'
146
+
147
+ # 2. Get gene mapping dataframe
148
+ mapping_data = get_gene_mapping(gene_annotation, prob_col, gene_col)
149
+
150
+ # 3. Convert probe-level measurements to gene expression
151
+ gene_data = apply_gene_mapping(gene_data, mapping_data)
152
+
153
+ # Print dimensions and first few rows to verify the mapping
154
+ print("Shape of gene expression data after mapping:", gene_data.shape)
155
+ print("\nFirst few rows of mapped data:")
156
+ print(gene_data.head())
157
+ # 1. Normalize gene symbols
158
+ gene_data = normalize_gene_symbols_in_index(gene_data)
159
+ gene_data.to_csv(out_gene_data_file)
160
+
161
+ # 2. Link clinical and genetic data
162
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
163
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
164
+
165
+ # 3. Handle missing values
166
+ linked_data = handle_missing_values(linked_data, trait)
167
+
168
+ # 4. Evaluate bias
169
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
170
+
171
+ # 5. Validate and save cohort info
172
+ is_usable = validate_and_save_cohort_info(
173
+ is_final=True,
174
+ cohort=cohort,
175
+ info_path=json_path,
176
+ is_gene_available=True,
177
+ is_trait_available=True,
178
+ is_biased=is_biased,
179
+ df=linked_data,
180
+ note="Dataset contains RNA transcriptome data in human sinonasal epithelial cells."
181
+ )
182
+
183
+ # 6. Save linked data if usable
184
+ if is_usable:
185
+ linked_data.to_csv(out_data_file)
p3/preprocess/Asthma/code/GSE182798.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE182798"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE182798"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE182798.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE182798.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE182798.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # The dataset contains PBMC and Nasal biopsy samples, which are suitable for gene expression profiling
38
+ is_gene_available = True
39
+
40
+ # 2.1 Data Row Identification
41
+ trait_row = 0 # diagnosis is in row 0
42
+ age_row = 2 # age is in row 2
43
+ gender_row = 1 # gender is in row 1, but all female so mark as None since constant
44
+ gender_row = None
45
+
46
+ # 2.2 Data Type Conversion Functions
47
+ def convert_trait(x):
48
+ if pd.isna(x):
49
+ return None
50
+ value = x.split(': ')[1].lower()
51
+ if 'adult-onset asthma' in value:
52
+ return 1
53
+ elif 'healthy' in value:
54
+ return 0
55
+ return None
56
+
57
+ def convert_age(x):
58
+ if pd.isna(x):
59
+ return None
60
+ try:
61
+ return float(x.split(': ')[1])
62
+ except:
63
+ return None
64
+
65
+ def convert_gender(x):
66
+ if pd.isna(x):
67
+ return None
68
+ value = x.split(': ')[1].lower()
69
+ if 'female' in value:
70
+ return 0
71
+ elif 'male' in value:
72
+ return 1
73
+ return None
74
+
75
+ # 3. Save Metadata
76
+ is_usable = validate_and_save_cohort_info(is_final=False,
77
+ cohort=cohort,
78
+ info_path=json_path,
79
+ is_gene_available=is_gene_available,
80
+ is_trait_available=trait_row is not None)
81
+
82
+ # 4. Clinical Feature Extraction
83
+ if trait_row is not None:
84
+ clinical_features = geo_select_clinical_features(clinical_df=clinical_data,
85
+ trait=trait,
86
+ trait_row=trait_row,
87
+ convert_trait=convert_trait,
88
+ age_row=age_row,
89
+ convert_age=convert_age,
90
+ gender_row=gender_row,
91
+ convert_gender=convert_gender)
92
+
93
+ # Preview the data
94
+ preview = preview_df(clinical_features)
95
+ print("Clinical Features Preview:", preview)
96
+
97
+ # Save to CSV
98
+ clinical_features.to_csv(out_clinical_data_file)
99
+ # Get file paths
100
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
101
+
102
+ # Extract gene expression data from matrix file
103
+ gene_data = get_genetic_data(matrix_file)
104
+
105
+ # Print first 20 row IDs and shape of data to help debug
106
+ print("Shape of gene expression data:", gene_data.shape)
107
+ print("\nFirst few rows of data:")
108
+ print(gene_data.head())
109
+ print("\nFirst 20 gene/probe identifiers:")
110
+ print(gene_data.index[:20])
111
+
112
+ # Inspect a snippet of raw file to verify identifier format
113
+ import gzip
114
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
115
+ lines = []
116
+ for i, line in enumerate(f):
117
+ if "!series_matrix_table_begin" in line:
118
+ # Get the next 5 lines after the marker
119
+ for _ in range(5):
120
+ lines.append(next(f).strip())
121
+ break
122
+ print("\nFirst few lines after matrix marker in raw file:")
123
+ for line in lines:
124
+ print(line)
125
+ # Looking at the identifiers, they start with "A_19_P" followed by numbers
126
+ # These are Agilent microarray probe IDs, not human gene symbols
127
+ requires_gene_mapping = True
128
+ # Get file paths
129
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
130
+
131
+ # Extract gene annotation from SOFT file
132
+ gene_annotation = get_gene_annotation(soft_file)
133
+
134
+ # Preview annotation dataframe structure
135
+ print("Gene Annotation Preview:")
136
+ print("Column names:", gene_annotation.columns.tolist())
137
+ print("\nFirst few rows as dictionary:")
138
+ print(preview_df(gene_annotation))
139
+ # 1. Create gene mapping dataframe from annotation
140
+ mapping_data = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
141
+
142
+ # 2. Apply gene mapping to convert probe-level measurements to gene expression values
143
+ gene_data = apply_gene_mapping(gene_data, mapping_data)
144
+
145
+ # 3. Print a quick preview of the mapped gene data
146
+ print("Gene expression data after mapping:")
147
+ print("Shape:", gene_data.shape)
148
+ print("\nFirst few rows:")
149
+ print(gene_data.head())
150
+ # 1. Normalize gene symbols
151
+ gene_data = normalize_gene_symbols_in_index(gene_data)
152
+ gene_data.to_csv(out_gene_data_file)
153
+
154
+ # 2. Link clinical and genetic data
155
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
156
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
157
+
158
+ # 3. Handle missing values
159
+ linked_data = handle_missing_values(linked_data, trait)
160
+
161
+ # 4. Evaluate bias
162
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
163
+
164
+ # 5. Validate and save cohort info
165
+ is_usable = validate_and_save_cohort_info(
166
+ is_final=True,
167
+ cohort=cohort,
168
+ info_path=json_path,
169
+ is_gene_available=True,
170
+ is_trait_available=True,
171
+ is_biased=is_biased,
172
+ df=linked_data,
173
+ note="Dataset contains RNA transcriptome data in human sinonasal epithelial cells."
174
+ )
175
+
176
+ # 6. Save linked data if usable
177
+ if is_usable:
178
+ linked_data.to_csv(out_data_file)
p3/preprocess/Asthma/code/GSE184382.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE184382"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE184382"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE184382.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE184382.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE184382.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # Based on series title and summary, this dataset contains miRNA data rather than gene expression data
38
+ is_gene_available = False
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # 2.1 Check data availability from sample characteristics
42
+ trait_row = None # Cannot reliably determine asthma status from AIT treatment alone
43
+ age_row = None # Age data not available
44
+ gender_row = None # Gender data not available
45
+
46
+ # 2.2 Define conversion functions (though data not available in this case)
47
+ def convert_trait(x):
48
+ return None
49
+
50
+ def convert_age(x):
51
+ return None
52
+
53
+ def convert_gender(x):
54
+ return None
55
+
56
+ # 3. Save metadata about dataset usability
57
+ validate_and_save_cohort_info(
58
+ is_final=False,
59
+ cohort=cohort,
60
+ info_path=json_path,
61
+ is_gene_available=is_gene_available,
62
+ is_trait_available=(trait_row is not None)
63
+ )
64
+
65
+ # 4. Clinical Feature Extraction
66
+ # Skip this step since trait_row is None
p3/preprocess/Asthma/code/GSE185658.py ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE185658"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE185658"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE185658.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE185658.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE185658.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # Yes, this dataset contains microarray data for gene expression (see Series_summary)
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # 2.1 Data Availability and Location
42
+ trait_row = 1 # 'group' feature contains asthma status
43
+ age_row = None # Age data not available
44
+ gender_row = None # Gender data not available
45
+
46
+ # 2.2 Data Type Conversion Functions
47
+ def convert_trait(value: str) -> Optional[int]:
48
+ """Convert asthma status to binary: 1 for asthma, 0 for healthy"""
49
+ if not value or ':' not in value:
50
+ return None
51
+ value = value.split(':')[1].strip()
52
+ if 'Asthma' in value: # Both AsthmaHDM and AsthmaHDMNeg are asthma cases
53
+ return 1
54
+ elif value == 'Healthy':
55
+ return 0
56
+ return None
57
+
58
+ convert_age = None # No age data
59
+ convert_gender = None # No gender data
60
+
61
+ # 3. Save Metadata
62
+ validate_and_save_cohort_info(
63
+ is_final=False,
64
+ cohort=cohort,
65
+ info_path=json_path,
66
+ is_gene_available=is_gene_available,
67
+ is_trait_available=trait_row is not None
68
+ )
69
+
70
+ # 4. Clinical Feature Extraction
71
+ if trait_row is not None:
72
+ # Extract clinical features
73
+ clinical_features = geo_select_clinical_features(
74
+ clinical_df=clinical_data,
75
+ trait=trait,
76
+ trait_row=trait_row,
77
+ convert_trait=convert_trait,
78
+ age_row=age_row,
79
+ convert_age=convert_age,
80
+ gender_row=gender_row,
81
+ convert_gender=convert_gender
82
+ )
83
+
84
+ # Preview the extracted features
85
+ print("Preview of clinical features:")
86
+ print(preview_df(clinical_features))
87
+
88
+ # Save to CSV
89
+ clinical_features.to_csv(out_clinical_data_file)
90
+ # Get file paths
91
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
92
+
93
+ # Extract gene expression data from matrix file
94
+ gene_data = get_genetic_data(matrix_file)
95
+
96
+ # Print first 20 row IDs and shape of data to help debug
97
+ print("Shape of gene expression data:", gene_data.shape)
98
+ print("\nFirst few rows of data:")
99
+ print(gene_data.head())
100
+ print("\nFirst 20 gene/probe identifiers:")
101
+ print(gene_data.index[:20])
102
+
103
+ # Inspect a snippet of raw file to verify identifier format
104
+ import gzip
105
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
106
+ lines = []
107
+ for i, line in enumerate(f):
108
+ if "!series_matrix_table_begin" in line:
109
+ # Get the next 5 lines after the marker
110
+ for _ in range(5):
111
+ lines.append(next(f).strip())
112
+ break
113
+ print("\nFirst few lines after matrix marker in raw file:")
114
+ for line in lines:
115
+ print(line)
116
+ # The identifiers are numeric IDs like '7892501', not standard gene symbols
117
+ # These appear to be probe IDs from a microarray platform that need to be mapped to gene symbols
118
+ requires_gene_mapping = True
119
+ # Get file paths
120
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
121
+
122
+ # Extract gene annotation from SOFT file
123
+ gene_annotation = get_gene_annotation(soft_file)
124
+
125
+ # Preview annotation dataframe structure
126
+ print("Gene Annotation Preview:")
127
+ print("Column names:", gene_annotation.columns.tolist())
128
+ print("\nFirst few rows as dictionary:")
129
+ print(preview_df(gene_annotation))
130
+ # 1. Identify mapping columns from gene annotation
131
+ # 'ID' column in annotation matches probe IDs in gene expression data
132
+ # 'gene_assignment' contains gene symbols and annotations
133
+ prob_col = 'ID'
134
+ gene_col = 'gene_assignment'
135
+
136
+ # 2. Get mapping between probe IDs and gene symbols
137
+ mapping_data = get_gene_mapping(gene_annotation, prob_col, gene_col)
138
+
139
+ # 3. Apply gene mapping to convert probe-level data to gene-level data
140
+ gene_data = apply_gene_mapping(gene_data, mapping_data)
141
+
142
+ # Print the shape and preview of mapped gene data
143
+ print("\nShape of mapped gene expression data:", gene_data.shape)
144
+ print("\nFirst few rows of mapped gene expression data:")
145
+ print(gene_data.head())
146
+ # 1. Normalize gene symbols
147
+ gene_data = normalize_gene_symbols_in_index(gene_data)
148
+ gene_data.to_csv(out_gene_data_file)
149
+
150
+ # 2. Link clinical and genetic data
151
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
152
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
153
+
154
+ # 3. Handle missing values
155
+ linked_data = handle_missing_values(linked_data, trait)
156
+
157
+ # 4. Evaluate bias
158
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
159
+
160
+ # 5. Validate and save cohort info
161
+ is_usable = validate_and_save_cohort_info(
162
+ is_final=True,
163
+ cohort=cohort,
164
+ info_path=json_path,
165
+ is_gene_available=True,
166
+ is_trait_available=True,
167
+ is_biased=is_biased,
168
+ df=linked_data,
169
+ note="Dataset contains RNA transcriptome data in human sinonasal epithelial cells."
170
+ )
171
+
172
+ # 6. Save linked data if usable
173
+ if is_usable:
174
+ linked_data.to_csv(out_data_file)
p3/preprocess/Asthma/code/GSE188424.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE188424"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE188424"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE188424.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE188424.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE188424.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # Yes, this dataset contains gene expression data from human blood samples,
38
+ # not just miRNA or methylation
39
+ is_gene_available = True
40
+
41
+ # 2. Variable Availability and Data Type Conversion
42
+ # 2.1 Data Availability
43
+ trait_row = None # Not available in characteristics dictionary
44
+ gender_row = 0 # Gender data is available at index 0
45
+ age_row = None # No age data available
46
+
47
+ # 2.2 Data Type Conversion Functions
48
+ def convert_trait(value):
49
+ # Won't be used since trait data is not available
50
+ return None
51
+
52
+ def convert_gender(value):
53
+ if not isinstance(value, str):
54
+ return None
55
+ value = value.lower().split(': ')[-1].strip()
56
+ if value == 'female':
57
+ return 0
58
+ elif value == 'male':
59
+ return 1
60
+ return None
61
+
62
+ def convert_age(value):
63
+ # Won't be used since age data is not available
64
+ return None
65
+
66
+ # 3. Save Metadata - Initial Filtering
67
+ validate_and_save_cohort_info(
68
+ is_final=False,
69
+ cohort=cohort,
70
+ info_path=json_path,
71
+ is_gene_available=is_gene_available,
72
+ is_trait_available=False # trait_row is None
73
+ )
74
+
75
+ # 4. Clinical Feature Extraction
76
+ # Skip this step since trait_row is None
77
+ # Get file paths
78
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
79
+
80
+ # Extract gene expression data from matrix file
81
+ gene_data = get_genetic_data(matrix_file)
82
+
83
+ # Print first 20 row IDs and shape of data to help debug
84
+ print("Shape of gene expression data:", gene_data.shape)
85
+ print("\nFirst few rows of data:")
86
+ print(gene_data.head())
87
+ print("\nFirst 20 gene/probe identifiers:")
88
+ print(gene_data.index[:20])
89
+
90
+ # Inspect a snippet of raw file to verify identifier format
91
+ import gzip
92
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
93
+ lines = []
94
+ for i, line in enumerate(f):
95
+ if "!series_matrix_table_begin" in line:
96
+ # Get the next 5 lines after the marker
97
+ for _ in range(5):
98
+ lines.append(next(f).strip())
99
+ break
100
+ print("\nFirst few lines after matrix marker in raw file:")
101
+ for line in lines:
102
+ print(line)
103
+ # These are Illumina probe IDs (starting with ILMN_) and need to be mapped to gene symbols
104
+ requires_gene_mapping = True
105
+ # Get file paths
106
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
107
+
108
+ # Extract gene annotation from SOFT file
109
+ gene_annotation = get_gene_annotation(soft_file)
110
+
111
+ # Preview annotation dataframe structure
112
+ print("Gene Annotation Preview:")
113
+ print("Column names:", gene_annotation.columns.tolist())
114
+ print("\nFirst few rows as dictionary:")
115
+ print(preview_df(gene_annotation))
116
+ # 1. Identify mapping columns from gene annotation data
117
+ # 'ID' column matches the probe IDs (ILMN_) in expression data
118
+ # 'Symbol' column contains the gene symbols to map to
119
+ prob_col = 'ID'
120
+ gene_col = 'Symbol'
121
+
122
+ # 2. Get gene mapping dataframe
123
+ mapping_df = get_gene_mapping(gene_annotation, prob_col, gene_col)
124
+
125
+ # 3. Apply gene mapping to convert probe-level data to gene-level data
126
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
127
+
128
+ # Print shape and preview mapped data
129
+ print("\nShape of gene-level expression data:", gene_data.shape)
130
+ print("\nPreview of gene-level expression data:")
131
+ print(gene_data.head())
132
+ # 1. Normalize gene symbols and save gene data
133
+ gene_data = normalize_gene_symbols_in_index(gene_data)
134
+ gene_data.to_csv(out_gene_data_file)
135
+
136
+ # 2. Update cohort info - dataset not usable due to missing trait data
137
+ validate_and_save_cohort_info(
138
+ is_final=True,
139
+ cohort=cohort,
140
+ info_path=json_path,
141
+ is_gene_available=True,
142
+ is_trait_available=False, # No trait data available
143
+ is_biased=True, # Dataset unusable without trait data
144
+ df=gene_data, # Pass gene expression data
145
+ note="Dataset contains gene expression data but lacks trait information needed for association studies."
146
+ )
p3/preprocess/Asthma/code/GSE205151.py ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE205151"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE205151"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE205151.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE205151.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE205151.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # Yes, this dataset contains gene expression data from Nanostring array
38
+ is_gene_available = True
39
+
40
+ # 2.1. Data Availability
41
+ # Use cluster information as trait data since it represents asthma phenotypes
42
+ trait_row = 1 # Feature 1 contains cluster info
43
+ age_row = None # Age not explicitly provided
44
+ gender_row = None # Gender not provided
45
+
46
+ # 2.2. Data Type Conversion Functions
47
+ def convert_trait(x):
48
+ if pd.isna(x):
49
+ return None
50
+ # Extract cluster number after colon and convert to binary
51
+ # cluster 1 -> 0, cluster 2 -> 1
52
+ try:
53
+ cluster = int(x.split(':')[1].strip())
54
+ if cluster == 1:
55
+ return 0
56
+ elif cluster == 2:
57
+ return 1
58
+ return None
59
+ except:
60
+ return None
61
+
62
+ def convert_age(x):
63
+ # Not used since age data unavailable
64
+ return None
65
+
66
+ def convert_gender(x):
67
+ # Not used since gender data unavailable
68
+ return None
69
+
70
+ # 3. Save Metadata
71
+ is_trait_available = trait_row is not None
72
+ validate_and_save_cohort_info(
73
+ is_final=False,
74
+ cohort=cohort,
75
+ info_path=json_path,
76
+ is_gene_available=is_gene_available,
77
+ is_trait_available=is_trait_available
78
+ )
79
+
80
+ # 4. Clinical Feature Extraction
81
+ if trait_row is not None:
82
+ selected_clinical_df = geo_select_clinical_features(
83
+ clinical_df=clinical_data,
84
+ trait=trait,
85
+ trait_row=trait_row,
86
+ convert_trait=convert_trait
87
+ )
88
+
89
+ # Preview the extracted features
90
+ print("Preview of extracted clinical features:")
91
+ print(preview_df(selected_clinical_df))
92
+
93
+ # Save to CSV
94
+ selected_clinical_df.to_csv(out_clinical_data_file)
95
+ # Get file paths
96
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
97
+
98
+ # Extract gene expression data from matrix file
99
+ gene_data = get_genetic_data(matrix_file)
100
+
101
+ # Print first 20 row IDs and shape of data to help debug
102
+ print("Shape of gene expression data:", gene_data.shape)
103
+ print("\nFirst few rows of data:")
104
+ print(gene_data.head())
105
+ print("\nFirst 20 gene/probe identifiers:")
106
+ print(gene_data.index[:20])
107
+
108
+ # Inspect a snippet of raw file to verify identifier format
109
+ import gzip
110
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
111
+ lines = []
112
+ for i, line in enumerate(f):
113
+ if "!series_matrix_table_begin" in line:
114
+ # Get the next 5 lines after the marker
115
+ for _ in range(5):
116
+ lines.append(next(f).strip())
117
+ break
118
+ print("\nFirst few lines after matrix marker in raw file:")
119
+ for line in lines:
120
+ print(line)
121
+ # Looking at the gene identifiers in the first few rows, they appear to be valid human gene symbols
122
+ # For example, ABCB1, ABCF1, ABL1, ADA, AHR are all standard human gene symbols
123
+ # The ID column contains recognized official human gene symbols that do not need mapping
124
+ requires_gene_mapping = False
125
+ # 1. Normalize gene symbols
126
+ gene_data = normalize_gene_symbols_in_index(gene_data)
127
+ gene_data.to_csv(out_gene_data_file)
128
+
129
+ # 2. Link clinical and genetic data
130
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
131
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
132
+
133
+ # 3. Handle missing values
134
+ linked_data = handle_missing_values(linked_data, trait)
135
+
136
+ # 4. Evaluate bias
137
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
138
+
139
+ # 5. Validate and save cohort info
140
+ is_usable = validate_and_save_cohort_info(
141
+ is_final=True,
142
+ cohort=cohort,
143
+ info_path=json_path,
144
+ is_gene_available=True,
145
+ is_trait_available=True,
146
+ is_biased=is_biased,
147
+ df=linked_data,
148
+ note="Dataset contains RNA transcriptome data in human sinonasal epithelial cells."
149
+ )
150
+
151
+ # 6. Save linked data if usable
152
+ if is_usable:
153
+ linked_data.to_csv(out_data_file)
p3/preprocess/Asthma/code/GSE230164.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE230164"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE230164"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE230164.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE230164.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE230164.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # 1. Gene Expression Data Availability
37
+ # Since "Gene expression profiling" is mentioned in series title,
38
+ # and series summary indicates this is a SuperSeries containing SubSeries,
39
+ # this dataset is likely to contain gene expression data
40
+ is_gene_available = True
41
+
42
+ # 2. Variable Availability and Data Type Conversion
43
+ # 2.1 Data Availability
44
+ # Based on sample characteristics, we can find:
45
+ # - Gender is available at key 0
46
+ # - Trait and age information are not explicitly available
47
+ trait_row = None
48
+ age_row = None
49
+ gender_row = 0
50
+
51
+ # 2.2 Data Type Conversion Functions
52
+ def convert_trait(x):
53
+ return None # Not available
54
+
55
+ def convert_age(x):
56
+ return None # Not available
57
+
58
+ def convert_gender(x):
59
+ # Extract value after colon and convert to binary
60
+ if not isinstance(x, str):
61
+ return None
62
+ value = x.split(': ')[-1].lower()
63
+ if value == 'female':
64
+ return 0
65
+ elif value == 'male':
66
+ return 1
67
+ return None
68
+
69
+ # 3. Save metadata about data availability
70
+ validate_and_save_cohort_info(
71
+ is_final=False,
72
+ cohort=cohort,
73
+ info_path=json_path,
74
+ is_gene_available=is_gene_available,
75
+ is_trait_available=(trait_row is not None)
76
+ )
77
+
78
+ # 4. Since trait_row is None, skip clinical feature extraction
79
+ # Get file paths
80
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
81
+
82
+ # Extract gene expression data from matrix file
83
+ gene_data = get_genetic_data(matrix_file)
84
+
85
+ # Print first 20 row IDs and shape of data to help debug
86
+ print("Shape of gene expression data:", gene_data.shape)
87
+ print("\nFirst few rows of data:")
88
+ print(gene_data.head())
89
+ print("\nFirst 20 gene/probe identifiers:")
90
+ print(gene_data.index[:20])
91
+
92
+ # Inspect a snippet of raw file to verify identifier format
93
+ import gzip
94
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
95
+ lines = []
96
+ for i, line in enumerate(f):
97
+ if "!series_matrix_table_begin" in line:
98
+ # Get the next 5 lines after the marker
99
+ for _ in range(5):
100
+ lines.append(next(f).strip())
101
+ break
102
+ print("\nFirst few lines after matrix marker in raw file:")
103
+ for line in lines:
104
+ print(line)
105
+ # The identifiers start with ILMN_ which indicates they are Illumina probe IDs
106
+ # These need to be mapped to human gene symbols for standardization
107
+ requires_gene_mapping = True
108
+ # Get file paths
109
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
110
+
111
+ # Extract gene annotation from SOFT file
112
+ gene_annotation = get_gene_annotation(soft_file)
113
+
114
+ # Preview annotation dataframe structure
115
+ print("Gene Annotation Preview:")
116
+ print("Column names:", gene_annotation.columns.tolist())
117
+ print("\nFirst few rows as dictionary:")
118
+ print(preview_df(gene_annotation))
119
+ # 1. Based on the preview, 'ID' in annotation matches probe IDs in expression data (ILMN_*),
120
+ # and 'Symbol' contains gene symbols
121
+
122
+ # 2. Extract ID and Symbol columns to create mapping dataframe
123
+ gene_mapping = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
124
+
125
+ # 3. Apply gene mapping to convert probe-level measurements to gene-level expression
126
+ gene_data = apply_gene_mapping(gene_data, gene_mapping)
127
+ # 1. Normalize gene symbols
128
+ gene_data = normalize_gene_symbols_in_index(gene_data)
129
+ gene_data.to_csv(out_gene_data_file)
130
+
131
+ # Create a minimal DataFrame for validation
132
+ linked_data = gene_data.T # Transpose to have samples as rows
133
+
134
+ # Validate and save cohort info
135
+ is_usable = validate_and_save_cohort_info(
136
+ is_final=True,
137
+ cohort=cohort,
138
+ info_path=json_path,
139
+ is_gene_available=True,
140
+ is_trait_available=False,
141
+ is_biased=True, # No trait data means it's biased by definition
142
+ df=linked_data,
143
+ note="Dataset contains gene expression data but lacks required trait information."
144
+ )
p3/preprocess/Asthma/code/GSE270312.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+ cohort = "GSE270312"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Asthma"
10
+ in_cohort_dir = "../DATA/GEO/Asthma/GSE270312"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Asthma/GSE270312.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/GSE270312.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/GSE270312.csv"
16
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
17
+
18
+ # Get file paths
19
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Extract background info and clinical data
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file)
23
+
24
+ # Get unique values per clinical feature
25
+ sample_characteristics = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print background info
28
+ print("Dataset Background Information:")
29
+ print(f"{background_info}\n")
30
+
31
+ # Print sample characteristics
32
+ print("Sample Characteristics:")
33
+ for feature, values in sample_characteristics.items():
34
+ print(f"Feature: {feature}")
35
+ print(f"Values: {values}\n")
36
+ # Data type conversion functions
37
+ def convert_trait(value: str) -> Optional[int]:
38
+ if not value or ':' not in value:
39
+ return None
40
+ asthma_status = value.split(':')[1].strip().lower()
41
+ if 'yes' in asthma_status:
42
+ return 1
43
+ elif 'no' in asthma_status:
44
+ return 0
45
+ return None
46
+
47
+ def convert_gender(value: str) -> Optional[int]:
48
+ if not value or ':' not in value:
49
+ return None
50
+ gender = value.split(':')[1].strip().lower()
51
+ if 'female' in gender:
52
+ return 0
53
+ elif 'male' in gender:
54
+ return 1
55
+ return None
56
+
57
+ # Gene expression data availability
58
+ is_gene_available = True # RNA transcriptome data available
59
+
60
+ # Variable row identification
61
+ trait_row = 3 # 'asthma status'
62
+ gender_row = 2 # 'gender'
63
+ age_row = None # Age not available in characteristics
64
+
65
+ # Initial validation and save metadata
66
+ is_trait_available = trait_row is not None
67
+ is_usable = validate_and_save_cohort_info(
68
+ is_final=False,
69
+ cohort=cohort,
70
+ info_path=json_path,
71
+ is_gene_available=is_gene_available,
72
+ is_trait_available=is_trait_available
73
+ )
74
+
75
+ # Clinical feature extraction since trait_row is not None
76
+ selected_clinical = geo_select_clinical_features(
77
+ clinical_df=clinical_data,
78
+ trait=trait,
79
+ trait_row=trait_row,
80
+ convert_trait=convert_trait,
81
+ gender_row=gender_row,
82
+ convert_gender=convert_gender
83
+ )
84
+
85
+ # Preview and save clinical data
86
+ preview_result = preview_df(selected_clinical)
87
+ print("Preview of clinical data:", preview_result)
88
+
89
+ # Save clinical data
90
+ os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
91
+ selected_clinical.to_csv(out_clinical_data_file)
92
+ # Get file paths
93
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
94
+
95
+ # Extract gene expression data from matrix file
96
+ gene_data = get_genetic_data(matrix_file)
97
+
98
+ # Print first 20 row IDs and shape of data to help debug
99
+ print("Shape of gene expression data:", gene_data.shape)
100
+ print("\nFirst few rows of data:")
101
+ print(gene_data.head())
102
+ print("\nFirst 20 gene/probe identifiers:")
103
+ print(gene_data.index[:20])
104
+
105
+ # Inspect a snippet of raw file to verify identifier format
106
+ import gzip
107
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
108
+ lines = []
109
+ for i, line in enumerate(f):
110
+ if "!series_matrix_table_begin" in line:
111
+ # Get the next 5 lines after the marker
112
+ for _ in range(5):
113
+ lines.append(next(f).strip())
114
+ break
115
+ print("\nFirst few lines after matrix marker in raw file:")
116
+ for line in lines:
117
+ print(line)
118
+ # The gene IDs appear to be valid human gene symbols like ABCF1, ACE, ACKR2, ACKR3, etc.
119
+ # The IDs match with official HGNC gene symbols, so no mapping is needed
120
+ requires_gene_mapping = False
121
+ # 1. Normalize gene symbols
122
+ gene_data = normalize_gene_symbols_in_index(gene_data)
123
+ gene_data.to_csv(out_gene_data_file)
124
+
125
+ # 2. Link clinical and genetic data
126
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
127
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
128
+
129
+ # 3. Handle missing values
130
+ linked_data = handle_missing_values(linked_data, trait)
131
+
132
+ # 4. Evaluate bias
133
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
134
+
135
+ # 5. Validate and save cohort info
136
+ is_usable = validate_and_save_cohort_info(
137
+ is_final=True,
138
+ cohort=cohort,
139
+ info_path=json_path,
140
+ is_gene_available=True,
141
+ is_trait_available=True,
142
+ is_biased=is_biased,
143
+ df=linked_data,
144
+ note="Dataset contains RNA transcriptome data in human sinonasal epithelial cells."
145
+ )
146
+
147
+ # 6. Save linked data if usable
148
+ if is_usable:
149
+ linked_data.to_csv(out_data_file)
p3/preprocess/Asthma/code/TCGA.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Asthma"
6
+
7
+ # Input paths
8
+ tcga_root_dir = "../DATA/TCGA"
9
+
10
+ # Output paths
11
+ out_data_file = "./output/preprocess/3/Asthma/TCGA.csv"
12
+ out_gene_data_file = "./output/preprocess/3/Asthma/gene_data/TCGA.csv"
13
+ out_clinical_data_file = "./output/preprocess/3/Asthma/clinical_data/TCGA.csv"
14
+ json_path = "./output/preprocess/3/Asthma/cohort_info.json"
15
+
16
+ # Review available cohorts for asthma relevance
17
+ tcga_dirs = os.listdir(tcga_root_dir)
18
+ # Filter out non-directory files
19
+ tcga_dirs = [d for d in tcga_dirs if os.path.isdir(os.path.join(tcga_root_dir, d))]
20
+
21
+ # For asthma trait, none of the TCGA cancer cohorts are directly relevant
22
+ print(f"No suitable TCGA cancer cohort was found for the trait: {trait}")
23
+
24
+ # Save cohort info to mark this trait as completed
25
+ _ = validate_and_save_cohort_info(
26
+ is_final=False,
27
+ cohort="TCGA",
28
+ info_path=json_path,
29
+ is_gene_available=False,
30
+ is_trait_available=False
31
+ )
32
+ # Exit preprocessing as no suitable data exists
33
+ clinical_df = None
34
+ genetic_df = None
p3/preprocess/Asthma/gene_data/GSE123086.csv ADDED
@@ -0,0 +1 @@
 
 
1
+ Gene,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049
p3/preprocess/Asthma/gene_data/GSE123088.csv ADDED
@@ -0,0 +1 @@
 
 
1
+ Gene,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049,GSM3495050,GSM3495051,GSM3495052,GSM3495053,GSM3495054,GSM3495055,GSM3495056,GSM3495057,GSM3495058,GSM3495059,GSM3495060,GSM3495061,GSM3495062,GSM3495063,GSM3495064,GSM3495065,GSM3495066,GSM3495067,GSM3495068,GSM3495069,GSM3495070,GSM3495071,GSM3495072,GSM3495073,GSM3495074,GSM3495075,GSM3495076,GSM3495077,GSM3495078,GSM3495079,GSM3495080,GSM3495081,GSM3495082,GSM3495083,GSM3495084,GSM3495085,GSM3495086,GSM3495087
p3/preprocess/Asthma/gene_data/GSE182797.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2c89eb3bac7063222f548a70cae9dcf6955d3bae51d8615289f1aed1c762141a
3
+ size 12907312
p3/preprocess/Asthma/gene_data/GSE182798.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1736c1173d0170af9186a9f06194f9a3b4ad28ca3097872349e7e46f3a6bf845
3
+ size 28328193
p3/preprocess/Asthma/gene_data/GSE185658.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3b064b4ff46319ff3299b7070c722d1dc8c5d18ccd250e48a01a23b881a5478
3
+ size 18243051
p3/preprocess/Asthma/gene_data/GSE188424.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e6255f788c2c7ca89a3dab26eb0d2a82c7ec2fc31f7e4b1b9d184fa1db05eec
3
+ size 25530449
p3/preprocess/Asthma/gene_data/GSE205151.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Asthma/gene_data/GSE230164.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7e6255f788c2c7ca89a3dab26eb0d2a82c7ec2fc31f7e4b1b9d184fa1db05eec
3
+ size 25530449
p3/preprocess/Asthma/gene_data/GSE270312.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Atrial_Fibrillation/GSE115574.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3daad640890cf0559e32fcc84a3fdb4e324a6b9efbbe24d355b043bc9baf340a
3
+ size 15534640
p3/preprocess/Atrial_Fibrillation/GSE143924.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Atrial_Fibrillation/GSE235307.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad0f7bf3d07aff5ac673d3e1721eaa5233fa6f9fbf4912b231aedc6f1593c391
3
+ size 30127846
p3/preprocess/Atrial_Fibrillation/GSE41177.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Atrial_Fibrillation/clinical_data/GSE115574.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ,GSM3182680,GSM3182681,GSM3182682,GSM3182683,GSM3182684,GSM3182685,GSM3182686,GSM3182687,GSM3182688,GSM3182689,GSM3182690,GSM3182691,GSM3182692,GSM3182693,GSM3182694,GSM3182695,GSM3182696,GSM3182697,GSM3182698,GSM3182699,GSM3182700,GSM3182701,GSM3182702,GSM3182703,GSM3182704,GSM3182705,GSM3182706,GSM3182707,GSM3182708,GSM3182709,GSM3182710,GSM3182711,GSM3182712,GSM3182713,GSM3182714,GSM3182715,GSM3182716,GSM3182717,GSM3182718,GSM3182719,GSM3182720,GSM3182721,GSM3182722,GSM3182723,GSM3182724,GSM3182725,GSM3182726,GSM3182727,GSM3182728,GSM3182729,GSM3182730,GSM3182731,GSM3182732,GSM3182733,GSM3182734,GSM3182735,GSM3182736,GSM3182737,GSM3182738
2
+ Atrial_Fibrillation,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
p3/preprocess/Atrial_Fibrillation/clinical_data/GSE143924.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ,GSM4276706,GSM4276707,GSM4276708,GSM4276709,GSM4276710,GSM4276711,GSM4276712,GSM4276713,GSM4276714,GSM4276715,GSM4276716,GSM4276717,GSM4276718,GSM4276719,GSM4276720,GSM4276721,GSM4276722,GSM4276723,GSM4276724,GSM4276725,GSM4276726,GSM4276727,GSM4276728,GSM4276729,GSM4276730,GSM4276731,GSM4276732,GSM4276733,GSM4276734,GSM4276735
2
+ Atrial_Fibrillation,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
p3/preprocess/Atrial_Fibrillation/clinical_data/GSE235307.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ,GSM7498589,GSM7498590,GSM7498591,GSM7498592,GSM7498593,GSM7498594,GSM7498595,GSM7498596,GSM7498597,GSM7498598,GSM7498599,GSM7498600,GSM7498601,GSM7498602,GSM7498603,GSM7498604,GSM7498605,GSM7498606,GSM7498607,GSM7498608,GSM7498609,GSM7498610,GSM7498611,GSM7498612,GSM7498613,GSM7498614,GSM7498615,GSM7498616,GSM7498617,GSM7498618,GSM7498619,GSM7498620,GSM7498621,GSM7498622,GSM7498623,GSM7498624,GSM7498625,GSM7498626,GSM7498627,GSM7498628,GSM7498629,GSM7498630,GSM7498631,GSM7498632,GSM7498633,GSM7498634,GSM7498635,GSM7498636,GSM7498637,GSM7498638,GSM7498639,GSM7498640,GSM7498641,GSM7498642,GSM7498643,GSM7498644,GSM7498645,GSM7498646,GSM7498647,GSM7498648,GSM7498649,GSM7498650,GSM7498651,GSM7498652,GSM7498653,GSM7498654,GSM7498655,GSM7498656,GSM7498657,GSM7498658,GSM7498659,GSM7498660,GSM7498661,GSM7498662,GSM7498663,GSM7498664,GSM7498665,GSM7498666,GSM7498667,GSM7498668,GSM7498669,GSM7498670,GSM7498671,GSM7498672,GSM7498673,GSM7498674,GSM7498675,GSM7498676,GSM7498677,GSM7498678,GSM7498679,GSM7498680,GSM7498681,GSM7498682,GSM7498683,GSM7498684,GSM7498685,GSM7498686,GSM7498687,GSM7498688,GSM7498689,GSM7498690,GSM7498691,GSM7498692,GSM7498693,GSM7498694,GSM7498695,GSM7498696,GSM7498697,GSM7498698,GSM7498699,GSM7498700,GSM7498701,GSM7498702,GSM7498703,GSM7498704,GSM7498705,GSM7498706,GSM7498707
2
+ Atrial_Fibrillation,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0
3
+ Age,63.0,60.0,60.0,72.0,63.0,66.0,70.0,64.0,63.0,61.0,70.0,64.0,63.0,44.0,54.0,44.0,50.0,79.0,63.0,63.0,64.0,60.0,51.0,55.0,55.0,67.0,52.0,70.0,54.0,54.0,73.0,54.0,76.0,76.0,43.0,64.0,64.0,68.0,43.0,54.0,72.0,51.0,68.0,50.0,78.0,69.0,64.0,54.0,54.0,57.0,55.0,60.0,59.0,54.0,54.0,54.0,54.0,53.0,52.0,68.0,72.0,70.0,65.0,64.0,56.0,56.0,63.0,57.0,63.0,68.0,66.0,74.0,38.0,56.0,57.0,71.0,78.0,51.0,50.0,37.0,37.0,70.0,72.0,73.0,69.0,69.0,63.0,62.0,59.0,67.0,76.0,63.0,55.0,57.0,53.0,59.0,77.0,54.0,64.0,75.0,75.0,72.0,58.0,75.0,78.0,58.0,64.0,63.0,61.0,60.0,59.0,68.0,77.0,57.0,62.0,66.0,57.0,65.0,59.0
4
+ Gender,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0
p3/preprocess/Atrial_Fibrillation/clinical_data/GSE41177.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ,GSM1005418,GSM1005419,GSM1005420,GSM1005421,GSM1005422,GSM1005423,GSM1005424,GSM1005425,GSM1005426,GSM1005427,GSM1005428,GSM1005429,GSM1005430,GSM1005431,GSM1005432,GSM1005433,GSM1005434,GSM1005435,GSM1005436,GSM1005437,GSM1005438,GSM1005439,GSM1005440,GSM1005441,GSM1005442,GSM1005443,GSM1005444,GSM1005445,GSM1006245,GSM1006246,GSM1006247,GSM1006248,GSM1006249,GSM1006250,GSM1006251,GSM1006252,GSM1006253,GSM1006254
2
+ Atrial_Fibrillation,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
3
+ Age,62.0,62.0,43.0,43.0,55.0,55.0,65.0,65.0,65.0,65.0,61.0,61.0,64.0,64.0,47.0,47.0,60.0,60.0,71.0,71.0,32.0,32.0,59.0,59.0,56.0,56.0,51.0,51.0,59.0,59.0,32.0,32.0,43.0,43.0,66.0,66.0,36.0,36.0
4
+ Gender,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0
p3/preprocess/Atrial_Fibrillation/clinical_data/GSE47727.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ,GSM1298251,GSM1298252,GSM1298253,GSM1298254,GSM1298255,GSM1298256,GSM1298257,GSM1298258,GSM1298259,GSM1298260,GSM1298261,GSM1298262,GSM1298263,GSM1298264,GSM1298265,GSM1298266,GSM1298267,GSM1298268,GSM1298269,GSM1298270,GSM1298271,GSM1298272,GSM1298273,GSM1298274,GSM1298275,GSM1298276,GSM1298277,GSM1298278,GSM1298279,GSM1298280,GSM1298281,GSM1298282,GSM1298283,GSM1298284,GSM1298285,GSM1298286,GSM1298287,GSM1298288,GSM1298289,GSM1298290,GSM1298291,GSM1298292,GSM1298293,GSM1298294,GSM1298295,GSM1298296,GSM1298297,GSM1298298,GSM1298299,GSM1298300,GSM1298301,GSM1298302,GSM1298303,GSM1298304,GSM1298305,GSM1298306,GSM1298307,GSM1298308,GSM1298309,GSM1298310,GSM1298311,GSM1298312,GSM1298313,GSM1298314,GSM1298315,GSM1298316,GSM1298317,GSM1298318,GSM1298319,GSM1298320,GSM1298321,GSM1298322,GSM1298323,GSM1298324,GSM1298325,GSM1298326,GSM1298327,GSM1298328,GSM1298329,GSM1298330,GSM1298331,GSM1298332,GSM1298333,GSM1298334,GSM1298335,GSM1298336,GSM1298337,GSM1298338,GSM1298339,GSM1298340,GSM1298341,GSM1298342,GSM1298343,GSM1298344,GSM1298345,GSM1298346,GSM1298347,GSM1298348,GSM1298349,GSM1298350,GSM1298351,GSM1298352,GSM1298353,GSM1298354,GSM1298355,GSM1298356,GSM1298357,GSM1298358,GSM1298359,GSM1298360,GSM1298361,GSM1298362,GSM1298363,GSM1298364,GSM1298365,GSM1298366,GSM1298367,GSM1298368,GSM1298369,GSM1298370,GSM1298371,GSM1298372
2
+ Atrial_Fibrillation,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
3
+ Age,67.0,54.0,73.0,52.0,75.0,59.0,74.0,75.0,74.0,76.0,73.0,67.0,58.0,60.0,66.0,70.0,75.0,70.0,78.0,77.0,72.0,78.0,57.0,77.0,63.0,62.0,52.0,74.0,59.0,64.0,60.0,60.0,63.0,67.0,61.0,69.0,61.0,69.0,60.0,62.0,66.0,60.0,63.0,77.0,78.0,78.0,76.0,69.0,68.0,70.0,72.0,68.0,75.0,76.0,72.0,72.0,73.0,67.0,62.0,76.0,82.0,76.0,73.0,75.0,78.0,57.0,77.0,60.0,75.0,75.0,77.0,72.0,73.0,72.0,74.0,78.0,71.0,70.0,76.0,74.0,76.0,71.0,61.0,63.0,68.0,67.0,64.0,56.0,52.0,72.0,73.0,53.0,63.0,49.0,54.0,54.0,52.0,52.0,51.0,63.0,71.0,76.0,73.0,68.0,73.0,76.0,64.0,79.0,58.0,67.0,71.0,80.0,71.0,73.0,71.0,69.0,70.0,63.0,65.0,64.0,67.0,67.0
4
+ Gender,1.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0
p3/preprocess/Atrial_Fibrillation/code/GSE115574.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Atrial_Fibrillation"
6
+ cohort = "GSE115574"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
10
+ in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE115574"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Atrial_Fibrillation/GSE115574.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Atrial_Fibrillation/gene_data/GSE115574.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Atrial_Fibrillation/clinical_data/GSE115574.csv"
16
+ json_path = "./output/preprocess/3/Atrial_Fibrillation/cohort_info.json"
17
+
18
+ # Get file paths for SOFT and matrix files
19
+ soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Get background info and clinical data from the matrix file
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
23
+
24
+ # Create dictionary of unique values for each feature
25
+ unique_values_dict = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print the information
28
+ print("Dataset Background Information:")
29
+ print(background_info)
30
+ print("\nSample Characteristics:")
31
+ for feature, values in unique_values_dict.items():
32
+ print(f"\n{feature}:")
33
+ print(values)
34
+ # 1. Gene Expression Data Availability
35
+ # The background info mentions "Affymetrix human gene expression microarrays"
36
+ is_gene_available = True
37
+
38
+ # 2.1 Variable Availability
39
+ trait_row = 0 # Disease state field contains AF vs SR status
40
+ age_row = None # Age not available
41
+ gender_row = None # Gender not available
42
+
43
+ # 2.2 Data Type Conversion
44
+ def convert_trait(value):
45
+ if not isinstance(value, str):
46
+ return None
47
+ val = value.lower().split(': ')[-1].strip()
48
+ if 'atrial fibrillation' in val:
49
+ return 1
50
+ elif 'sinus rhythm' in val:
51
+ return 0
52
+ return None
53
+
54
+ def convert_age(value):
55
+ return None # Not used but defined for completeness
56
+
57
+ def convert_gender(value):
58
+ return None # Not used but defined for completeness
59
+
60
+ # 3. Save Metadata
61
+ is_usable = validate_and_save_cohort_info(
62
+ is_final=False,
63
+ cohort=cohort,
64
+ info_path=json_path,
65
+ is_gene_available=is_gene_available,
66
+ is_trait_available=(trait_row is not None)
67
+ )
68
+
69
+ # 4. Clinical Feature Extraction
70
+ if trait_row is not None:
71
+ clinical_features = geo_select_clinical_features(
72
+ clinical_df=clinical_data,
73
+ trait=trait,
74
+ trait_row=trait_row,
75
+ convert_trait=convert_trait,
76
+ age_row=age_row,
77
+ convert_age=convert_age,
78
+ gender_row=gender_row,
79
+ convert_gender=convert_gender
80
+ )
81
+
82
+ # Preview the extracted features
83
+ preview = preview_df(clinical_features)
84
+ print("Preview of clinical features:")
85
+ print(preview)
86
+
87
+ # Save to CSV
88
+ clinical_features.to_csv(out_clinical_data_file)
89
+ # Extract gene expression data from matrix file
90
+ genetic_data = get_genetic_data(matrix_file_path)
91
+
92
+ # Print first 20 row IDs
93
+ print("First 20 gene/probe IDs:")
94
+ print(list(genetic_data.index[:20]))
95
+ # These appear to be Affymetrix probe IDs (e.g. '1007_s_at') rather than human gene symbols
96
+ # They will need to be mapped to standard gene symbols for analysis
97
+ requires_gene_mapping = True
98
+ # Extract gene annotation data
99
+ gene_metadata = get_gene_annotation(soft_file_path)
100
+
101
+ # Preview column names and first few values
102
+ preview = preview_df(gene_metadata)
103
+ print("\nGene annotation columns and sample values:")
104
+ print(preview)
105
+ # 1. ID and Gene Symbol columns identified from the annotation preview
106
+ # ID column matches the probe IDs in gene expression data (e.g. '1007_s_at')
107
+ # Gene Symbol column contains the target gene symbols
108
+ prob_col = 'ID'
109
+ gene_col = 'Gene Symbol'
110
+
111
+ # 2. Get gene mapping dataframe
112
+ mapping_data = get_gene_mapping(gene_metadata, prob_col, gene_col)
113
+
114
+ # 3. Apply gene mapping to convert probe measurements to gene expression data
115
+ gene_data = apply_gene_mapping(genetic_data, mapping_data)
116
+
117
+ # Preview the first few rows to verify the mapping
118
+ print("\nFirst few rows of mapped gene expression data:")
119
+ print(preview_df(gene_data))
120
+ # 1. Normalize gene symbols and save gene data
121
+ genetic_data = normalize_gene_symbols_in_index(gene_data)
122
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
123
+ genetic_data.to_csv(out_gene_data_file)
124
+
125
+ # 2. Link clinical and genetic data
126
+ clinical_features = pd.read_csv(out_clinical_data_file, index_col=0)
127
+ linked_data = geo_link_clinical_genetic_data(clinical_features, genetic_data)
128
+
129
+ # 3. Handle missing values
130
+ linked_data = handle_missing_values(linked_data, trait)
131
+
132
+ # 4. Judge bias in features and remove biased ones
133
+ trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
134
+
135
+ # 5. Final validation and save metadata
136
+ is_usable = validate_and_save_cohort_info(
137
+ is_final=True,
138
+ cohort=cohort,
139
+ info_path=json_path,
140
+ is_gene_available=is_gene_available,
141
+ is_trait_available=True,
142
+ is_biased=trait_biased,
143
+ df=linked_data,
144
+ note="Sample size adequate. Gene expression data quality good. Trait is postoperative atrial fibrillation vs sinus rhythm."
145
+ )
146
+
147
+ # 6. Save linked data if usable
148
+ if is_usable:
149
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
150
+ linked_data.to_csv(out_data_file)
p3/preprocess/Atrial_Fibrillation/code/GSE143924.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Atrial_Fibrillation"
6
+ cohort = "GSE143924"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
10
+ in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE143924"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Atrial_Fibrillation/GSE143924.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Atrial_Fibrillation/gene_data/GSE143924.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Atrial_Fibrillation/clinical_data/GSE143924.csv"
16
+ json_path = "./output/preprocess/3/Atrial_Fibrillation/cohort_info.json"
17
+
18
+ # Get file paths for SOFT and matrix files
19
+ soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Get background info and clinical data from the matrix file
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
23
+
24
+ # Create dictionary of unique values for each feature
25
+ unique_values_dict = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print the information
28
+ print("Dataset Background Information:")
29
+ print(background_info)
30
+ print("\nSample Characteristics:")
31
+ for feature, values in unique_values_dict.items():
32
+ print(f"\n{feature}:")
33
+ print(values)
34
+ # 1. Gene Expression Data Availability
35
+ # Based on background information, this is a transcriptome analysis study from tissue biopsies
36
+ is_gene_available = True
37
+
38
+ # 2.1 Data Availability
39
+ # From sample characteristics, trait data is in row 1 (POAF vs SR)
40
+ trait_row = 1
41
+ # Age and gender are not available in the sample characteristics
42
+ age_row = None
43
+ gender_row = None
44
+
45
+ # 2.2 Data Type Conversion Functions
46
+ def convert_trait(value):
47
+ if not isinstance(value, str):
48
+ return None
49
+ value = value.split(": ")[-1].lower()
50
+ if "postoperative atrial fibrillation" in value or "poaf" in value:
51
+ return 1
52
+ elif "sinus rhythm" in value:
53
+ return 0
54
+ return None
55
+
56
+ def convert_age(value):
57
+ return None # Not used since age data not available
58
+
59
+ def convert_gender(value):
60
+ return None # Not used since gender data not available
61
+
62
+ # 3. Save Initial Metadata
63
+ is_trait_available = trait_row is not None
64
+ validate_and_save_cohort_info(
65
+ is_final=False,
66
+ cohort=cohort,
67
+ info_path=json_path,
68
+ is_gene_available=is_gene_available,
69
+ is_trait_available=is_trait_available
70
+ )
71
+
72
+ # 4. Extract Clinical Features
73
+ if trait_row is not None:
74
+ clinical_df = geo_select_clinical_features(
75
+ clinical_df=clinical_data,
76
+ trait=trait,
77
+ trait_row=trait_row,
78
+ convert_trait=convert_trait,
79
+ age_row=age_row,
80
+ convert_age=convert_age,
81
+ gender_row=gender_row,
82
+ convert_gender=convert_gender
83
+ )
84
+
85
+ # Preview the processed clinical data
86
+ print("Preview of processed clinical data:")
87
+ print(preview_df(clinical_df))
88
+
89
+ # Save clinical data
90
+ clinical_df.to_csv(out_clinical_data_file)
91
+ # Extract gene expression data from matrix file
92
+ genetic_data = get_genetic_data(matrix_file_path)
93
+
94
+ # Print first 20 row IDs
95
+ print("First 20 gene/probe IDs:")
96
+ print(list(genetic_data.index[:20]))
97
+ # These appear to be human gene symbols - they follow standard HUGO nomenclature with accepted formats like:
98
+ # - Standard gene symbols (e.g. AACS, AADAC)
99
+ # - Antisense RNA annotations (-AS1 suffix)
100
+ # - Pseudogene annotations (P suffix)
101
+ # No mapping needed as they are already in the desired format
102
+
103
+ requires_gene_mapping = False
104
+ # 1. Normalize gene symbols and save gene data
105
+ genetic_data = normalize_gene_symbols_in_index(genetic_data)
106
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
107
+ genetic_data.to_csv(out_gene_data_file)
108
+
109
+ # 2. Link clinical and genetic data
110
+ linked_data = geo_link_clinical_genetic_data(clinical_df, genetic_data)
111
+
112
+ # 3. Handle missing values
113
+ linked_data = handle_missing_values(linked_data, trait)
114
+
115
+ # 4. Judge bias in features and remove biased ones
116
+ trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
117
+
118
+ # 5. Final validation and save metadata
119
+ is_usable = validate_and_save_cohort_info(
120
+ is_final=True,
121
+ cohort=cohort,
122
+ info_path=json_path,
123
+ is_gene_available=is_gene_available,
124
+ is_trait_available=True,
125
+ is_biased=trait_biased,
126
+ df=linked_data,
127
+ note="Sample size adequate. Gene expression data quality good. Trait is postoperative atrial fibrillation vs sinus rhythm."
128
+ )
129
+
130
+ # 6. Save linked data if usable
131
+ if is_usable:
132
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
133
+ linked_data.to_csv(out_data_file)
p3/preprocess/Atrial_Fibrillation/code/GSE235307.py ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Atrial_Fibrillation"
6
+ cohort = "GSE235307"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
10
+ in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE235307"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Atrial_Fibrillation/GSE235307.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Atrial_Fibrillation/gene_data/GSE235307.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Atrial_Fibrillation/clinical_data/GSE235307.csv"
16
+ json_path = "./output/preprocess/3/Atrial_Fibrillation/cohort_info.json"
17
+
18
+ # Get file paths for SOFT and matrix files
19
+ soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Get background info and clinical data from the matrix file
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
23
+
24
+ # Create dictionary of unique values for each feature
25
+ unique_values_dict = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print the information
28
+ print("Dataset Background Information:")
29
+ print(background_info)
30
+ print("\nSample Characteristics:")
31
+ for feature, values in unique_values_dict.items():
32
+ print(f"\n{feature}:")
33
+ print(values)
34
+ # 1. Gene Expression Data Availability
35
+ # From background info, this is a blood gene expression study
36
+ is_gene_available = True
37
+
38
+ # 2.1 Data Row Identification
39
+ trait_row = 5 # cardiac rhythm after 1 year follow-up
40
+ age_row = 2 # age is available
41
+ gender_row = 1 # gender is available
42
+
43
+ # 2.2 Data Type Conversion Functions
44
+ def convert_trait(value: str) -> Optional[int]:
45
+ """Convert AF status to binary: 1 for AF, 0 for sinus rhythm"""
46
+ if value is None:
47
+ return None
48
+ value = value.split(': ')[-1].lower().strip()
49
+ if 'atrial fibrillation' in value:
50
+ return 1
51
+ elif 'sinus rhythm' in value:
52
+ return 0
53
+ return None
54
+
55
+ def convert_age(value: str) -> Optional[float]:
56
+ """Convert age to float"""
57
+ if value is None:
58
+ return None
59
+ try:
60
+ return float(value.split(': ')[-1])
61
+ except:
62
+ return None
63
+
64
+ def convert_gender(value: str) -> Optional[int]:
65
+ """Convert gender to binary: 0 for female, 1 for male"""
66
+ if value is None:
67
+ return None
68
+ value = value.split(': ')[-1].lower().strip()
69
+ if value == 'female':
70
+ return 0
71
+ elif value == 'male':
72
+ return 1
73
+ return None
74
+
75
+ # 3. Save Metadata
76
+ validate_and_save_cohort_info(
77
+ is_final=False,
78
+ cohort=cohort,
79
+ info_path=json_path,
80
+ is_gene_available=is_gene_available,
81
+ is_trait_available=trait_row is not None
82
+ )
83
+
84
+ # 4. Clinical Feature Extraction
85
+ if trait_row is not None:
86
+ clinical_features = geo_select_clinical_features(
87
+ clinical_df=clinical_data,
88
+ trait=trait,
89
+ trait_row=trait_row,
90
+ convert_trait=convert_trait,
91
+ age_row=age_row,
92
+ convert_age=convert_age,
93
+ gender_row=gender_row,
94
+ convert_gender=convert_gender
95
+ )
96
+
97
+ # Preview the extracted features
98
+ print("Preview of clinical features:")
99
+ print(preview_df(clinical_features))
100
+
101
+ # Save to CSV
102
+ clinical_features.to_csv(out_clinical_data_file)
103
+ # Extract gene expression data from matrix file
104
+ genetic_data = get_genetic_data(matrix_file_path)
105
+
106
+ # Print first 20 row IDs
107
+ print("First 20 gene/probe IDs:")
108
+ print(list(genetic_data.index[:20]))
109
+ # The gene identifiers in this dataset appear to be simple numeric values,
110
+ # which are not standard human gene symbols.
111
+ # Standard gene symbols would be like "BRCA1", "TP53", etc
112
+ # Therefore mapping is required to convert these to proper gene symbols.
113
+
114
+ requires_gene_mapping = True
115
+ # Extract gene annotation data
116
+ gene_metadata = get_gene_annotation(soft_file_path)
117
+
118
+ # Preview column names and first few values
119
+ preview = preview_df(gene_metadata)
120
+ print("\nGene annotation columns and sample values:")
121
+ print(preview)
122
+ # 1. From the preview, 'ID' contains numeric identifiers matching gene expression data,
123
+ # and 'GENE_SYMBOL' contains human gene symbols
124
+
125
+ # 2. Extract mapping between probe IDs and gene symbols
126
+ mapping_data = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='GENE_SYMBOL')
127
+
128
+ # 3. Apply mapping to convert probe-level data to gene expression data
129
+ gene_data = apply_gene_mapping(genetic_data, mapping_data)
130
+
131
+ # Normalize gene symbols in the gene expression data
132
+ gene_data = normalize_gene_symbols_in_index(gene_data)
133
+
134
+ # Preview the mapped gene data
135
+ print("\nFirst 20 genes after mapping:")
136
+ print(list(gene_data.index[:20]))
137
+
138
+ # Save gene expression data
139
+ gene_data.to_csv(out_gene_data_file)
140
+ # 1. Normalize gene symbols and save gene data
141
+ gene_data = normalize_gene_symbols_in_index(gene_data)
142
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
143
+ gene_data.to_csv(out_gene_data_file)
144
+
145
+ # 2. Link clinical and genetic data
146
+ linked_data = geo_link_clinical_genetic_data(clinical_features, gene_data)
147
+
148
+ # 3. Handle missing values
149
+ linked_data = handle_missing_values(linked_data, trait)
150
+
151
+ # 4. Judge bias in features and remove biased ones
152
+ trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
153
+
154
+ # 5. Final validation and save metadata
155
+ is_usable = validate_and_save_cohort_info(
156
+ is_final=True,
157
+ cohort=cohort,
158
+ info_path=json_path,
159
+ is_gene_available=is_gene_available,
160
+ is_trait_available=True,
161
+ is_biased=trait_biased,
162
+ df=linked_data,
163
+ note="Sample size adequate. Gene expression data quality good. Trait is early vs late recurrence."
164
+ )
165
+
166
+ # 6. Save linked data if usable
167
+ if is_usable:
168
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
169
+ linked_data.to_csv(out_data_file)
p3/preprocess/Atrial_Fibrillation/code/GSE41177.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Atrial_Fibrillation"
6
+ cohort = "GSE41177"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
10
+ in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE41177"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Atrial_Fibrillation/GSE41177.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Atrial_Fibrillation/gene_data/GSE41177.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Atrial_Fibrillation/clinical_data/GSE41177.csv"
16
+ json_path = "./output/preprocess/3/Atrial_Fibrillation/cohort_info.json"
17
+
18
+ # Get file paths for SOFT and matrix files
19
+ soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Get background info and clinical data from the matrix file
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
23
+
24
+ # Create dictionary of unique values for each feature
25
+ unique_values_dict = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print the information
28
+ print("Dataset Background Information:")
29
+ print(background_info)
30
+ print("\nSample Characteristics:")
31
+ for feature, values in unique_values_dict.items():
32
+ print(f"\n{feature}:")
33
+ print(values)
34
+ # 1. Gene Expression Data Availability
35
+ is_gene_available = True # Dataset contains microarray gene expression data per background info
36
+
37
+ # 2.1 Data Availability
38
+ trait_row = 3 # 'af duration' indicates AF status duration
39
+ age_row = 2 # Age data available
40
+ gender_row = 1 # Gender data available
41
+
42
+ # 2.2 Data Type Conversion Functions
43
+ def convert_trait(x):
44
+ if not isinstance(x, str):
45
+ return None
46
+ value = x.split(': ')[-1].strip()
47
+ # Convert AF duration to binary - any duration indicates AF presence
48
+ if value == '0M':
49
+ return 0
50
+ elif 'M' in value: # Has months duration
51
+ return 1
52
+ return None
53
+
54
+ def convert_age(x):
55
+ if not isinstance(x, str):
56
+ return None
57
+ value = x.split(': ')[-1].strip()
58
+ if value.endswith('Y'):
59
+ try:
60
+ return float(value[:-1]) # Remove 'Y' and convert to float
61
+ except:
62
+ return None
63
+ return None
64
+
65
+ def convert_gender(x):
66
+ if not isinstance(x, str):
67
+ return None
68
+ value = x.split(': ')[-1].strip().lower()
69
+ if value == 'female':
70
+ return 0
71
+ elif value == 'male':
72
+ return 1
73
+ return None
74
+
75
+ # 3. Save Metadata
76
+ validate_and_save_cohort_info(is_final=False,
77
+ cohort=cohort,
78
+ info_path=json_path,
79
+ is_gene_available=is_gene_available,
80
+ is_trait_available=trait_row is not None)
81
+
82
+ # 4. Extract Clinical Features
83
+ selected_clinical_df = geo_select_clinical_features(clinical_df=clinical_data,
84
+ trait=trait,
85
+ trait_row=trait_row,
86
+ convert_trait=convert_trait,
87
+ age_row=age_row,
88
+ convert_age=convert_age,
89
+ gender_row=gender_row,
90
+ convert_gender=convert_gender)
91
+
92
+ # Preview the processed clinical data
93
+ print(preview_df(selected_clinical_df))
94
+
95
+ # Save clinical data
96
+ selected_clinical_df.to_csv(out_clinical_data_file)
97
+ # Extract gene expression data from matrix file
98
+ genetic_data = get_genetic_data(matrix_file_path)
99
+
100
+ # Print first 20 row IDs
101
+ print("First 20 gene/probe IDs:")
102
+ print(list(genetic_data.index[:20]))
103
+ # These are Affymetrix probe IDs (starting with numbers and containing "_at"), not human gene symbols
104
+ # They need to be mapped to standard gene symbols for analysis
105
+ requires_gene_mapping = True
106
+ # Extract gene annotation data
107
+ gene_metadata = get_gene_annotation(soft_file_path)
108
+
109
+ # Preview column names and first few values
110
+ preview = preview_df(gene_metadata)
111
+ print("\nGene annotation columns and sample values:")
112
+ print(preview)
113
+ # Get gene mapping dataframe from annotation data
114
+ # 'ID' column contains probe IDs matching genetic_data, 'Gene Symbol' contains gene symbols
115
+ mapping_df = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='Gene Symbol')
116
+
117
+ # Apply gene mapping to convert from probes to genes
118
+ gene_data = apply_gene_mapping(genetic_data, mapping_df)
119
+
120
+ # Preview the first few rows and columns of the mapped gene data
121
+ print("\nFirst few rows of mapped gene expression data:")
122
+ print(preview_df(gene_data))
123
+ # 1. Normalize gene symbols and save gene data
124
+ gene_data = normalize_gene_symbols_in_index(gene_data)
125
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
126
+ gene_data.to_csv(out_gene_data_file)
127
+
128
+ # 2. Link clinical and genetic data
129
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, gene_data)
130
+
131
+ # 3. Handle missing values
132
+ linked_data = handle_missing_values(linked_data, trait)
133
+
134
+ # 4. Judge bias in features and remove biased ones
135
+ trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
136
+
137
+ # 5. Final validation and save metadata
138
+ is_usable = validate_and_save_cohort_info(
139
+ is_final=True,
140
+ cohort=cohort,
141
+ info_path=json_path,
142
+ is_gene_available=is_gene_available,
143
+ is_trait_available=True,
144
+ is_biased=trait_biased,
145
+ df=linked_data,
146
+ note="Sample size adequate. Gene expression data quality good. Trait is early vs late recurrence."
147
+ )
148
+
149
+ # 6. Save linked data if usable
150
+ if is_usable:
151
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
152
+ linked_data.to_csv(out_data_file)
p3/preprocess/Atrial_Fibrillation/code/GSE47727.py ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Atrial_Fibrillation"
6
+ cohort = "GSE47727"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
10
+ in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE47727"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Atrial_Fibrillation/GSE47727.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Atrial_Fibrillation/gene_data/GSE47727.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Atrial_Fibrillation/clinical_data/GSE47727.csv"
16
+ json_path = "./output/preprocess/3/Atrial_Fibrillation/cohort_info.json"
17
+
18
+ # Get file paths for SOFT and matrix files
19
+ soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
20
+
21
+ # Get background info and clinical data from the matrix file
22
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
23
+
24
+ # Create dictionary of unique values for each feature
25
+ unique_values_dict = get_unique_values_by_row(clinical_data)
26
+
27
+ # Print the information
28
+ print("Dataset Background Information:")
29
+ print(background_info)
30
+ print("\nSample Characteristics:")
31
+ for feature, values in unique_values_dict.items():
32
+ print(f"\n{feature}:")
33
+ print(values)
34
+ # 1. Gene Expression Data Availability
35
+ # Based on the background info mentioning "gene expression" and "HumanHT-12", this is gene expression data
36
+ is_gene_available = True
37
+
38
+ # 2.1 Data Row Identification
39
+ # From characteristics dictionary:
40
+ # For trait: no direct AF status, all are controls based on background info
41
+ trait_row = None
42
+
43
+ # Age is in row 0
44
+ age_row = 0
45
+
46
+ # Gender is in row 1
47
+ gender_row = 1
48
+
49
+ # 2.2 Data Type Conversion Functions
50
+ def convert_trait(x):
51
+ # All samples are controls
52
+ return 0
53
+
54
+ def convert_age(x):
55
+ # Extract numeric age from strings like "age (yrs): 67"
56
+ try:
57
+ age = int(x.split(': ')[1])
58
+ return age
59
+ except:
60
+ return None
61
+
62
+ def convert_gender(x):
63
+ # Convert gender strings to binary (female=0, male=1)
64
+ gender = x.split(': ')[1].lower()
65
+ if gender == 'female':
66
+ return 0
67
+ elif gender == 'male':
68
+ return 1
69
+ return None
70
+
71
+ # 3. Save initial metadata
72
+ validate_and_save_cohort_info(
73
+ is_final=False,
74
+ cohort=cohort,
75
+ info_path=json_path,
76
+ is_gene_available=is_gene_available,
77
+ is_trait_available=False # trait_row is None
78
+ )
79
+
80
+ # 4. Extract clinical features
81
+ clinical_df = geo_select_clinical_features(
82
+ clinical_df=clinical_data,
83
+ trait=trait,
84
+ trait_row=trait_row,
85
+ convert_trait=convert_trait,
86
+ age_row=age_row,
87
+ convert_age=convert_age,
88
+ gender_row=gender_row,
89
+ convert_gender=convert_gender
90
+ )
91
+
92
+ # Preview the extracted features
93
+ print("\nPreview of extracted clinical features:")
94
+ print(preview_df(clinical_df))
95
+
96
+ # Save to CSV
97
+ clinical_df.to_csv(out_clinical_data_file)