Liu-Hy commited on
Commit
1ff5953
·
verified ·
1 Parent(s): 1f724fe

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 +23 -0
  2. p1/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/gene_data/TCGA.csv +3 -0
  3. p1/preprocess/Kidney_Clear_Cell_Carcinoma/TCGA.csv +3 -0
  4. p1/preprocess/Kidney_Clear_Cell_Carcinoma/gene_data/TCGA.csv +3 -0
  5. p1/preprocess/Liver_Cancer/TCGA.csv +3 -0
  6. p1/preprocess/Liver_Cancer/gene_data/TCGA.csv +3 -0
  7. p1/preprocess/Liver_cirrhosis/TCGA.csv +3 -0
  8. p1/preprocess/Liver_cirrhosis/gene_data/TCGA.csv +3 -0
  9. p1/preprocess/Mesothelioma/GSE68950.csv +3 -0
  10. p1/preprocess/Mesothelioma/gene_data/GSE68950.csv +3 -0
  11. p1/preprocess/Mesothelioma/gene_data/TCGA.csv +3 -0
  12. p1/preprocess/Metabolic_Rate/gene_data/GSE101492.csv +3 -0
  13. p1/preprocess/Metabolic_Rate/gene_data/GSE61225.csv +3 -0
  14. p1/preprocess/Migraine/GSE67311.csv +3 -0
  15. p1/preprocess/Migraine/gene_data/GSE67311.csv +3 -0
  16. p1/preprocess/Mitochondrial_Disorders/GSE30933.csv +3 -0
  17. p1/preprocess/Mitochondrial_Disorders/gene_data/GSE30933.csv +3 -0
  18. p1/preprocess/Mitochondrial_Disorders/gene_data/GSE42986.csv +0 -0
  19. p1/preprocess/Multiple_Endocrine_Neoplasia_Type_2/GSE19987.csv +0 -0
  20. p1/preprocess/Multiple_Endocrine_Neoplasia_Type_2/code/GSE19987.py +178 -0
  21. p1/preprocess/Multiple_Endocrine_Neoplasia_Type_2/code/TCGA.py +14 -0
  22. p1/preprocess/Multiple_Endocrine_Neoplasia_Type_2/gene_data/GSE19987.csv +0 -0
  23. p1/preprocess/Multiple_sclerosis/GSE131281.csv +3 -0
  24. p1/preprocess/Multiple_sclerosis/GSE131282.csv +3 -0
  25. p1/preprocess/Multiple_sclerosis/GSE135511.csv +0 -0
  26. p1/preprocess/Multiple_sclerosis/clinical_data/GSE131281.csv +4 -0
  27. p1/preprocess/Multiple_sclerosis/clinical_data/GSE131282.csv +4 -0
  28. p1/preprocess/Multiple_sclerosis/clinical_data/GSE135511.csv +2 -0
  29. p1/preprocess/Multiple_sclerosis/code/GSE131279.py +134 -0
  30. p1/preprocess/Multiple_sclerosis/code/GSE131281.py +173 -0
  31. p1/preprocess/Multiple_sclerosis/code/GSE131282.py +175 -0
  32. p1/preprocess/Multiple_sclerosis/code/GSE135511.py +161 -0
  33. p1/preprocess/Multiple_sclerosis/code/GSE141381.py +159 -0
  34. p1/preprocess/Multiple_sclerosis/code/GSE141804.py +144 -0
  35. p1/preprocess/Multiple_sclerosis/code/GSE146383.py +135 -0
  36. p1/preprocess/Multiple_sclerosis/code/GSE189788.py +150 -0
  37. p1/preprocess/Multiple_sclerosis/code/GSE193442.py +99 -0
  38. p1/preprocess/Multiple_sclerosis/code/GSE203241.py +144 -0
  39. p1/preprocess/Multiple_sclerosis/code/TCGA.py +61 -0
  40. p1/preprocess/Multiple_sclerosis/cohort_info.json +1 -0
  41. p1/preprocess/Multiple_sclerosis/gene_data/GSE131279.csv +3 -0
  42. p1/preprocess/Multiple_sclerosis/gene_data/GSE131281.csv +3 -0
  43. p1/preprocess/Multiple_sclerosis/gene_data/GSE135511.csv +0 -0
  44. p1/preprocess/Multiple_sclerosis/gene_data/GSE141381.csv +3 -0
  45. p1/preprocess/Multiple_sclerosis/gene_data/GSE141804.csv +0 -0
  46. p1/preprocess/Multiple_sclerosis/gene_data/GSE146383.csv +3 -0
  47. p1/preprocess/Multiple_sclerosis/gene_data/GSE203241.csv +0 -0
  48. p1/preprocess/Obesity/GSE181339.csv +0 -0
  49. p1/preprocess/Obesity/GSE84046.csv +3 -0
  50. p1/preprocess/Obesity/clinical_data/GSE123086.csv +4 -0
.gitattributes CHANGED
@@ -1271,3 +1271,26 @@ p1/preprocess/Mesothelioma/gene_data/GSE107754.csv filter=lfs diff=lfs merge=lfs
1271
  p1/preprocess/Mesothelioma/gene_data/GSE131027.csv filter=lfs diff=lfs merge=lfs -text
1272
  p1/preprocess/Metabolic_Rate/GSE61225.csv filter=lfs diff=lfs merge=lfs -text
1273
  p1/preprocess/Metabolic_Rate/GSE101492.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1271
  p1/preprocess/Mesothelioma/gene_data/GSE131027.csv filter=lfs diff=lfs merge=lfs -text
1272
  p1/preprocess/Metabolic_Rate/GSE61225.csv filter=lfs diff=lfs merge=lfs -text
1273
  p1/preprocess/Metabolic_Rate/GSE101492.csv filter=lfs diff=lfs merge=lfs -text
1274
+ p1/preprocess/Mesothelioma/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1275
+ p1/preprocess/Kidney_Clear_Cell_Carcinoma/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1276
+ p1/preprocess/Liver_Cancer/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1277
+ p1/preprocess/Metabolic_Rate/gene_data/GSE61225.csv filter=lfs diff=lfs merge=lfs -text
1278
+ p1/preprocess/Metabolic_Rate/gene_data/GSE101492.csv filter=lfs diff=lfs merge=lfs -text
1279
+ p1/preprocess/Kidney_Clear_Cell_Carcinoma/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1280
+ p1/preprocess/Liver_Cancer/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1281
+ p1/preprocess/Migraine/GSE67311.csv filter=lfs diff=lfs merge=lfs -text
1282
+ p1/preprocess/Migraine/gene_data/GSE67311.csv filter=lfs diff=lfs merge=lfs -text
1283
+ p1/preprocess/Mitochondrial_Disorders/GSE30933.csv filter=lfs diff=lfs merge=lfs -text
1284
+ p1/preprocess/Mesothelioma/GSE68950.csv filter=lfs diff=lfs merge=lfs -text
1285
+ p1/preprocess/Multiple_sclerosis/GSE131281.csv filter=lfs diff=lfs merge=lfs -text
1286
+ p1/preprocess/Mitochondrial_Disorders/gene_data/GSE30933.csv filter=lfs diff=lfs merge=lfs -text
1287
+ p1/preprocess/Liver_cirrhosis/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1288
+ p1/preprocess/Multiple_sclerosis/gene_data/GSE131279.csv filter=lfs diff=lfs merge=lfs -text
1289
+ p1/preprocess/Multiple_sclerosis/gene_data/GSE141381.csv filter=lfs diff=lfs merge=lfs -text
1290
+ p1/preprocess/Mesothelioma/gene_data/GSE68950.csv filter=lfs diff=lfs merge=lfs -text
1291
+ p1/preprocess/Multiple_sclerosis/gene_data/GSE146383.csv filter=lfs diff=lfs merge=lfs -text
1292
+ p1/preprocess/Multiple_sclerosis/GSE131282.csv filter=lfs diff=lfs merge=lfs -text
1293
+ p1/preprocess/Multiple_sclerosis/gene_data/GSE131281.csv filter=lfs diff=lfs merge=lfs -text
1294
+ p1/preprocess/Obesity/GSE84046.csv filter=lfs diff=lfs merge=lfs -text
1295
+ p1/preprocess/Liver_cirrhosis/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1296
+ p1/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
p1/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/gene_data/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:96c986e5a3d878aa4fe521d4d98915e250b7f0cdb97445343a36450f05661288
3
+ size 339317879
p1/preprocess/Kidney_Clear_Cell_Carcinoma/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f180db87ae4fb3e7fb90d2a9b093e8d31b1094daa4c5a599e116ff7adda383a
3
+ size 182068747
p1/preprocess/Kidney_Clear_Cell_Carcinoma/gene_data/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad56d64496541ee0872327215eca3da6769d5e7ccee6a3d8759e9c00555c00ed
3
+ size 182067513
p1/preprocess/Liver_Cancer/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9a684d83efae816e03c0691e0ab29cc7c975b511bbc6275aa6ee8478d0c1c48
3
+ size 126898641
p1/preprocess/Liver_Cancer/gene_data/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fda4b7e0eb1b7d3ae8ef43544fbcfc1289fc40b4c948499e0a55cde48b1cf574
3
+ size 126894803
p1/preprocess/Liver_cirrhosis/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8300dea21510062fb8f3f9d9d892babfc8897728cb48b3a0479c8ee77c2638a3
3
+ size 126898644
p1/preprocess/Liver_cirrhosis/gene_data/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fda4b7e0eb1b7d3ae8ef43544fbcfc1289fc40b4c948499e0a55cde48b1cf574
3
+ size 126894803
p1/preprocess/Mesothelioma/GSE68950.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21d20f875a1b841ffac9a946ddeaf6d225a140041dfeb79ffaa0207764abc127
3
+ size 65414218
p1/preprocess/Mesothelioma/gene_data/GSE68950.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:54bc2618961cab9be52e2e0e50a219b5df5559caeddf32ce819e42341796dec5
3
+ size 65411017
p1/preprocess/Mesothelioma/gene_data/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f385b762e7b0334f1439581a6ec7717d33d79162ccf22c050bd6eaf23ab39ecf
3
+ size 26282027
p1/preprocess/Metabolic_Rate/gene_data/GSE101492.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c5adf567d60c34738bdf5a6466eb55d82139f6b33ceedd28a8d6de575089e9d5
3
+ size 22356219
p1/preprocess/Metabolic_Rate/gene_data/GSE61225.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48bc07e8b37b35fecb1c6a1c1a4ba16583326afa9becbd526d97f068140712ad
3
+ size 15566705
p1/preprocess/Migraine/GSE67311.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:beeae2b2ac954549ef43eecab5d5fed26119577f9b5827551e33427d578e1237
3
+ size 31000729
p1/preprocess/Migraine/gene_data/GSE67311.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdc80550137956d622d2ec9a5baefec581baacd4c28f983c456b9d007fbd70b7
3
+ size 33088822
p1/preprocess/Mitochondrial_Disorders/GSE30933.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0059fce8cabfd403b5a939e7a644b8a2677b6c43e0629381b3561262b2d76219
3
+ size 30581053
p1/preprocess/Mitochondrial_Disorders/gene_data/GSE30933.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ce2431b3620e47f214e5e85db1b34b434bf915536f3056e35901f04def55ca06
3
+ size 30580601
p1/preprocess/Mitochondrial_Disorders/gene_data/GSE42986.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Multiple_Endocrine_Neoplasia_Type_2/GSE19987.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Multiple_Endocrine_Neoplasia_Type_2/code/GSE19987.py ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_Endocrine_Neoplasia_Type_2"
6
+ cohort = "GSE19987"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_Endocrine_Neoplasia_Type_2"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_Endocrine_Neoplasia_Type_2/GSE19987"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_Endocrine_Neoplasia_Type_2/GSE19987.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_Endocrine_Neoplasia_Type_2/gene_data/GSE19987.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_Endocrine_Neoplasia_Type_2/clinical_data/GSE19987.csv"
16
+ json_path = "./output/preprocess/1/Multiple_Endocrine_Neoplasia_Type_2/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Gene Expression Data Availability
37
+ is_gene_available = True # This dataset likely contains gene expression data based on the background info.
38
+
39
+ # 2. Variable Availability and Data Type Conversion
40
+
41
+ # 2.1 Identify the row keys for trait, age, and gender
42
+ # - We found "MEN2A" in the 'genetic class:' row, which is indexed as 1.
43
+ # - Age and gender data are not available in the sample characteristics dictionary.
44
+ trait_row = 1
45
+ age_row = None
46
+ gender_row = None
47
+
48
+ # 2.2 Define data type conversions
49
+
50
+ def convert_trait(value: str) -> Optional[int]:
51
+ """
52
+ Convert the genetic class field to 1 for MEN2A and 0 for any other genetic class.
53
+ Unknown or malformed values become None.
54
+ """
55
+ parts = value.split(':')
56
+ if len(parts) < 2:
57
+ return None
58
+ val = parts[1].strip().upper()
59
+ return 1 if val == 'MEN2A' else 0
60
+
61
+ convert_age = None # Not applicable because age data is not available
62
+ convert_gender = None # Not applicable because gender data is not available
63
+
64
+ # 3. Save Metadata (initial filtering)
65
+ is_trait_available = (trait_row is not None)
66
+
67
+ is_usable = validate_and_save_cohort_info(
68
+ is_final=False,
69
+ cohort=cohort,
70
+ info_path=json_path,
71
+ is_gene_available=is_gene_available,
72
+ is_trait_available=is_trait_available
73
+ )
74
+
75
+ # 4. Clinical Feature Extraction (only if trait data is available)
76
+ if trait_row is not None:
77
+ clinical_features_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=convert_age,
84
+ gender_row=gender_row,
85
+ convert_gender=convert_gender
86
+ )
87
+
88
+ # Preview and save the clinical features
89
+ preview_info = preview_df(clinical_features_df, n=5, max_items=200)
90
+ print(preview_info)
91
+
92
+ clinical_features_df.to_csv(out_clinical_data_file, index=False)
93
+ # STEP3
94
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
95
+ gene_data = get_genetic_data(matrix_file)
96
+
97
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
98
+ print(gene_data.index[:20])
99
+ # Based on the provided identifiers (e.g., '1007_s_at', '1053_at', etc.), these are Affymetrix probe IDs.
100
+ # They are not direct gene symbols. Therefore, gene mapping is required.
101
+ print("requires_gene_mapping = True")
102
+ # STEP5
103
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
104
+ gene_annotation = get_gene_annotation(soft_file)
105
+
106
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
107
+ print("Gene annotation preview:")
108
+ print(preview_df(gene_annotation))
109
+ # STEP6: Gene Identifier Mapping
110
+ # 1. Identify the corresponding columns in the annotation DataFrame for the probes and gene symbols.
111
+ # From the preview, 'ID' matches the gene expression data index, and 'Gene Symbol' appears to contain the gene symbols.
112
+
113
+ mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
114
+
115
+ # 2. Map probe-level measurements to gene-level expression data.
116
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
117
+
118
+ # For verification, print out some info about the resulting gene_data
119
+ print("Gene mapping complete. Gene expression data now has shape:", gene_data.shape)
120
+ print("First 20 gene symbols after mapping:", list(gene_data.index[:20]))
121
+ import os
122
+ import pandas as pd
123
+
124
+ # STEP 7: Data Normalization and Linking
125
+
126
+ # First, check if the clinical CSV file exists. If it does not, we cannot proceed with trait-based linking.
127
+ if not os.path.exists(out_clinical_data_file):
128
+ # No trait data file => dataset is not usable for trait analysis
129
+ df_null = pd.DataFrame()
130
+ is_biased = True # Arbitrary boolean to satisfy function requirement
131
+ validate_and_save_cohort_info(
132
+ is_final=True,
133
+ cohort=cohort,
134
+ info_path=json_path,
135
+ is_gene_available=True,
136
+ is_trait_available=False,
137
+ is_biased=is_biased,
138
+ df=df_null,
139
+ note="No trait data file found; dataset not usable for trait analysis."
140
+ )
141
+
142
+ else:
143
+ # 1. Normalize the mapped gene expression data using known gene symbol synonyms, then save.
144
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
145
+ normalized_gene_data.to_csv(out_gene_data_file)
146
+
147
+ # 2. Load the previously extracted clinical CSV.
148
+ selected_clinical_df = pd.read_csv(out_clinical_data_file)
149
+ # If we had a single-row trait, rename row 0 to the trait name (example usage).
150
+ selected_clinical_df = selected_clinical_df.rename(index={0: trait})
151
+
152
+ # Combine these as our final clinical data; in this dataset, we only have trait info (if any).
153
+ combined_clinical_df = selected_clinical_df
154
+
155
+ # Link the clinical and genetic data by matching sample IDs in columns.
156
+ linked_data = geo_link_clinical_genetic_data(combined_clinical_df, normalized_gene_data)
157
+
158
+ # 3. Handle missing values in the linked data (drop incomplete rows/columns, then impute).
159
+ processed_data = handle_missing_values(linked_data, trait)
160
+
161
+ # 4. Check trait bias and remove any biased demographic features (if any).
162
+ trait_biased, processed_data = judge_and_remove_biased_features(processed_data, trait)
163
+
164
+ # 5. Final validation and metadata saving.
165
+ is_usable = validate_and_save_cohort_info(
166
+ is_final=True,
167
+ cohort=cohort,
168
+ info_path=json_path,
169
+ is_gene_available=True,
170
+ is_trait_available=True,
171
+ is_biased=trait_biased,
172
+ df=processed_data,
173
+ note="Completed trait-based preprocessing."
174
+ )
175
+
176
+ # 6. If final dataset is usable, save. Otherwise, skip.
177
+ if is_usable:
178
+ processed_data.to_csv(out_data_file)
p1/preprocess/Multiple_Endocrine_Neoplasia_Type_2/code/TCGA.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_Endocrine_Neoplasia_Type_2"
6
+
7
+ # Input paths
8
+ tcga_root_dir = "../DATA/TCGA"
9
+
10
+ # Output paths
11
+ out_data_file = "./output/preprocess/1/Multiple_Endocrine_Neoplasia_Type_2/TCGA.csv"
12
+ out_gene_data_file = "./output/preprocess/1/Multiple_Endocrine_Neoplasia_Type_2/gene_data/TCGA.csv"
13
+ out_clinical_data_file = "./output/preprocess/1/Multiple_Endocrine_Neoplasia_Type_2/clinical_data/TCGA.csv"
14
+ json_path = "./output/preprocess/1/Multiple_Endocrine_Neoplasia_Type_2/cohort_info.json"
p1/preprocess/Multiple_Endocrine_Neoplasia_Type_2/gene_data/GSE19987.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Multiple_sclerosis/GSE131281.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:646958207969cdade9c0dc0a32ef2795f0be6453daaae0fa17449c749f97c54e
3
+ size 22200784
p1/preprocess/Multiple_sclerosis/GSE131282.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7b2eb15314ae67d1a1c34239abfea5c32955bf4bc0b8f5af316f63c0c080415
3
+ size 38310482
p1/preprocess/Multiple_sclerosis/GSE135511.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Multiple_sclerosis/clinical_data/GSE131281.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ GSM3768613,GSM3768614,GSM3768616,GSM3768617,GSM3768619,GSM3768620,GSM3768621,GSM3768623,GSM3768624,GSM3768625,GSM3768626,GSM3768627,GSM3768628,GSM3768629,GSM3768630,GSM3768631,GSM3768632,GSM3768633,GSM3768634,GSM3768635,GSM3768636,GSM3768637,GSM3768638,GSM3768639,GSM3768640,GSM3768641,GSM3768642,GSM3768643,GSM3768644,GSM3768645,GSM3768646,GSM3768647,GSM3768648,GSM3768649,GSM3768650,GSM3768651,GSM3768652,GSM3768653,GSM3768654,GSM3768655,GSM3768656,GSM3768657,GSM3768658,GSM3768659,GSM3768660,GSM3768661,GSM3768662,GSM3768663,GSM3768664,GSM3768665,GSM3768666,GSM3768667,GSM3768668,GSM3768669,GSM3768670,GSM3768671,GSM3768672,GSM3768673,GSM3768674,GSM3768675,GSM3768676,GSM3768677,GSM3768678,GSM3768679,GSM3768680,GSM3768681,GSM3768682,GSM3768683,GSM3768684,GSM3768685,GSM3768686,GSM3768687,GSM3768688,GSM3768689,GSM3768690,GSM3768691,GSM3768692,GSM3768693,GSM3768694,GSM3768695,GSM3768696,GSM3768697,GSM3768698,GSM3768699,GSM3768700,GSM3768701,GSM3768702,GSM3768703,GSM3768704,GSM3768705,GSM3768706,GSM3768707,GSM3768708,GSM3768709,GSM3768710,GSM3768711,GSM3768712,GSM3768713,GSM3768714,GSM3768715,GSM3768716,GSM3768717,GSM3768718,GSM3768719,GSM3768720,GSM3768721
2
+ 1.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.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,0.0,0.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,1.0,1.0,0.0,1.0
3
+ 58.0,92.0,56.0,35.0,80.0,56.0,84.0,75.0,38.0,59.0,77.0,58.0,78.0,64.0,56.0,95.0,60.0,78.0,75.0,58.0,78.0,75.0,51.0,56.0,64.0,77.0,58.0,78.0,60.0,39.0,47.0,87.0,75.0,88.0,64.0,75.0,35.0,58.0,39.0,56.0,61.0,78.0,84.0,73.0,59.0,75.0,47.0,78.0,77.0,39.0,60.0,77.0,49.0,89.0,75.0,58.0,58.0,84.0,70.0,47.0,77.0,58.0,56.0,60.0,75.0,58.0,88.0,92.0,45.0,59.0,84.0,78.0,84.0,60.0,75.0,58.0,58.0,49.0,51.0,58.0,78.0,77.0,35.0,84.0,49.0,75.0,75.0,61.0,75.0,78.0,47.0,58.0,39.0,78.0,77.0,87.0,35.0,45.0,84.0,70.0,58.0,73.0,45.0,78.0,64.0,58.0
4
+ 0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0
p1/preprocess/Multiple_sclerosis/clinical_data/GSE131282.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ ,GSM3768507,GSM3768508,GSM3768509,GSM3768510,GSM3768511,GSM3768512,GSM3768513,GSM3768514,GSM3768515,GSM3768516,GSM3768517,GSM3768518,GSM3768519,GSM3768520,GSM3768521,GSM3768522,GSM3768523,GSM3768524,GSM3768525,GSM3768526,GSM3768527,GSM3768528,GSM3768529,GSM3768530,GSM3768531,GSM3768532,GSM3768533,GSM3768534,GSM3768535,GSM3768536,GSM3768537,GSM3768538,GSM3768539,GSM3768540,GSM3768541,GSM3768542,GSM3768543,GSM3768544,GSM3768545,GSM3768546,GSM3768547,GSM3768548,GSM3768549,GSM3768550,GSM3768551,GSM3768552,GSM3768553,GSM3768554,GSM3768555,GSM3768556,GSM3768557,GSM3768558,GSM3768559,GSM3768560,GSM3768561,GSM3768562,GSM3768563,GSM3768564,GSM3768565,GSM3768566,GSM3768567,GSM3768568,GSM3768569,GSM3768570,GSM3768571,GSM3768572,GSM3768573,GSM3768574,GSM3768575,GSM3768576,GSM3768577,GSM3768578,GSM3768579,GSM3768580,GSM3768581,GSM3768582,GSM3768583,GSM3768584,GSM3768613,GSM3768614,GSM3768616,GSM3768617,GSM3768619,GSM3768620,GSM3768621,GSM3768623,GSM3768624,GSM3768625,GSM3768626,GSM3768627,GSM3768628,GSM3768629,GSM3768630,GSM3768631,GSM3768632,GSM3768633,GSM3768634,GSM3768635,GSM3768636,GSM3768637,GSM3768638,GSM3768639,GSM3768640,GSM3768641,GSM3768642,GSM3768643,GSM3768644,GSM3768645,GSM3768646,GSM3768647,GSM3768648,GSM3768649,GSM3768650,GSM3768651,GSM3768652,GSM3768653,GSM3768654,GSM3768655,GSM3768656,GSM3768657,GSM3768658,GSM3768659,GSM3768660,GSM3768661,GSM3768662,GSM3768663,GSM3768664,GSM3768665,GSM3768666,GSM3768667,GSM3768668,GSM3768669,GSM3768670,GSM3768671,GSM3768672,GSM3768673,GSM3768674,GSM3768675,GSM3768676,GSM3768677,GSM3768678,GSM3768679,GSM3768680,GSM3768681,GSM3768682,GSM3768683,GSM3768684,GSM3768685,GSM3768686,GSM3768687,GSM3768688,GSM3768689,GSM3768690,GSM3768691,GSM3768692,GSM3768693,GSM3768694,GSM3768695,GSM3768696,GSM3768697,GSM3768698,GSM3768699,GSM3768700,GSM3768701,GSM3768702,GSM3768703,GSM3768704,GSM3768705,GSM3768706,GSM3768707,GSM3768708,GSM3768709,GSM3768710,GSM3768711,GSM3768712,GSM3768713,GSM3768714,GSM3768715,GSM3768716,GSM3768717,GSM3768718,GSM3768719,GSM3768720,GSM3768721
2
+ Multiple_sclerosis,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
3
+ Age,58.0,59.0,80.0,63.0,47.0,78.0,59.0,88.0,45.0,45.0,61.0,50.0,54.0,78.0,80.0,61.0,45.0,69.0,39.0,58.0,78.0,56.0,44.0,58.0,78.0,58.0,58.0,80.0,58.0,56.0,78.0,42.0,58.0,58.0,50.0,78.0,92.0,54.0,71.0,58.0,39.0,78.0,78.0,56.0,58.0,54.0,45.0,59.0,45.0,77.0,78.0,56.0,44.0,58.0,78.0,34.0,58.0,63.0,78.0,78.0,58.0,92.0,58.0,69.0,58.0,49.0,47.0,78.0,45.0,58.0,70.0,56.0,58.0,71.0,45.0,78.0,78.0,49.0,58.0,92.0,56.0,35.0,80.0,56.0,84.0,75.0,38.0,59.0,77.0,58.0,78.0,64.0,56.0,95.0,60.0,78.0,75.0,58.0,78.0,75.0,51.0,56.0,64.0,77.0,58.0,78.0,60.0,39.0,47.0,87.0,75.0,88.0,64.0,75.0,35.0,58.0,39.0,56.0,61.0,78.0,84.0,73.0,59.0,75.0,47.0,78.0,77.0,39.0,60.0,77.0,49.0,89.0,75.0,58.0,58.0,84.0,70.0,47.0,77.0,58.0,56.0,60.0,75.0,58.0,88.0,92.0,45.0,59.0,84.0,78.0,84.0,60.0,75.0,58.0,58.0,49.0,51.0,58.0,78.0,77.0,35.0,84.0,49.0,75.0,75.0,61.0,75.0,78.0,47.0,58.0,39.0,78.0,77.0,87.0,35.0,45.0,84.0,70.0,58.0,73.0,45.0,78.0,64.0,58.0
4
+ Gender,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.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,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0
p1/preprocess/Multiple_sclerosis/clinical_data/GSE135511.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ GSM4013300,GSM4013301,GSM4013302,GSM4013303,GSM4013304,GSM4013305,GSM4013306,GSM4013307,GSM4013308,GSM4013309,GSM4013310,GSM4013311,GSM4013312,GSM4013313,GSM4013314,GSM4013315,GSM4013316,GSM4013317,GSM4013318,GSM4013319,GSM4013320,GSM4013321,GSM4013322,GSM4013323,GSM4013324,GSM4013325,GSM4013326,GSM4013327,GSM4013328,GSM4013329,GSM4013330,GSM4013331,GSM4013332,GSM4013333,GSM4013334,GSM4013335,GSM4013336,GSM4013337,GSM4013338,GSM4013339,GSM4013340,GSM4013341,GSM4013342,GSM4013343,GSM4013344,GSM4013345,GSM4013346,GSM4013347,GSM4013348,GSM4013349
2
+ 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
p1/preprocess/Multiple_sclerosis/code/GSE131279.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE131279"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE131279"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE131279.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE131279.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE131279.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Decide if the dataset likely contains gene expression data
37
+ is_gene_available = True # Based on the series summary, gene expression was analyzed
38
+
39
+ # 2. Determine data availability for trait, age, gender
40
+ # For this dataset, all samples are MS (subtypes only), so there's no variability in "Multiple_sclerosis" status.
41
+ trait_row = None # No separate control vs MS column; "ms type" subtypes do not provide control vs MS info
42
+
43
+ # We see that age is given under key "2" as "age at death: <value>"
44
+ age_row = 2
45
+
46
+ # We see that gender is given under key "1" as "Sex: F" or "Sex: M"
47
+ gender_row = 1
48
+
49
+ # 2.2 Define conversion functions
50
+ def convert_trait(value: str):
51
+ # Trait data is not available in a variable sense, so always None
52
+ return None
53
+
54
+ def convert_age(value: str):
55
+ # Example: "age at death: 58" -> 58.0
56
+ parts = value.split(':', 1)
57
+ if len(parts) < 2:
58
+ return None
59
+ raw_value = parts[1].strip()
60
+ try:
61
+ return float(raw_value)
62
+ except ValueError:
63
+ return None
64
+
65
+ def convert_gender(value: str):
66
+ # Example: "Sex: F" -> 0, "Sex: M" -> 1
67
+ parts = value.split(':', 1)
68
+ if len(parts) < 2:
69
+ return None
70
+ gender_str = parts[1].strip().upper()
71
+ if gender_str == 'F':
72
+ return 0
73
+ elif gender_str == 'M':
74
+ return 1
75
+ return None
76
+
77
+ # 3. Save metadata with initial filtering
78
+ is_trait_available = (trait_row is not None)
79
+ _ = validate_and_save_cohort_info(
80
+ is_final=False,
81
+ cohort=cohort,
82
+ info_path=json_path,
83
+ is_gene_available=is_gene_available,
84
+ is_trait_available=is_trait_available
85
+ )
86
+
87
+ # 4. Since trait_row is None, we skip the clinical feature extraction step
88
+ # STEP3
89
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
90
+ gene_data = get_genetic_data(matrix_file)
91
+
92
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
93
+ print(gene_data.index[:20])
94
+ # The given identifiers (e.g., 'ILMN_1343048') are Illumina probe IDs, not standard human gene symbols.
95
+ # Therefore, they need to be mapped to gene symbols.
96
+ requires_gene_mapping = True
97
+ # STEP5
98
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
99
+ gene_annotation = get_gene_annotation(soft_file)
100
+
101
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
102
+ print("Gene annotation preview:")
103
+ print(preview_df(gene_annotation))
104
+ # STEP: Gene Identifier Mapping
105
+ # 1. Identify the columns in 'gene_annotation' that match the gene expression data index (ID) and the gene symbols (Symbol).
106
+ # 2. Extract these columns and create a gene mapping dataframe.
107
+ mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
108
+
109
+ # 3. Convert probe-level data to gene-level data using the mapping, distributing multiple-gene mappings and summing up.
110
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
111
+ # STEP 7
112
+
113
+ # 1. Normalize the gene expression data to standard gene symbols and save the result.
114
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
115
+ normalized_gene_data.to_csv(out_gene_data_file)
116
+ print("Normalized gene expression data saved to:", out_gene_data_file)
117
+
118
+ # Since trait_row is None from a previous step, we know trait data is not available for this cohort.
119
+ # We therefore skip linking with clinical data and final data handling, because there's no trait column.
120
+
121
+ is_gene_available = True # As determined earlier
122
+ is_trait_available = False # No trait data found or it's all the same subtype with no control
123
+
124
+ # According to the library, for cohorts that fail trait requirements, we do not finalize.
125
+ # 2. Save metadata with initial filtering (is_final=False). This logs that trait data is unavailable.
126
+ is_usable = validate_and_save_cohort_info(
127
+ is_final=False,
128
+ cohort=cohort,
129
+ info_path=json_path,
130
+ is_gene_available=is_gene_available,
131
+ is_trait_available=is_trait_available
132
+ )
133
+
134
+ print("No trait data available, dataset deemed not usable for association studies. Skipping final data save.")
p1/preprocess/Multiple_sclerosis/code/GSE131281.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE131281"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE131281"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE131281.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE131281.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE131281.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1) Decide if the dataset likely contains gene expression data
37
+ # Based on the background info about differential gene expression in cortical grey matter,
38
+ # it appears to be a gene expression dataset (not miRNA-only or methylation).
39
+ is_gene_available = True
40
+
41
+ # 2) Identify data availability for trait, age, and gender
42
+ # From inspection:
43
+ # - The "patient id: M##" vs "patient id: C##" in row 0 can be used to determine MS vs control.
44
+ # - Row 2, "age at death: ##", indicates the age.
45
+ # - Row 1, "Sex: F" or "Sex: M", indicates gender.
46
+ trait_row = 0
47
+ age_row = 2
48
+ gender_row = 1
49
+
50
+ # 2.2) Define data type conversion functions
51
+ def convert_trait(x: str):
52
+ # Example input: "patient id: M06"
53
+ val = x.split(":", 1)[-1].strip() # e.g. "M06"
54
+ if val.startswith("M"):
55
+ return 1
56
+ elif val.startswith("C"):
57
+ return 0
58
+ else:
59
+ return None
60
+
61
+ def convert_age(x: str):
62
+ # Example input: "age at death: 58"
63
+ val = x.split(":", 1)[-1].strip() # e.g. "58"
64
+ if val.isdigit():
65
+ return float(val)
66
+ else:
67
+ return None
68
+
69
+ def convert_gender(x: str):
70
+ # Example input: "Sex: F"
71
+ val = x.split(":", 1)[-1].strip() # e.g. "F"
72
+ if val.upper().startswith("F"):
73
+ return 0
74
+ elif val.upper().startswith("M"):
75
+ return 1
76
+ else:
77
+ return None
78
+
79
+ # 3) Conduct initial filtering and save metadata
80
+ is_trait_available = (trait_row is not None)
81
+ is_usable = validate_and_save_cohort_info(
82
+ is_final=False,
83
+ cohort=cohort,
84
+ info_path=json_path,
85
+ is_gene_available=is_gene_available,
86
+ is_trait_available=is_trait_available
87
+ )
88
+
89
+ # 4) If trait info is available, extract clinical features and save
90
+ if trait_row is not None:
91
+ selected_clinical = geo_select_clinical_features(
92
+ clinical_df=clinical_data,
93
+ trait=trait,
94
+ trait_row=trait_row,
95
+ convert_trait=convert_trait,
96
+ age_row=age_row,
97
+ convert_age=convert_age,
98
+ gender_row=gender_row,
99
+ convert_gender=convert_gender
100
+ )
101
+ # Preview clinical data
102
+ preview = preview_df(selected_clinical)
103
+ print("Clinical data preview:", preview)
104
+
105
+ # Save the extracted clinical data
106
+ selected_clinical.to_csv(out_clinical_data_file, index=False)
107
+ # STEP3
108
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
109
+ gene_data = get_genetic_data(matrix_file)
110
+
111
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
112
+ print(gene_data.index[:20])
113
+ # Based on the observation of ILMN probe identifiers, they are not standard human gene symbols.
114
+ # Therefore, they require mapping to gene symbols.
115
+
116
+ print("\nrequires_gene_mapping = True")
117
+ # STEP5
118
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
119
+ gene_annotation = get_gene_annotation(soft_file)
120
+
121
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
122
+ print("Gene annotation preview:")
123
+ print(preview_df(gene_annotation))
124
+ # STEP: Gene Identifier Mapping
125
+
126
+ # 1) From our examination of the gene annotation preview and the gene expression data,
127
+ # we see that the "ID" column in gene_annotation matches the probe IDs in gene_data,
128
+ # and the "Symbol" column in gene_annotation stores gene symbols.
129
+
130
+ # 2) Get the gene mapping dataframe using "ID" for the probe column and "Symbol" for the gene symbol column.
131
+ mapping_df = get_gene_mapping(gene_annotation, prob_col="ID", gene_col="Symbol")
132
+
133
+ # 3) Map probe-level measurements to gene-level data using the apply_gene_mapping function.
134
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
135
+
136
+ # (Optional) For quick observation, let's print a small preview of the mapped gene_data
137
+ print("Mapped gene_data preview:")
138
+ print(gene_data.head())
139
+ # STEP 7
140
+
141
+ # 1. Normalize the gene expression data to standard gene symbols and save the result.
142
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
143
+ normalized_gene_data.to_csv(out_gene_data_file)
144
+ print("Normalized gene expression data saved to:", out_gene_data_file)
145
+
146
+ # 2. Link the clinical and genetic data on sample IDs.
147
+ # Replace "selected_clinical_df" with the correct variable name "selected_clinical"
148
+ linked_data = geo_link_clinical_genetic_data(selected_clinical, normalized_gene_data)
149
+
150
+ # 3. Handle missing values in the linked data.
151
+ linked_data = handle_missing_values(df=linked_data, trait_col=trait)
152
+
153
+ # 4. Determine whether the trait and demographics (if any) are severely biased.
154
+ is_biased, linked_data = judge_and_remove_biased_features(df=linked_data, trait=trait)
155
+
156
+ # 5. Perform final quality validation and save metadata.
157
+ is_usable = validate_and_save_cohort_info(
158
+ is_final=True,
159
+ cohort=cohort,
160
+ info_path=json_path,
161
+ is_gene_available=True,
162
+ is_trait_available=True,
163
+ is_biased=is_biased,
164
+ df=linked_data,
165
+ note="Dataset includes multiple sclerosis trait from post-mortem motor cortex samples."
166
+ )
167
+
168
+ # 6. If the dataset is usable, save the final linked data.
169
+ if is_usable:
170
+ linked_data.to_csv(out_data_file)
171
+ print("Final linked data saved to:", out_data_file)
172
+ else:
173
+ print("Dataset is deemed not usable. No final data saved.")
p1/preprocess/Multiple_sclerosis/code/GSE131282.py ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE131282"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE131282"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE131282.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE131282.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE131282.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Determine if gene expression data is available
37
+ is_gene_available = True # Based on the description, this dataset likely contains gene expression data.
38
+
39
+ # 2. Identify the availability of trait, age, and gender
40
+ # and define their corresponding row indices. Use None if not available.
41
+ trait_row = 4 # "ms type: ..." or "pm simple: ..." can be used to infer MS vs. control
42
+ age_row = 2 # "age at death: ..."
43
+ gender_row = 1 # "Sex: F" or "Sex: M"
44
+
45
+ # 2.2 Define the conversion functions
46
+ def convert_trait(x: str):
47
+ parts = x.split(":", 1)
48
+ if len(parts) < 2:
49
+ return None
50
+ val = parts[1].strip().lower()
51
+ # If the string contains "ms type:", interpret as MS=1; if "pm simple:", interpret as control=0.
52
+ if "ms type:" in x.lower():
53
+ # Even if it contains '?', it's still MS, just unknown subtype.
54
+ return 1
55
+ elif "pm simple:" in x.lower():
56
+ return 0
57
+ else:
58
+ return None
59
+
60
+ def convert_age(x: str):
61
+ parts = x.split(":", 1)
62
+ if len(parts) < 2:
63
+ return None
64
+ val = parts[1].strip()
65
+ if val == "?":
66
+ return None
67
+ try:
68
+ return float(val)
69
+ except ValueError:
70
+ return None
71
+
72
+ def convert_gender(x: str):
73
+ parts = x.split(":", 1)
74
+ if len(parts) < 2:
75
+ return None
76
+ val = parts[1].strip().lower()
77
+ if val == "f":
78
+ return 0
79
+ elif val == "m":
80
+ return 1
81
+ else:
82
+ return None
83
+
84
+ # 3. Initial filtering and save metadata
85
+ is_trait_available = (trait_row is not None)
86
+ _ = validate_and_save_cohort_info(
87
+ is_final=False,
88
+ cohort=cohort,
89
+ info_path=json_path,
90
+ is_gene_available=is_gene_available,
91
+ is_trait_available=is_trait_available
92
+ )
93
+
94
+ # 4. If trait data is available, extract clinical features
95
+ if trait_row is not None:
96
+ selected_clinical_df = geo_select_clinical_features(
97
+ clinical_df=clinical_data,
98
+ trait=trait,
99
+ trait_row=trait_row,
100
+ convert_trait=convert_trait,
101
+ age_row=age_row,
102
+ convert_age=convert_age,
103
+ gender_row=gender_row,
104
+ convert_gender=convert_gender
105
+ )
106
+ preview = preview_df(selected_clinical_df)
107
+ print(preview)
108
+ selected_clinical_df.to_csv(out_clinical_data_file)
109
+ # STEP3
110
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
111
+ gene_data = get_genetic_data(matrix_file)
112
+
113
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
114
+ print(gene_data.index[:20])
115
+ # These are Illumina microarray probe identifiers (e.g., ILMN_1343048).
116
+ # They are not official human gene symbols and require mapping to gene symbols.
117
+ requires_gene_mapping = True
118
+ # STEP5
119
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
120
+ gene_annotation = get_gene_annotation(soft_file)
121
+
122
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
123
+ print("Gene annotation preview:")
124
+ print(preview_df(gene_annotation))
125
+ # STEP: Gene Identifier Mapping
126
+
127
+ # 1. Identify the columns for probe identifiers and gene symbols in the annotation dataframe
128
+ # From our inspection, the probe identifier column is "ID" and the gene symbol column is "Symbol".
129
+
130
+ mapping_df = get_gene_mapping(
131
+ annotation=gene_annotation,
132
+ prob_col="ID", # Probe/array identifier column
133
+ gene_col="Symbol" # Gene symbol column
134
+ )
135
+
136
+ # 2. Map probe-level expression to gene-level expression
137
+ gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
138
+
139
+ # (Optional) Quick inspection to confirm the gene_data structure
140
+ print("Mapped gene expression DataFrame shape:", gene_data.shape)
141
+ print("First 5 mapped gene names:", gene_data.index[:5].tolist())
142
+ # STEP7
143
+
144
+ # 1. Normalize the gene expression data to standard gene symbols and save the result.
145
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
146
+ normalized_gene_data.to_csv(out_gene_data_file)
147
+ print("Normalized gene expression data saved to:", out_gene_data_file)
148
+
149
+ # 2. Link the clinical and genetic data on sample IDs.
150
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
151
+
152
+ # 3. Handle missing values in the linked data.
153
+ linked_data = handle_missing_values(df=linked_data, trait_col=trait)
154
+
155
+ # 4. Determine whether the trait and demographics (if any) are severely biased.
156
+ is_biased, linked_data = judge_and_remove_biased_features(df=linked_data, trait=trait)
157
+
158
+ # 5. Perform final quality validation and save metadata.
159
+ is_usable = validate_and_save_cohort_info(
160
+ is_final=True,
161
+ cohort=cohort,
162
+ info_path=json_path,
163
+ is_gene_available=True,
164
+ is_trait_available=True,
165
+ is_biased=is_biased,
166
+ df=linked_data,
167
+ note="Dataset includes multiple sclerosis trait from post-mortem motor cortex samples."
168
+ )
169
+
170
+ # 6. If the dataset is usable, save the final linked data.
171
+ if is_usable:
172
+ linked_data.to_csv(out_data_file)
173
+ print("Final linked data saved to:", out_data_file)
174
+ else:
175
+ print("Dataset is deemed not usable. No final data saved.")
p1/preprocess/Multiple_sclerosis/code/GSE135511.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE135511"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE135511"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE135511.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE135511.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE135511.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1) Gene expression data availability
37
+ is_gene_available = True # Based on the series title indicating "Gene expression profiling..."
38
+
39
+ # 2) Variable availability and data type conversion
40
+ # From the sample characteristics dictionary, trait is found at index 0. Age and gender are not present.
41
+ trait_row = 0
42
+ age_row = None
43
+ gender_row = None
44
+
45
+ # Define the conversion functions.
46
+
47
+ def convert_trait(value: str):
48
+ """
49
+ Convert the 'disease state' string to binary:
50
+ 'Healthy Control' -> 0, 'Multiple Sclerosis' -> 1, otherwise None.
51
+ """
52
+ parts = value.split(':')
53
+ if len(parts) < 2:
54
+ return None
55
+ val = parts[1].strip().lower()
56
+ if val == 'healthy control':
57
+ return 0
58
+ elif val == 'multiple sclerosis':
59
+ return 1
60
+ return None
61
+
62
+ def convert_age(value: str):
63
+ """No age data is available, so always return None."""
64
+ return None
65
+
66
+ def convert_gender(value: str):
67
+ """No gender data is available, so always return None."""
68
+ return None
69
+
70
+ # 3) Save metadata (initial filtering)
71
+ is_trait_available = (trait_row is not None)
72
+ is_usable = validate_and_save_cohort_info(
73
+ is_final=False,
74
+ cohort=cohort,
75
+ info_path=json_path,
76
+ is_gene_available=is_gene_available,
77
+ is_trait_available=is_trait_available
78
+ )
79
+
80
+ # 4) Clinical feature extraction if trait data is available
81
+ if trait_row is not None:
82
+ selected_clinical_df = geo_select_clinical_features(
83
+ clinical_data,
84
+ trait=trait,
85
+ trait_row=trait_row,
86
+ convert_trait=convert_trait,
87
+ age_row=age_row,
88
+ convert_age=convert_age,
89
+ gender_row=gender_row,
90
+ convert_gender=convert_gender
91
+ )
92
+
93
+ # Preview the extracted clinical features
94
+ preview_result = preview_df(selected_clinical_df)
95
+ print("Preview of selected clinical data:", preview_result)
96
+
97
+ # Save the clinical data to CSV
98
+ selected_clinical_df.to_csv(out_clinical_data_file, index=False)
99
+ # STEP3
100
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
101
+ gene_data = get_genetic_data(matrix_file)
102
+
103
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
104
+ print(gene_data.index[:20])
105
+ # The observed identifiers (ILMN_xxxxxxx) are Illumina probe IDs and are not human gene symbols.
106
+ # Hence, they require mapping to official gene symbols.
107
+ print("requires_gene_mapping = True")
108
+ # STEP5
109
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
110
+ gene_annotation = get_gene_annotation(soft_file)
111
+
112
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
113
+ print("Gene annotation preview:")
114
+ print(preview_df(gene_annotation))
115
+ # STEP6: Gene Identifier Mapping
116
+
117
+ # 1) Identify the columns in the annotation that match the expression data IDs (e.g., "ID")
118
+ # and the columns that contain gene symbols (e.g., "Symbol").
119
+ # 2) Get the gene mapping dataframe from the annotation dataframe.
120
+ mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
121
+
122
+ # 3) Convert probe-level expression data to gene-level expression data.
123
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
124
+
125
+ # Print some information about the resulting gene-level dataframe
126
+ print("Mapped Gene Data Shape:", gene_data.shape)
127
+ print("Sample of mapped Gene Data index:", gene_data.index[:20])
128
+ # STEP7
129
+
130
+ # 1. Normalize the gene expression data to standard gene symbols and save the result.
131
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
132
+ normalized_gene_data.to_csv(out_gene_data_file)
133
+ print("Normalized gene expression data saved to:", out_gene_data_file)
134
+
135
+ # 2. Link the clinical and genetic data on sample IDs.
136
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
137
+
138
+ # 3. Handle missing values in the linked data.
139
+ linked_data = handle_missing_values(df=linked_data, trait_col=trait)
140
+
141
+ # 4. Determine whether the trait and demographics (if any) are severely biased.
142
+ is_biased, linked_data = judge_and_remove_biased_features(df=linked_data, trait=trait)
143
+
144
+ # 5. Perform final quality validation and save metadata.
145
+ is_usable = validate_and_save_cohort_info(
146
+ is_final=True,
147
+ cohort=cohort,
148
+ info_path=json_path,
149
+ is_gene_available=True,
150
+ is_trait_available=True,
151
+ is_biased=is_biased,
152
+ df=linked_data,
153
+ note="Dataset includes multiple sclerosis trait from post-mortem motor cortex samples."
154
+ )
155
+
156
+ # 6. If the dataset is usable, save the final linked data.
157
+ if is_usable:
158
+ linked_data.to_csv(out_data_file)
159
+ print("Final linked data saved to:", out_data_file)
160
+ else:
161
+ print("Dataset is deemed not usable. No final data saved.")
p1/preprocess/Multiple_sclerosis/code/GSE141381.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE141381"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE141381"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE141381.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE141381.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE141381.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1) Gene Expression Data Availability
37
+ is_gene_available = True # Based on the dataset description, it's likely gene expression data.
38
+
39
+ # 2) Variable Availability and Data Type Conversion
40
+ # From the sample characteristics, we see no variation for "Multiple_sclerosis" (all samples have SPMS),
41
+ # so 'trait_row' is None. For 'age', row 1 holds multiple numeric entries. For 'gender', row 0 has two distinct values.
42
+
43
+ trait_row = None # No varying disease status in the sample characteristics
44
+ age_row = 1
45
+ gender_row = 0
46
+
47
+ # Define data conversion functions:
48
+ def convert_trait(x: str) -> Optional[int]:
49
+ """
50
+ Placeholder for trait conversion. No real usage here since trait_row is None.
51
+ """
52
+ return None
53
+
54
+ def convert_age(x: str) -> Optional[float]:
55
+ """
56
+ Convert an 'age: 52' style string to a float.
57
+ If the value is 'unknown' or invalid, return None.
58
+ """
59
+ # Typically split by ':', take the right side, strip and parse
60
+ parts = x.split(':', 1)
61
+ if len(parts) < 2:
62
+ return None
63
+ val = parts[1].strip()
64
+ if val.lower() == "unknown" or val == "":
65
+ return None
66
+ try:
67
+ return float(val)
68
+ except ValueError:
69
+ return None
70
+
71
+ def convert_gender(x: str) -> Optional[int]:
72
+ """
73
+ Convert 'gender: male' or 'gender: female' to 1 or 0, respectively.
74
+ Unknown or invalid entries are None.
75
+ """
76
+ parts = x.split(':', 1)
77
+ if len(parts) < 2:
78
+ return None
79
+ val = parts[1].strip().lower()
80
+ if val == "female":
81
+ return 0
82
+ elif val == "male":
83
+ return 1
84
+ return None
85
+
86
+ # 3) Initial Filtering and Save Metadata
87
+ is_trait_available = (trait_row is not None)
88
+ validate_and_save_cohort_info(
89
+ is_final=False,
90
+ cohort=cohort,
91
+ info_path=json_path,
92
+ is_gene_available=is_gene_available,
93
+ is_trait_available=is_trait_available
94
+ )
95
+
96
+ # 4) Clinical Feature Extraction
97
+ # Since trait_row is None, we skip extraction of clinical features.
98
+ # STEP3
99
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
100
+ gene_data = get_genetic_data(matrix_file)
101
+
102
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
103
+ print(gene_data.index[:20])
104
+ # Observing the provided identifiers, they appear to be probe IDs and not standard human gene symbols.
105
+ # Hence, we conclude that they require mapping to gene symbols.
106
+
107
+ requires_gene_mapping = True
108
+ # STEP5
109
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
110
+ gene_annotation = get_gene_annotation(soft_file)
111
+
112
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
113
+ print("Gene annotation preview:")
114
+ print(preview_df(gene_annotation))
115
+ # STEP: Gene Identifier Mapping
116
+
117
+ # 1) Identify the columns in 'gene_annotation' that match the probe IDs from the expression data
118
+ # and the gene symbol data, respectively. From inspection, 'ID' matches the expression probe IDs,
119
+ # and 'gene_assignment' stores the strings containing gene symbols.
120
+ mapping_df = get_gene_mapping(gene_annotation, 'ID', 'gene_assignment')
121
+
122
+ # 2) Convert probe-level measurements to gene-level sums using the mapping
123
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
124
+
125
+ # 3) Optionally, check the size and a few gene IDs after mapping
126
+ print("Mapped gene_data shape:", gene_data.shape)
127
+ print("First 20 gene symbols after mapping:")
128
+ print(gene_data.index[:20])
129
+ # STEP7
130
+ # Since the trait was determined to be unavailable (trait_row is None),
131
+ # we cannot fully link clinical data or perform trait-based quality checks.
132
+ # However, we still normalize the gene expression data and then perform a final
133
+ # validation call to record the dataset's status (unusable for trait-based analysis).
134
+
135
+ # 1. Normalize the obtained gene data with the 'normalize_gene_symbols_in_index' function from the library.
136
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
137
+ normalized_gene_data.to_csv(out_gene_data_file)
138
+
139
+ print("Normalized gene expression data saved to:", out_gene_data_file)
140
+
141
+ # 2. We have no trait data for linking, so skip steps requiring trait information (linking, missing trait handling, etc.).
142
+
143
+ # 3. Perform final validation to record that the dataset is not usable due to missing trait data.
144
+ # We must pass a dummy dataframe (the normalized gene data transposed) so the function can run in final mode.
145
+ final_df = normalized_gene_data.T
146
+
147
+ validate_and_save_cohort_info(
148
+ is_final=True,
149
+ cohort=cohort,
150
+ info_path=json_path,
151
+ is_gene_available=True, # We do have gene expression data
152
+ is_trait_available=False, # No trait data
153
+ is_biased=False, # Not applicable, but required by the function
154
+ df=final_df,
155
+ note="Trait data is not available, so this dataset is not usable for trait-based analysis."
156
+ )
157
+
158
+ # 4. Because the dataset is not usable (trait is unavailable), we do NOT save any linked data.
159
+ print("Trait data is not available. The dataset is marked unusable for trait-based analysis. No linked data saved.")
p1/preprocess/Multiple_sclerosis/code/GSE141804.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE141804"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE141804"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE141804.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE141804.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE141804.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ import re
37
+
38
+ # 1. Gene Expression Data Availability
39
+ is_gene_available = True # based on the series title mentioning 'Gene Expression'
40
+
41
+ # 2. Variable Availability and Data Type Conversion
42
+ # -------------------------------------------------
43
+ # From the sample characteristics dict, the available keys are 0 for gender, 1 for age.
44
+ # No row appears to contain the trait "Multiple_sclerosis", so trait is not available.
45
+
46
+ trait_row = None
47
+ age_row = 1
48
+ gender_row = 0
49
+
50
+ # Define functions to parse the value after the colon:
51
+ def convert_trait(value: str):
52
+ """
53
+ This dataset does not have explicit or inferable trait information.
54
+ Return None directly.
55
+ """
56
+ return None
57
+
58
+ def convert_age(value: str):
59
+ """
60
+ Extract the numeric part after the colon and convert to float.
61
+ Unknowns are mapped to None.
62
+ """
63
+ # Typically something like: "age (years): 42.50"
64
+ match = re.split(r':\s*', value)
65
+ if len(match) < 2:
66
+ return None
67
+ try:
68
+ return float(match[1])
69
+ except ValueError:
70
+ return None
71
+
72
+ def convert_gender(value: str):
73
+ """
74
+ Convert female => 0, male => 1; unknown => None.
75
+ """
76
+ # Typically something like: "gender: Male"
77
+ match = re.split(r':\s*', value)
78
+ if len(match) < 2:
79
+ return None
80
+ gender_str = match[1].strip().lower()
81
+ if gender_str == 'female':
82
+ return 0
83
+ elif gender_str == 'male':
84
+ return 1
85
+ else:
86
+ return None
87
+
88
+ # 3. Save Metadata (Initial Filtering)
89
+ is_trait_available = (trait_row is not None)
90
+
91
+ is_usable = validate_and_save_cohort_info(
92
+ is_final=False,
93
+ cohort=cohort,
94
+ info_path=json_path,
95
+ is_gene_available=is_gene_available,
96
+ is_trait_available=is_trait_available
97
+ )
98
+
99
+ # 4. Clinical Feature Extraction
100
+ # Since trait_row is None, we skip this step (no clinical feature extraction).
101
+ # STEP3
102
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
103
+ gene_data = get_genetic_data(matrix_file)
104
+
105
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
106
+ print(gene_data.index[:20])
107
+ # Observing the gene identifiers, they appear to be microarray probe set IDs from an Affymetrix platform.
108
+ # Therefore, they are not standard gene symbols and require mapping.
109
+
110
+ print("requires_gene_mapping = True")
111
+ # STEP5
112
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
113
+ gene_annotation = get_gene_annotation(soft_file)
114
+
115
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
116
+ print("Gene annotation preview:")
117
+ print(preview_df(gene_annotation))
118
+ # STEP: Gene Identifier Mapping
119
+
120
+ # 1. Identify the correct columns in the annotation for probe ID and gene symbol.
121
+ # From the preview, "ID" matches the gene_data index, and "Gene Symbol" contains the gene symbols.
122
+
123
+ # 2. Create a gene mapping dataframe.
124
+ mapping_df = get_gene_mapping(gene_annotation, prob_col="ID", gene_col="Gene Symbol")
125
+
126
+ # 3. Apply the mapping to convert probe-level measurements to gene-level expression.
127
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
128
+
129
+ # Optionally, confirm the shape or head of the resulting gene_data
130
+ print("Mapped gene_data dimension:", gene_data.shape)
131
+ print("First few gene symbols in the mapped gene_data:")
132
+ print(gene_data.index[:10])
133
+ # STEP7
134
+ # Since the trait was determined to be unavailable (trait_row is None),
135
+ # we cannot link with clinical data or perform final quality checks based on the trait.
136
+ # However, we can still normalize the gene expression data and save it separately.
137
+
138
+ # 1. Normalize the obtained gene data with the 'normalize_gene_symbols_in_index' function from the library.
139
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
140
+ normalized_gene_data.to_csv(out_gene_data_file)
141
+
142
+ # 2. Trait data is not available. We therefore skip linking with clinical data,
143
+ # handling missing trait, bias checking, and final validation.
144
+ print("Trait data is not available. Steps requiring trait information are skipped.")
p1/preprocess/Multiple_sclerosis/code/GSE146383.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE146383"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE146383"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE146383.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE146383.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE146383.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Determine gene expression data availability
37
+ is_gene_available = True # From background info indicating a transcriptome study
38
+
39
+ # 2.1 Identify data availability
40
+ # No row was found for the trait "Multiple_sclerosis" => treat as not available
41
+ trait_row = None
42
+
43
+ # Row 1 clearly corresponds to age, with multiple distinct values
44
+ age_row = 1
45
+
46
+ # Row 0 describes gender, with "Female" and "Male"
47
+ gender_row = 0
48
+
49
+ # 2.2 Define data type conversion functions
50
+ def convert_trait(value: str):
51
+ """
52
+ Since trait_row is None, this function won't be used.
53
+ But we define it to comply with the specification.
54
+ """
55
+ return None
56
+
57
+ def convert_age(value: str):
58
+ """
59
+ Extract the portion after the colon and parse it as float.
60
+ If parsing fails, return None.
61
+ """
62
+ parts = value.split(':', 1)
63
+ if len(parts) < 2:
64
+ return None
65
+ val_str = parts[1].strip()
66
+ try:
67
+ return float(val_str)
68
+ except ValueError:
69
+ return None
70
+
71
+ def convert_gender(value: str):
72
+ """
73
+ Extract the portion after the colon, convert Female->0, Male->1, otherwise None.
74
+ """
75
+ parts = value.split(':', 1)
76
+ if len(parts) < 2:
77
+ return None
78
+ val_str = parts[1].strip().lower()
79
+ if val_str.startswith('f'):
80
+ return 0
81
+ elif val_str.startswith('m'):
82
+ return 1
83
+ else:
84
+ return None
85
+
86
+ # 3. Save metadata - initial filtering
87
+ is_trait_available = (trait_row is not None)
88
+ _ = validate_and_save_cohort_info(
89
+ is_final=False,
90
+ cohort=cohort,
91
+ info_path=json_path,
92
+ is_gene_available=is_gene_available,
93
+ is_trait_available=is_trait_available
94
+ )
95
+
96
+ # 4. Since trait_row is None, we skip the clinical feature extraction step.
97
+ # STEP3
98
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
99
+ gene_data = get_genetic_data(matrix_file)
100
+
101
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
102
+ print(gene_data.index[:20])
103
+ # Based on the Affymetrix probe set identifiers, these are not human gene symbols and therefore require mapping.
104
+ print("requires_gene_mapping = True")
105
+ # STEP5
106
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
107
+ gene_annotation = get_gene_annotation(soft_file)
108
+
109
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
110
+ print("Gene annotation preview:")
111
+ print(preview_df(gene_annotation))
112
+ # STEP: Gene Identifier Mapping
113
+
114
+ # 1. From the preview, we see that "ID" in gene_annotation matches the probe identifiers in gene_data,
115
+ # and "Gene Symbol" holds the actual gene symbols.
116
+ probe_col = "ID"
117
+ symbol_col = "Gene Symbol"
118
+
119
+ # 2. Generate a mapping DataFrame between probes and gene symbols
120
+ gene_mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=symbol_col)
121
+
122
+ # 3. Convert from probe-level measurements to gene-level expression
123
+ gene_data = apply_gene_mapping(gene_data, gene_mapping_df)
124
+ # STEP7
125
+ # Since the trait was determined to be unavailable (trait_row is None),
126
+ # we cannot link with clinical data or perform final quality checks based on the trait.
127
+ # However, we can still normalize the gene expression data and save it separately.
128
+
129
+ # 1. Normalize the obtained gene data with the 'normalize_gene_symbols_in_index' function from the library.
130
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
131
+ normalized_gene_data.to_csv(out_gene_data_file)
132
+
133
+ # 2. Trait data is not available. We therefore skip linking with clinical data,
134
+ # handling missing trait, bias checking, and final validation.
135
+ print("Trait data is not available. Steps requiring trait information are skipped.")
p1/preprocess/Multiple_sclerosis/code/GSE189788.py ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE189788"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE189788"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE189788.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE189788.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE189788.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Determine gene expression data availability
37
+ is_gene_available = True # Affymetrix HU-133A-2 is a standard gene expression array
38
+
39
+ # 2. Identify data availability for trait, age, and gender
40
+ # and define the corresponding row keys
41
+ # Here, all samples have the same trait ("multiple sclerosis"), so it's not useful for associational studies.
42
+ trait_row = None
43
+ age_row = 2
44
+ gender_row = 3
45
+
46
+ # 2.2 Define conversion functions for trait, age, and gender
47
+ def convert_trait(value: str):
48
+ """
49
+ Dummy conversion function for trait.
50
+ Although trait_row is None for this dataset (meaning no variability),
51
+ the function is provided to fulfill the requirement.
52
+ """
53
+ val_str = value.split(':')[-1].strip().lower()
54
+ # If the dataset had multiple values, we could convert them to 0/1 accordingly.
55
+ if val_str == "multiple sclerosis":
56
+ return 1
57
+ return None
58
+
59
+ def convert_age(value: str):
60
+ """
61
+ Convert the age string (e.g., 'age(years): 43') into a float.
62
+ Unknown or invalid values become None.
63
+ """
64
+ val_str = value.split(':')[-1].strip()
65
+ try:
66
+ return float(val_str)
67
+ except ValueError:
68
+ return None
69
+
70
+ def convert_gender(value: str):
71
+ """
72
+ Convert the gender string (e.g., 'gender: female') to binary (female=0, male=1).
73
+ Unknown values become None.
74
+ """
75
+ val_str = value.split(':')[-1].strip().lower()
76
+ if val_str == "female":
77
+ return 0
78
+ elif val_str == "male":
79
+ return 1
80
+ return None
81
+
82
+ # 3. Conduct initial filtering and save metadata
83
+ is_trait_available = (trait_row is not None)
84
+ validate_and_save_cohort_info(
85
+ is_final=False,
86
+ cohort=cohort,
87
+ info_path=json_path,
88
+ is_gene_available=is_gene_available,
89
+ is_trait_available=is_trait_available
90
+ )
91
+
92
+ # 4. Clinical feature extraction is skipped because trait_row is None
93
+ # STEP3
94
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
95
+ gene_data = get_genetic_data(matrix_file)
96
+
97
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
98
+ print(gene_data.index[:20])
99
+ # Observing the identifiers ('1007_s_at', '1053_at', etc.), they appear to be Affymetrix probe set IDs, not gene symbols.
100
+ # Therefore, they will require mapping to gene symbols.
101
+ print("requires_gene_mapping = True")
102
+ # STEP5
103
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
104
+ gene_annotation = get_gene_annotation(soft_file)
105
+
106
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
107
+ print("Gene annotation preview:")
108
+ print(preview_df(gene_annotation))
109
+ # STEP: Gene Identifier Mapping
110
+
111
+ # 1. Identify the appropriate columns in 'gene_annotation' that match the probe identifiers in 'gene_data.index'
112
+ # and provide gene symbols.
113
+ probe_col = "ID"
114
+ gene_symbol_col = "Gene Symbol"
115
+
116
+ # 2. Construct a mapping DataFrame between the probe identifier and the gene symbol.
117
+ mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
118
+
119
+ # 3. Convert probe-level data to gene-level expression by distributing expression values among mapped genes.
120
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
121
+ # STEP7
122
+ # Since trait_row is None, we have no usable trait data for linking or further clinical analysis.
123
+ # Nevertheless, we still normalize the gene symbols. Then we finalize the metadata to indicate
124
+ # that the dataset is not usable for trait-based analysis. We do not proceed with linking or
125
+ # saving any "linked" data as there is no trait to link.
126
+
127
+ import pandas as pd
128
+
129
+ # 1. Normalize gene symbols in the obtained gene data with the 'normalize_gene_symbols_in_index' function.
130
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
131
+ normalized_gene_data.to_csv(out_gene_data_file)
132
+
133
+ # 2. Because trait data is not available (trait_row is None), skip clinical-genetic linking,
134
+ # missing-value handling, bias checks, and saving any linked data.
135
+
136
+ # 3. Conduct final validation to record that the dataset does not contain trait data.
137
+ # Provide a dummy DataFrame and a placeholder is_biased value to satisfy function requirements.
138
+ dummy_df = pd.DataFrame()
139
+ validate_and_save_cohort_info(
140
+ is_final=True,
141
+ cohort=cohort,
142
+ info_path=json_path,
143
+ is_gene_available=True, # We do have gene expression data
144
+ is_trait_available=False, # Trait not available for analysis
145
+ is_biased=False, # Placeholder
146
+ df=dummy_df,
147
+ note="Trait not available; dataset skipped for trait-based analysis."
148
+ )
149
+
150
+ # Since the dataset is not usable for trait-based analysis, do not save any linked data.
p1/preprocess/Multiple_sclerosis/code/GSE193442.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE193442"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE193442"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE193442.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE193442.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE193442.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # Step 1. Gene Expression Data Availability
37
+ # From the background info ("Transcriptional profiling..."), we infer it is likely gene expression data.
38
+ is_gene_available = True
39
+
40
+ # Step 2. Variable Availability and Data Type Conversion
41
+ # Sample characteristics dictionary:
42
+ # {0: ['tissue: PBMC'], 1: ['cell type: KIR+ CD8 T']}
43
+ #
44
+ # We do not find any key indicating the trait "Multiple_sclerosis", age, or gender.
45
+ # Hence all these rows are None.
46
+
47
+ trait_row = None
48
+ age_row = None
49
+ gender_row = None
50
+
51
+ # Define data conversion functions (they won't be applied since rows are None, but are required by the specification).
52
+ def convert_trait(value: str):
53
+ """Convert trait data to binary (0 or 1), or return None for unknown."""
54
+ if not value:
55
+ return None
56
+ # Extract the portion after the colon
57
+ parts = value.split(':')
58
+ raw_val = parts[-1].strip() if len(parts) > 1 else value.strip()
59
+ # No actual data is available in this dataset, so default to None here.
60
+ return None
61
+
62
+ def convert_age(value: str):
63
+ """Convert age data to a continuous variable, or return None for unknown."""
64
+ if not value:
65
+ return None
66
+ parts = value.split(':')
67
+ raw_val = parts[-1].strip() if len(parts) > 1 else value.strip()
68
+ # No actual data is available in this dataset, so default to None here.
69
+ return None
70
+
71
+ def convert_gender(value: str):
72
+ """Convert gender data to binary (female=0, male=1), or return None for unknown."""
73
+ if not value:
74
+ return None
75
+ parts = value.split(':')
76
+ raw_val = parts[-1].strip() if len(parts) > 1 else value.strip()
77
+ # No actual data is available in this dataset, so default to None here.
78
+ return None
79
+
80
+ # Step 3. Initial filtering and save metadata
81
+ # Trait data availability depends on whether trait_row is None.
82
+ is_trait_available = (trait_row is not None)
83
+
84
+ is_usable = validate_and_save_cohort_info(
85
+ is_final=False,
86
+ cohort=cohort,
87
+ info_path=json_path,
88
+ is_gene_available=is_gene_available,
89
+ is_trait_available=is_trait_available
90
+ )
91
+
92
+ # Step 4. Clinical Feature Extraction
93
+ # Since trait_row is None, we skip this step as instructed.
94
+ # STEP3
95
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
96
+ gene_data = get_genetic_data(matrix_file)
97
+
98
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
99
+ print(gene_data.index[:20])
p1/preprocess/Multiple_sclerosis/code/GSE203241.py ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+ cohort = "GSE203241"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Multiple_sclerosis"
10
+ in_cohort_dir = "../DATA/GEO/Multiple_sclerosis/GSE203241"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/GSE203241.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/GSE203241.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/GSE203241.csv"
16
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1) Gene Expression Data Availability
37
+ # Based on the series description mentioning "blood mononuclear cell transcriptome",
38
+ # we consider that gene expression data is available for this cohort.
39
+ is_gene_available = True
40
+
41
+ # 2) Variable Availability
42
+ # From the sample characteristics dictionary, we see:
43
+ # key=0 => gender: Male/Female
44
+ # key=1 => age (years): numeric
45
+ # No evident row containing trait (Multiple_sclerosis) data is found; hence trait_row = None.
46
+ trait_row = None
47
+ age_row = 1
48
+ gender_row = 0
49
+
50
+ # 2.2) Data Type Conversion Functions
51
+
52
+ def convert_trait(x: str):
53
+ """
54
+ Since 'trait_row' is None for this dataset, this function won't be called.
55
+ We define a dummy function here for demonstration.
56
+ """
57
+ return None
58
+
59
+ def convert_age(x: str):
60
+ """
61
+ Convert 'age (years): X' to a float. If conversion fails or the value is invalid, return None.
62
+ """
63
+ try:
64
+ # Split by colon and strip whitespace
65
+ parts = x.split(':')
66
+ if len(parts) < 2:
67
+ return None
68
+ val_str = parts[1].strip()
69
+ return float(val_str)
70
+ except:
71
+ return None
72
+
73
+ def convert_gender(x: str):
74
+ """
75
+ Convert 'gender: Male/Female' to binary (Male=1, Female=0). Unknown values => None.
76
+ """
77
+ parts = x.split(':')
78
+ if len(parts) < 2:
79
+ return None
80
+ val_str = parts[1].strip().lower()
81
+ if val_str == 'male':
82
+ return 1
83
+ elif val_str == 'female':
84
+ return 0
85
+ return None
86
+
87
+ # 3) Save Metadata with initial filtering
88
+ # Trait data availability is determined by whether trait_row is None.
89
+ is_trait_available = (trait_row is not None)
90
+
91
+ # Perform initial validation and save metadata
92
+ validate_and_save_cohort_info(
93
+ is_final=False,
94
+ cohort=cohort,
95
+ info_path=json_path,
96
+ is_gene_available=is_gene_available,
97
+ is_trait_available=is_trait_available
98
+ )
99
+
100
+ # 4) Clinical Feature Extraction is only performed if trait_row is not None.
101
+ # Since trait_row = None, we skip this step.
102
+ # STEP3
103
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
104
+ gene_data = get_genetic_data(matrix_file)
105
+
106
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
107
+ print(gene_data.index[:20])
108
+ # Based on the identifiers like "1007_s_at", "1053_at", etc., these are Affymetrix probe sets rather than
109
+ # direct human gene symbols. Therefore, mapping to gene symbols is required.
110
+ requires_gene_mapping = True
111
+ # STEP5
112
+ # 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
113
+ gene_annotation = get_gene_annotation(soft_file)
114
+
115
+ # 2. Use the 'preview_df' function from the library to preview the data and print out the results.
116
+ print("Gene annotation preview:")
117
+ print(preview_df(gene_annotation))
118
+ # STEP: Gene Identifier Mapping
119
+
120
+ # 1. Identify the annotation columns that match the probe IDs from gene expression data and the gene symbols.
121
+ probe_col = "ID"
122
+ gene_symbol_col = "Gene Symbol"
123
+
124
+ # 2. Extract the corresponding mapping from the gene_annotation dataframe.
125
+ mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
126
+
127
+ # 3. Apply the mapping to convert the probe-level measurements in 'gene_data' to gene-level data.
128
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
129
+
130
+ # Optional: Check the resulting shape or partial content
131
+ print("Mapped gene_data dimensions:", gene_data.shape)
132
+ print("Mapped gene_data (first 5 rows):")
133
+ print(gene_data.head(5))
134
+ # STEP7
135
+ # Since trait_row = None, there is no trait data to link. We cannot do final validation because
136
+ # validate_and_save_cohort_info(...) raises ValueError if is_final=True but df or is_biased is None.
137
+ # Therefore, we only normalize and save gene expression data, and skip the rest.
138
+
139
+ # 1. Normalize the obtained gene data with the 'normalize_gene_symbols_in_index' function from the library.
140
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
141
+ normalized_gene_data.to_csv(out_gene_data_file)
142
+
143
+ # 2. Because trait data is unavailable, we skip clinical–genetic linking, missing value handling, and bias checks.
144
+ # 3. We also skip final validation, since trait data is not available.
p1/preprocess/Multiple_sclerosis/code/TCGA.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Multiple_sclerosis"
6
+
7
+ # Input paths
8
+ tcga_root_dir = "../DATA/TCGA"
9
+
10
+ # Output paths
11
+ out_data_file = "./output/preprocess/1/Multiple_sclerosis/TCGA.csv"
12
+ out_gene_data_file = "./output/preprocess/1/Multiple_sclerosis/gene_data/TCGA.csv"
13
+ out_clinical_data_file = "./output/preprocess/1/Multiple_sclerosis/clinical_data/TCGA.csv"
14
+ json_path = "./output/preprocess/1/Multiple_sclerosis/cohort_info.json"
15
+
16
+ import os
17
+
18
+ # Step 1: Identify subdirectory that might relate to "Multiple_sclerosis"
19
+ subdirs = [
20
+ 'CrawlData.ipynb', '.DS_Store', 'TCGA_lower_grade_glioma_and_glioblastoma_(GBMLGG)',
21
+ 'TCGA_Uterine_Carcinosarcoma_(UCS)', 'TCGA_Thyroid_Cancer_(THCA)', 'TCGA_Thymoma_(THYM)',
22
+ 'TCGA_Testicular_Cancer_(TGCT)', 'TCGA_Stomach_Cancer_(STAD)', 'TCGA_Sarcoma_(SARC)',
23
+ 'TCGA_Rectal_Cancer_(READ)', 'TCGA_Prostate_Cancer_(PRAD)', 'TCGA_Pheochromocytoma_Paraganglioma_(PCPG)',
24
+ 'TCGA_Pancreatic_Cancer_(PAAD)', 'TCGA_Ovarian_Cancer_(OV)', 'TCGA_Ocular_melanomas_(UVM)',
25
+ 'TCGA_Mesothelioma_(MESO)', 'TCGA_Melanoma_(SKCM)', 'TCGA_Lung_Squamous_Cell_Carcinoma_(LUSC)',
26
+ 'TCGA_Lung_Cancer_(LUNG)', 'TCGA_Lung_Adenocarcinoma_(LUAD)', 'TCGA_Lower_Grade_Glioma_(LGG)',
27
+ 'TCGA_Liver_Cancer_(LIHC)', 'TCGA_Large_Bcell_Lymphoma_(DLBC)', 'TCGA_Kidney_Papillary_Cell_Carcinoma_(KIRP)',
28
+ 'TCGA_Kidney_Clear_Cell_Carcinoma_(KIRC)', 'TCGA_Kidney_Chromophobe_(KICH)', 'TCGA_Head_and_Neck_Cancer_(HNSC)',
29
+ 'TCGA_Glioblastoma_(GBM)', 'TCGA_Esophageal_Cancer_(ESCA)', 'TCGA_Endometrioid_Cancer_(UCEC)',
30
+ 'TCGA_Colon_and_Rectal_Cancer_(COADREAD)', 'TCGA_Colon_Cancer_(COAD)', 'TCGA_Cervical_Cancer_(CESC)',
31
+ 'TCGA_Breast_Cancer_(BRCA)', 'TCGA_Bladder_Cancer_(BLCA)', 'TCGA_Bile_Duct_Cancer_(CHOL)',
32
+ 'TCGA_Adrenocortical_Cancer_(ACC)', 'TCGA_Acute_Myeloid_Leukemia_(LAML)'
33
+ ]
34
+
35
+ suitable_subdir = None
36
+
37
+ for sd in subdirs:
38
+ if "multiple_sclerosis" in sd.lower():
39
+ suitable_subdir = sd
40
+ break
41
+
42
+ if not suitable_subdir:
43
+ print("No suitable subdirectory found for trait 'Multiple_sclerosis'. Skipping this trait.")
44
+ # Mark as completed but unavailable in metadata
45
+ validate_and_save_cohort_info(
46
+ is_final=False,
47
+ cohort="TCGA",
48
+ info_path=json_path,
49
+ is_gene_available=False,
50
+ is_trait_available=False
51
+ )
52
+ else:
53
+ # Step 2: Identify clinical and genetic file paths
54
+ clinical_path, genetic_path = tcga_get_relevant_filepaths(os.path.join(tcga_root_dir, suitable_subdir))
55
+
56
+ # Step 3: Load data into dataframes
57
+ clinical_df = pd.read_csv(clinical_path, index_col=0, sep='\t')
58
+ genetic_df = pd.read_csv(genetic_path, index_col=0, sep='\t')
59
+
60
+ # Step 4: Print clinical data columns
61
+ print("Clinical Data Columns:", clinical_df.columns.tolist())
p1/preprocess/Multiple_sclerosis/cohort_info.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"GSE203241": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE193442": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE189788": {"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": "Trait not available; dataset skipped for trait-based analysis."}, "GSE146383": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE141804": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE141381": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "Trait data is not available, so this dataset is not usable for trait-based analysis."}, "GSE135511": {"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": 50, "note": "Dataset includes multiple sclerosis trait from post-mortem motor cortex samples."}, "GSE131282": {"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": 184, "note": "Dataset includes multiple sclerosis trait from post-mortem motor cortex samples."}, "GSE131281": {"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": 106, "note": "Dataset includes multiple sclerosis trait from post-mortem motor cortex samples."}, "GSE131279": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "TCGA": {"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}}
p1/preprocess/Multiple_sclerosis/gene_data/GSE131279.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:24fa10e76fb83c960d4c4f9ce6ee5cb352d7de11b4eac005113fcca9f5fa7866
3
+ size 16241112
p1/preprocess/Multiple_sclerosis/gene_data/GSE131281.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9d0251f7e8b277b4fc2cc5c151ec6c995d84a70320f903123b1940473721c5c8
3
+ size 22199380
p1/preprocess/Multiple_sclerosis/gene_data/GSE135511.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Multiple_sclerosis/gene_data/GSE141381.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:46f8eac4b864768b8ec310ef12e06c8b64861021e3893acd087561269cdbaf9c
3
+ size 13785375
p1/preprocess/Multiple_sclerosis/gene_data/GSE141804.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Multiple_sclerosis/gene_data/GSE146383.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f7b771eabe6abce883da26af84b3184449c14f9e517d1825526d06f7c4799bfe
3
+ size 12383233
p1/preprocess/Multiple_sclerosis/gene_data/GSE203241.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Obesity/GSE181339.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Obesity/GSE84046.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9af8be3a5d5c5168a25e9a8a286cf2779b589946518a999988c264941e23e3e
3
+ size 12844556
p1/preprocess/Obesity/clinical_data/GSE123086.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049
2
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
3
+ 56.0,,20.0,51.0,37.0,61.0,,31.0,56.0,41.0,61.0,,80.0,53.0,61.0,73.0,60.0,76.0,77.0,74.0,69.0,77.0,81.0,70.0,82.0,69.0,82.0,67.0,67.0,78.0,67.0,74.0,,51.0,72.0,66.0,80.0,36.0,67.0,31.0,31.0,45.0,56.0,65.0,53.0,48.0,50.0,76.0,,24.0,42.0,76.0,22.0,,23.0,34.0,43.0,47.0,24.0,55.0,48.0,58.0,30.0,28.0,41.0,63.0,55.0,55.0,67.0,47.0,46.0,49.0,23.0,68.0,39.0,24.0,36.0,58.0,38.0,27.0,67.0,61.0,69.0,63.0,60.0,17.0,10.0,9.0,13.0,10.0,13.0,15.0,12.0,13.0,81.0,94.0,51.0,40.0,,97.0,23.0,93.0,58.0,28.0,54.0,15.0,8.0,11.0,12.0,8.0,14.0,8.0,10.0,14.0,13.0,40.0,52.0,42.0,29.0,43.0,41.0,54.0,42.0,49.0,45.0,56.0,64.0,71.0,48.0,20.0,53.0,32.0,26.0,28.0,47.0,24.0,48.0,,19.0,41.0,38.0,,15.0,12.0,13.0,,11.0,,16.0,11.0,,35.0,26.0,39.0,46.0,42.0,20.0,69.0,69.0,47.0,47.0,56.0,54.0,53.0,50.0,22.0
4
+ 1.0,,0.0,0.0,1.0,1.0,,1.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,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,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,0.0,0.0,1.0,1.0,,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,0.0,0.0,0.0,,0.0,1.0,0.0,,1.0,,1.0,1.0,,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0