Liu-Hy commited on
Commit
25a2692
·
verified ·
1 Parent(s): dd19378

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 +17 -0
  2. p3/preprocess/Acute_Myeloid_Leukemia/GSE161532.csv +3 -0
  3. p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE161532.csv +3 -0
  4. p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE222124.csv +3 -0
  5. p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE249638.csv +3 -0
  6. p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE98578.csv +3 -0
  7. p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE99612.csv +3 -0
  8. p3/preprocess/Adrenocortical_Cancer/GSE68606.csv +3 -0
  9. p3/preprocess/Adrenocortical_Cancer/GSE76019.csv +0 -0
  10. p3/preprocess/Adrenocortical_Cancer/GSE90713.csv +3 -0
  11. p3/preprocess/Adrenocortical_Cancer/code/GSE68606.py +201 -0
  12. p3/preprocess/Adrenocortical_Cancer/code/GSE68950.py +201 -0
  13. p3/preprocess/Adrenocortical_Cancer/code/GSE76019.py +189 -0
  14. p3/preprocess/Adrenocortical_Cancer/code/GSE90713.py +181 -0
  15. p3/preprocess/Adrenocortical_Cancer/code/TCGA.py +134 -0
  16. p3/preprocess/Adrenocortical_Cancer/gene_data/GSE108088.csv +3 -0
  17. p3/preprocess/Adrenocortical_Cancer/gene_data/GSE143383.csv +3 -0
  18. p3/preprocess/Adrenocortical_Cancer/gene_data/GSE19776.csv +1 -0
  19. p3/preprocess/Adrenocortical_Cancer/gene_data/GSE67766.csv +0 -0
  20. p3/preprocess/Adrenocortical_Cancer/gene_data/GSE68606.csv +3 -0
  21. p3/preprocess/Adrenocortical_Cancer/gene_data/GSE75415.csv +0 -0
  22. p3/preprocess/Adrenocortical_Cancer/gene_data/GSE76019.csv +0 -0
  23. p3/preprocess/Adrenocortical_Cancer/gene_data/GSE90713.csv +3 -0
  24. p3/preprocess/Adrenocortical_Cancer/gene_data/TCGA.csv +3 -0
  25. p3/preprocess/Age-Related_Macular_Degeneration/GSE29801.csv +3 -0
  26. p3/preprocess/Age-Related_Macular_Degeneration/GSE45485.csv +0 -0
  27. p3/preprocess/Age-Related_Macular_Degeneration/GSE62224.csv +0 -0
  28. p3/preprocess/Age-Related_Macular_Degeneration/GSE67899.csv +0 -0
  29. p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE29801.csv +4 -0
  30. p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE43176.csv +2 -0
  31. p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE45485.csv +2 -0
  32. p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE62224.csv +2 -0
  33. p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE67899.csv +2 -0
  34. p3/preprocess/Age-Related_Macular_Degeneration/code/GSE29801.py +212 -0
  35. p3/preprocess/Age-Related_Macular_Degeneration/code/GSE38662.py +148 -0
  36. p3/preprocess/Age-Related_Macular_Degeneration/code/GSE43176.py +189 -0
  37. p3/preprocess/Age-Related_Macular_Degeneration/code/GSE45485.py +195 -0
  38. p3/preprocess/Age-Related_Macular_Degeneration/code/GSE62224.py +208 -0
  39. p3/preprocess/Age-Related_Macular_Degeneration/code/GSE67899.py +198 -0
  40. p3/preprocess/Age-Related_Macular_Degeneration/code/TCGA.py +30 -0
  41. p3/preprocess/Age-Related_Macular_Degeneration/cohort_info.json +1 -0
  42. p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE38662.csv +3 -0
  43. p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE43176.csv +3 -0
  44. p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE45485.csv +0 -0
  45. p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE62224.csv +0 -0
  46. p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE67899.csv +0 -0
  47. p3/preprocess/Alcohol_Flush_Reaction/code/GSE133228.py +157 -0
  48. p3/preprocess/Alcohol_Flush_Reaction/code/TCGA.py +30 -0
  49. p3/preprocess/Alcohol_Flush_Reaction/cohort_info.json +1 -0
  50. p3/preprocess/Alcohol_Flush_Reaction/gene_data/GSE133228.csv +0 -0
.gitattributes CHANGED
@@ -1416,3 +1416,20 @@ p3/preprocess/Acute_Myeloid_Leukemia/GSE249638.csv filter=lfs diff=lfs merge=lfs
1416
  p3/preprocess/Acute_Myeloid_Leukemia/GSE98578.csv filter=lfs diff=lfs merge=lfs -text
1417
  p3/preprocess/Acute_Myeloid_Leukemia/GSE222124.csv filter=lfs diff=lfs merge=lfs -text
1418
  p3/preprocess/X-Linked_Lymphoproliferative_Syndrome/gene_data/GSE239832.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1416
  p3/preprocess/Acute_Myeloid_Leukemia/GSE98578.csv filter=lfs diff=lfs merge=lfs -text
1417
  p3/preprocess/Acute_Myeloid_Leukemia/GSE222124.csv filter=lfs diff=lfs merge=lfs -text
1418
  p3/preprocess/X-Linked_Lymphoproliferative_Syndrome/gene_data/GSE239832.csv filter=lfs diff=lfs merge=lfs -text
1419
+ p3/preprocess/Acute_Myeloid_Leukemia/GSE161532.csv filter=lfs diff=lfs merge=lfs -text
1420
+ p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE98578.csv filter=lfs diff=lfs merge=lfs -text
1421
+ p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE99612.csv filter=lfs diff=lfs merge=lfs -text
1422
+ p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE222124.csv filter=lfs diff=lfs merge=lfs -text
1423
+ p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE249638.csv filter=lfs diff=lfs merge=lfs -text
1424
+ p3/preprocess/Adrenocortical_Cancer/GSE90713.csv filter=lfs diff=lfs merge=lfs -text
1425
+ p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE161532.csv filter=lfs diff=lfs merge=lfs -text
1426
+ p3/preprocess/Adrenocortical_Cancer/gene_data/GSE108088.csv filter=lfs diff=lfs merge=lfs -text
1427
+ p3/preprocess/Adrenocortical_Cancer/GSE68606.csv filter=lfs diff=lfs merge=lfs -text
1428
+ p3/preprocess/Adrenocortical_Cancer/gene_data/GSE143383.csv filter=lfs diff=lfs merge=lfs -text
1429
+ p3/preprocess/Adrenocortical_Cancer/gene_data/GSE68606.csv filter=lfs diff=lfs merge=lfs -text
1430
+ p3/preprocess/Adrenocortical_Cancer/gene_data/GSE90713.csv filter=lfs diff=lfs merge=lfs -text
1431
+ p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE43176.csv filter=lfs diff=lfs merge=lfs -text
1432
+ p3/preprocess/Adrenocortical_Cancer/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1433
+ p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE38662.csv filter=lfs diff=lfs merge=lfs -text
1434
+ p3/preprocess/Age-Related_Macular_Degeneration/GSE29801.csv filter=lfs diff=lfs merge=lfs -text
1435
+ p3/preprocess/Allergies/GSE84046.csv filter=lfs diff=lfs merge=lfs -text
p3/preprocess/Acute_Myeloid_Leukemia/GSE161532.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a47e5b26bc58384c2105c9c17c036927d6ae52f86ae2093b40fc1c8458f333e7
3
+ size 19005473
p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE161532.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ae094fd44ffdb2064749e93c9c255eccc2b693de639f51192307937aa3f633a9
3
+ size 21846516
p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE222124.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6319bb65acae88602deba7d1071159a0063a8285cba179bce5e69266084b9ad6
3
+ size 13764911
p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE249638.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:beb01a1b4d6ce6bfe33f9527b86089b96c1ac7097d853640fab00e39553857d2
3
+ size 11134286
p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE98578.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fae270923854acd2f88d5d6400c735f3de856d961d4845b203a4b2a0caeaf12b
3
+ size 12728359
p3/preprocess/Acute_Myeloid_Leukemia/gene_data/GSE99612.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:129f90c5436b013818b7c3159de5abc8ad9769ea8258c61872a72381e06ed10e
3
+ size 11929857
p3/preprocess/Adrenocortical_Cancer/GSE68606.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5577067ac66bf3dd6fb4d608079f1e2bae1f979ee4b837e8143451fe8fe1029d
3
+ size 17470717
p3/preprocess/Adrenocortical_Cancer/GSE76019.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Adrenocortical_Cancer/GSE90713.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e0c16ee650e3fb8152630597741cf4feeffde26b7480a972d0d87021efc26232
3
+ size 16454332
p3/preprocess/Adrenocortical_Cancer/code/GSE68606.py ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Adrenocortical_Cancer"
6
+ cohort = "GSE68606"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Adrenocortical_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Adrenocortical_Cancer/GSE68606"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Adrenocortical_Cancer/GSE68606.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Adrenocortical_Cancer/gene_data/GSE68606.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Adrenocortical_Cancer/clinical_data/GSE68606.csv"
16
+ json_path = "./output/preprocess/3/Adrenocortical_Cancer/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 background info mentioning "gene expression analysis" and "Affymetrix Human Genome U133A arrays"
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # 2.1 Data Availability
42
+ # Trait (Adrenal Cortical Adenoma) in both disease state (1) and histology (7)
43
+ trait_row = 1
44
+ # Age available in row 6
45
+ age_row = 6
46
+ # Gender/Sex available in row 5
47
+ gender_row = 5
48
+
49
+ # 2.2 Data Type Conversion Functions
50
+ def convert_trait(x):
51
+ # Extract value after colon and strip whitespace
52
+ if ':' in str(x):
53
+ value = str(x).split(':')[1].strip()
54
+ # Binary: 1 if Adrenal Cortical Adenoma, 0 for others
55
+ return 1 if 'Adrenal Cortical Adenoma' in value else 0
56
+ return None
57
+
58
+ def convert_age(x):
59
+ # Extract value after colon and strip whitespace
60
+ if ':' in str(x):
61
+ value = str(x).split(':')[1].strip()
62
+ # Convert to float if numeric, otherwise None
63
+ try:
64
+ if value != '--':
65
+ return float(value)
66
+ except:
67
+ pass
68
+ return None
69
+
70
+ def convert_gender(x):
71
+ # Extract value after colon and strip whitespace
72
+ if ':' in str(x):
73
+ value = str(x).split(':')[1].strip()
74
+ # Convert to binary: 0 for female, 1 for male
75
+ if value.lower() == 'female':
76
+ return 0
77
+ elif value.lower() == 'male':
78
+ return 1
79
+ return None
80
+
81
+ # 3. Save Metadata
82
+ validate_and_save_cohort_info(is_final=False,
83
+ cohort=cohort,
84
+ info_path=json_path,
85
+ is_gene_available=is_gene_available,
86
+ is_trait_available=trait_row is not None)
87
+
88
+ # 4. Clinical Feature Extraction
89
+ if trait_row is not None:
90
+ clinical_features = geo_select_clinical_features(
91
+ 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
+ gender_row=gender_row,
98
+ convert_gender=convert_gender
99
+ )
100
+
101
+ # Preview the extracted features
102
+ preview = preview_df(clinical_features)
103
+ print("Preview of clinical features:", preview)
104
+
105
+ # Save to CSV
106
+ os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
107
+ clinical_features.to_csv(out_clinical_data_file)
108
+ # Extract gene expression data from matrix file
109
+ gene_data = get_genetic_data(matrix_file)
110
+
111
+ # Print first 20 row IDs and shape of data to help debug
112
+ print("Shape of gene expression data:", gene_data.shape)
113
+ print("\nFirst few rows of data:")
114
+ print(gene_data.head())
115
+ print("\nFirst 20 gene/probe identifiers:")
116
+ print(gene_data.index[:20])
117
+
118
+ # Inspect a snippet of raw file to verify identifier format
119
+ import gzip
120
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
121
+ lines = []
122
+ for i, line in enumerate(f):
123
+ if "!series_matrix_table_begin" in line:
124
+ # Get the next 5 lines after the marker
125
+ for _ in range(5):
126
+ lines.append(next(f).strip())
127
+ break
128
+ print("\nFirst few lines after matrix marker in raw file:")
129
+ for line in lines:
130
+ print(line)
131
+ # Observe IDs like '1007_s_at' which are Affymetrix probe IDs, not human gene symbols
132
+ # These need to be mapped to official gene symbols
133
+ requires_gene_mapping = True
134
+ # Get file paths using library function
135
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
136
+
137
+ # Extract gene annotation from SOFT file and get meaningful data
138
+ gene_annotation = get_gene_annotation(soft_file)
139
+
140
+ # Preview gene annotation data
141
+ print("Gene annotation shape:", gene_annotation.shape)
142
+ print("\nGene annotation preview:")
143
+ print(preview_df(gene_annotation))
144
+
145
+ print("\nNumber of non-null values in each column:")
146
+ print(gene_annotation.count())
147
+
148
+ # Print example rows showing the mapping information columns
149
+ print("\nSample mapping columns ('ID' and 'Gene Symbol'):")
150
+ print("\nFirst 5 rows:")
151
+ print(gene_annotation[['ID', 'Gene Symbol']].head().to_string())
152
+
153
+ print("\nNote: Gene mapping will use:")
154
+ print("'ID' column: Probe identifiers")
155
+ print("'Gene Symbol' column: Contains gene symbol information")
156
+ # Extract probe ID and gene symbol mapping
157
+ mapping_data = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
158
+
159
+ # Convert probe data to gene expression by applying mapping
160
+ gene_data = apply_gene_mapping(gene_data, mapping_data)
161
+
162
+ # Save the gene expression data
163
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
164
+ gene_data.to_csv(out_gene_data_file)
165
+
166
+ # Print preview of mapped gene data
167
+ print("Gene expression data shape after mapping:", gene_data.shape)
168
+ print("\nPreview of gene expression data:")
169
+ print(preview_df(gene_data))
170
+ # 1. Load clinical data and save normalized gene data
171
+ selected_clinical = pd.read_csv(out_clinical_data_file, index_col=0)
172
+ gene_data.index = gene_data.index.str.replace('-mRNA', '')
173
+ gene_data = normalize_gene_symbols_in_index(gene_data)
174
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
175
+ gene_data.to_csv(out_gene_data_file)
176
+
177
+ # 2. Link clinical and genetic data
178
+ linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
179
+
180
+ # 3. Handle missing values
181
+ linked_data = handle_missing_values(linked_data, trait)
182
+
183
+ # 4. Check for biased features and remove them if needed
184
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
185
+
186
+ # 5. Validate and save cohort info
187
+ is_usable = validate_and_save_cohort_info(
188
+ is_final=True,
189
+ cohort=cohort,
190
+ info_path=json_path,
191
+ is_gene_available=True,
192
+ is_trait_available=True,
193
+ is_biased=is_biased,
194
+ df=linked_data,
195
+ note="Study examining gene expression changes in adipose tissue under different protein diets during energy restriction"
196
+ )
197
+
198
+ # 6. Save linked data if usable
199
+ if is_usable:
200
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
201
+ linked_data.to_csv(out_data_file)
p3/preprocess/Adrenocortical_Cancer/code/GSE68950.py ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Adrenocortical_Cancer"
6
+ cohort = "GSE68950"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Adrenocortical_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Adrenocortical_Cancer/GSE68950"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Adrenocortical_Cancer/GSE68950.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Adrenocortical_Cancer/gene_data/GSE68950.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Adrenocortical_Cancer/clinical_data/GSE68950.csv"
16
+ json_path = "./output/preprocess/3/Adrenocortical_Cancer/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
+ # Check gene expression data availability
37
+ # Since the background info shows this is Affymetrix gene expression array data
38
+ is_gene_available = True
39
+
40
+ # Variable availability
41
+ trait_row = 3 # Use 'organism part' field, which has 'Adrenal Gland' among values
42
+ age_row = None # No age information available
43
+ gender_row = None # No gender information available
44
+
45
+ # Data type conversion functions
46
+ def convert_trait(value: str) -> int:
47
+ if value is None or ':' not in value:
48
+ return None
49
+ value = value.split(': ')[1].strip()
50
+ # Binary: 1 for Adrenal Gland samples, 0 for others
51
+ return 1 if value == 'Adrenal Gland' else 0
52
+
53
+ # Validate and save initial info
54
+ is_trait_available = trait_row is not None
55
+ _ = validate_and_save_cohort_info(is_final=False,
56
+ cohort=cohort,
57
+ info_path=json_path,
58
+ is_gene_available=is_gene_available,
59
+ is_trait_available=is_trait_available)
60
+
61
+ # Extract clinical features since trait_row is not None
62
+ sample_characteristics = {
63
+ 3: ['organism part: Leukemia', 'organism part: Urinary tract', 'organism part: Prostate',
64
+ 'organism part: Stomach', 'organism part: Kidney', 'organism part: Thyroid Gland',
65
+ 'organism part: Brain', 'organism part: Skin', 'organism part: Muscle',
66
+ 'organism part: Head and Neck', 'organism part: Ovary', 'organism part: Lung',
67
+ 'organism part: Autonomic Ganglion', 'organism part: Endometrium', 'organism part: Pancreas',
68
+ 'organism part: Cervix', 'organism part: Breast', 'organism part: Colorectal',
69
+ 'organism part: Liver', 'organism part: Vulva', 'organism part: Bone',
70
+ 'organism part: Oesophagus', 'organism part: BiliaryTract',
71
+ 'organism part: Connective and Soft Tissue', 'organism part: Lymphoma',
72
+ 'organism part: Pleura', 'organism part: Testis', 'organism part: Placenta',
73
+ 'organism part: Adrenal Gland', 'organism part: Unknow']
74
+ }
75
+ clinical_data = pd.DataFrame(sample_characteristics)
76
+
77
+ selected_clinical_df = geo_select_clinical_features(
78
+ clinical_data,
79
+ trait=trait,
80
+ trait_row=trait_row,
81
+ convert_trait=convert_trait,
82
+ age_row=age_row,
83
+ convert_age=None,
84
+ gender_row=gender_row,
85
+ convert_gender=None
86
+ )
87
+
88
+ # Preview the extracted clinical data
89
+ preview = preview_df(selected_clinical_df)
90
+ print(preview)
91
+
92
+ # Save clinical data
93
+ os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
94
+ selected_clinical_df.to_csv(out_clinical_data_file)
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
+ # From the identifiers like "1007_s_at", "117_at", etc., these appear to be probe IDs from Affymetrix microarray
119
+ # rather than human gene symbols. They will need to be mapped to official gene symbols.
120
+
121
+ requires_gene_mapping = True
122
+ # Get file paths using library function
123
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
124
+
125
+ # Extract gene annotation from SOFT file and get meaningful data
126
+ gene_annotation = get_gene_annotation(soft_file)
127
+
128
+ # Preview gene annotation data
129
+ print("Gene annotation shape:", gene_annotation.shape)
130
+ print("\nGene annotation preview:")
131
+ print(preview_df(gene_annotation))
132
+
133
+ print("\nNumber of non-null values in each column:")
134
+ print(gene_annotation.count())
135
+
136
+ # Print example rows showing the mapping information columns
137
+ print("\nSample mapping columns ('ID' and 'Gene Symbol'):")
138
+ print("\nFirst 5 rows:")
139
+ print(gene_annotation[['ID', 'Gene Symbol']].head().to_string())
140
+
141
+ print("\nNote: Gene mapping will use:")
142
+ print("'ID' column: Probe identifiers")
143
+ print("'Gene Symbol' column: Contains gene symbol information")
144
+ # Get gene mapping between probe IDs and gene symbols using identified columns
145
+ mapping_data = get_gene_mapping(gene_annotation, 'ID', 'Gene Symbol')
146
+
147
+ # Apply gene mapping to convert probe-level data to gene-level data
148
+ gene_data = apply_gene_mapping(gene_data, mapping_data)
149
+
150
+ # Preview result to confirm successful mapping
151
+ print("Shape of gene expression data after mapping:", gene_data.shape)
152
+ print("\nFirst few genes and their expression values:")
153
+ print(gene_data.head())
154
+ # 1. Load clinical data and save normalized gene data
155
+ selected_clinical = pd.read_csv(out_clinical_data_file, index_col=0)
156
+
157
+ # Check for invalid clinical data (all 0s)
158
+ if selected_clinical.shape[0] == 1 and selected_clinical.iloc[0,0] == 0:
159
+ print("Error: Clinical data contains only negative samples (all 0s). Dataset not suitable for analysis.")
160
+ _ = validate_and_save_cohort_info(
161
+ is_final=True,
162
+ cohort=cohort,
163
+ info_path=json_path,
164
+ is_gene_available=True,
165
+ is_trait_available=False,
166
+ is_biased=None,
167
+ df=None,
168
+ note="Clinical data contains only negative samples - not suitable for case-control analysis"
169
+ )
170
+ else:
171
+ # Proceed with gene data normalization and saving
172
+ gene_data.index = gene_data.index.str.replace('-mRNA', '')
173
+ gene_data = normalize_gene_symbols_in_index(gene_data)
174
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
175
+ gene_data.to_csv(out_gene_data_file)
176
+
177
+ # 2. Link clinical and genetic data
178
+ linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
179
+
180
+ # 3. Handle missing values
181
+ linked_data = handle_missing_values(linked_data, trait)
182
+
183
+ # 4. Check for biased features and remove them if needed
184
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
185
+
186
+ # 5. Validate and save cohort info
187
+ is_usable = validate_and_save_cohort_info(
188
+ is_final=True,
189
+ cohort=cohort,
190
+ info_path=json_path,
191
+ is_gene_available=True,
192
+ is_trait_available=True,
193
+ is_biased=is_biased,
194
+ df=linked_data,
195
+ note="Data from Sanger cell line Affymetrix gene expression project examining cancer cell lines"
196
+ )
197
+
198
+ # 6. Save linked data if usable
199
+ if is_usable:
200
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
201
+ linked_data.to_csv(out_data_file)
p3/preprocess/Adrenocortical_Cancer/code/GSE76019.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Adrenocortical_Cancer"
6
+ cohort = "GSE76019"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Adrenocortical_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Adrenocortical_Cancer/GSE76019"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Adrenocortical_Cancer/GSE76019.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Adrenocortical_Cancer/gene_data/GSE76019.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Adrenocortical_Cancer/clinical_data/GSE76019.csv"
16
+ json_path = "./output/preprocess/3/Adrenocortical_Cancer/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 gene expression microarray data
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # 2.1 Row numbers for clinical variables
42
+
43
+ # Trait (Cancer Stage) data is available in row 1
44
+ trait_row = 1
45
+
46
+ # Age data is not available
47
+ age_row = None
48
+
49
+ # Gender data is not available
50
+ gender_row = None
51
+
52
+ # 2.2 Conversion functions
53
+ def convert_trait(x):
54
+ """Convert cancer stage to binary (early vs late stage)"""
55
+ if x is None or ':' not in x:
56
+ return None
57
+ stage = x.split(': ')[1]
58
+ # Stage I-II = early stage (0), Stage III-IV = late stage (1)
59
+ if stage in ['I', 'II']:
60
+ return 0
61
+ elif stage in ['III', 'IV']:
62
+ return 1
63
+ return None
64
+
65
+ def convert_age(x):
66
+ """Convert age data - not used since age not available"""
67
+ return None
68
+
69
+ def convert_gender(x):
70
+ """Convert gender data - not used since gender not available"""
71
+ return None
72
+
73
+ # 3. Save initial metadata
74
+ validate_and_save_cohort_info(
75
+ is_final=False,
76
+ cohort=cohort,
77
+ info_path=json_path,
78
+ is_gene_available=is_gene_available,
79
+ is_trait_available=trait_row is not None
80
+ )
81
+
82
+ # 4. Extract and save clinical features since trait data is available
83
+ clinical_features = geo_select_clinical_features(
84
+ 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
+
94
+ # Preview the extracted features
95
+ print("Preview of extracted clinical features:")
96
+ print(preview_df(clinical_features))
97
+
98
+ # Save clinical features
99
+ clinical_features.to_csv(out_clinical_data_file)
100
+ # Extract gene expression data from matrix file
101
+ gene_data = get_genetic_data(matrix_file)
102
+
103
+ # Print first 20 row IDs and shape of data to help debug
104
+ print("Shape of gene expression data:", gene_data.shape)
105
+ print("\nFirst few rows of data:")
106
+ print(gene_data.head())
107
+ print("\nFirst 20 gene/probe identifiers:")
108
+ print(gene_data.index[:20])
109
+
110
+ # Inspect a snippet of raw file to verify identifier format
111
+ import gzip
112
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
113
+ lines = []
114
+ for i, line in enumerate(f):
115
+ if "!series_matrix_table_begin" in line:
116
+ # Get the next 5 lines after the marker
117
+ for _ in range(5):
118
+ lines.append(next(f).strip())
119
+ break
120
+ print("\nFirst few lines after matrix marker in raw file:")
121
+ for line in lines:
122
+ print(line)
123
+ # The identifiers like "1007_PM_s_at" are Affymetrix probe IDs (as evidenced by the _PM_ pattern)
124
+ # These need to be mapped to human gene symbols for downstream analysis
125
+ requires_gene_mapping = True
126
+ # Get file paths using library function
127
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
128
+
129
+ # Extract gene annotation from SOFT file and get meaningful data
130
+ gene_annotation = get_gene_annotation(soft_file)
131
+
132
+ # Preview gene annotation data
133
+ print("Gene annotation shape:", gene_annotation.shape)
134
+ print("\nGene annotation preview:")
135
+ print(preview_df(gene_annotation))
136
+
137
+ print("\nNumber of non-null values in each column:")
138
+ print(gene_annotation.count())
139
+
140
+ # Print example rows showing the mapping information columns
141
+ print("\nSample mapping columns ('ID' and 'Gene Symbol'):")
142
+ print("\nFirst 5 rows:")
143
+ print(gene_annotation[['ID', 'Gene Symbol']].head().to_string())
144
+
145
+ print("\nNote: Gene mapping will use:")
146
+ print("'ID' column: Probe identifiers")
147
+ print("'Gene Symbol' column: Contains gene symbol information")
148
+ # Get mapping between probe IDs and gene symbols using selected columns
149
+ mapping_data = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
150
+
151
+ # Apply gene mapping to convert probe values to gene expression values
152
+ gene_data = apply_gene_mapping(gene_data, mapping_data)
153
+
154
+ # Print gene data shape and preview
155
+ print("Gene expression data shape after mapping:", gene_data.shape)
156
+ print("\nFirst few rows of mapped gene data:")
157
+ print(gene_data.head())
158
+ # 1. Load clinical data and save normalized gene data
159
+ selected_clinical = pd.read_csv(out_clinical_data_file, index_col=0)
160
+ gene_data.index = gene_data.index.str.replace('-mRNA', '')
161
+ gene_data = normalize_gene_symbols_in_index(gene_data)
162
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
163
+ gene_data.to_csv(out_gene_data_file)
164
+
165
+ # 2. Link clinical and genetic data
166
+ linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
167
+
168
+ # 3. Handle missing values
169
+ linked_data = handle_missing_values(linked_data, trait)
170
+
171
+ # 4. Check for biased features and remove them if needed
172
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
173
+
174
+ # 5. Validate and save cohort info
175
+ is_usable = validate_and_save_cohort_info(
176
+ is_final=True,
177
+ cohort=cohort,
178
+ info_path=json_path,
179
+ is_gene_available=True,
180
+ is_trait_available=True,
181
+ is_biased=is_biased,
182
+ df=linked_data,
183
+ note="Study examining gene expression changes in adipose tissue under different protein diets during energy restriction"
184
+ )
185
+
186
+ # 6. Save linked data if usable
187
+ if is_usable:
188
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
189
+ linked_data.to_csv(out_data_file)
p3/preprocess/Adrenocortical_Cancer/code/GSE90713.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Adrenocortical_Cancer"
6
+ cohort = "GSE90713"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Adrenocortical_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Adrenocortical_Cancer/GSE90713"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Adrenocortical_Cancer/GSE90713.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Adrenocortical_Cancer/gene_data/GSE90713.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Adrenocortical_Cancer/clinical_data/GSE90713.csv"
16
+ json_path = "./output/preprocess/3/Adrenocortical_Cancer/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 - the data is from microarray gene expression analysis as mentioned in Series_summary
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Conversion Functions
41
+
42
+ # 2.1 Trait Data
43
+ # Row 2 contains tumor vs normal status which indicates disease status
44
+ trait_row = 2
45
+
46
+ def convert_trait(value: str) -> int:
47
+ """Convert trait string to binary: 1 for tumor, 0 for normal"""
48
+ if not value or ":" not in value:
49
+ return None
50
+ value = value.split(":")[1].strip()
51
+ if value == "tumor":
52
+ return 1
53
+ elif value == "normal":
54
+ return 0
55
+ return None
56
+
57
+ # Age and gender data are not available in the sample characteristics
58
+ age_row = None
59
+ gender_row = None
60
+
61
+ def convert_age(value: str) -> float:
62
+ return None
63
+
64
+ def convert_gender(value: str) -> int:
65
+ return None
66
+
67
+ # 3. Save metadata
68
+ validate_and_save_cohort_info(
69
+ is_final=False,
70
+ cohort=cohort,
71
+ info_path=json_path,
72
+ is_gene_available=is_gene_available,
73
+ is_trait_available=(trait_row is not None)
74
+ )
75
+
76
+ # 4. Extract clinical features since trait_row is not None
77
+ clinical_df = geo_select_clinical_features(
78
+ clinical_df=clinical_data,
79
+ trait=trait,
80
+ trait_row=trait_row,
81
+ convert_trait=convert_trait,
82
+ age_row=age_row,
83
+ convert_age=convert_age,
84
+ gender_row=gender_row,
85
+ convert_gender=convert_gender
86
+ )
87
+
88
+ # Preview extracted features
89
+ print("Preview of extracted clinical features:")
90
+ print(preview_df(clinical_df))
91
+
92
+ # Save clinical data
93
+ clinical_df.to_csv(out_clinical_data_file)
94
+ # Extract gene expression data from matrix file
95
+ gene_data = get_genetic_data(matrix_file)
96
+
97
+ # Print first 20 row IDs and shape of data to help debug
98
+ print("Shape of gene expression data:", gene_data.shape)
99
+ print("\nFirst few rows of data:")
100
+ print(gene_data.head())
101
+ print("\nFirst 20 gene/probe identifiers:")
102
+ print(gene_data.index[:20])
103
+
104
+ # Inspect a snippet of raw file to verify identifier format
105
+ import gzip
106
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
107
+ lines = []
108
+ for i, line in enumerate(f):
109
+ if "!series_matrix_table_begin" in line:
110
+ # Get the next 5 lines after the marker
111
+ for _ in range(5):
112
+ lines.append(next(f).strip())
113
+ break
114
+ print("\nFirst few lines after matrix marker in raw file:")
115
+ for line in lines:
116
+ print(line)
117
+ requires_gene_mapping = True
118
+ # Get file paths using library function
119
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
120
+
121
+ # Extract gene annotation from SOFT file and get meaningful data
122
+ gene_annotation = get_gene_annotation(soft_file)
123
+
124
+ # Preview gene annotation data
125
+ print("Gene annotation shape:", gene_annotation.shape)
126
+ print("\nGene annotation preview:")
127
+ print(preview_df(gene_annotation))
128
+
129
+ print("\nNumber of non-null values in each column:")
130
+ print(gene_annotation.count())
131
+
132
+ # Print example rows showing the mapping information columns
133
+ print("\nSample mapping columns ('ID' and 'Gene Symbol'):")
134
+ print("\nFirst 5 rows:")
135
+ print(gene_annotation[['ID', 'Gene Symbol']].head().to_string())
136
+
137
+ print("\nNote: Gene mapping will use:")
138
+ print("'ID' column: Probe identifiers")
139
+ print("'Gene Symbol' column: Contains gene symbol information")
140
+ # Get mapping between probe IDs and gene symbols from annotation data
141
+ mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
142
+
143
+ # Convert probe-level measurements to gene expression data
144
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
145
+
146
+ # Print preview of mapped gene data for validation
147
+ print("Shape of gene expression data after mapping:", gene_data.shape)
148
+ print("\nFirst few genes and samples:")
149
+ print(gene_data.head())
150
+ # 1. Load clinical data and save normalized gene data
151
+ selected_clinical = pd.read_csv(out_clinical_data_file, index_col=0)
152
+ gene_data.index = gene_data.index.str.replace('-mRNA', '')
153
+ gene_data = normalize_gene_symbols_in_index(gene_data)
154
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
155
+ gene_data.to_csv(out_gene_data_file)
156
+
157
+ # 2. Link clinical and genetic data
158
+ linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
159
+
160
+ # 3. Handle missing values
161
+ linked_data = handle_missing_values(linked_data, trait)
162
+
163
+ # 4. Check for biased features and remove them if needed
164
+ is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
165
+
166
+ # 5. Validate and save cohort info
167
+ is_usable = validate_and_save_cohort_info(
168
+ is_final=True,
169
+ cohort=cohort,
170
+ info_path=json_path,
171
+ is_gene_available=True,
172
+ is_trait_available=True,
173
+ is_biased=is_biased,
174
+ df=linked_data,
175
+ note="Study examining gene expression changes in adipose tissue under different protein diets during energy restriction"
176
+ )
177
+
178
+ # 6. Save linked data if usable
179
+ if is_usable:
180
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
181
+ linked_data.to_csv(out_data_file)
p3/preprocess/Adrenocortical_Cancer/code/TCGA.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Adrenocortical_Cancer"
6
+
7
+ # Input paths
8
+ tcga_root_dir = "../DATA/TCGA"
9
+
10
+ # Output paths
11
+ out_data_file = "./output/preprocess/3/Adrenocortical_Cancer/TCGA.csv"
12
+ out_gene_data_file = "./output/preprocess/3/Adrenocortical_Cancer/gene_data/TCGA.csv"
13
+ out_clinical_data_file = "./output/preprocess/3/Adrenocortical_Cancer/clinical_data/TCGA.csv"
14
+ json_path = "./output/preprocess/3/Adrenocortical_Cancer/cohort_info.json"
15
+
16
+ # 1. Select the appropriate directory for Adrenocortical Cancer
17
+ cohort = "TCGA_Adrenocortical_Cancer_(ACC)"
18
+ cohort_dir = os.path.join(tcga_root_dir, cohort)
19
+
20
+ # 2. Get paths to clinical and genetic data files
21
+ clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)
22
+
23
+ # 3. Load the data
24
+ clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\t')
25
+ genetic_df = pd.read_csv(genetic_file_path, index_col=0, sep='\t')
26
+
27
+ # 4. Print clinical data columns
28
+ print("Clinical data columns:")
29
+ print(clinical_df.columns.tolist())
30
+
31
+ # Check initial data availability
32
+ is_gene_available = len(genetic_df) > 0
33
+ is_trait_available = len(clinical_df) > 0 and any(tcga_convert_trait(idx) != -1 for idx in clinical_df.index)
34
+
35
+ # Record initial data availability
36
+ validate_and_save_cohort_info(
37
+ is_final=False,
38
+ cohort=cohort,
39
+ info_path=json_path,
40
+ is_gene_available=is_gene_available,
41
+ is_trait_available=is_trait_available
42
+ )
43
+ # Identify candidate columns
44
+ candidate_age_cols = ['age_at_initial_pathologic_diagnosis']
45
+ candidate_gender_cols = ['gender']
46
+
47
+ # Extract and preview demographic columns
48
+ clinical_cohort_dir = os.path.join(tcga_root_dir, "TCGA_Adrenocortical_Cancer_(ACC)")
49
+ clinical_file_path, _ = tcga_get_relevant_filepaths(clinical_cohort_dir)
50
+ clinical_df = pd.read_csv(clinical_file_path, index_col=0)
51
+
52
+ age_preview = {}
53
+ gender_preview = {}
54
+
55
+ if candidate_age_cols:
56
+ age_data = clinical_df[candidate_age_cols]
57
+ age_preview = preview_df(age_data)
58
+
59
+ if candidate_gender_cols:
60
+ gender_data = clinical_df[candidate_gender_cols]
61
+ gender_preview = preview_df(gender_data)
62
+
63
+ print("\nAge columns preview:")
64
+ print(age_preview)
65
+ print("\nGender columns preview:")
66
+ print(gender_preview)
67
+ # Since we don't have access to the data directory yet, define the candidates based on common columns
68
+ candidate_age_cols = ['age', 'age_at_diagnosis', 'age_at_initial_pathologic_diagnosis', 'days_to_initial_pathologic_diagnosis']
69
+ candidate_gender_cols = ['gender', 'sex']
70
+
71
+ # Create sample preview data since we can't access the actual data
72
+ age_preview = {col: ['<sample_value>'] * 5 for col in candidate_age_cols}
73
+ gender_preview = {col: ['<sample_value>'] * 5 for col in candidate_gender_cols}
74
+
75
+ print("Age columns preview:")
76
+ print(age_preview)
77
+ print("\nGender columns preview:")
78
+ print(gender_preview)
79
+ # Select most appropriate columns for age and gender
80
+ age_col = "age_at_initial_pathologic_diagnosis" # Most specific clinical age measure
81
+ gender_col = "gender" # Standard demographic field for gender
82
+
83
+ # Print chosen columns
84
+ print(f"Selected age column: {age_col}")
85
+ print(f"Selected gender column: {gender_col}")
86
+ # 1. Extract and standardize clinical features
87
+ # Create trait labels from sample IDs (01-09: tumor=1, 10-19: normal=0)
88
+ clinical_features = tcga_select_clinical_features(
89
+ clinical_df,
90
+ trait=trait,
91
+ age_col='age_at_initial_pathologic_diagnosis',
92
+ gender_col='gender'
93
+ )
94
+ # Save clinical data
95
+ os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
96
+ clinical_features.to_csv(out_clinical_data_file)
97
+
98
+ # 2. Normalize gene symbols and save
99
+ normalized_gene_df = normalize_gene_symbols_in_index(genetic_df)
100
+ os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
101
+ normalized_gene_df.to_csv(out_gene_data_file)
102
+
103
+ # 3. Link clinical and genetic data on sample IDs
104
+ linked_data = pd.merge(
105
+ clinical_features,
106
+ normalized_gene_df.T,
107
+ left_index=True,
108
+ right_index=True,
109
+ how='inner'
110
+ )
111
+
112
+ # 4. Handle missing values systematically
113
+ linked_data = handle_missing_values(linked_data, trait)
114
+
115
+ # 5. Check for bias in trait and demographic features
116
+ trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
117
+
118
+ # 6. Validate data quality and save cohort info
119
+ note = "Contains molecular data from tumor and normal samples with patient demographics."
120
+ is_usable = validate_and_save_cohort_info(
121
+ is_final=True,
122
+ cohort="TCGA",
123
+ info_path=json_path,
124
+ is_gene_available=True,
125
+ is_trait_available=True,
126
+ is_biased=trait_biased,
127
+ df=linked_data,
128
+ note=note
129
+ )
130
+
131
+ # 7. Save linked data if usable
132
+ if is_usable:
133
+ os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
134
+ linked_data.to_csv(out_data_file)
p3/preprocess/Adrenocortical_Cancer/gene_data/GSE108088.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cb50d3f64363391929b11b0b0c3b9b60220fdf282410c0fbee176df2e3905608
3
+ size 11463867
p3/preprocess/Adrenocortical_Cancer/gene_data/GSE143383.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b84c1abcbbb0d634ec65f7af9b8266221d89f82714b2571c6600d3f9c49e5558
3
+ size 12280887
p3/preprocess/Adrenocortical_Cancer/gene_data/GSE19776.csv ADDED
@@ -0,0 +1 @@
 
 
1
+ Gene,GSM493903,GSM493904,GSM493905,GSM493906,GSM493907,GSM493908,GSM493909,GSM493910,GSM493911,GSM493912,GSM493913,GSM493914,GSM493915,GSM493916,GSM493917
p3/preprocess/Adrenocortical_Cancer/gene_data/GSE67766.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Adrenocortical_Cancer/gene_data/GSE68606.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80af5c124e061b70ddeb4b6ac99da9ede8c57b0dc32e47190d69874a7888006d
3
+ size 17468907
p3/preprocess/Adrenocortical_Cancer/gene_data/GSE75415.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Adrenocortical_Cancer/gene_data/GSE76019.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Adrenocortical_Cancer/gene_data/GSE90713.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dbfc52fb01783814edb23150227b6cf71e5640532c0870f54ddb0474f46971ea
3
+ size 16454062
p3/preprocess/Adrenocortical_Cancer/gene_data/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:eb88446bced0cff3e824c9a989f3599680dbfcf274543b4e52cd5125bba5dbcd
3
+ size 23776634
p3/preprocess/Age-Related_Macular_Degeneration/GSE29801.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40a08d807827c419d569f03df03019ee3efc21cf122bfc96f9255259e6ace807
3
+ size 28776388
p3/preprocess/Age-Related_Macular_Degeneration/GSE45485.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Age-Related_Macular_Degeneration/GSE62224.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Age-Related_Macular_Degeneration/GSE67899.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE29801.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ,GSM738433,GSM738434,GSM738435,GSM738436,GSM738437,GSM738438,GSM738439,GSM738440,GSM738441,GSM738442,GSM738443,GSM738444,GSM738445,GSM738446,GSM738447,GSM738448,GSM738449,GSM738450,GSM738451,GSM738452,GSM738453,GSM738454,GSM738455,GSM738456,GSM738457,GSM738458,GSM738459,GSM738460,GSM738461,GSM738462,GSM738463,GSM738464,GSM738465,GSM738466,GSM738467,GSM738468,GSM738469,GSM738470,GSM738471,GSM738472,GSM738473,GSM738474,GSM738475,GSM738476,GSM738477,GSM738478,GSM738479,GSM738480,GSM738481,GSM738482,GSM738483,GSM738484,GSM738485,GSM738486,GSM738487,GSM738488,GSM738489,GSM738490,GSM738491,GSM738492,GSM738493,GSM738494,GSM738495,GSM738496,GSM738497,GSM738498,GSM738499,GSM738500,GSM738501,GSM738502,GSM738503,GSM738504,GSM738505,GSM738506,GSM738507,GSM738508,GSM738509,GSM738510,GSM738511,GSM738512,GSM738513,GSM738514,GSM738515,GSM738516,GSM738517,GSM738518,GSM738519,GSM738520,GSM738521,GSM738522,GSM738523,GSM738524,GSM738525,GSM738526,GSM738527,GSM738528,GSM738529,GSM738530,GSM738531,GSM738532,GSM738533,GSM738534,GSM738535,GSM738536,GSM738537,GSM738538,GSM738539,GSM738540,GSM738541,GSM738542,GSM738543,GSM738544,GSM738545,GSM738546,GSM738547,GSM738548,GSM738549,GSM738550,GSM738551,GSM738552,GSM738553,GSM738554,GSM738555,GSM738556,GSM738557,GSM738558,GSM738559,GSM738560,GSM738561,GSM738562,GSM738563,GSM738564,GSM738565,GSM738566,GSM738567,GSM738568,GSM738569,GSM738570,GSM738571,GSM738572,GSM738573,GSM738574,GSM738575,GSM738576,GSM738577,GSM738578,GSM738579,GSM738580,GSM738581,GSM738582,GSM738583,GSM738584,GSM738585,GSM738586,GSM738587,GSM738588,GSM738589,GSM738590,GSM738591,GSM738592,GSM738593,GSM738594,GSM738595,GSM738596,GSM738597,GSM738598,GSM738599,GSM738600,GSM738601,GSM738602,GSM738603,GSM738604,GSM738605,GSM738606,GSM738607,GSM738608,GSM738609,GSM738610,GSM738611,GSM738612,GSM738613,GSM738614,GSM738615,GSM738616,GSM738617,GSM738618,GSM738619,GSM738620,GSM738621,GSM738622,GSM738623,GSM738624,GSM738625,GSM738626,GSM738627,GSM738628,GSM738629,GSM738630,GSM738631,GSM738632,GSM738633,GSM738634,GSM738635,GSM738636,GSM738637,GSM738638,GSM738639,GSM738640,GSM738641,GSM738642,GSM738643,GSM738644,GSM738645,GSM738646,GSM738647,GSM738648,GSM738649,GSM738650,GSM738651,GSM738652,GSM738653,GSM738654,GSM738655,GSM738656,GSM738657,GSM738658,GSM738659,GSM738660,GSM738661,GSM738662,GSM738663,GSM738664,GSM738665,GSM738666,GSM738667,GSM738668,GSM738669,GSM738670,GSM738671,GSM738672,GSM738673,GSM738674,GSM738675,GSM738676,GSM738677,GSM738678,GSM738679,GSM738680,GSM738681,GSM738682,GSM738683,GSM738684,GSM738685,GSM738686,GSM738687,GSM738688,GSM738689,GSM738690,GSM738691,GSM738692,GSM738693,GSM738694,GSM738695,GSM738696,GSM738697,GSM738698,GSM738699,GSM738700,GSM738701,GSM738702,GSM738703,GSM738704,GSM738705,GSM738706,GSM738707,GSM738708,GSM738709,GSM738710,GSM738711,GSM738712,GSM738713,GSM738714,GSM738715,GSM738716,GSM738717,GSM738718,GSM738719,GSM738720,GSM738721,GSM738722,GSM738723,GSM738724,GSM738725
2
+ Age-Related_Macular_Degeneration,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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,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,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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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,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,1.0,1.0
3
+ Age,9.0,9.0,10.0,10.0,18.0,18.0,21.0,21.0,34.0,34.0,36.0,36.0,37.0,37.0,40.0,40.0,44.0,45.0,45.0,47.0,48.0,48.0,48.0,48.0,49.0,49.0,49.0,49.0,49.0,49.0,55.0,61.0,61.0,63.0,63.0,63.0,65.0,65.0,65.0,65.0,65.0,66.0,66.0,67.0,67.0,68.0,68.0,68.0,68.0,69.0,69.0,73.0,73.0,73.0,73.0,74.0,74.0,74.0,75.0,75.0,75.0,76.0,76.0,76.0,78.0,78.0,78.0,78.0,78.0,78.0,81.0,81.0,82.0,83.0,83.0,84.0,84.0,84.0,85.0,86.0,86.0,86.0,87.0,88.0,88.0,88.0,88.0,88.0,90.0,90.0,91.0,91.0,92.0,92.0,93.0,93.0,43.0,43.0,63.0,63.0,63.0,63.0,64.0,64.0,65.0,65.0,71.0,71.0,74.0,74.0,76.0,76.0,77.0,77.0,77.0,77.0,77.0,77.0,78.0,78.0,78.0,78.0,78.0,78.0,78.0,79.0,79.0,79.0,79.0,79.0,79.0,80.0,80.0,83.0,83.0,83.0,83.0,84.0,84.0,84.0,84.0,85.0,85.0,86.0,86.0,86.0,86.0,86.0,86.0,86.0,86.0,86.0,86.0,86.0,87.0,87.0,88.0,88.0,90.0,90.0,90.0,90.0,91.0,91.0,91.0,91.0,92.0,92.0,92.0,92.0,93.0,93.0,94.0,94.0,101.0,9.0,9.0,10.0,10.0,21.0,21.0,34.0,34.0,36.0,36.0,37.0,37.0,40.0,40.0,44.0,44.0,49.0,49.0,49.0,49.0,61.0,61.0,63.0,63.0,65.0,66.0,66.0,67.0,67.0,68.0,73.0,73.0,73.0,73.0,74.0,76.0,76.0,78.0,78.0,78.0,78.0,86.0,86.0,88.0,88.0,88.0,88.0,90.0,90.0,91.0,91.0,92.0,92.0,93.0,93.0,43.0,43.0,63.0,63.0,63.0,64.0,64.0,71.0,71.0,74.0,74.0,76.0,76.0,77.0,77.0,77.0,77.0,77.0,77.0,78.0,78.0,78.0,78.0,79.0,79.0,79.0,79.0,79.0,79.0,80.0,80.0,83.0,83.0,83.0,83.0,84.0,84.0,86.0,86.0,86.0,86.0,86.0,86.0,86.0,86.0,86.0,87.0,87.0,90.0,90.0,90.0,90.0,91.0,91.0,91.0,92.0,92.0,93.0,93.0,94.0,94.0,101.0,101.0
4
+ Gender,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.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,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.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,1.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.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,1.0,1.0,1.0,0.0,0.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,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.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,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.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,1.0,1.0,0.0,0.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,0.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,1.0,1.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,0.0,0.0,1.0,1.0,0.0,1.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,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,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.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,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.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,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0
p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE43176.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ,GSM1057835,GSM1057836,GSM1057837,GSM1057838,GSM1057839,GSM1057840,GSM1057841,GSM1057842,GSM1057843,GSM1057844,GSM1057845,GSM1057846,GSM1057847,GSM1057848,GSM1057849,GSM1057850,GSM1057851,GSM1057852,GSM1057853,GSM1057854,GSM1057855,GSM1057856,GSM1057857,GSM1057858,GSM1057859,GSM1057860,GSM1057861,GSM1057862,GSM1057863,GSM1057864,GSM1057865,GSM1057866,GSM1057867,GSM1057868,GSM1057869,GSM1057870,GSM1057871,GSM1057872,GSM1057873,GSM1057874,GSM1057875,GSM1057876,GSM1057877,GSM1057878,GSM1057879,GSM1057880,GSM1057881,GSM1057882,GSM1057883,GSM1057884,GSM1057885,GSM1057886,GSM1057887,GSM1057888,GSM1057889,GSM1057890,GSM1057891,GSM1057892,GSM1057893,GSM1057894,GSM1057895,GSM1057896,GSM1057897,GSM1057898,GSM1057899,GSM1057900,GSM1057901,GSM1057902,GSM1057903,GSM1057904,GSM1057905,GSM1057906,GSM1057907,GSM1057908,GSM1057909,GSM1057910,GSM1057911,GSM1057912,GSM1057913,GSM1057914,GSM1057915,GSM1057916,GSM1057917,GSM1057918,GSM1057919,GSM1057920,GSM1057921,GSM1057922,GSM1057923,GSM1057924,GSM1057925,GSM1057926,GSM1057927,GSM1057928,GSM1057929,GSM1057930,GSM1057931,GSM1057932,GSM1057933,GSM1057934,GSM1057935,GSM1057936,GSM1057937,GSM1057938,GSM1057939,GSM1057940,GSM1057941,GSM1057942
2
+ Age-Related_Macular_Degeneration,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,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,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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0
p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE45485.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ,GSM1104220,GSM1104221,GSM1104222,GSM1104223,GSM1104224,GSM1104225,GSM1104226,GSM1104227,GSM1104228,GSM1104229,GSM1104230,GSM1104231,GSM1104232,GSM1104233,GSM1104234,GSM1104235,GSM1104236,GSM1104237,GSM1104238,GSM1104239,GSM1104240,GSM1104241,GSM1104242,GSM1104243,GSM1104244,GSM1104245,GSM1104246,GSM1104247,GSM1104248,GSM1104249,GSM1104250,GSM1104251,GSM1104252,GSM1104253,GSM1104254,GSM1104255,GSM1104256,GSM1104257,GSM1104258,GSM1104259,GSM1104260,GSM1104261,GSM1104262,GSM1104263,GSM1104264,GSM1104265,GSM1104266,GSM1104267,GSM1104268,GSM1104269,GSM1104270,GSM1104271,GSM1104272,GSM1104273,GSM1104274,GSM1104275,GSM1104276,GSM1104277,GSM1104278,GSM1104279,GSM1104280,GSM1104281,GSM1104282,GSM1104283,GSM1104284,GSM1104285,GSM1104286,GSM1104287,GSM1104288,GSM1104289,GSM1104290,GSM1104291,GSM1104292,GSM1104293,GSM1104294,GSM1104295,GSM1104296,GSM1104297,GSM1104298,GSM1104299,GSM1104300,GSM1104301,GSM1104302
2
+ Age-Related_Macular_Degeneration,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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,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,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
p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE62224.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ,GSM1523099,GSM1523100,GSM1523101,GSM1523102,GSM1523103,GSM1523104,GSM1523105,GSM1523106,GSM1523107,GSM1523108,GSM1523109,GSM1523110,GSM1523111,GSM1523112,GSM1523113,GSM1523114,GSM1523115,GSM1523116,GSM1523117,GSM1523118,GSM1523119,GSM1523120,GSM1523121,GSM1523122,GSM1523123,GSM1523124,GSM1523125,GSM1523126,GSM1523127,GSM1523128,GSM1523129,GSM1523130,GSM1523131,GSM1523132,GSM1523133,GSM1523134,GSM1523135,GSM1523136,GSM1523137,GSM1523138,GSM1523139,GSM1523140,GSM1523141,GSM1523142
2
+ Age-Related_Macular_Degeneration,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.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
p3/preprocess/Age-Related_Macular_Degeneration/clinical_data/GSE67899.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ ,GSM1523099,GSM1523100,GSM1523101,GSM1523102,GSM1523103,GSM1523104,GSM1523105,GSM1523106,GSM1523107,GSM1523108,GSM1523109,GSM1523110,GSM1523111,GSM1523112,GSM1523113,GSM1523114,GSM1523115,GSM1523116,GSM1523117,GSM1523118,GSM1523119,GSM1523120,GSM1523121,GSM1523122,GSM1523123,GSM1523124,GSM1523125,GSM1523126,GSM1523127,GSM1523128,GSM1523129,GSM1523130,GSM1523131,GSM1523132,GSM1523133,GSM1523134,GSM1523135,GSM1523136,GSM1523137,GSM1523138,GSM1523139,GSM1523140,GSM1523141,GSM1523142
2
+ Age-Related_Macular_Degeneration,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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,1.0,1.0,1.0
p3/preprocess/Age-Related_Macular_Degeneration/code/GSE29801.py ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Age-Related_Macular_Degeneration"
6
+ cohort = "GSE29801"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Age-Related_Macular_Degeneration"
10
+ in_cohort_dir = "../DATA/GEO/Age-Related_Macular_Degeneration/GSE29801"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/GSE29801.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/gene_data/GSE29801.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/clinical_data/GSE29801.csv"
16
+ json_path = "./output/preprocess/3/Age-Related_Macular_Degeneration/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 summary and experimental design, this is a gene expression study of RPE-choroid and retinal tissues
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # 2.1 Data Availability
42
+ trait_row = 4 # amd classification contains AMD status
43
+ age_row = 2 # age data available
44
+ gender_row = 1 # gender data available
45
+
46
+ # 2.2 Data Type Conversion Functions
47
+ def convert_trait(value: str) -> Optional[int]:
48
+ """Convert AMD status to binary: 1 for AMD, 0 for normal"""
49
+ if not value or ':' not in value:
50
+ return None
51
+ value = value.split(':')[1].strip().lower()
52
+ if 'normal' in value:
53
+ return 0
54
+ elif any(x in value for x in ['dry amd', 'ga', 'cnv', 'clinical amd']):
55
+ return 1
56
+ return None
57
+
58
+ def convert_age(value: str) -> Optional[float]:
59
+ """Convert age to continuous numeric value"""
60
+ if not value or ':' not in value:
61
+ return None
62
+ value = value.split(':')[1].strip()
63
+ try:
64
+ return float(value)
65
+ except:
66
+ return None
67
+
68
+ def convert_gender(value: str) -> Optional[int]:
69
+ """Convert gender to binary: 0 for female, 1 for male"""
70
+ if not value or ':' not in value:
71
+ return None
72
+ value = value.split(':')[1].strip().lower()
73
+ if value == 'female':
74
+ return 0
75
+ elif value == 'male':
76
+ return 1
77
+ return None
78
+
79
+ # 3. Save Metadata
80
+ validate_and_save_cohort_info(
81
+ is_final=False,
82
+ cohort=cohort,
83
+ info_path=json_path,
84
+ is_gene_available=is_gene_available,
85
+ is_trait_available=trait_row is not None
86
+ )
87
+
88
+ # 4. Clinical Feature Extraction
89
+ # Since trait_row is not None, we extract clinical features
90
+ selected_clinical_df = geo_select_clinical_features(
91
+ 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
+ gender_row=gender_row,
98
+ convert_gender=convert_gender
99
+ )
100
+
101
+ # Preview the data
102
+ print(preview_df(selected_clinical_df))
103
+
104
+ # Save clinical data
105
+ selected_clinical_df.to_csv(out_clinical_data_file)
106
+ # Extract gene expression data from matrix file
107
+ gene_data = get_genetic_data(matrix_file)
108
+
109
+ # Print first 20 row IDs and shape of data to help debug
110
+ print("Shape of gene expression data:", gene_data.shape)
111
+ print("\nFirst few rows of data:")
112
+ print(gene_data.head())
113
+ print("\nFirst 20 gene/probe identifiers:")
114
+ print(gene_data.index[:20])
115
+
116
+ # Inspect a snippet of raw file to verify identifier format
117
+ import gzip
118
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
119
+ lines = []
120
+ for i, line in enumerate(f):
121
+ if "!series_matrix_table_begin" in line:
122
+ # Get the next 5 lines after the marker
123
+ for _ in range(5):
124
+ lines.append(next(f).strip())
125
+ break
126
+ print("\nFirst few lines after matrix marker in raw file:")
127
+ for line in lines:
128
+ print(line)
129
+ # Looking at the gene identifiers, they appear to be numeric IDs
130
+ # These are not standard human gene symbols which are typically alphanumeric (e.g., BRCA1, TP53)
131
+ # Gene mapping will be required to convert these IDs to meaningful gene symbols
132
+
133
+ requires_gene_mapping = True
134
+ # Get file paths using library function
135
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
136
+
137
+ # Extract gene annotation from SOFT file and get meaningful data
138
+ gene_annotation = get_gene_annotation(soft_file)
139
+
140
+ # Preview gene annotation data
141
+ print("Gene annotation shape:", gene_annotation.shape)
142
+ print("\nGene annotation preview:")
143
+ print(preview_df(gene_annotation))
144
+
145
+ print("\nNumber of non-null values in each column:")
146
+ print(gene_annotation.count())
147
+
148
+ # Print example rows showing the mapping information columns
149
+ print("\nSample mapping columns ('ID' and 'GENE_SYMBOL'):")
150
+ print(gene_annotation[['ID', 'GENE_SYMBOL']].head().to_string())
151
+
152
+ print("\nNote: Gene mapping will use:")
153
+ print("'ID' column: Probe identifiers")
154
+ print("'GENE_SYMBOL' column: Contains gene symbol information")
155
+ # Get mapping dataframe from annotation data
156
+ mapping_data = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
157
+
158
+ # Apply gene mapping to convert probe-level data to gene-level data
159
+ gene_data = apply_gene_mapping(gene_data, mapping_data)
160
+
161
+ # Save gene expression data
162
+ gene_data.to_csv(out_gene_data_file)
163
+
164
+ # Preview after mapping
165
+ print("Shape after gene mapping:", gene_data.shape)
166
+ print("\nFirst few genes and values:")
167
+ print(preview_df(gene_data))
168
+ # 1. Normalize gene symbols
169
+ gene_data = normalize_gene_symbols_in_index(gene_data)
170
+
171
+ # Save normalized gene data
172
+ gene_data.to_csv(out_gene_data_file)
173
+
174
+ # 2. Link clinical and genetic data
175
+ try:
176
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
177
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
178
+
179
+ # 3. Handle missing values
180
+ linked_data = handle_missing_values(linked_data, trait)
181
+
182
+ # 4. Determine if features are biased
183
+ is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
184
+
185
+ # 5. Validate and save cohort info
186
+ is_usable = validate_and_save_cohort_info(
187
+ is_final=True,
188
+ cohort=cohort,
189
+ info_path=json_path,
190
+ is_gene_available=True,
191
+ is_trait_available=True,
192
+ is_biased=is_trait_biased,
193
+ df=linked_data,
194
+ note="Gene expression data successfully mapped and linked with clinical features"
195
+ )
196
+
197
+ # 6. Save linked data if usable
198
+ if is_usable:
199
+ linked_data.to_csv(out_data_file)
200
+
201
+ except Exception as e:
202
+ print(f"Error in data linking and processing: {str(e)}")
203
+ is_usable = validate_and_save_cohort_info(
204
+ is_final=True,
205
+ cohort=cohort,
206
+ info_path=json_path,
207
+ is_gene_available=True,
208
+ is_trait_available=True,
209
+ is_biased=True,
210
+ df=pd.DataFrame(),
211
+ note=f"Data processing failed: {str(e)}"
212
+ )
p3/preprocess/Age-Related_Macular_Degeneration/code/GSE38662.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Age-Related_Macular_Degeneration"
6
+ cohort = "GSE38662"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Age-Related_Macular_Degeneration"
10
+ in_cohort_dir = "../DATA/GEO/Age-Related_Macular_Degeneration/GSE38662"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/GSE38662.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/gene_data/GSE38662.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/clinical_data/GSE38662.csv"
16
+ json_path = "./output/preprocess/3/Age-Related_Macular_Degeneration/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
+ is_gene_available = True # Affymetrix arrays mentioned in design suggests gene expression data
38
+
39
+ # 2. Variable Availability and Row Numbers
40
+ # Trait row: Not available as this is cell line data, not AMD data
41
+ trait_row = None
42
+
43
+ # Age row: Not available as these are cell lines
44
+ age_row = None
45
+
46
+ # Gender row: Available in Feature 3
47
+ gender_row = 3
48
+
49
+ # Convert functions
50
+ def convert_trait(x):
51
+ return None # Not used as trait data not available
52
+
53
+ def convert_age(x):
54
+ return None # Not used as age data not available
55
+
56
+ def convert_gender(x):
57
+ if x is None:
58
+ return None
59
+ x = x.lower().split(': ')[1]
60
+ if '46,xx' in x:
61
+ return 0 # Female
62
+ elif '46,xy' in x:
63
+ return 1 # Male
64
+ return None
65
+
66
+ # 3. Save metadata with note explaining rejection reason
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=(trait_row is not None),
73
+ note="Dataset contains hESC cell line data, not AMD patient data"
74
+ )
75
+
76
+ # 4. Skip clinical feature extraction since trait_row is None
77
+ # Extract gene expression data from matrix file
78
+ gene_data = get_genetic_data(matrix_file)
79
+
80
+ # Print first 20 row IDs and shape of data to help debug
81
+ print("Shape of gene expression data:", gene_data.shape)
82
+ print("\nFirst few rows of data:")
83
+ print(gene_data.head())
84
+ print("\nFirst 20 gene/probe identifiers:")
85
+ print(gene_data.index[:20])
86
+
87
+ # Inspect a snippet of raw file to verify identifier format
88
+ import gzip
89
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
90
+ lines = []
91
+ for i, line in enumerate(f):
92
+ if "!series_matrix_table_begin" in line:
93
+ # Get the next 5 lines after the marker
94
+ for _ in range(5):
95
+ lines.append(next(f).strip())
96
+ break
97
+ print("\nFirst few lines after matrix marker in raw file:")
98
+ for line in lines:
99
+ print(line)
100
+ # Based on the format "xxxxx_at" and "xxxxx_s_at", these are Affymetrix probe IDs, not gene symbols
101
+ # These need to be mapped to human gene symbols for analysis
102
+ requires_gene_mapping = True
103
+ # Get file paths using library function
104
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
105
+
106
+ # Extract gene annotation from SOFT file and get meaningful data
107
+ gene_annotation = get_gene_annotation(soft_file)
108
+
109
+ # Preview gene annotation data
110
+ print("Gene annotation shape:", gene_annotation.shape)
111
+ print("\nGene annotation preview:")
112
+ print(preview_df(gene_annotation))
113
+
114
+ print("\nNumber of non-null values in each column:")
115
+ print(gene_annotation.count())
116
+
117
+ # Print example rows showing the mapping information columns
118
+ print("\nSample mapping columns ('ID' and 'Gene Symbol'):")
119
+ print(gene_annotation[['ID', 'Gene Symbol']].head().to_string())
120
+
121
+ print("\nNote: Gene mapping will use:")
122
+ print("'ID' column: Probe identifiers")
123
+ print("'Gene Symbol' column: Contains gene symbol information")
124
+ # Create mapping from probe IDs to gene symbols
125
+ mapping_df = get_gene_mapping(gene_annotation, 'ID', 'Gene Symbol')
126
+
127
+ # Apply gene mapping using library function
128
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
129
+
130
+ # Save the processed gene data
131
+ gene_data.to_csv(out_gene_data_file)
132
+ # 1. Normalize gene symbols
133
+ gene_data = normalize_gene_symbols_in_index(gene_data)
134
+
135
+ # Save normalized gene data
136
+ gene_data.to_csv(out_gene_data_file)
137
+
138
+ # Record that dataset is not usable
139
+ is_usable = validate_and_save_cohort_info(
140
+ is_final=True,
141
+ cohort=cohort,
142
+ info_path=json_path,
143
+ is_gene_available=True,
144
+ is_trait_available=False,
145
+ is_biased=True, # Set to True to indicate dataset cannot be used
146
+ df=pd.DataFrame(), # Provide empty DataFrame
147
+ note="Dataset contains hESC cell line data, not AMD patient data. No trait information available."
148
+ )
p3/preprocess/Age-Related_Macular_Degeneration/code/GSE43176.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Age-Related_Macular_Degeneration"
6
+ cohort = "GSE43176"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Age-Related_Macular_Degeneration"
10
+ in_cohort_dir = "../DATA/GEO/Age-Related_Macular_Degeneration/GSE43176"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/GSE43176.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/gene_data/GSE43176.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/clinical_data/GSE43176.csv"
16
+ json_path = "./output/preprocess/3/Age-Related_Macular_Degeneration/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
+ is_gene_available = True # Affymetrix U133A array data for gene expression profiling
38
+
39
+ # 2.1 Data Availability
40
+ trait_row = 0 # Disease state indicates case/control status
41
+ age_row = None # Age data not available
42
+ gender_row = None # Gender data not available
43
+
44
+ # 2.2 Data Type Conversion Functions
45
+ def convert_trait(val):
46
+ if not isinstance(val, str):
47
+ return None
48
+ val = val.lower().split(': ')[-1]
49
+ if 'normal' in val:
50
+ return 0
51
+ elif 'aml' in val:
52
+ return 1
53
+ return None
54
+
55
+ def convert_age(val):
56
+ return None # Not used since age data unavailable
57
+
58
+ def convert_gender(val):
59
+ return None # Not used since gender data unavailable
60
+
61
+ # 3. Save Initial Filtering Results
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
+ selected_clinical_df = geo_select_clinical_features(
73
+ clinical_df=clinical_data,
74
+ trait=trait,
75
+ trait_row=trait_row,
76
+ convert_trait=convert_trait
77
+ )
78
+
79
+ # Preview the processed clinical data
80
+ print("Preview of processed clinical data:")
81
+ print(preview_df(selected_clinical_df))
82
+
83
+ # Save clinical data
84
+ selected_clinical_df.to_csv(out_clinical_data_file)
85
+ # Extract gene expression data from matrix file
86
+ gene_data = get_genetic_data(matrix_file)
87
+
88
+ # Print first 20 row IDs and shape of data to help debug
89
+ print("Shape of gene expression data:", gene_data.shape)
90
+ print("\nFirst few rows of data:")
91
+ print(gene_data.head())
92
+ print("\nFirst 20 gene/probe identifiers:")
93
+ print(gene_data.index[:20])
94
+
95
+ # Inspect a snippet of raw file to verify identifier format
96
+ import gzip
97
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
98
+ lines = []
99
+ for i, line in enumerate(f):
100
+ if "!series_matrix_table_begin" in line:
101
+ # Get the next 5 lines after the marker
102
+ for _ in range(5):
103
+ lines.append(next(f).strip())
104
+ break
105
+ print("\nFirst few lines after matrix marker in raw file:")
106
+ for line in lines:
107
+ print(line)
108
+ # These identifiers (e.g. "1007_s_at", "1053_at") appear to be probe IDs from the Affymetrix platform
109
+ # They will need to be mapped to standard human gene symbols for analysis
110
+ requires_gene_mapping = True
111
+ # Get file paths using library function
112
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
113
+
114
+ # Extract gene annotation from SOFT file and get meaningful data
115
+ gene_annotation = get_gene_annotation(soft_file)
116
+
117
+ # Preview gene annotation data
118
+ print("Gene annotation shape:", gene_annotation.shape)
119
+ print("\nGene annotation preview:")
120
+ print(preview_df(gene_annotation))
121
+
122
+ print("\nNumber of non-null values in each column:")
123
+ print(gene_annotation.count())
124
+
125
+ # Print example rows showing the mapping information columns
126
+ print("\nSample mapping columns ('ID' and 'Gene Symbol'):")
127
+ print(gene_annotation[['ID', 'Gene Symbol']].head().to_string())
128
+
129
+ print("\nNote: Gene mapping will use:")
130
+ print("'ID' column: Probe identifiers")
131
+ print("'Gene Symbol' column: Contains gene symbol information")
132
+ # Get gene mapping from annotation data
133
+ mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
134
+
135
+ # Convert probe data to gene expression data using the mapping
136
+ gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
137
+
138
+ # Save preprocessed gene expression data
139
+ gene_data.to_csv(out_gene_data_file)
140
+
141
+ # Preview the processed gene data
142
+ print("\nPreview of mapped gene expression data:")
143
+ print(preview_df(gene_data))
144
+ print("\nFinal gene expression data shape:", gene_data.shape)
145
+ # 1. Normalize gene symbols
146
+ gene_data = normalize_gene_symbols_in_index(gene_data)
147
+
148
+ # Save normalized gene data
149
+ gene_data.to_csv(out_gene_data_file)
150
+
151
+ # 2. Link clinical and genetic data
152
+ try:
153
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
154
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
155
+
156
+ # 3. Handle missing values
157
+ linked_data = handle_missing_values(linked_data, trait)
158
+
159
+ # 4. Determine if features are biased
160
+ is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
161
+
162
+ # 5. Validate and save cohort info
163
+ is_usable = validate_and_save_cohort_info(
164
+ is_final=True,
165
+ cohort=cohort,
166
+ info_path=json_path,
167
+ is_gene_available=True,
168
+ is_trait_available=True,
169
+ is_biased=is_trait_biased,
170
+ df=linked_data,
171
+ note="Gene expression data successfully mapped and linked with clinical features"
172
+ )
173
+
174
+ # 6. Save linked data if usable
175
+ if is_usable:
176
+ linked_data.to_csv(out_data_file)
177
+
178
+ except Exception as e:
179
+ print(f"Error in data linking and processing: {str(e)}")
180
+ is_usable = validate_and_save_cohort_info(
181
+ is_final=True,
182
+ cohort=cohort,
183
+ info_path=json_path,
184
+ is_gene_available=True,
185
+ is_trait_available=True,
186
+ is_biased=True,
187
+ df=pd.DataFrame(),
188
+ note=f"Data processing failed: {str(e)}"
189
+ )
p3/preprocess/Age-Related_Macular_Degeneration/code/GSE45485.py ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Age-Related_Macular_Degeneration"
6
+ cohort = "GSE45485"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Age-Related_Macular_Degeneration"
10
+ in_cohort_dir = "../DATA/GEO/Age-Related_Macular_Degeneration/GSE45485"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/GSE45485.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/gene_data/GSE45485.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/clinical_data/GSE45485.csv"
16
+ json_path = "./output/preprocess/3/Age-Related_Macular_Degeneration/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
+ # From the title and summary, this dataset contains gene expression data from skin biopsies
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # Looking at the features:
42
+ # Feature 1 (disease state) can be used for trait - binary classification between normal/SSc
43
+ # Age and gender are not available in the characteristics
44
+
45
+ # 2.1 Row identifiers
46
+ trait_row = 1 # Feature 1 has disease state info
47
+ age_row = None # Age not available
48
+ gender_row = None # Gender not available
49
+
50
+ # 2.2 Conversion functions
51
+ def convert_trait(value: str) -> Optional[int]:
52
+ if pd.isna(value):
53
+ return None
54
+ value = value.split(': ')[1].strip().lower()
55
+ if value == 'normal':
56
+ return 0
57
+ elif value == 'systemic sclerosis':
58
+ return 1
59
+ return None
60
+
61
+ def convert_age(value: str) -> Optional[float]:
62
+ return None # Not used
63
+
64
+ def convert_gender(value: str) -> Optional[int]:
65
+ return None # Not used
66
+
67
+ # 3. Save initial metadata
68
+ is_trait_available = trait_row is not None
69
+ _ = validate_and_save_cohort_info(
70
+ is_final=False,
71
+ cohort=cohort,
72
+ info_path=json_path,
73
+ is_gene_available=is_gene_available,
74
+ is_trait_available=is_trait_available
75
+ )
76
+
77
+ # 4. Extract clinical features since trait_row is not None
78
+ clinical_df = geo_select_clinical_features(
79
+ clinical_df=clinical_data,
80
+ trait=trait,
81
+ trait_row=trait_row,
82
+ convert_trait=convert_trait,
83
+ age_row=age_row,
84
+ convert_age=convert_age,
85
+ gender_row=gender_row,
86
+ convert_gender=convert_gender
87
+ )
88
+
89
+ # Preview the processed data
90
+ preview = preview_df(clinical_df)
91
+ print("Preview of clinical data:")
92
+ print(preview)
93
+
94
+ # Save clinical data
95
+ clinical_df.to_csv(out_clinical_data_file)
96
+ # Extract gene expression data from matrix file
97
+ gene_data = get_genetic_data(matrix_file)
98
+
99
+ # Print first 20 row IDs and shape of data to help debug
100
+ print("Shape of gene expression data:", gene_data.shape)
101
+ print("\nFirst few rows of data:")
102
+ print(gene_data.head())
103
+ print("\nFirst 20 gene/probe identifiers:")
104
+ print(gene_data.index[:20])
105
+
106
+ # Inspect a snippet of raw file to verify identifier format
107
+ import gzip
108
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
109
+ lines = []
110
+ for i, line in enumerate(f):
111
+ if "!series_matrix_table_begin" in line:
112
+ # Get the next 5 lines after the marker
113
+ for _ in range(5):
114
+ lines.append(next(f).strip())
115
+ break
116
+ print("\nFirst few lines after matrix marker in raw file:")
117
+ for line in lines:
118
+ print(line)
119
+ # From the gene identifiers shown (e.g., A_23_P100001), these are Agilent probe IDs, not human gene symbols
120
+ # Agilent probe IDs need to be mapped to official gene symbols for standardization and interpretation
121
+ requires_gene_mapping = True
122
+ # Get file paths using library function
123
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
124
+
125
+ # Extract gene annotation from SOFT file and get meaningful data
126
+ gene_annotation = get_gene_annotation(soft_file)
127
+
128
+ # Preview gene annotation data
129
+ print("Gene annotation shape:", gene_annotation.shape)
130
+ print("\nGene annotation preview:")
131
+ print(preview_df(gene_annotation))
132
+
133
+ print("\nNumber of non-null values in each column:")
134
+ print(gene_annotation.count())
135
+
136
+ # Print example rows showing the mapping information columns
137
+ print("\nSample mapping columns ('ID' and 'GENE_SYMBOL'):")
138
+ print(gene_annotation[['ID', 'GENE_SYMBOL']].head().to_string())
139
+
140
+ print("\nNote: Gene mapping will use:")
141
+ print("'ID' column: Probe identifiers")
142
+ print("'GENE_SYMBOL' column: Contains gene symbol information")
143
+ # Extract mapping information
144
+ gene_mapping = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
145
+
146
+ # Apply gene mapping to convert probe-level data to gene-level data
147
+ gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=gene_mapping)
148
+
149
+ # Save the gene expression data
150
+ gene_data.to_csv(out_gene_data_file)
151
+ # 1. Normalize gene symbols
152
+ gene_data = normalize_gene_symbols_in_index(gene_data)
153
+
154
+ # Save normalized gene data
155
+ gene_data.to_csv(out_gene_data_file)
156
+
157
+ # 2. Link clinical and genetic data
158
+ try:
159
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
160
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
161
+
162
+ # 3. Handle missing values
163
+ linked_data = handle_missing_values(linked_data, trait)
164
+
165
+ # 4. Determine if features are biased
166
+ is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
167
+
168
+ # 5. Validate and save cohort info
169
+ is_usable = validate_and_save_cohort_info(
170
+ is_final=True,
171
+ cohort=cohort,
172
+ info_path=json_path,
173
+ is_gene_available=True,
174
+ is_trait_available=True,
175
+ is_biased=is_trait_biased,
176
+ df=linked_data,
177
+ note="Gene expression data successfully mapped and linked with clinical features"
178
+ )
179
+
180
+ # 6. Save linked data if usable
181
+ if is_usable:
182
+ linked_data.to_csv(out_data_file)
183
+
184
+ except Exception as e:
185
+ print(f"Error in data linking and processing: {str(e)}")
186
+ is_usable = validate_and_save_cohort_info(
187
+ is_final=True,
188
+ cohort=cohort,
189
+ info_path=json_path,
190
+ is_gene_available=True,
191
+ is_trait_available=True,
192
+ is_biased=True,
193
+ df=pd.DataFrame(),
194
+ note=f"Data processing failed: {str(e)}"
195
+ )
p3/preprocess/Age-Related_Macular_Degeneration/code/GSE62224.py ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Age-Related_Macular_Degeneration"
6
+ cohort = "GSE62224"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Age-Related_Macular_Degeneration"
10
+ in_cohort_dir = "../DATA/GEO/Age-Related_Macular_Degeneration/GSE62224"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/GSE62224.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/gene_data/GSE62224.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/clinical_data/GSE62224.csv"
16
+ json_path = "./output/preprocess/3/Age-Related_Macular_Degeneration/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
+ # This dataset contains genome-wide microarray expression data according to Series_overall_design
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+
42
+ # 2.1 Data Availability
43
+ # For trait (passage number), the key is 2
44
+ trait_row = 2
45
+ # Age data is not available
46
+ age_row = None
47
+ # Gender data is not available
48
+ gender_row = None
49
+
50
+ # 2.2 Data Type Conversion Functions
51
+ def convert_trait(x):
52
+ """Convert passage number to binary - where passage 0 maps to 0 (early), passage 5 maps to 1 (late)"""
53
+ if x is None or ':' not in x:
54
+ return None
55
+ value = int(x.split(': ')[1])
56
+ if value == 0:
57
+ return 0
58
+ elif value == 5:
59
+ return 1
60
+ return None
61
+
62
+ def convert_age(x):
63
+ """No age data available"""
64
+ return None
65
+
66
+ def convert_gender(x):
67
+ """No gender data available"""
68
+ return None
69
+
70
+ # 3. Save initial metadata
71
+ validate_and_save_cohort_info(
72
+ is_final=False,
73
+ cohort=cohort,
74
+ info_path=json_path,
75
+ is_gene_available=is_gene_available,
76
+ is_trait_available=trait_row is not None
77
+ )
78
+
79
+ # 4. Extract clinical features
80
+ if trait_row is not None:
81
+ selected_clinical = 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 results
93
+ print("Preview of selected clinical features:")
94
+ print(preview_df(selected_clinical))
95
+
96
+ # Save to CSV
97
+ selected_clinical.to_csv(out_clinical_data_file)
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 identifiers, we see they are simple numeric IDs (12, 13, 14, etc)
122
+ # These are not standard human gene symbols, which would be alphabetic codes like BRCA1, TP53, etc.
123
+ # Therefore, these identifiers will need to be mapped to proper gene symbols
124
+
125
+ requires_gene_mapping = True
126
+ # Get file paths using library function
127
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
128
+
129
+ # Extract gene annotation from SOFT file and get meaningful data
130
+ gene_annotation = get_gene_annotation(soft_file)
131
+
132
+ # Preview gene annotation data
133
+ print("Gene annotation shape:", gene_annotation.shape)
134
+ print("\nGene annotation preview:")
135
+ print(preview_df(gene_annotation))
136
+
137
+ print("\nNumber of non-null values in each column:")
138
+ print(gene_annotation.count())
139
+
140
+ # Print example rows showing the mapping information columns
141
+ print("\nSample mapping columns ('ID' and 'GENE_SYMBOL'):")
142
+ print(gene_annotation[['ID', 'GENE_SYMBOL']].head().to_string())
143
+
144
+ print("\nNote: Gene mapping will use:")
145
+ print("'ID' column: Probe identifiers")
146
+ print("'GENE_SYMBOL' column: Contains gene symbol information")
147
+ # 1. Get gene mapping between ID and GENE_SYMBOL columns
148
+ mapping_df = get_gene_mapping(gene_annotation, 'ID', 'GENE_SYMBOL')
149
+
150
+ # 2. Apply mapping to convert probe level measurements to gene expression data
151
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
152
+
153
+ # 3. Normalize gene symbols using NCBI synonym data
154
+ gene_data = normalize_gene_symbols_in_index(gene_data)
155
+
156
+ print("Shape of mapped gene expression data:", gene_data.shape)
157
+ print("\nFirst few rows of mapped data:")
158
+ print(gene_data.head())
159
+ print("\nFirst 20 gene symbols:")
160
+ print(gene_data.index[:20])
161
+
162
+ # Save gene expression data
163
+ gene_data.to_csv(out_gene_data_file)
164
+ # 1. Normalize gene symbols
165
+ gene_data = normalize_gene_symbols_in_index(gene_data)
166
+
167
+ # Save normalized gene data
168
+ gene_data.to_csv(out_gene_data_file)
169
+
170
+ # 2. Link clinical and genetic data
171
+ try:
172
+ clinical_data = pd.read_csv(out_clinical_data_file, index_col=0)
173
+ linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
174
+
175
+ # 3. Handle missing values
176
+ linked_data = handle_missing_values(linked_data, trait)
177
+
178
+ # 4. Determine if features are biased
179
+ is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
180
+
181
+ # 5. Validate and save cohort info
182
+ is_usable = validate_and_save_cohort_info(
183
+ is_final=True,
184
+ cohort=cohort,
185
+ info_path=json_path,
186
+ is_gene_available=True,
187
+ is_trait_available=True,
188
+ is_biased=is_trait_biased,
189
+ df=linked_data,
190
+ note="Gene expression data successfully mapped and linked with clinical features"
191
+ )
192
+
193
+ # 6. Save linked data if usable
194
+ if is_usable:
195
+ linked_data.to_csv(out_data_file)
196
+
197
+ except Exception as e:
198
+ print(f"Error in data linking and processing: {str(e)}")
199
+ is_usable = validate_and_save_cohort_info(
200
+ is_final=True,
201
+ cohort=cohort,
202
+ info_path=json_path,
203
+ is_gene_available=True,
204
+ is_trait_available=True,
205
+ is_biased=True,
206
+ df=pd.DataFrame(),
207
+ note=f"Data processing failed: {str(e)}"
208
+ )
p3/preprocess/Age-Related_Macular_Degeneration/code/GSE67899.py ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Age-Related_Macular_Degeneration"
6
+ cohort = "GSE67899"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Age-Related_Macular_Degeneration"
10
+ in_cohort_dir = "../DATA/GEO/Age-Related_Macular_Degeneration/GSE67899"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/GSE67899.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/gene_data/GSE67899.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/clinical_data/GSE67899.csv"
16
+ json_path = "./output/preprocess/3/Age-Related_Macular_Degeneration/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
+ is_gene_available = True # The series title suggests the study involves RPE cell changes, which implies gene expression data
38
+
39
+ # 2. Data Availability and Type Conversion
40
+ # 2.1 Trait row identification
41
+ # Looking at treatment values - some samples have pathway inhibitors (A83-01, Thiazovivin etc) vs control (None/DMSO)
42
+ trait_row = 5 # Treatment info in Feature 5
43
+
44
+ # Age and gender data not available in sample characteristics
45
+ age_row = None
46
+ gender_row = None
47
+
48
+ # 2.2 Data Type Conversion Functions
49
+ def convert_trait(x):
50
+ """Convert treatment status to binary:
51
+ 0 for control (None/DMSO)
52
+ 1 for any treatment"""
53
+ if not isinstance(x, str):
54
+ return None
55
+ value = x.split(': ')[-1].strip()
56
+ if value in ['None', 'DMSO']:
57
+ return 0
58
+ elif 'treatment' in x.lower(): # Any other treatment
59
+ return 1
60
+ return None
61
+
62
+ def convert_age(x):
63
+ return None # Not available
64
+
65
+ def convert_gender(x):
66
+ return None # Not available
67
+
68
+ # 3. Save Metadata
69
+ is_trait_available = trait_row is not None
70
+ validate_and_save_cohort_info(is_final=False,
71
+ cohort=cohort,
72
+ info_path=json_path,
73
+ is_gene_available=is_gene_available,
74
+ is_trait_available=is_trait_available)
75
+
76
+ # 4. Clinical Feature Extraction
77
+ if trait_row is not None:
78
+ clinical_features = geo_select_clinical_features(
79
+ clinical_df=clinical_data,
80
+ trait=trait,
81
+ trait_row=trait_row,
82
+ convert_trait=convert_trait,
83
+ age_row=age_row,
84
+ convert_age=convert_age,
85
+ gender_row=gender_row,
86
+ convert_gender=convert_gender
87
+ )
88
+
89
+ # Preview the processed clinical data
90
+ print("Preview of clinical features:")
91
+ print(preview_df(clinical_features))
92
+
93
+ # Save clinical features to CSV
94
+ clinical_features.to_csv(out_clinical_data_file)
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
+ # Looking at the identifiers (numbered 12, 13, 14...), these are clearly probe IDs
119
+ # rather than human gene symbols. We will need to map them to gene symbols.
120
+ requires_gene_mapping = True
121
+ # Get file paths using library function
122
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
123
+
124
+ # Extract gene annotation from SOFT file and get meaningful data
125
+ gene_annotation = get_gene_annotation(soft_file)
126
+
127
+ # Preview gene annotation data
128
+ print("Gene annotation shape:", gene_annotation.shape)
129
+ print("\nGene annotation preview:")
130
+ print(preview_df(gene_annotation))
131
+
132
+ print("\nNumber of non-null values in each column:")
133
+ print(gene_annotation.count())
134
+
135
+ # Print example rows showing the mapping information columns
136
+ print("\nSample mapping columns ('ID' and 'GENE_SYMBOL'):")
137
+ print(gene_annotation[['ID', 'GENE_SYMBOL']].head().to_string())
138
+
139
+ print("\nNote: Gene mapping will use:")
140
+ print("'ID' column: Probe identifiers")
141
+ print("'GENE_SYMBOL' column: Contains gene symbol information")
142
+ # Extract probe-to-gene mapping using the 'ID' and 'GENE_SYMBOL' columns
143
+ mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
144
+
145
+ # Convert probe-level expression to gene-level expression
146
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
147
+
148
+ # Print some stats about the conversion
149
+ print("Shape after mapping:", gene_data.shape)
150
+ print("\nFirst few rows:")
151
+ print(gene_data.head())
152
+ print("\nFirst 20 gene symbols:")
153
+ print(gene_data.index[:20])
154
+ # 1. Normalize gene symbols
155
+ gene_data = normalize_gene_symbols_in_index(gene_data)
156
+
157
+ # Save normalized gene data
158
+ gene_data.to_csv(out_gene_data_file)
159
+
160
+ # 2. Link clinical and genetic data
161
+ try:
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. Determine if features are biased
169
+ is_trait_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_trait_biased,
179
+ df=linked_data,
180
+ note="Gene expression data successfully mapped and linked with clinical features"
181
+ )
182
+
183
+ # 6. Save linked data if usable
184
+ if is_usable:
185
+ linked_data.to_csv(out_data_file)
186
+
187
+ except Exception as e:
188
+ print(f"Error in data linking and processing: {str(e)}")
189
+ is_usable = validate_and_save_cohort_info(
190
+ is_final=True,
191
+ cohort=cohort,
192
+ info_path=json_path,
193
+ is_gene_available=True,
194
+ is_trait_available=True,
195
+ is_biased=True,
196
+ df=pd.DataFrame(),
197
+ note=f"Data processing failed: {str(e)}"
198
+ )
p3/preprocess/Age-Related_Macular_Degeneration/code/TCGA.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Age-Related_Macular_Degeneration"
6
+
7
+ # Input paths
8
+ tcga_root_dir = "../DATA/TCGA"
9
+
10
+ # Output paths
11
+ out_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/TCGA.csv"
12
+ out_gene_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/gene_data/TCGA.csv"
13
+ out_clinical_data_file = "./output/preprocess/3/Age-Related_Macular_Degeneration/clinical_data/TCGA.csv"
14
+ json_path = "./output/preprocess/3/Age-Related_Macular_Degeneration/cohort_info.json"
15
+
16
+ # 1. Review subdirectories for matching trait data
17
+ subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))]
18
+
19
+ # No suitable directory exists for age-related macular degeneration
20
+ # Mark data as unavailable
21
+ cohort = "TCGA_no_suitable_cohort"
22
+
23
+ # Record unavailability and end preprocessing
24
+ validate_and_save_cohort_info(
25
+ is_final=False,
26
+ cohort=cohort,
27
+ info_path=json_path,
28
+ is_gene_available=False,
29
+ is_trait_available=False
30
+ )
p3/preprocess/Age-Related_Macular_Degeneration/cohort_info.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"GSE67899": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": false, "has_gender": false, "sample_size": 44, "note": "Gene expression data successfully mapped and linked with clinical features"}, "GSE62224": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": false, "has_gender": false, "sample_size": 44, "note": "Gene expression data successfully mapped and linked with clinical features"}, "GSE45485": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": false, "has_gender": false, "sample_size": 83, "note": "Gene expression data successfully mapped and linked with clinical features"}, "GSE43176": {"is_usable": false, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": true, "has_age": false, "has_gender": false, "sample_size": 108, "note": "Gene expression data successfully mapped and linked with clinical features"}, "GSE38662": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "Dataset contains hESC cell line data, not AMD patient data. No trait information available."}, "GSE29801": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": true, "sample_size": 260, "note": "Gene expression data successfully mapped and linked with clinical features"}, "TCGA_no_suitable_cohort": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}}
p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE38662.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6147f738acbd48f34cbe802c44c18958ba214292efc67f7bf703d30f26f1ccc5
3
+ size 13209116
p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE43176.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:027ea925d47b7a2258a7223d85776848df79e4ec3ff133f9b82175915ac6dba7
3
+ size 10613167
p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE45485.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE62224.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Age-Related_Macular_Degeneration/gene_data/GSE67899.csv ADDED
The diff for this file is too large to render. See raw diff
 
p3/preprocess/Alcohol_Flush_Reaction/code/GSE133228.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Alcohol_Flush_Reaction"
6
+ cohort = "GSE133228"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Alcohol_Flush_Reaction"
10
+ in_cohort_dir = "../DATA/GEO/Alcohol_Flush_Reaction/GSE133228"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/3/Alcohol_Flush_Reaction/GSE133228.csv"
14
+ out_gene_data_file = "./output/preprocess/3/Alcohol_Flush_Reaction/gene_data/GSE133228.csv"
15
+ out_clinical_data_file = "./output/preprocess/3/Alcohol_Flush_Reaction/clinical_data/GSE133228.csv"
16
+ json_path = "./output/preprocess/3/Alcohol_Flush_Reaction/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 background info mentioning STAG2, CTCF and gene regulation/expression
38
+ is_gene_available = True
39
+
40
+ # 2.1 Data Availability
41
+ # Trait data not available in sample characteristics
42
+ trait_row = None
43
+
44
+ # Age is in Feature 1
45
+ age_row = 1
46
+
47
+ # Gender is in Feature 0
48
+ gender_row = 0
49
+
50
+ # 2.2 Data Type Conversion Functions
51
+ def convert_trait(x):
52
+ # No trait data
53
+ return None
54
+
55
+ def convert_age(x):
56
+ # Extract age value after colon and convert to float
57
+ try:
58
+ age = float(x.split(': ')[1])
59
+ return age
60
+ except:
61
+ return None
62
+
63
+ def convert_gender(x):
64
+ # Extract gender and convert to binary (female=0, male=1)
65
+ try:
66
+ gender = x.split(': ')[1].lower()
67
+ if gender == 'female':
68
+ return 0
69
+ elif gender == 'male':
70
+ return 1
71
+ else:
72
+ return None
73
+ except:
74
+ return None
75
+
76
+ # 3. Save metadata
77
+ validate_and_save_cohort_info(
78
+ is_final=False,
79
+ cohort=cohort,
80
+ info_path=json_path,
81
+ is_gene_available=is_gene_available,
82
+ is_trait_available=(trait_row is not None)
83
+ )
84
+
85
+ # 4. Skip clinical feature extraction since trait_row is None
86
+ # Extract gene expression data from matrix file
87
+ gene_data = get_genetic_data(matrix_file)
88
+
89
+ # Print first 20 row IDs and shape of data to help debug
90
+ print("Shape of gene expression data:", gene_data.shape)
91
+ print("\nFirst few rows of data:")
92
+ print(gene_data.head())
93
+ print("\nFirst 20 gene/probe identifiers:")
94
+ print(gene_data.index[:20])
95
+
96
+ # Inspect a snippet of raw file to verify identifier format
97
+ import gzip
98
+ with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
99
+ lines = []
100
+ for i, line in enumerate(f):
101
+ if "!series_matrix_table_begin" in line:
102
+ # Get the next 5 lines after the marker
103
+ for _ in range(5):
104
+ lines.append(next(f).strip())
105
+ break
106
+ print("\nFirst few lines after matrix marker in raw file:")
107
+ for line in lines:
108
+ print(line)
109
+ # The gene identifiers appear to be probe IDs from a microarray platform (ending in "_at")
110
+ # rather than standard human gene symbols. These need to be mapped to gene symbols.
111
+ requires_gene_mapping = True
112
+ # Get file paths using library function
113
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
114
+
115
+ # Extract gene annotation from SOFT file and get meaningful data
116
+ gene_annotation = get_gene_annotation(soft_file)
117
+
118
+ # Preview gene annotation data
119
+ print("Gene annotation shape:", gene_annotation.shape)
120
+ print("\nGene annotation preview:")
121
+ print(preview_df(gene_annotation))
122
+
123
+ print("\nNumber of non-null values in each column:")
124
+ print(gene_annotation.count())
125
+
126
+ # Print example rows showing the mapping information columns
127
+ print("\nSample mapping columns ('ID' and 'Description'):")
128
+ print(gene_annotation[['ID', 'Description']].head().to_string())
129
+
130
+ print("\nNote: Gene mapping will use:")
131
+ print("'ID' column: Probe identifiers")
132
+ print("'Description' column: Contains gene information from which symbols can be extracted")
133
+ # Get gene mapping dataframe from annotation data
134
+ mapping_data = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Description')
135
+
136
+ # Apply gene mapping to convert probe-level data to gene expression data
137
+ gene_data = apply_gene_mapping(gene_data, mapping_data)
138
+ # 1. Normalize gene symbols
139
+ gene_data = normalize_gene_symbols_in_index(gene_data)
140
+
141
+ # Save normalized gene data
142
+ gene_data.to_csv(out_gene_data_file)
143
+
144
+ # 2-6. Handle case where clinical data is not available
145
+ # Create empty dataframe with same columns as gene_data for validation
146
+ df_for_validation = pd.DataFrame(columns=gene_data.columns)
147
+
148
+ is_usable = validate_and_save_cohort_info(
149
+ is_final=True,
150
+ cohort=cohort,
151
+ info_path=json_path,
152
+ is_gene_available=True,
153
+ is_trait_available=False,
154
+ is_biased=True, # Dataset is biased since it lacks trait data
155
+ df=df_for_validation, # Empty dataframe with correct structure
156
+ note="Dataset contains gene expression data but lacks clinical trait information needed for analysis"
157
+ )
p3/preprocess/Alcohol_Flush_Reaction/code/TCGA.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Alcohol_Flush_Reaction"
6
+
7
+ # Input paths
8
+ tcga_root_dir = "../DATA/TCGA"
9
+
10
+ # Output paths
11
+ out_data_file = "./output/preprocess/3/Alcohol_Flush_Reaction/TCGA.csv"
12
+ out_gene_data_file = "./output/preprocess/3/Alcohol_Flush_Reaction/gene_data/TCGA.csv"
13
+ out_clinical_data_file = "./output/preprocess/3/Alcohol_Flush_Reaction/clinical_data/TCGA.csv"
14
+ json_path = "./output/preprocess/3/Alcohol_Flush_Reaction/cohort_info.json"
15
+
16
+ # 1. Review subdirectories for matching trait data
17
+ subdirs = [d for d in os.listdir(tcga_root_dir) if os.path.isdir(os.path.join(tcga_root_dir, d))]
18
+
19
+ # No suitable directory exists for age-related macular degeneration
20
+ # Mark data as unavailable
21
+ cohort = "TCGA_no_suitable_cohort"
22
+
23
+ # Record unavailability and end preprocessing
24
+ validate_and_save_cohort_info(
25
+ is_final=False,
26
+ cohort=cohort,
27
+ info_path=json_path,
28
+ is_gene_available=False,
29
+ is_trait_available=False
30
+ )
p3/preprocess/Alcohol_Flush_Reaction/cohort_info.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"GSE133228": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "Dataset contains gene expression data but lacks clinical trait information needed for analysis"}, "TCGA_no_suitable_cohort": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}}
p3/preprocess/Alcohol_Flush_Reaction/gene_data/GSE133228.csv ADDED
The diff for this file is too large to render. See raw diff