Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- input/GEO/Underweight/GSE84954/GSE84954_series_matrix.txt.gz +3 -0
- input/GEO/Uterine_Carcinosarcoma/GSE32507/GSE32507_series_matrix.txt.gz +3 -0
- input/GEO/Vitamin_D_Levels/GSE35925/GSE35925_family.soft.gz +3 -0
- p1/preprocess/Adrenocortical_Cancer/GSE75415.csv +0 -0
- p1/preprocess/Adrenocortical_Cancer/code/TCGA.py +112 -0
- p1/preprocess/Adrenocortical_Cancer/gene_data/GSE67766.csv +0 -0
- p1/preprocess/Alzheimers_Disease/gene_data/GSE137202.csv +0 -0
- p1/preprocess/Alzheimers_Disease/gene_data/GSE139384.csv +0 -0
- p1/preprocess/Alzheimers_Disease/gene_data/GSE185909.csv +0 -0
- p1/preprocess/Alzheimers_Disease/gene_data/GSE214417.csv +31 -0
- p1/preprocess/Asthma/code/GSE182797.py +189 -0
- p1/preprocess/Asthma/code/GSE182798.py +189 -0
- p1/preprocess/Asthma/code/GSE184382.py +155 -0
- p1/preprocess/Asthma/code/GSE185658.py +157 -0
- p1/preprocess/Asthma/code/GSE188424.py +134 -0
- p1/preprocess/Asthma/code/GSE205151.py +96 -0
- p1/preprocess/Asthma/code/GSE230164.py +160 -0
- p1/preprocess/Asthma/code/GSE270312.py +162 -0
- p1/preprocess/Asthma/code/TCGA.py +59 -0
- p1/preprocess/Asthma/gene_data/GSE123086.csv +1 -0
- p1/preprocess/Asthma/gene_data/GSE123088.csv +1 -0
- p1/preprocess/Asthma/gene_data/GSE182797.csv +1 -0
- p1/preprocess/Asthma/gene_data/GSE182798.csv +1 -0
- p1/preprocess/Asthma/gene_data/GSE184382.csv +1 -0
- p1/preprocess/Asthma/gene_data/GSE185658.csv +1 -0
- p1/preprocess/Asthma/gene_data/GSE188424.csv +1 -0
- p1/preprocess/Asthma/gene_data/GSE230164.csv +1 -0
- p1/preprocess/Asthma/gene_data/GSE270312.csv +1 -0
- p1/preprocess/Atrial_Fibrillation/GSE143924.csv +0 -0
- p1/preprocess/Atrial_Fibrillation/clinical_data/GSE115574.csv +2 -0
- p1/preprocess/Atrial_Fibrillation/clinical_data/GSE143924.csv +2 -0
- p1/preprocess/Atrial_Fibrillation/clinical_data/GSE235307.csv +4 -0
- p1/preprocess/Atrial_Fibrillation/code/GSE115574.py +159 -0
- p1/preprocess/Atrial_Fibrillation/code/GSE143924.py +153 -0
- p1/preprocess/Atrial_Fibrillation/code/GSE235307.py +177 -0
- p1/preprocess/Atrial_Fibrillation/code/GSE41177.py +178 -0
- p1/preprocess/Atrial_Fibrillation/code/GSE47727.py +124 -0
- p1/preprocess/Atrial_Fibrillation/code/TCGA.py +41 -0
- p1/preprocess/Atrial_Fibrillation/cohort_info.json +1 -0
- p1/preprocess/Atrial_Fibrillation/gene_data/GSE143924.csv +0 -0
- p1/preprocess/Atrial_Fibrillation/gene_data/GSE41177.csv +0 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE111175.csv +3 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE113842.csv +3 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE123302.csv +3 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE148450.csv +3 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE42133.csv +2 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE65106.csv +4 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE87847.csv +3 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE89594.csv +4 -0
- p1/preprocess/Autism_spectrum_disorder_(ASD)/code/GSE111175.py +194 -0
input/GEO/Underweight/GSE84954/GSE84954_series_matrix.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d3c97db7c280dd80249f6fc7e4e99daf4ac909f9759f17f0924ee3c26b78d224
|
3 |
+
size 6786415
|
input/GEO/Uterine_Carcinosarcoma/GSE32507/GSE32507_series_matrix.txt.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ee991c978414606e81ab4f44291f7f53c20c042e59ee2ea8bea9cd88c52f889c
|
3 |
+
size 9200143
|
input/GEO/Vitamin_D_Levels/GSE35925/GSE35925_family.soft.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:38b7133993cd54ff1066efdd30980771e3955085e5d62f71e92214d4133721c7
|
3 |
+
size 23011968
|
p1/preprocess/Adrenocortical_Cancer/GSE75415.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Adrenocortical_Cancer/code/TCGA.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Adrenocortical_Cancer"
|
6 |
+
|
7 |
+
# Input paths
|
8 |
+
tcga_root_dir = "../DATA/TCGA"
|
9 |
+
|
10 |
+
# Output paths
|
11 |
+
out_data_file = "./output/preprocess/1/Adrenocortical_Cancer/TCGA.csv"
|
12 |
+
out_gene_data_file = "./output/preprocess/1/Adrenocortical_Cancer/gene_data/TCGA.csv"
|
13 |
+
out_clinical_data_file = "./output/preprocess/1/Adrenocortical_Cancer/clinical_data/TCGA.csv"
|
14 |
+
json_path = "./output/preprocess/1/Adrenocortical_Cancer/cohort_info.json"
|
15 |
+
|
16 |
+
import os
|
17 |
+
import pandas as pd
|
18 |
+
|
19 |
+
# 1. Identify the relevant subdirectory for the trait "Obesity"
|
20 |
+
subdirectories = [
|
21 |
+
'CrawlData.ipynb', '.DS_Store', 'TCGA_lower_grade_glioma_and_glioblastoma_(GBMLGG)',
|
22 |
+
'TCGA_Uterine_Carcinosarcoma_(UCS)', 'TCGA_Thyroid_Cancer_(THCA)', 'TCGA_Thymoma_(THYM)',
|
23 |
+
'TCGA_Testicular_Cancer_(TGCT)', 'TCGA_Stomach_Cancer_(STAD)', 'TCGA_Sarcoma_(SARC)',
|
24 |
+
'TCGA_Rectal_Cancer_(READ)', 'TCGA_Prostate_Cancer_(PRAD)', 'TCGA_Pheochromocytoma_Paraganglioma_(PCPG)',
|
25 |
+
'TCGA_Pancreatic_Cancer_(PAAD)', 'TCGA_Ovarian_Cancer_(OV)', 'TCGA_Ocular_melanomas_(UVM)',
|
26 |
+
'TCGA_Mesothelioma_(MESO)', 'TCGA_Melanoma_(SKCM)', 'TCGA_Lung_Squamous_Cell_Carcinoma_(LUSC)',
|
27 |
+
'TCGA_Lung_Cancer_(LUNG)', 'TCGA_Lung_Adenocarcinoma_(LUAD)', 'TCGA_Lower_Grade_Glioma_(LGG)',
|
28 |
+
'TCGA_Liver_Cancer_(LIHC)', 'TCGA_Large_Bcell_Lymphoma_(DLBC)', 'TCGA_Kidney_Papillary_Cell_Carcinoma_(KIRP)',
|
29 |
+
'TCGA_Kidney_Clear_Cell_Carcinoma_(KIRC)', 'TCGA_Kidney_Chromophobe_(KICH)', 'TCGA_Head_and_Neck_Cancer_(HNSC)',
|
30 |
+
'TCGA_Glioblastoma_(GBM)', 'TCGA_Esophageal_Cancer_(ESCA)', 'TCGA_Endometrioid_Cancer_(UCEC)',
|
31 |
+
'TCGA_Colon_and_Rectal_Cancer_(COADREAD)', 'TCGA_Colon_Cancer_(COAD)', 'TCGA_Cervical_Cancer_(CESC)',
|
32 |
+
'TCGA_Breast_Cancer_(BRCA)', 'TCGA_Bladder_Cancer_(BLCA)', 'TCGA_Bile_Duct_Cancer_(CHOL)',
|
33 |
+
'TCGA_Adrenocortical_Cancer_(ACC)', 'TCGA_Acute_Myeloid_Leukemia_(LAML)'
|
34 |
+
]
|
35 |
+
|
36 |
+
trait_keyword = trait
|
37 |
+
target_subdir = None
|
38 |
+
|
39 |
+
for sd in subdirectories:
|
40 |
+
if trait_keyword.lower() in sd.lower():
|
41 |
+
target_subdir = sd
|
42 |
+
break
|
43 |
+
|
44 |
+
if target_subdir is None:
|
45 |
+
# No suitable data found for this trait; mark as completed
|
46 |
+
print("No TCGA subdirectory found for the trait. Skipping.")
|
47 |
+
else:
|
48 |
+
# 2. Locate clinical and genetic data files
|
49 |
+
cohort_dir = os.path.join(tcga_root_dir, target_subdir)
|
50 |
+
clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)
|
51 |
+
|
52 |
+
# 3. Load the data
|
53 |
+
clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\t')
|
54 |
+
genetic_df = pd.read_csv(genetic_file_path, index_col=0, sep='\t')
|
55 |
+
|
56 |
+
# 4. Print column names of clinical data
|
57 |
+
print(clinical_df.columns)
|
58 |
+
candidate_age_cols = ["age_at_initial_pathologic_diagnosis"]
|
59 |
+
candidate_gender_cols = []
|
60 |
+
|
61 |
+
candidate_demo_cols = candidate_age_cols + candidate_gender_cols
|
62 |
+
if candidate_demo_cols:
|
63 |
+
extracted_df = clinical_df[candidate_demo_cols]
|
64 |
+
preview_data = preview_df(extracted_df)
|
65 |
+
print(preview_data)
|
66 |
+
# Based on the inspection of the provided dictionaries for age and gender:
|
67 |
+
age_col = "age_at_initial_pathologic_diagnosis"
|
68 |
+
gender_col = None
|
69 |
+
|
70 |
+
print("Chosen age_col:", age_col)
|
71 |
+
print("Chosen gender_col:", gender_col)
|
72 |
+
# 1. Extract and standardize the clinical features
|
73 |
+
selected_clinical_df = tcga_select_clinical_features(
|
74 |
+
clinical_df=clinical_df,
|
75 |
+
trait=trait,
|
76 |
+
age_col=age_col,
|
77 |
+
gender_col=gender_col
|
78 |
+
)
|
79 |
+
|
80 |
+
# (Optional) Save the selected clinical data
|
81 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
82 |
+
|
83 |
+
# 2. Normalize gene symbols in the genetic data
|
84 |
+
normalized_gene_df = normalize_gene_symbols_in_index(genetic_df)
|
85 |
+
normalized_gene_df.to_csv(out_gene_data_file)
|
86 |
+
|
87 |
+
# 3. Link the clinical and genetic data on sample IDs
|
88 |
+
linked_data = selected_clinical_df.join(normalized_gene_df.T, how="inner")
|
89 |
+
|
90 |
+
# 4. Handle missing values
|
91 |
+
cleaned_df = handle_missing_values(linked_data, trait)
|
92 |
+
|
93 |
+
# 5. Determine if the trait or demographic features are biased
|
94 |
+
is_biased, final_df = judge_and_remove_biased_features(cleaned_df, trait)
|
95 |
+
|
96 |
+
# 6. Final quality validation
|
97 |
+
is_gene_available = not normalized_gene_df.empty
|
98 |
+
is_trait_available = trait in final_df.columns
|
99 |
+
is_usable = validate_and_save_cohort_info(
|
100 |
+
is_final=True,
|
101 |
+
cohort="TCGA",
|
102 |
+
info_path=json_path,
|
103 |
+
is_gene_available=is_gene_available,
|
104 |
+
is_trait_available=is_trait_available,
|
105 |
+
is_biased=is_biased,
|
106 |
+
df=final_df,
|
107 |
+
note=""
|
108 |
+
)
|
109 |
+
|
110 |
+
# 7. If the dataset is usable, save the final dataframe
|
111 |
+
if is_usable:
|
112 |
+
final_df.to_csv(out_data_file)
|
p1/preprocess/Adrenocortical_Cancer/gene_data/GSE67766.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Alzheimers_Disease/gene_data/GSE137202.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Alzheimers_Disease/gene_data/GSE139384.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Alzheimers_Disease/gene_data/GSE185909.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Alzheimers_Disease/gene_data/GSE214417.csv
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Gene,GSM6567822,GSM6567823,GSM6567824,GSM6567825,GSM6567826,GSM6567827,GSM6567828,GSM6567829,GSM6567830,GSM6567831,GSM6567832,GSM6567833,GSM6567834,GSM6567835,GSM6567836,GSM6567837,GSM6567838,GSM6567839,GSM6567840,GSM6567841,GSM6567842,GSM6567843,GSM6567844,GSM6567845
|
2 |
+
ATP8,1.9,1.73,1.75,1.88,1.79,1.76,1.81,1.79,1.79,1.82,1.78,1.83,1.75,1.8,1.79,1.74,1.93,1.86,1.84,1.89,1.92,1.89,1.91,1.86
|
3 |
+
C2,0.4,0.2,0.59,0.18,0.05,0.71,0.4,0.35,0.29,0.51,0.04,0.16,0.19,0.43,0.34,0.32,0.38,0.24,0.4,0.33,0.21,0.89,0.44,0.15
|
4 |
+
C3,1.52,1.07,1.31,1.3199999999999998,1.32,1.46,1.44,1.33,1.51,0.5900000000000001,0.9099999999999999,0.8300000000000001,1.21,1.54,0.91,1.38,1.58,1.66,1.44,0.72,0.81,0.8,1.49,1.0
|
5 |
+
C6,-1.24,-1.19,-0.96,-1.2,-1.16,-1.18,-1.1,-1.11,-1.24,-1.21,-1.18,-1.13,-1.17,-0.97,-1.14,-1.21,-1.17,-0.91,-1.04,-1.32,-0.68,-0.74,-1.05,-1.13
|
6 |
+
C7,0.22,-0.02,-0.06,0.07,-0.05,-0.07,-0.01,-0.06,0.02,-0.04,-0.06,0.09,-0.07,-0.07,-0.01,-0.05,0.2,0.19,0.24,0.29,0.13,0.15,0.18,0.15
|
7 |
+
C9,-0.82,-1.31,-1.09,-1.2,-1.12,-0.73,-1.24,-0.77,-1.25,-1.21,-1.18,-1.23,-0.34,-0.46,-1.1,-0.67,-1.17,-0.82,-0.17,-0.39,-1.18,-0.22,-0.98,-0.5
|
8 |
+
COX1,2.3,2.25,2.27,2.38,2.4,2.34,2.32,2.26,2.35,2.36,2.33,2.43,2.31,2.31,2.32,2.27,2.42,2.47,2.26,2.44,2.31,2.61,2.32,2.57
|
9 |
+
COX2,2.3,2.12,2.18,2.31,2.26,2.21,2.19,2.21,2.21,2.29,2.25,2.31,2.19,2.24,2.22,2.16,2.58,2.6,2.56,2.55,2.73,2.7,2.67,2.64
|
10 |
+
CYTB,2.31,2.17,2.21,2.36,2.47,2.3,2.2,2.31,2.26,2.36,2.29,2.33,2.27,2.27,2.1,2.26,2.47,2.49,2.47,2.5,2.62,2.6,2.6,2.57
|
11 |
+
F10,-1.23,-1.01,-1.11,-1.18,-1.21,-0.92,-1.22,-1.23,-0.9,-1.21,-1.26,-1.22,-0.41,-0.49,-1.23,-0.84,-0.74,-0.87,-0.86,-1.16,-1.01,-0.97,-1.12,-1.21
|
12 |
+
F11,-1.03,-0.57,-0.88,-1.08,-1.2,-0.84,-0.85,-0.97,-0.93,-1.12,-0.97,-1.03,-0.88,-0.8,-0.83,-0.83,-0.69,-1.0,-1.3,-1.33,-1.19,-1.11,-1.19,-1.23
|
13 |
+
F12,-0.22,-0.18,-0.25,-0.32,-0.24,-0.34,-0.19,-0.38,-0.22,-0.19,-0.28,-0.18,-0.11,-0.2,-0.16,-0.22,-0.23,-0.28,-0.28,-0.16,-0.21,-0.33,-0.35,-0.3
|
14 |
+
F2,-0.92,-0.79,-0.79,-1.08,-0.92,-1.23,-0.82,-0.99,-0.76,-0.55,-0.92,-0.89,0.04,-0.1,-0.71,-0.74,-0.83,-0.75,-0.8,-0.61,-0.68,-0.72,-1.21,-1.25
|
15 |
+
F3,1.34,1.31,1.3,1.3,1.26,1.25,1.3,1.31,1.34,1.32,1.29,1.29,1.25,1.31,1.29,1.31,1.15,1.15,1.17,1.14,1.16,1.28,1.19,1.18
|
16 |
+
F5,1.35,0.01,0.86,0.17,0.76,1.2,1.19,1.37,0.58,-0.05,-0.13,-0.17,0.35,1.04,-0.12,1.38,0.22,0.13,1.22,1.17,-0.16,1.0,1.12,-0.05
|
17 |
+
F7,-1.23,-1.03,-0.89,-0.81,-1.2,-1.23,-1.23,-1.07,-0.79,-1.1,-0.8,-1.16,-0.5,-1.21,-0.79,-1.2,-1.08,-1.14,-1.02,-0.89,-0.73,-1.11,-1.12,-0.98
|
18 |
+
F8,-0.25,-0.17,-0.3,-0.32,-0.31,-0.25,-0.34,-0.25,-0.22,-0.3,-0.35,-0.28,-0.21,-0.32,-0.28,-0.23,-0.25,-0.46,-0.39,-0.49,-0.55,-0.59,-0.51,-0.6
|
19 |
+
F9,-1.08,-0.72,-0.83,-0.93,-0.65,-0.61,-0.59,-0.75,-0.8,-0.63,-0.75,-0.75,-0.65,-0.75,-0.72,-1.17,-0.94,-0.71,-0.75,-0.86,-1.11,-1.11,-0.93,-0.91
|
20 |
+
H19,-0.28,-0.48,-0.38,-0.57,-0.48,-0.34,-0.28,-0.46,-0.39,-0.58,-0.54,-0.75,-0.49,-0.48,-0.56,-0.24,-0.27,-0.33,-0.63,-0.44,-0.53,-0.2,-0.4,-0.49
|
21 |
+
HM13,1.8299999999999998,1.73,1.62,1.71,1.4500000000000002,1.48,1.58,1.6,1.7599999999999998,1.7000000000000004,1.5400000000000003,1.91,1.9100000000000001,1.81,1.6,1.9100000000000001,1.5899999999999999,1.3499999999999999,1.89,1.58,1.5300000000000002,1.74,1.3,1.1700000000000002
|
22 |
+
IGKV1-5,-0.35,-0.45,-0.34,-0.47,-0.44,-0.61,-0.41,-0.51,-0.43,-0.57,-0.37,-0.45,-0.42,-0.56,-0.42,-0.51,-0.45,-0.41,-0.03,-0.47,-0.6,-0.63,-0.57,-0.41
|
23 |
+
MOSMO,2.45,2.61,2.42,2.61,2.67,2.66,2.63,2.65,2.5599999999999996,2.7199999999999998,2.69,2.4699999999999998,2.58,2.69,2.53,2.6399999999999997,2.5700000000000003,2.67,2.6100000000000003,2.5,2.63,2.56,2.56,2.6399999999999997
|
24 |
+
ND1,1.84,1.68,1.67,1.8,1.72,1.66,1.52,1.7,1.69,1.62,1.68,1.72,1.59,1.62,1.67,1.62,1.74,1.7,1.7,1.78,1.76,1.7,1.74,1.68
|
25 |
+
ND2,2.26,2.0,2.04,2.09,2.13,2.08,2.07,2.09,2.06,2.1,2.07,2.13,2.04,2.1,2.08,2.0,2.38,2.38,2.35,2.38,2.49,2.44,2.44,2.39
|
26 |
+
ND3,2.04,1.86,1.83,2.01,2.01,1.9,1.96,1.97,1.89,2.0,2.0,1.96,1.95,2.0,1.99,1.9,2.27,2.25,2.26,2.25,2.38,2.36,2.35,2.29
|
27 |
+
ND4,2.13,1.96,2.03,2.16,2.22,2.04,2.05,2.06,2.03,2.1,2.07,2.13,2.04,2.08,2.06,2.0,2.26,2.29,2.26,2.29,2.39,2.36,2.36,2.34
|
28 |
+
ND4L,2.21,2.05,2.1,2.23,2.11,2.07,2.1,2.13,2.11,2.14,2.09,2.24,2.06,2.12,2.12,1.99,2.25,2.24,2.22,2.26,2.35,2.33,2.27,2.26
|
29 |
+
ND5,2.04,1.85,1.87,2.0,1.89,1.87,1.9,1.92,1.91,1.89,1.93,2.0,1.84,1.88,1.92,1.87,1.85,1.86,1.84,1.89,1.91,1.91,1.83,1.84
|
30 |
+
ND6,0.23,0.38,0.38,0.42,0.49,0.36,0.38,0.47,0.41,0.56,0.52,0.46,0.49,0.53,0.44,0.41,0.35,0.34,0.33,0.15,0.31,0.26,0.28,0.26
|
31 |
+
SLC25A5,-0.46,-0.59,-0.43,-0.58,0.07,-0.42,-0.52,-0.47,-0.35,-1.17,-0.73,-0.78,-0.51,-0.56,-0.52,-0.53,-0.54,-0.7,-0.58,-0.76,-0.97,-0.59,-0.89,-1.1
|
p1/preprocess/Asthma/code/GSE182797.py
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
cohort = "GSE182797"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE182797"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Asthma/GSE182797.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/GSE182797.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/GSE182797.csv"
|
16 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP 1
|
19 |
+
|
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(
|
27 |
+
matrix_file,
|
28 |
+
background_prefixes,
|
29 |
+
clinical_prefixes
|
30 |
+
)
|
31 |
+
|
32 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
33 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
34 |
+
|
35 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
36 |
+
print("Background Information:")
|
37 |
+
print(background_info)
|
38 |
+
print("\nSample Characteristics Dictionary:")
|
39 |
+
print(sample_characteristics_dict)
|
40 |
+
# 1) Gene Expression Data Availability
|
41 |
+
is_gene_available = True # Based on "Transcriptomic profiling" and "microarray analyses"
|
42 |
+
|
43 |
+
# 2) Variable Availability and Data Type Conversion
|
44 |
+
# 2.1 Identify rows
|
45 |
+
trait_row = 0 # "diagnosis: ..." contains multiple distinct values including "adult-onset asthma"
|
46 |
+
age_row = 2 # "age: ..." contains multiple numerical values
|
47 |
+
gender_row = None # Only "gender: Female" found, no variability => not available
|
48 |
+
|
49 |
+
# 2.2 Define conversion functions
|
50 |
+
def convert_trait(value: str):
|
51 |
+
"""
|
52 |
+
Convert diagnosis data to a binary label:
|
53 |
+
adult-onset asthma -> 1, otherwise (healthy/IEI) -> 0, unknown -> None
|
54 |
+
"""
|
55 |
+
parts = value.split(':')
|
56 |
+
if len(parts) < 2:
|
57 |
+
return None
|
58 |
+
val = parts[1].strip().lower()
|
59 |
+
if 'adult-onset asthma' in val:
|
60 |
+
return 1
|
61 |
+
elif 'healthy' in val or 'iei' in val:
|
62 |
+
return 0
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_age(value: str):
|
66 |
+
"""Convert age data to a float. Unknown or invalid entries -> None."""
|
67 |
+
parts = value.split(':')
|
68 |
+
if len(parts) < 2:
|
69 |
+
return None
|
70 |
+
val = parts[1].strip()
|
71 |
+
try:
|
72 |
+
return float(val)
|
73 |
+
except ValueError:
|
74 |
+
return None
|
75 |
+
|
76 |
+
def convert_gender(value: str):
|
77 |
+
"""
|
78 |
+
Convert gender data to binary (female->0, male->1).
|
79 |
+
Not used here because gender_row is None, but defined for completeness.
|
80 |
+
"""
|
81 |
+
parts = value.split(':')
|
82 |
+
if len(parts) < 2:
|
83 |
+
return None
|
84 |
+
val = parts[1].strip().lower()
|
85 |
+
if val == 'female':
|
86 |
+
return 0
|
87 |
+
elif val == 'male':
|
88 |
+
return 1
|
89 |
+
return None
|
90 |
+
|
91 |
+
# 3) Save Metadata (initial filtering)
|
92 |
+
is_trait_available = (trait_row is not None)
|
93 |
+
is_usable = validate_and_save_cohort_info(
|
94 |
+
is_final=False,
|
95 |
+
cohort=cohort,
|
96 |
+
info_path=json_path,
|
97 |
+
is_gene_available=is_gene_available,
|
98 |
+
is_trait_available=is_trait_available
|
99 |
+
)
|
100 |
+
|
101 |
+
# 4) Clinical Feature Extraction (only if trait data is available)
|
102 |
+
if trait_row is not None:
|
103 |
+
# 'clinical_data' is assumed to be the DataFrame containing sample characteristics
|
104 |
+
selected_clinical_df = geo_select_clinical_features(
|
105 |
+
clinical_df=clinical_data,
|
106 |
+
trait=trait,
|
107 |
+
trait_row=trait_row,
|
108 |
+
convert_trait=convert_trait,
|
109 |
+
age_row=age_row,
|
110 |
+
convert_age=convert_age,
|
111 |
+
gender_row=gender_row,
|
112 |
+
convert_gender=convert_gender
|
113 |
+
)
|
114 |
+
|
115 |
+
# Preview and save the selected clinical data
|
116 |
+
preview = preview_df(selected_clinical_df)
|
117 |
+
print("Preview of extracted clinical data:", preview)
|
118 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
119 |
+
# STEP3
|
120 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
121 |
+
gene_data = get_genetic_data(matrix_file)
|
122 |
+
|
123 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
124 |
+
print(gene_data.index[:20])
|
125 |
+
# These identifiers (e.g., 'A_19_P00315452') are microarray probe IDs
|
126 |
+
# and do not appear to be standard human gene symbols.
|
127 |
+
# Therefore, they need to be mapped to gene symbols.
|
128 |
+
print("requires_gene_mapping = True")
|
129 |
+
# STEP5
|
130 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
131 |
+
gene_annotation = get_gene_annotation(soft_file)
|
132 |
+
|
133 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
134 |
+
print("Gene annotation preview:")
|
135 |
+
print(preview_df(gene_annotation))
|
136 |
+
# STEP: Gene Identifier Mapping
|
137 |
+
|
138 |
+
# 1. Identify columns in gene_annotation for probe IDs and gene symbols
|
139 |
+
probe_col = 'ID'
|
140 |
+
gene_symbol_col = 'GENE_SYMBOL'
|
141 |
+
|
142 |
+
# 2. Get the mapping of probe IDs to gene symbols
|
143 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
|
144 |
+
|
145 |
+
# 3. Convert probe-level data to gene-level data
|
146 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
147 |
+
|
148 |
+
# (Optional) Check the shape or a small preview of the mapped gene_data
|
149 |
+
print("Mapped gene_data shape:", gene_data.shape)
|
150 |
+
# STEP 7: Data Normalization and Linking
|
151 |
+
|
152 |
+
# 1) Normalize gene symbols
|
153 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
154 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
155 |
+
print(f"Saved normalized gene data to {out_gene_data_file}")
|
156 |
+
|
157 |
+
# 2) Read the previously saved clinical data (which should have shape (2 rows) x (80 columns))
|
158 |
+
# so that it aligns correctly with normalized_gene_data.
|
159 |
+
temp_clinical = pd.read_csv(out_clinical_data_file) # Use the first row as header
|
160 |
+
temp_clinical.index = [trait, "Age"]
|
161 |
+
temp_clinical.columns = normalized_gene_data.columns # Match with the 80 sample IDs
|
162 |
+
|
163 |
+
# Link the clinical and gene data
|
164 |
+
linked_data = geo_link_clinical_genetic_data(temp_clinical, normalized_gene_data)
|
165 |
+
|
166 |
+
# 3) Handle missing values
|
167 |
+
processed_data = handle_missing_values(linked_data, trait_col=trait)
|
168 |
+
|
169 |
+
# 4) Remove biased demographic features; check whether our trait is overly biased
|
170 |
+
trait_biased, final_data = judge_and_remove_biased_features(processed_data, trait=trait)
|
171 |
+
|
172 |
+
# 5) Conduct final dataset validation
|
173 |
+
is_usable = validate_and_save_cohort_info(
|
174 |
+
is_final=True,
|
175 |
+
cohort=cohort,
|
176 |
+
info_path=json_path,
|
177 |
+
is_gene_available=True,
|
178 |
+
is_trait_available=True,
|
179 |
+
is_biased=trait_biased,
|
180 |
+
df=final_data,
|
181 |
+
note="Final processed dataset for trait and gene expression."
|
182 |
+
)
|
183 |
+
|
184 |
+
# 6) If the dataset is usable, save the final linked data
|
185 |
+
if is_usable:
|
186 |
+
final_data.to_csv(out_data_file)
|
187 |
+
print(f"Saved final linked data to {out_data_file}")
|
188 |
+
else:
|
189 |
+
print("Dataset not usable. No final linked file was saved.")
|
p1/preprocess/Asthma/code/GSE182798.py
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
cohort = "GSE182798"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE182798"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Asthma/GSE182798.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/GSE182798.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/GSE182798.csv"
|
16 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP 1
|
19 |
+
|
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(
|
27 |
+
matrix_file,
|
28 |
+
background_prefixes,
|
29 |
+
clinical_prefixes
|
30 |
+
)
|
31 |
+
|
32 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
33 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
34 |
+
|
35 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
36 |
+
print("Background Information:")
|
37 |
+
print(background_info)
|
38 |
+
print("\nSample Characteristics Dictionary:")
|
39 |
+
print(sample_characteristics_dict)
|
40 |
+
def convert_trait(x):
|
41 |
+
if not isinstance(x, str):
|
42 |
+
return None
|
43 |
+
# Split only once, to ensure we keep the part after the colon.
|
44 |
+
parts = x.split(':', 1)
|
45 |
+
if len(parts) < 2:
|
46 |
+
return None
|
47 |
+
val = parts[1].strip().lower()
|
48 |
+
# Convert to a binary indicator: 1 if adult-onset asthma, else 0
|
49 |
+
# (other categories like IEI or healthy => 0)
|
50 |
+
if 'adult-onset asthma' in val:
|
51 |
+
return 1
|
52 |
+
else:
|
53 |
+
return 0
|
54 |
+
|
55 |
+
def convert_age(x):
|
56 |
+
if not isinstance(x, str):
|
57 |
+
return None
|
58 |
+
parts = x.split(':', 1)
|
59 |
+
if len(parts) < 2:
|
60 |
+
return None
|
61 |
+
try:
|
62 |
+
return float(parts[1].strip())
|
63 |
+
except ValueError:
|
64 |
+
return None
|
65 |
+
|
66 |
+
def convert_gender(x):
|
67 |
+
if not isinstance(x, str):
|
68 |
+
return None
|
69 |
+
parts = x.split(':', 1)
|
70 |
+
if len(parts) < 2:
|
71 |
+
return None
|
72 |
+
val = parts[1].strip().lower()
|
73 |
+
if val in ['female', 'f']:
|
74 |
+
return 0
|
75 |
+
elif val in ['male', 'm']:
|
76 |
+
return 1
|
77 |
+
return None
|
78 |
+
|
79 |
+
# 1. Check gene expression data availability
|
80 |
+
is_gene_available = True # Based on the transcriptomic profiling background
|
81 |
+
|
82 |
+
# 2.1 Identify row indices for trait, age, and gender
|
83 |
+
trait_row = 0 # "diagnosis: adult-onset asthma", etc. => available
|
84 |
+
age_row = 2 # "age: 33.42", "age: 46.08", ... => available
|
85 |
+
# Row 1 (gender) has only one unique value => treat it as not available
|
86 |
+
gender_row = None
|
87 |
+
|
88 |
+
# 3. Metadata: initial filtering
|
89 |
+
# trait_row != None => trait is available
|
90 |
+
is_trait_available = (trait_row is not None)
|
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. If trait is available, extract clinical features
|
100 |
+
if trait_row is not None:
|
101 |
+
selected_clinical_df = geo_select_clinical_features(
|
102 |
+
clinical_data,
|
103 |
+
trait=trait,
|
104 |
+
trait_row=trait_row,
|
105 |
+
convert_trait=convert_trait,
|
106 |
+
age_row=age_row,
|
107 |
+
convert_age=convert_age,
|
108 |
+
gender_row=gender_row, # None
|
109 |
+
convert_gender=convert_gender
|
110 |
+
)
|
111 |
+
preview_result = preview_df(selected_clinical_df)
|
112 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
113 |
+
print(preview_result)
|
114 |
+
# STEP3
|
115 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
116 |
+
gene_data = get_genetic_data(matrix_file)
|
117 |
+
|
118 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
119 |
+
print(gene_data.index[:20])
|
120 |
+
# These IDs (e.g., 'A_19_P00315452') appear to be array probe identifiers rather than standard gene symbols.
|
121 |
+
# Therefore, gene mapping is required.
|
122 |
+
print("requires_gene_mapping = True")
|
123 |
+
# STEP5
|
124 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
125 |
+
gene_annotation = get_gene_annotation(soft_file)
|
126 |
+
|
127 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
128 |
+
print("Gene annotation preview:")
|
129 |
+
print(preview_df(gene_annotation))
|
130 |
+
# STEP: Gene Identifier Mapping
|
131 |
+
|
132 |
+
# 1) Identify the appropriate columns in the gene annotation
|
133 |
+
# - The probe ID column in the annotation that matches the expression data index is "ID"
|
134 |
+
# - The gene symbol column is "GENE_SYMBOL"
|
135 |
+
|
136 |
+
# 2) Get a dataframe mapping probe IDs to gene symbols
|
137 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col="ID", gene_col="GENE_SYMBOL")
|
138 |
+
|
139 |
+
# 3) Convert probe-level expression data into gene-level expression data
|
140 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
141 |
+
|
142 |
+
# (Optional) Print the shape or a small preview of the resulting gene_data
|
143 |
+
print("Gene-level expression data shape:", gene_data.shape)
|
144 |
+
print("Gene-level expression data (head):")
|
145 |
+
print(gene_data.head())
|
146 |
+
# STEP 7: Data Normalization and Linking
|
147 |
+
|
148 |
+
# 1) Normalize gene symbols in the obtained gene expression data;
|
149 |
+
# remove unrecognized symbols and average duplicates.
|
150 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
151 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
152 |
+
print(f"Saved normalized gene data to {out_gene_data_file}")
|
153 |
+
|
154 |
+
# 2) Read previously saved clinical data. Because we saved it in Step 2 with index=False and each row representing
|
155 |
+
# a feature (trait or age), we need to transpose it so that the samples become rows and features become columns.
|
156 |
+
clinical_df = pd.read_csv(out_clinical_data_file, header=0)
|
157 |
+
clinical_df = clinical_df.T
|
158 |
+
# Rename the columns so they match the variables we want
|
159 |
+
clinical_df.columns = [trait, "Age"]
|
160 |
+
|
161 |
+
# 3) Link clinical with genetic data
|
162 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, normalized_gene_data)
|
163 |
+
|
164 |
+
# 4) Handle missing values in the linked data:
|
165 |
+
# remove samples with missing trait, remove genes with >20% missing,
|
166 |
+
# remove samples with >5% missing genes, then impute for the rest.
|
167 |
+
linked_data = handle_missing_values(linked_data, trait)
|
168 |
+
|
169 |
+
# 5) Check for severe bias in the trait and remove biased demographic features
|
170 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
171 |
+
|
172 |
+
# 6) Conduct final quality validation and save metadata
|
173 |
+
is_usable = validate_and_save_cohort_info(
|
174 |
+
is_final=True,
|
175 |
+
cohort=cohort,
|
176 |
+
info_path=json_path,
|
177 |
+
is_gene_available=True,
|
178 |
+
is_trait_available=True,
|
179 |
+
is_biased=trait_biased,
|
180 |
+
df=linked_data,
|
181 |
+
note="Processed with trait and gene data successfully."
|
182 |
+
)
|
183 |
+
|
184 |
+
# 7) If the dataset is usable, save the final linked data to CSV
|
185 |
+
if is_usable:
|
186 |
+
linked_data.to_csv(out_data_file)
|
187 |
+
print(f"Saved final linked data to {out_data_file}")
|
188 |
+
else:
|
189 |
+
print("Data not usable. No final linked file was saved.")
|
p1/preprocess/Asthma/code/GSE184382.py
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
cohort = "GSE184382"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE184382"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Asthma/GSE184382.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/GSE184382.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/GSE184382.csv"
|
16 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP 1
|
19 |
+
|
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(
|
27 |
+
matrix_file,
|
28 |
+
background_prefixes,
|
29 |
+
clinical_prefixes
|
30 |
+
)
|
31 |
+
|
32 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
33 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
34 |
+
|
35 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
36 |
+
print("Background Information:")
|
37 |
+
print(background_info)
|
38 |
+
print("\nSample Characteristics Dictionary:")
|
39 |
+
print(sample_characteristics_dict)
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
is_gene_available = True # This dataset includes transcriptome microarray data.
|
42 |
+
|
43 |
+
# 2. Variable Availability
|
44 |
+
trait_row = None # No row indicates "asthma" or similar
|
45 |
+
age_row = None # No row for age
|
46 |
+
gender_row = None # No row for gender
|
47 |
+
|
48 |
+
# 2.2 Data Type Conversion
|
49 |
+
def convert_trait(value: str) -> int:
|
50 |
+
"""
|
51 |
+
Convert raw trait string to a binary indicator (0 or 1).
|
52 |
+
Since trait_row is None, this function won't be used.
|
53 |
+
"""
|
54 |
+
# Placeholder implementation
|
55 |
+
return None
|
56 |
+
|
57 |
+
def convert_age(value: str) -> float:
|
58 |
+
"""
|
59 |
+
Convert raw age string to a float (continuous).
|
60 |
+
Since age_row is None, this function won't be used.
|
61 |
+
"""
|
62 |
+
# Placeholder implementation
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_gender(value: str) -> int:
|
66 |
+
"""
|
67 |
+
Convert raw gender string to 0 (female) or 1 (male).
|
68 |
+
Since gender_row is None, this function won't be used.
|
69 |
+
"""
|
70 |
+
# Placeholder implementation
|
71 |
+
return None
|
72 |
+
|
73 |
+
# 3. Save Metadata
|
74 |
+
# Determine trait availability
|
75 |
+
is_trait_available = (trait_row is not None)
|
76 |
+
|
77 |
+
is_usable = validate_and_save_cohort_info(
|
78 |
+
is_final=False,
|
79 |
+
cohort=cohort,
|
80 |
+
info_path=json_path,
|
81 |
+
is_gene_available=is_gene_available,
|
82 |
+
is_trait_available=is_trait_available
|
83 |
+
)
|
84 |
+
|
85 |
+
# 4. Clinical Feature Extraction
|
86 |
+
# Since trait_row is None, we skip feature extraction.
|
87 |
+
# STEP3
|
88 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
89 |
+
gene_data = get_genetic_data(matrix_file)
|
90 |
+
|
91 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
92 |
+
print(gene_data.index[:20])
|
93 |
+
# These identifiers (e.g., "A_19_P...", "(+)E1A_r60_...", "3xSLv1") are not standard human gene symbols.
|
94 |
+
# They appear to be array or custom IDs that require mapping to gene symbols.
|
95 |
+
|
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 |
+
|
106 |
+
# 1 & 2. Identify the columns in the annotation corresponding to the gene expression IDs and the gene symbols
|
107 |
+
# Here, 'ID' holds probe identifiers matching those in 'gene_data'
|
108 |
+
# and 'GENE_SYMBOL' holds the corresponding gene symbols.
|
109 |
+
|
110 |
+
gene_mapping_df = get_gene_mapping(gene_annotation, prob_col="ID", gene_col="GENE_SYMBOL")
|
111 |
+
|
112 |
+
# 3. Convert probe-level measurements to gene-level data using the mapping.
|
113 |
+
gene_data = apply_gene_mapping(gene_data, gene_mapping_df)
|
114 |
+
# STEP 7: Data Normalization and Linking
|
115 |
+
|
116 |
+
# We know from prior steps:
|
117 |
+
# - Trait is NOT available (trait_row = None), so no clinical CSV was saved.
|
118 |
+
# - We do have gene data, so we will at least normalize it.
|
119 |
+
|
120 |
+
# 1) Normalize gene symbols
|
121 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
122 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
123 |
+
print(f"Saved normalized gene data to {out_gene_data_file}")
|
124 |
+
|
125 |
+
# 2) Since trait is not available, we cannot link or handle clinical data.
|
126 |
+
# We'll set up placeholders for final validation.
|
127 |
+
is_trait_available = False
|
128 |
+
trait_biased = False # Arbitrarily set; the library requires a boolean.
|
129 |
+
|
130 |
+
# 3) We have no clinical data to integrate; skip missing value handling.
|
131 |
+
|
132 |
+
# 4) With no trait, we cannot check bias meaningfully. Skipped.
|
133 |
+
|
134 |
+
# 5) Final dataset validation
|
135 |
+
# The library requires df and is_biased if is_final=True, so we provide an empty DataFrame.
|
136 |
+
# This ensures it records the dataset as not usable.
|
137 |
+
empty_df = pd.DataFrame()
|
138 |
+
is_usable = validate_and_save_cohort_info(
|
139 |
+
is_final=True,
|
140 |
+
cohort=cohort,
|
141 |
+
info_path=json_path,
|
142 |
+
is_gene_available=True, # Gene data is available
|
143 |
+
is_trait_available=False, # Trait is not available
|
144 |
+
is_biased=trait_biased,
|
145 |
+
df=empty_df,
|
146 |
+
note="No trait data; final record."
|
147 |
+
)
|
148 |
+
|
149 |
+
# 6) If the linked data were usable, we would save it. But here, is_usable will be False.
|
150 |
+
if is_usable:
|
151 |
+
# This block won't run in our scenario, but included for completeness
|
152 |
+
empty_df.to_csv(out_data_file)
|
153 |
+
print(f"Saved final linked data to {out_data_file}")
|
154 |
+
else:
|
155 |
+
print("Data not usable (no trait). No final linked file was saved.")
|
p1/preprocess/Asthma/code/GSE185658.py
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
cohort = "GSE185658"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE185658"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Asthma/GSE185658.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/GSE185658.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/GSE185658.csv"
|
16 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP 1
|
19 |
+
|
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(
|
27 |
+
matrix_file,
|
28 |
+
background_prefixes,
|
29 |
+
clinical_prefixes
|
30 |
+
)
|
31 |
+
|
32 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
33 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
34 |
+
|
35 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
36 |
+
print("Background Information:")
|
37 |
+
print(background_info)
|
38 |
+
print("\nSample Characteristics Dictionary:")
|
39 |
+
print(sample_characteristics_dict)
|
40 |
+
# 1) Gene Expression Data Availability
|
41 |
+
is_gene_available = True # The background indicates Affymetrix microarrays for global gene expression
|
42 |
+
|
43 |
+
# 2) Variable Availability and Data Type Conversion
|
44 |
+
# Based on the sample characteristics dictionary, we only see a "group" field (row=1) that includes asthma vs healthy.
|
45 |
+
trait_row = 1
|
46 |
+
age_row = None
|
47 |
+
gender_row = None
|
48 |
+
|
49 |
+
# Define the conversion function for the trait (binary: 1 for Asthma, 0 for Healthy, None otherwise).
|
50 |
+
def convert_trait(value):
|
51 |
+
parts = value.split(':')
|
52 |
+
label = parts[-1].strip().lower() # Take text after ':'
|
53 |
+
if 'asthma' in label:
|
54 |
+
return 1
|
55 |
+
elif 'healthy' in label:
|
56 |
+
return 0
|
57 |
+
return None
|
58 |
+
|
59 |
+
# We do not have age or gender data, so these conversion functions are not used.
|
60 |
+
convert_age = None
|
61 |
+
convert_gender = None
|
62 |
+
|
63 |
+
# 3) Save Metadata (initial filtering)
|
64 |
+
is_trait_available = (trait_row is not None)
|
65 |
+
is_usable = validate_and_save_cohort_info(
|
66 |
+
is_final=False,
|
67 |
+
cohort=cohort,
|
68 |
+
info_path=json_path,
|
69 |
+
is_gene_available=is_gene_available,
|
70 |
+
is_trait_available=is_trait_available
|
71 |
+
)
|
72 |
+
|
73 |
+
# 4) Clinical Feature Extraction (only if trait data is available)
|
74 |
+
if trait_row is not None:
|
75 |
+
selected_clinical_df = geo_select_clinical_features(
|
76 |
+
clinical_df=clinical_data, # previously obtained DataFrame of sample characteristics
|
77 |
+
trait=trait,
|
78 |
+
trait_row=trait_row,
|
79 |
+
convert_trait=convert_trait,
|
80 |
+
age_row=age_row,
|
81 |
+
convert_age=convert_age,
|
82 |
+
gender_row=gender_row,
|
83 |
+
convert_gender=convert_gender
|
84 |
+
)
|
85 |
+
preview_dict = preview_df(selected_clinical_df)
|
86 |
+
print("Preview of selected clinical features:", preview_dict)
|
87 |
+
|
88 |
+
# Save the extracted clinical features to CSV
|
89 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
90 |
+
# STEP3
|
91 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
92 |
+
gene_data = get_genetic_data(matrix_file)
|
93 |
+
|
94 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
95 |
+
print(gene_data.index[:20])
|
96 |
+
# Based on the numeric format (e.g., '7892501'), these are likely not standard human gene symbols.
|
97 |
+
# Therefore, we conclude that gene mapping is required.
|
98 |
+
print("requires_gene_mapping = True")
|
99 |
+
# STEP5
|
100 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
101 |
+
gene_annotation = get_gene_annotation(soft_file)
|
102 |
+
|
103 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
104 |
+
print("Gene annotation preview:")
|
105 |
+
print(preview_df(gene_annotation))
|
106 |
+
# STEP: Gene Identifier Mapping
|
107 |
+
|
108 |
+
# 1. Decide which columns in the gene_annotation dataframe correspond to the probe ID and the gene symbol text.
|
109 |
+
# From the preview, "ID" appears to match the probe identifier (same as gene_data index),
|
110 |
+
# and "gene_assignment" appears to contain the gene symbols (though in a messy string).
|
111 |
+
|
112 |
+
# 2. Build a mapping dataframe using these two columns.
|
113 |
+
mapping_df = get_gene_mapping(annotation=gene_annotation, prob_col="ID", gene_col="gene_assignment")
|
114 |
+
|
115 |
+
# 3. Convert the probe-level measurements to gene expression data using the mapping,
|
116 |
+
# distributing expression when a probe maps to multiple genes and summing the contributions for each gene.
|
117 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
118 |
+
# STEP 7: Data Normalization and Linking
|
119 |
+
|
120 |
+
# 1) Normalize gene symbols
|
121 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
122 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
123 |
+
print(f"Saved normalized gene data to {out_gene_data_file}")
|
124 |
+
|
125 |
+
# 2) Link clinical and genetic data
|
126 |
+
# We know from previous steps that we do have trait data in out_clinical_data_file.
|
127 |
+
clinical_df = pd.read_csv(out_clinical_data_file, header=0)
|
128 |
+
# The clinical CSV contains a single row with the trait values and columns as sample IDs.
|
129 |
+
# Label that row with the trait name, so that geo_link_clinical_genetic_data can handle it properly.
|
130 |
+
clinical_df.index = [trait]
|
131 |
+
|
132 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, normalized_gene_data)
|
133 |
+
|
134 |
+
# 3) Handle missing values
|
135 |
+
linked_data = handle_missing_values(df=linked_data, trait_col=trait)
|
136 |
+
|
137 |
+
# 4) Determine bias
|
138 |
+
trait_biased, linked_data = judge_and_remove_biased_features(df=linked_data, trait=trait)
|
139 |
+
|
140 |
+
# 5) Final dataset validation
|
141 |
+
is_usable = validate_and_save_cohort_info(
|
142 |
+
is_final=True,
|
143 |
+
cohort=cohort,
|
144 |
+
info_path=json_path,
|
145 |
+
is_gene_available=True,
|
146 |
+
is_trait_available=True,
|
147 |
+
is_biased=trait_biased,
|
148 |
+
df=linked_data,
|
149 |
+
note="Completed data preprocessing and quality checks."
|
150 |
+
)
|
151 |
+
|
152 |
+
# 6) If usable, save the final linked data
|
153 |
+
if is_usable:
|
154 |
+
linked_data.to_csv(out_data_file, index=True)
|
155 |
+
print(f"Saved final linked data to {out_data_file}")
|
156 |
+
else:
|
157 |
+
print("Data not usable. No final file was saved.")
|
p1/preprocess/Asthma/code/GSE188424.py
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
cohort = "GSE188424"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE188424"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Asthma/GSE188424.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/GSE188424.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/GSE188424.csv"
|
16 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP 1
|
19 |
+
|
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(
|
27 |
+
matrix_file,
|
28 |
+
background_prefixes,
|
29 |
+
clinical_prefixes
|
30 |
+
)
|
31 |
+
|
32 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
33 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
34 |
+
|
35 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
36 |
+
print("Background Information:")
|
37 |
+
print(background_info)
|
38 |
+
print("\nSample Characteristics Dictionary:")
|
39 |
+
print(sample_characteristics_dict)
|
40 |
+
# Step 1: Determine gene expression data availability
|
41 |
+
is_gene_available = True # Transcriptome data indicated in the series description
|
42 |
+
|
43 |
+
# Step 2.1: Determine availability of trait, age, and gender data
|
44 |
+
# From the dictionary {0: ['gender: female', 'gender: male']},
|
45 |
+
# only gender data is found under key=0. No separate entries for trait or age are available.
|
46 |
+
trait_row = None
|
47 |
+
age_row = None
|
48 |
+
gender_row = 0
|
49 |
+
|
50 |
+
# Step 2.2: Define data conversion functions
|
51 |
+
def convert_trait(value: str):
|
52 |
+
# No trait data row is available; return None.
|
53 |
+
return None
|
54 |
+
|
55 |
+
def convert_age(value: str):
|
56 |
+
# No age data row is available; return None.
|
57 |
+
return None
|
58 |
+
|
59 |
+
def convert_gender(value: str):
|
60 |
+
"""
|
61 |
+
Convert the gender string to 0 or 1:
|
62 |
+
- female -> 0
|
63 |
+
- male -> 1
|
64 |
+
- others/unknown -> None
|
65 |
+
"""
|
66 |
+
parts = value.split(':', 1)
|
67 |
+
if len(parts) < 2:
|
68 |
+
return None
|
69 |
+
gender_str = parts[1].strip().lower()
|
70 |
+
if gender_str == 'female':
|
71 |
+
return 0
|
72 |
+
elif gender_str == 'male':
|
73 |
+
return 1
|
74 |
+
return None
|
75 |
+
|
76 |
+
# Step 3: Save metadata via initial filtering
|
77 |
+
# Trait data availability is determined by whether trait_row is None.
|
78 |
+
is_trait_available = (trait_row is not None)
|
79 |
+
|
80 |
+
is_usable = validate_and_save_cohort_info(
|
81 |
+
is_final=False,
|
82 |
+
cohort=cohort,
|
83 |
+
info_path=json_path,
|
84 |
+
is_gene_available=is_gene_available,
|
85 |
+
is_trait_available=is_trait_available
|
86 |
+
)
|
87 |
+
|
88 |
+
# Step 4: Since trait_row is None, we skip clinical feature extraction.
|
89 |
+
# STEP3
|
90 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
91 |
+
gene_data = get_genetic_data(matrix_file)
|
92 |
+
|
93 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
94 |
+
print(gene_data.index[:20])
|
95 |
+
# Based on the observed identifiers (e.g., ILMN_1651199), these are Illumina probe IDs
|
96 |
+
# rather than human gene symbols and require mapping.
|
97 |
+
print("requires_gene_mapping = True")
|
98 |
+
# STEP5
|
99 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
100 |
+
gene_annotation = get_gene_annotation(soft_file)
|
101 |
+
|
102 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
103 |
+
print("Gene annotation preview:")
|
104 |
+
print(preview_df(gene_annotation))
|
105 |
+
# STEP: Gene Identifier Mapping
|
106 |
+
|
107 |
+
# 1 & 2. Identify the correct columns in gene_annotation corresponding to the Illumina probe IDs and gene symbols
|
108 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
|
109 |
+
|
110 |
+
# 3. Convert probe-level measurements to gene expression data by applying the gene mapping
|
111 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
112 |
+
# STEP 7: Data Normalization and Linking
|
113 |
+
|
114 |
+
# 1. Normalize gene symbols in the obtained gene expression data
|
115 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
116 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
117 |
+
print(f"Saved normalized gene data to {out_gene_data_file}")
|
118 |
+
|
119 |
+
# Since 'trait_row' was None, no clinical feature extraction occurred and trait data is unavailable.
|
120 |
+
# We must skip linking and final data prep steps and directly do final validation to record that this dataset is unusable for trait-based analysis.
|
121 |
+
|
122 |
+
empty_df = pd.DataFrame() # Placeholder, as df must be provided to the validation function
|
123 |
+
is_usable = validate_and_save_cohort_info(
|
124 |
+
is_final=True,
|
125 |
+
cohort=cohort,
|
126 |
+
info_path=json_path,
|
127 |
+
is_gene_available=True,
|
128 |
+
is_trait_available=False, # No trait data was found
|
129 |
+
is_biased=True, # Arbitrary True to pass validation, making the dataset not usable
|
130 |
+
df=empty_df,
|
131 |
+
note="Trait data is unavailable; skipping linking and final data steps."
|
132 |
+
)
|
133 |
+
|
134 |
+
print("Trait data unavailable. Skipping linking and final data output.")
|
p1/preprocess/Asthma/code/GSE205151.py
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
cohort = "GSE205151"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE205151"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Asthma/GSE205151.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/GSE205151.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/GSE205151.csv"
|
16 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP 1
|
19 |
+
|
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(
|
27 |
+
matrix_file,
|
28 |
+
background_prefixes,
|
29 |
+
clinical_prefixes
|
30 |
+
)
|
31 |
+
|
32 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
33 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
34 |
+
|
35 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
36 |
+
print("Background Information:")
|
37 |
+
print(background_info)
|
38 |
+
print("\nSample Characteristics Dictionary:")
|
39 |
+
print(sample_characteristics_dict)
|
40 |
+
# 1. Gene expression data availability
|
41 |
+
# Based on the metadata: "mRNA was analyzed using a targeted Nanostring immunology array,"
|
42 |
+
# indicating this study involves gene expression data.
|
43 |
+
is_gene_available = True
|
44 |
+
|
45 |
+
# 2. Variable Availability and Conversion
|
46 |
+
|
47 |
+
# From the sample characteristics, only two keys (0 and 1) are available:
|
48 |
+
# 0 -> polyic_stimulation, and 1 -> cluster
|
49 |
+
# There's no mention of 'Asthma' variation, age, or gender.
|
50 |
+
# So, all samples are asthmatic, which yields no variability in 'trait',
|
51 |
+
# and age/gender aren't in the dictionary.
|
52 |
+
|
53 |
+
trait_row = None # No variation in "Asthma" (everyone is asthmatic)
|
54 |
+
age_row = None # Not found
|
55 |
+
gender_row = None # Not found
|
56 |
+
|
57 |
+
def convert_trait(value: str) -> int:
|
58 |
+
"""
|
59 |
+
Trait data is not available/variable here,
|
60 |
+
so we won't actually use this function.
|
61 |
+
"""
|
62 |
+
return None
|
63 |
+
|
64 |
+
def convert_age(value: str) -> float:
|
65 |
+
"""
|
66 |
+
Age data not available.
|
67 |
+
"""
|
68 |
+
return None
|
69 |
+
|
70 |
+
def convert_gender(value: str) -> int:
|
71 |
+
"""
|
72 |
+
Gender data not available.
|
73 |
+
"""
|
74 |
+
return None
|
75 |
+
|
76 |
+
# 3. Save Metadata (initial filtering)
|
77 |
+
# Trait data is not available because there's no variability.
|
78 |
+
is_trait_available = False
|
79 |
+
is_usable = 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. Clinical Feature Extraction
|
88 |
+
# Since trait_row is None, we skip extraction for this dataset.
|
89 |
+
# STEP3
|
90 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
91 |
+
gene_data = get_genetic_data(matrix_file)
|
92 |
+
|
93 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
94 |
+
print(gene_data.index[:20])
|
95 |
+
# Based on inspection, these appear to be standard human gene symbols.
|
96 |
+
print("requires_gene_mapping = False")
|
p1/preprocess/Asthma/code/GSE230164.py
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
cohort = "GSE230164"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE230164"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Asthma/GSE230164.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/GSE230164.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/GSE230164.csv"
|
16 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP 1
|
19 |
+
|
20 |
+
from tools.preprocess import *
|
21 |
+
|
22 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
23 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
24 |
+
|
25 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
26 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
27 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
28 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
29 |
+
matrix_file,
|
30 |
+
background_prefixes,
|
31 |
+
clinical_prefixes
|
32 |
+
)
|
33 |
+
|
34 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
35 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
36 |
+
|
37 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
38 |
+
print("Background Information:")
|
39 |
+
print(background_info)
|
40 |
+
print("\nSample Characteristics Dictionary:")
|
41 |
+
print(sample_characteristics_dict)
|
42 |
+
# Step 1: Determine if gene expression data is likely available
|
43 |
+
is_gene_available = True # Based on the title "Gene expression profiling of asthma"
|
44 |
+
|
45 |
+
# Step 2: Identify the rows for trait, age, and gender
|
46 |
+
# From the provided sample characteristics dictionary (only key 0 with gender info),
|
47 |
+
# we see no mention of the trait (asthma) or age, so these are not available.
|
48 |
+
trait_row = None
|
49 |
+
age_row = None
|
50 |
+
gender_row = 0 # "gender: female" and "gender: male" are present
|
51 |
+
|
52 |
+
# Data type conversion functions
|
53 |
+
|
54 |
+
def convert_trait(value: str) -> Optional[int]:
|
55 |
+
"""
|
56 |
+
Convert trait values to binary (e.g., 'asthma' -> 1, 'control' or 'healthy' -> 0).
|
57 |
+
Returns None if unknown.
|
58 |
+
"""
|
59 |
+
# Extract the actual data after the colon if present
|
60 |
+
parts = value.split(':', 1)
|
61 |
+
val = parts[1].strip().lower() if len(parts) > 1 else value.lower()
|
62 |
+
|
63 |
+
# Example mapping (if we had trait data)
|
64 |
+
if 'asthma' in val:
|
65 |
+
return 1
|
66 |
+
if 'control' in val or 'healthy' in val:
|
67 |
+
return 0
|
68 |
+
|
69 |
+
return None
|
70 |
+
|
71 |
+
def convert_age(value: str) -> Optional[float]:
|
72 |
+
"""
|
73 |
+
Convert age values to continuous floats.
|
74 |
+
Returns None if parsing fails or data is unknown.
|
75 |
+
"""
|
76 |
+
parts = value.split(':', 1)
|
77 |
+
val = parts[1].strip() if len(parts) > 1 else value
|
78 |
+
try:
|
79 |
+
return float(val)
|
80 |
+
except ValueError:
|
81 |
+
return None
|
82 |
+
|
83 |
+
def convert_gender(value: str) -> Optional[int]:
|
84 |
+
"""
|
85 |
+
Convert gender to binary (female -> 0, male -> 1).
|
86 |
+
Returns None if unknown.
|
87 |
+
"""
|
88 |
+
parts = value.split(':', 1)
|
89 |
+
val = parts[1].strip().lower() if len(parts) > 1 else value.lower()
|
90 |
+
if 'female' in val:
|
91 |
+
return 0
|
92 |
+
if 'male' in val:
|
93 |
+
return 1
|
94 |
+
return None
|
95 |
+
|
96 |
+
# Step 3: Initial filtering and saving of metadata
|
97 |
+
is_trait_available = trait_row is not None
|
98 |
+
|
99 |
+
dataset_usable = validate_and_save_cohort_info(
|
100 |
+
is_final=False,
|
101 |
+
cohort=cohort,
|
102 |
+
info_path=json_path,
|
103 |
+
is_gene_available=is_gene_available,
|
104 |
+
is_trait_available=is_trait_available
|
105 |
+
)
|
106 |
+
|
107 |
+
# Step 4: Since trait_row is None, we skip substep of clinical feature extraction
|
108 |
+
# STEP3
|
109 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
110 |
+
gene_data = get_genetic_data(matrix_file)
|
111 |
+
|
112 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
113 |
+
print(gene_data.index[:20])
|
114 |
+
# Based on the given identifiers (e.g., ILMN_1651199), these appear to be Illumina probe IDs
|
115 |
+
# rather than standard human gene symbols. Therefore, gene symbol mapping is required.
|
116 |
+
|
117 |
+
print("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 in the gene annotation dataframe
|
128 |
+
# - "ID" column contains Illumina probe IDs matching those in the expression data
|
129 |
+
# - "Symbol" column contains the gene symbols
|
130 |
+
prob_col = 'ID'
|
131 |
+
gene_col = 'Symbol'
|
132 |
+
|
133 |
+
# 2. Get a gene mapping dataframe by extracting the two columns
|
134 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=prob_col, gene_col=gene_col)
|
135 |
+
|
136 |
+
# 3. Convert probe-level measurements to gene expression data
|
137 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
138 |
+
# STEP 7: Data Normalization and Linking
|
139 |
+
|
140 |
+
# 1. Normalize gene symbols in the obtained gene expression data
|
141 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
142 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
143 |
+
print(f"Saved normalized gene data to {out_gene_data_file}")
|
144 |
+
|
145 |
+
# Since 'trait_row' was None, no clinical feature extraction occurred and trait data is unavailable.
|
146 |
+
# We must skip linking and final data prep steps and directly do final validation to record that this dataset is unusable for trait-based analysis.
|
147 |
+
|
148 |
+
empty_df = pd.DataFrame() # Placeholder, as df must be provided to the validation function
|
149 |
+
is_usable = validate_and_save_cohort_info(
|
150 |
+
is_final=True,
|
151 |
+
cohort=cohort,
|
152 |
+
info_path=json_path,
|
153 |
+
is_gene_available=True,
|
154 |
+
is_trait_available=False, # No trait data was found
|
155 |
+
is_biased=True, # Arbitrary True to pass validation, making the dataset not usable
|
156 |
+
df=empty_df,
|
157 |
+
note="Trait data is unavailable; skipping linking and final data steps."
|
158 |
+
)
|
159 |
+
|
160 |
+
print("Trait data unavailable. Skipping linking and final data output.")
|
p1/preprocess/Asthma/code/GSE270312.py
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
cohort = "GSE270312"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Asthma"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Asthma/GSE270312"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Asthma/GSE270312.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/GSE270312.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/GSE270312.csv"
|
16 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP 1
|
19 |
+
|
20 |
+
from tools.preprocess import *
|
21 |
+
|
22 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
23 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
24 |
+
|
25 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
26 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
27 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
28 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
29 |
+
matrix_file,
|
30 |
+
background_prefixes,
|
31 |
+
clinical_prefixes
|
32 |
+
)
|
33 |
+
|
34 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
35 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
36 |
+
|
37 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
38 |
+
print("Background Information:")
|
39 |
+
print(background_info)
|
40 |
+
print("\nSample Characteristics Dictionary:")
|
41 |
+
print(sample_characteristics_dict)
|
42 |
+
# Step 1: Gene Expression Data Availability
|
43 |
+
# Based on the background stating "RNA transcriptome responses" were measured, we consider it gene expression data.
|
44 |
+
is_gene_available = True
|
45 |
+
|
46 |
+
# Step 2: Variable Availability and Conversion
|
47 |
+
|
48 |
+
# 2.1 Identify rows for trait, age, and gender
|
49 |
+
# From the sample characteristics dictionary, 'asthma status' = row 3, 'gender' = row 2.
|
50 |
+
# No age information is provided.
|
51 |
+
trait_row = 3
|
52 |
+
age_row = None
|
53 |
+
gender_row = 2
|
54 |
+
|
55 |
+
# 2.2 Define data conversion functions
|
56 |
+
def convert_trait(value: str):
|
57 |
+
# Example: "asthma status: Yes"
|
58 |
+
# Split by colon, then strip extra spaces
|
59 |
+
parts = value.split(":")
|
60 |
+
if len(parts) < 2:
|
61 |
+
return None
|
62 |
+
val = parts[1].strip().lower()
|
63 |
+
if val == "yes":
|
64 |
+
return 1
|
65 |
+
elif val == "no":
|
66 |
+
return 0
|
67 |
+
return None
|
68 |
+
|
69 |
+
def convert_age(value: str):
|
70 |
+
# No age data available, so return None
|
71 |
+
return None
|
72 |
+
|
73 |
+
def convert_gender(value: str):
|
74 |
+
# Example: "gender: Female"
|
75 |
+
parts = value.split(":")
|
76 |
+
if len(parts) < 2:
|
77 |
+
return None
|
78 |
+
val = parts[1].strip().lower()
|
79 |
+
if val == "female":
|
80 |
+
return 0
|
81 |
+
elif val == "male":
|
82 |
+
return 1
|
83 |
+
return None
|
84 |
+
|
85 |
+
# Step 3: Save Metadata (initial filtering)
|
86 |
+
# Trait data is considered available if we have a valid row for it
|
87 |
+
is_trait_available = (trait_row is not None)
|
88 |
+
|
89 |
+
filter_pass = validate_and_save_cohort_info(
|
90 |
+
is_final=False,
|
91 |
+
cohort=cohort,
|
92 |
+
info_path=json_path,
|
93 |
+
is_gene_available=is_gene_available,
|
94 |
+
is_trait_available=is_trait_available
|
95 |
+
)
|
96 |
+
|
97 |
+
# Step 4: Clinical Feature Extraction
|
98 |
+
if trait_row is not None:
|
99 |
+
selected_clinical_df = geo_select_clinical_features(
|
100 |
+
clinical_df=clinical_data,
|
101 |
+
trait=trait,
|
102 |
+
trait_row=trait_row,
|
103 |
+
convert_trait=convert_trait,
|
104 |
+
age_row=age_row,
|
105 |
+
convert_age=convert_age,
|
106 |
+
gender_row=gender_row,
|
107 |
+
convert_gender=convert_gender
|
108 |
+
)
|
109 |
+
|
110 |
+
# Preview the selected clinical features
|
111 |
+
preview_clinical = preview_df(selected_clinical_df)
|
112 |
+
# (You could print the preview or store it if needed; omitted here for brevity.)
|
113 |
+
|
114 |
+
# Save the clinical data
|
115 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
116 |
+
# STEP3
|
117 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
118 |
+
gene_data = get_genetic_data(matrix_file)
|
119 |
+
|
120 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
121 |
+
print(gene_data.index[:20])
|
122 |
+
# Based on the observed gene identifiers such as ABCF1, ACE, ACKR2, etc.,
|
123 |
+
# these appear to be valid human gene symbols and do not require additional mapping.
|
124 |
+
|
125 |
+
print("These genes are human gene symbols.")
|
126 |
+
|
127 |
+
# Conclusion
|
128 |
+
print("\nrequires_gene_mapping = False")
|
129 |
+
# STEP 7: Data Normalization and Linking
|
130 |
+
|
131 |
+
# 1. Normalize gene symbols in the obtained gene expression data
|
132 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
133 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
134 |
+
print(f"Saved normalized gene data to {out_gene_data_file}")
|
135 |
+
|
136 |
+
# 2. Link the clinical and genetic data on sample IDs
|
137 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
138 |
+
|
139 |
+
# 3. Handle missing values in the linked data
|
140 |
+
linked_data = handle_missing_values(linked_data, trait_col=trait)
|
141 |
+
|
142 |
+
# 4. Determine whether the trait/demographic features are severely biased
|
143 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait=trait)
|
144 |
+
|
145 |
+
# 5. Conduct final quality validation and save metadata
|
146 |
+
is_usable = validate_and_save_cohort_info(
|
147 |
+
is_final=True,
|
148 |
+
cohort=cohort,
|
149 |
+
info_path=json_path,
|
150 |
+
is_gene_available=True,
|
151 |
+
is_trait_available=True,
|
152 |
+
is_biased=trait_biased,
|
153 |
+
df=linked_data,
|
154 |
+
note="Trait data and gene data successfully linked."
|
155 |
+
)
|
156 |
+
|
157 |
+
# 6. If the dataset is deemed usable, save the final linked data as a CSV file
|
158 |
+
if is_usable:
|
159 |
+
linked_data.to_csv(out_data_file)
|
160 |
+
print(f"Saved final linked data to {out_data_file}")
|
161 |
+
else:
|
162 |
+
print("Dataset was not deemed usable; final linked data not saved.")
|
p1/preprocess/Asthma/code/TCGA.py
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Asthma"
|
6 |
+
|
7 |
+
# Input paths
|
8 |
+
tcga_root_dir = "../DATA/TCGA"
|
9 |
+
|
10 |
+
# Output paths
|
11 |
+
out_data_file = "./output/preprocess/1/Asthma/TCGA.csv"
|
12 |
+
out_gene_data_file = "./output/preprocess/1/Asthma/gene_data/TCGA.csv"
|
13 |
+
out_clinical_data_file = "./output/preprocess/1/Asthma/clinical_data/TCGA.csv"
|
14 |
+
json_path = "./output/preprocess/1/Asthma/cohort_info.json"
|
15 |
+
|
16 |
+
import os
|
17 |
+
|
18 |
+
# Step 1: Identify subdirectory that might relate to "Asthma"
|
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 |
+
# Since we're looking for "Asthma" and no subdirectory name suggests an asthma-related cancer,
|
36 |
+
# no suitable subdirectory is found.
|
37 |
+
suitable_subdir = None
|
38 |
+
|
39 |
+
# Confirm no matching subdirectory
|
40 |
+
for sd in subdirs:
|
41 |
+
# Normally, you'd check synonyms for "Asthma" if needed.
|
42 |
+
if "asthma" in sd.lower():
|
43 |
+
suitable_subdir = sd
|
44 |
+
break
|
45 |
+
|
46 |
+
# If not found, skip the trait:
|
47 |
+
if not suitable_subdir:
|
48 |
+
print("No suitable subdirectory found for trait 'Asthma'. Skipping this trait.")
|
49 |
+
# Mark as completed but unavailable in metadata
|
50 |
+
validate_and_save_cohort_info(
|
51 |
+
is_final=False,
|
52 |
+
cohort="TCGA",
|
53 |
+
info_path=json_path,
|
54 |
+
is_gene_available=False,
|
55 |
+
is_trait_available=False
|
56 |
+
)
|
57 |
+
else:
|
58 |
+
# (Would proceed to load data if a matching subdirectory was found.)
|
59 |
+
pass
|
p1/preprocess/Asthma/gene_data/GSE123086.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049
|
p1/preprocess/Asthma/gene_data/GSE123088.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049,GSM3495050,GSM3495051,GSM3495052,GSM3495053,GSM3495054,GSM3495055,GSM3495056,GSM3495057,GSM3495058,GSM3495059,GSM3495060,GSM3495061,GSM3495062,GSM3495063,GSM3495064,GSM3495065,GSM3495066,GSM3495067,GSM3495068,GSM3495069,GSM3495070,GSM3495071,GSM3495072,GSM3495073,GSM3495074,GSM3495075,GSM3495076,GSM3495077,GSM3495078,GSM3495079,GSM3495080,GSM3495081,GSM3495082,GSM3495083,GSM3495084,GSM3495085,GSM3495086,GSM3495087
|
p1/preprocess/Asthma/gene_data/GSE182797.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM5537157,GSM5537158,GSM5537159,GSM5537160,GSM5537161,GSM5537162,GSM5537163,GSM5537164,GSM5537165,GSM5537166,GSM5537167,GSM5537168,GSM5537169,GSM5537170,GSM5537171,GSM5537172,GSM5537173,GSM5537174,GSM5537175,GSM5537176,GSM5537177,GSM5537178,GSM5537179,GSM5537180,GSM5537181,GSM5537182,GSM5537183,GSM5537184,GSM5537185,GSM5537186,GSM5537187,GSM5537188,GSM5537189,GSM5537190,GSM5537191,GSM5537192,GSM5537193,GSM5537194,GSM5537195,GSM5537196,GSM5537197,GSM5537198,GSM5537199,GSM5537200,GSM5537201,GSM5537202,GSM5537203,GSM5537204,GSM5537205,GSM5537206,GSM5537207,GSM5537208,GSM5537209,GSM5537210,GSM5537211,GSM5537212,GSM5537213,GSM5537214,GSM5537215,GSM5537216,GSM5537217,GSM5537218,GSM5537219,GSM5537220,GSM5537221,GSM5537222,GSM5537223,GSM5537224,GSM5537225,GSM5537226,GSM5537227,GSM5537228,GSM5537229,GSM5537230,GSM5537231,GSM5537232,GSM5537233,GSM5537234,GSM5537235,GSM5537236
|
p1/preprocess/Asthma/gene_data/GSE182798.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM5530417,GSM5530418,GSM5530419,GSM5530420,GSM5530421,GSM5530422,GSM5530423,GSM5530424,GSM5530425,GSM5530426,GSM5530427,GSM5530428,GSM5530429,GSM5530430,GSM5530431,GSM5530432,GSM5530433,GSM5530434,GSM5530435,GSM5530436,GSM5530437,GSM5530438,GSM5530439,GSM5530440,GSM5530441,GSM5530442,GSM5530443,GSM5530444,GSM5530445,GSM5530446,GSM5530447,GSM5530448,GSM5530449,GSM5530450,GSM5530451,GSM5530452,GSM5530453,GSM5530454,GSM5530455,GSM5530456,GSM5530457,GSM5530458,GSM5530459,GSM5530460,GSM5530461,GSM5530462,GSM5530463,GSM5530464,GSM5530465,GSM5530466,GSM5530467,GSM5530468,GSM5530469,GSM5530470,GSM5530471,GSM5530472,GSM5530473,GSM5530474,GSM5530475,GSM5530476,GSM5530477,GSM5530478,GSM5530479,GSM5530480,GSM5530481,GSM5530482,GSM5530483,GSM5530484,GSM5530485,GSM5530486,GSM5530487,GSM5530488,GSM5530489,GSM5530490,GSM5530491,GSM5530492,GSM5530493,GSM5530494,GSM5530495,GSM5530496,GSM5530497,GSM5530498,GSM5530499,GSM5530500,GSM5530501,GSM5530502,GSM5530503,GSM5530504,GSM5530505,GSM5530506,GSM5530507,GSM5530508,GSM5530509,GSM5530510,GSM5530511,GSM5530512,GSM5530513,GSM5530514,GSM5530515,GSM5530516,GSM5530517,GSM5530518,GSM5537157,GSM5537158,GSM5537159,GSM5537160,GSM5537161,GSM5537162,GSM5537163,GSM5537164,GSM5537165,GSM5537166,GSM5537167,GSM5537168,GSM5537169,GSM5537170,GSM5537171,GSM5537172,GSM5537173,GSM5537174,GSM5537175,GSM5537176,GSM5537177,GSM5537178,GSM5537179,GSM5537180,GSM5537181,GSM5537182,GSM5537183,GSM5537184,GSM5537185,GSM5537186,GSM5537187,GSM5537188,GSM5537189,GSM5537190,GSM5537191,GSM5537192,GSM5537193,GSM5537194,GSM5537195,GSM5537196,GSM5537197,GSM5537198,GSM5537199,GSM5537200,GSM5537201,GSM5537202,GSM5537203,GSM5537204,GSM5537205,GSM5537206,GSM5537207,GSM5537208,GSM5537209,GSM5537210,GSM5537211,GSM5537212,GSM5537213,GSM5537214,GSM5537215,GSM5537216,GSM5537217,GSM5537218,GSM5537219,GSM5537220,GSM5537221,GSM5537222,GSM5537223,GSM5537224,GSM5537225,GSM5537226,GSM5537227,GSM5537228,GSM5537229,GSM5537230,GSM5537231,GSM5537232,GSM5537233,GSM5537234,GSM5537235,GSM5537236
|
p1/preprocess/Asthma/gene_data/GSE184382.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM5585358,GSM5585359,GSM5585360,GSM5585361,GSM5585362,GSM5585363,GSM5585364,GSM5585365,GSM5585366,GSM5585367,GSM5585368,GSM5585369,GSM5585370,GSM5585371,GSM5585372,GSM5585373,GSM5585374,GSM5585375,GSM5585376,GSM5585377,GSM5585378,GSM5585379,GSM5585380,GSM5585381,GSM5585382,GSM5585383,GSM5585384,GSM5585385,GSM5585386,GSM5585387,GSM5585388,GSM5585389,GSM5585390,GSM5585391,GSM5585392,GSM5585393,GSM5585394,GSM5585395,GSM5585396
|
p1/preprocess/Asthma/gene_data/GSE185658.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM5621296,GSM5621297,GSM5621298,GSM5621299,GSM5621300,GSM5621301,GSM5621302,GSM5621303,GSM5621304,GSM5621305,GSM5621306,GSM5621307,GSM5621308,GSM5621309,GSM5621310,GSM5621311,GSM5621312,GSM5621313,GSM5621314,GSM5621315,GSM5621316,GSM5621317,GSM5621318,GSM5621319,GSM5621320,GSM5621321,GSM5621322,GSM5621323,GSM5621324,GSM5621325,GSM5621326,GSM5621327,GSM5621328,GSM5621329,GSM5621330,GSM5621331,GSM5621332,GSM5621333,GSM5621334,GSM5621335,GSM5621336,GSM5621337,GSM5621338,GSM5621339,GSM5621340,GSM5621341,GSM5621342,GSM5621343
|
p1/preprocess/Asthma/gene_data/GSE188424.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM5681954,GSM5681955,GSM5681956,GSM5681957,GSM5681958,GSM5681959,GSM5681960,GSM5681961,GSM5681962,GSM5681963,GSM5681964,GSM5681965,GSM5681966,GSM5681967,GSM5681968,GSM5681969,GSM5681970,GSM5681971,GSM5681972,GSM5681973,GSM5681974,GSM5681975,GSM5681976,GSM5681977,GSM5681978,GSM5681979,GSM5681980,GSM5681981,GSM5681982,GSM5681983,GSM5681984,GSM5681985,GSM5681986,GSM5681987,GSM5681988,GSM5681989,GSM5681990,GSM5681991,GSM5681992,GSM5681993,GSM5681994,GSM5681995,GSM5681996,GSM5681997,GSM5681998,GSM5681999,GSM5682000,GSM5682001,GSM5682002,GSM5682003,GSM5682004,GSM5682005,GSM5682006,GSM5682007,GSM5682008,GSM5682009,GSM5682010,GSM5682011,GSM5682012,GSM5682013,GSM5682014,GSM5682015,GSM5682016,GSM5682017,GSM5682018,GSM5682019,GSM5682020,GSM5682021,GSM5682022,GSM5682023,GSM5682024,GSM5682025,GSM5682026,GSM5682027,GSM5682028,GSM5682029,GSM5682030,GSM5682031,GSM5682032,GSM5682033,GSM5682034,GSM5682035,GSM5682036,GSM5682037,GSM5682038,GSM5682039,GSM5682040,GSM5682041,GSM5682042,GSM5682043,GSM5682044,GSM5682045,GSM5682046,GSM5682047,GSM5682048,GSM5682049,GSM5682050,GSM5682051,GSM5682052
|
p1/preprocess/Asthma/gene_data/GSE230164.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM5681954,GSM5681955,GSM5681956,GSM5681957,GSM5681958,GSM5681959,GSM5681960,GSM5681961,GSM5681962,GSM5681963,GSM5681964,GSM5681965,GSM5681966,GSM5681967,GSM5681968,GSM5681969,GSM5681970,GSM5681971,GSM5681972,GSM5681973,GSM5681974,GSM5681975,GSM5681976,GSM5681977,GSM5681978,GSM5681979,GSM5681980,GSM5681981,GSM5681982,GSM5681983,GSM5681984,GSM5681985,GSM5681986,GSM5681987,GSM5681988,GSM5681989,GSM5681990,GSM5681991,GSM5681992,GSM5681993,GSM5681994,GSM5681995,GSM5681996,GSM5681997,GSM5681998,GSM5681999,GSM5682000,GSM5682001,GSM5682002,GSM5682003,GSM5682004,GSM5682005,GSM5682006,GSM5682007,GSM5682008,GSM5682009,GSM5682010,GSM5682011,GSM5682012,GSM5682013,GSM5682014,GSM5682015,GSM5682016,GSM5682017,GSM5682018,GSM5682019,GSM5682020,GSM5682021,GSM5682022,GSM5682023,GSM5682024,GSM5682025,GSM5682026,GSM5682027,GSM5682028,GSM5682029,GSM5682030,GSM5682031,GSM5682032,GSM5682033,GSM5682034,GSM5682035,GSM5682036,GSM5682037,GSM5682038,GSM5682039,GSM5682040,GSM5682041,GSM5682042,GSM5682043,GSM5682044,GSM5682045,GSM5682046,GSM5682047,GSM5682048,GSM5682049,GSM5682050,GSM5682051,GSM5682052
|
p1/preprocess/Asthma/gene_data/GSE270312.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
ID,GSM8339381,GSM8339382,GSM8339383,GSM8339384,GSM8339385,GSM8339386,GSM8339387,GSM8339388,GSM8339389,GSM8339390,GSM8339391,GSM8339392,GSM8339393,GSM8339394,GSM8339395,GSM8339396,GSM8339397,GSM8339398,GSM8339399,GSM8339400,GSM8339401,GSM8339402,GSM8339403,GSM8339404,GSM8339405,GSM8339406,GSM8339407,GSM8339408,GSM8339409,GSM8339410,GSM8339411,GSM8339412,GSM8339413,GSM8339414,GSM8339415,GSM8339416,GSM8339417,GSM8339418,GSM8339419,GSM8339420,GSM8339421,GSM8339422,GSM8339423,GSM8339424,GSM8339425,GSM8339426,GSM8339427,GSM8339428,GSM8339429,GSM8339430,GSM8339431,GSM8339432,GSM8339433,GSM8339434,GSM8339435,GSM8339436,GSM8339437,GSM8339438,GSM8339439,GSM8339440,GSM8339441,GSM8339442,GSM8339443,GSM8339444,GSM8339445,GSM8339446,GSM8339447,GSM8339448,GSM8339449,GSM8339450,GSM8339451,GSM8339452,GSM8339453,GSM8339454,GSM8339455,GSM8339456,GSM8339457,GSM8339458,GSM8339459,GSM8339460,GSM8339461,GSM8339462,GSM8339463,GSM8339464,GSM8339465,GSM8339466,GSM8339467,GSM8339468,GSM8339469,GSM8339470
|
p1/preprocess/Atrial_Fibrillation/GSE143924.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Atrial_Fibrillation/clinical_data/GSE115574.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM3182680,GSM3182681,GSM3182682,GSM3182683,GSM3182684,GSM3182685,GSM3182686,GSM3182687,GSM3182688,GSM3182689,GSM3182690,GSM3182691,GSM3182692,GSM3182693,GSM3182694,GSM3182695,GSM3182696,GSM3182697,GSM3182698,GSM3182699,GSM3182700,GSM3182701,GSM3182702,GSM3182703,GSM3182704,GSM3182705,GSM3182706,GSM3182707,GSM3182708,GSM3182709,GSM3182710,GSM3182711,GSM3182712,GSM3182713,GSM3182714,GSM3182715,GSM3182716,GSM3182717,GSM3182718,GSM3182719,GSM3182720,GSM3182721,GSM3182722,GSM3182723,GSM3182724,GSM3182725,GSM3182726,GSM3182727,GSM3182728,GSM3182729,GSM3182730,GSM3182731,GSM3182732,GSM3182733,GSM3182734,GSM3182735,GSM3182736,GSM3182737,GSM3182738
|
2 |
+
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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
|
p1/preprocess/Atrial_Fibrillation/clinical_data/GSE143924.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM4276706,GSM4276707,GSM4276708,GSM4276709,GSM4276710,GSM4276711,GSM4276712,GSM4276713,GSM4276714,GSM4276715,GSM4276716,GSM4276717,GSM4276718,GSM4276719,GSM4276720,GSM4276721,GSM4276722,GSM4276723,GSM4276724,GSM4276725,GSM4276726,GSM4276727,GSM4276728,GSM4276729,GSM4276730,GSM4276731,GSM4276732,GSM4276733,GSM4276734,GSM4276735
|
2 |
+
0.0,0.0,0.0,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
|
p1/preprocess/Atrial_Fibrillation/clinical_data/GSE235307.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GSM7498589,GSM7498590,GSM7498591,GSM7498592,GSM7498593,GSM7498594,GSM7498595,GSM7498596,GSM7498597,GSM7498598,GSM7498599,GSM7498600,GSM7498601,GSM7498602,GSM7498603,GSM7498604,GSM7498605,GSM7498606,GSM7498607,GSM7498608,GSM7498609,GSM7498610,GSM7498611,GSM7498612,GSM7498613,GSM7498614,GSM7498615,GSM7498616,GSM7498617,GSM7498618,GSM7498619,GSM7498620,GSM7498621,GSM7498622,GSM7498623,GSM7498624,GSM7498625,GSM7498626,GSM7498627,GSM7498628,GSM7498629,GSM7498630,GSM7498631,GSM7498632,GSM7498633,GSM7498634,GSM7498635,GSM7498636,GSM7498637,GSM7498638,GSM7498639,GSM7498640,GSM7498641,GSM7498642,GSM7498643,GSM7498644,GSM7498645,GSM7498646,GSM7498647,GSM7498648,GSM7498649,GSM7498650,GSM7498651,GSM7498652,GSM7498653,GSM7498654,GSM7498655,GSM7498656,GSM7498657,GSM7498658,GSM7498659,GSM7498660,GSM7498661,GSM7498662,GSM7498663,GSM7498664,GSM7498665,GSM7498666,GSM7498667,GSM7498668,GSM7498669,GSM7498670,GSM7498671,GSM7498672,GSM7498673,GSM7498674,GSM7498675,GSM7498676,GSM7498677,GSM7498678,GSM7498679,GSM7498680,GSM7498681,GSM7498682,GSM7498683,GSM7498684,GSM7498685,GSM7498686,GSM7498687,GSM7498688,GSM7498689,GSM7498690,GSM7498691,GSM7498692,GSM7498693,GSM7498694,GSM7498695,GSM7498696,GSM7498697,GSM7498698,GSM7498699,GSM7498700,GSM7498701,GSM7498702,GSM7498703,GSM7498704,GSM7498705,GSM7498706,GSM7498707
|
2 |
+
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0
|
3 |
+
63.0,60.0,60.0,72.0,63.0,66.0,70.0,64.0,63.0,61.0,70.0,64.0,63.0,44.0,54.0,44.0,50.0,79.0,63.0,63.0,64.0,60.0,51.0,55.0,55.0,67.0,52.0,70.0,54.0,54.0,73.0,54.0,76.0,76.0,43.0,64.0,64.0,68.0,43.0,54.0,72.0,51.0,68.0,50.0,78.0,69.0,64.0,54.0,54.0,57.0,55.0,60.0,59.0,54.0,54.0,54.0,54.0,53.0,52.0,68.0,72.0,70.0,65.0,64.0,56.0,56.0,63.0,57.0,63.0,68.0,66.0,74.0,38.0,56.0,57.0,71.0,78.0,51.0,50.0,37.0,37.0,70.0,72.0,73.0,69.0,69.0,63.0,62.0,59.0,67.0,76.0,63.0,55.0,57.0,53.0,59.0,77.0,54.0,64.0,75.0,75.0,72.0,58.0,75.0,78.0,58.0,64.0,63.0,61.0,60.0,59.0,68.0,77.0,57.0,62.0,66.0,57.0,65.0,59.0
|
4 |
+
1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Atrial_Fibrillation/code/GSE115574.py
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atrial_Fibrillation"
|
6 |
+
cohort = "GSE115574"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE115574"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Atrial_Fibrillation/GSE115574.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Atrial_Fibrillation/gene_data/GSE115574.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Atrial_Fibrillation/clinical_data/GSE115574.csv"
|
16 |
+
json_path = "./output/preprocess/1/Atrial_Fibrillation/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 # The series title and summary indicate "gene expression microarrays" were used
|
38 |
+
|
39 |
+
# 2. Variable Availability and Data Type Conversion
|
40 |
+
|
41 |
+
# 2.1 Identify rows for trait, age, gender.
|
42 |
+
# Examining the provided dictionary:
|
43 |
+
# {0: ['disease state: atrial fibrillation patient with severe mitral regurgitation',
|
44 |
+
# 'disease state: sinus rhythm patient with severe mitral regurgitation'],
|
45 |
+
# 1: ['tissue: left atrium - heart', 'tissue: right atrium - heart']}
|
46 |
+
# Row 0 has multiple unique values related to AF vs. sinus rhythm.
|
47 |
+
trait_row = 0
|
48 |
+
age_row = None # No row provides age info
|
49 |
+
gender_row = None # No row provides gender info
|
50 |
+
|
51 |
+
# 2.2 Define conversion functions
|
52 |
+
|
53 |
+
def convert_trait(value: str) -> int:
|
54 |
+
"""Convert trait info to a binary indicator: AF=1, otherwise=0."""
|
55 |
+
# Extract the part after the first colon
|
56 |
+
parts = value.split(':', 1)
|
57 |
+
raw_str = parts[1].strip().lower() if len(parts) > 1 else value.lower()
|
58 |
+
if 'atrial fibrillation' in raw_str:
|
59 |
+
return 1
|
60 |
+
elif 'sinus rhythm' in raw_str:
|
61 |
+
return 0
|
62 |
+
else:
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_age(value: str) -> float:
|
66 |
+
"""Unused here because age_row is None, but define a placeholder."""
|
67 |
+
return None
|
68 |
+
|
69 |
+
def convert_gender(value: str) -> int:
|
70 |
+
"""Unused here because gender_row is None, but define a placeholder."""
|
71 |
+
return None
|
72 |
+
|
73 |
+
# 3. Save Metadata (initial filtering)
|
74 |
+
is_trait_available = (trait_row is not None)
|
75 |
+
_ = validate_and_save_cohort_info(
|
76 |
+
is_final=False,
|
77 |
+
cohort=cohort,
|
78 |
+
info_path=json_path,
|
79 |
+
is_gene_available=is_gene_available,
|
80 |
+
is_trait_available=is_trait_available
|
81 |
+
)
|
82 |
+
|
83 |
+
# 4. Clinical Feature Extraction
|
84 |
+
if trait_row is not None:
|
85 |
+
selected_features = geo_select_clinical_features(
|
86 |
+
clinical_df=clinical_data, # Assumes 'clinical_data' DataFrame is already in environment
|
87 |
+
trait=trait,
|
88 |
+
trait_row=trait_row,
|
89 |
+
convert_trait=convert_trait,
|
90 |
+
age_row=age_row,
|
91 |
+
convert_age=convert_age,
|
92 |
+
gender_row=gender_row,
|
93 |
+
convert_gender=convert_gender
|
94 |
+
)
|
95 |
+
# Preview the selected features
|
96 |
+
preview_dict = preview_df(selected_features, n=5, max_items=200)
|
97 |
+
print("Clinical Features Preview:", preview_dict)
|
98 |
+
|
99 |
+
# Save the extracted clinical features
|
100 |
+
selected_features.to_csv(out_clinical_data_file, index=False)
|
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 |
+
# Based on the probe IDs (e.g. '1007_s_at', '1053_at'), these are Affymetrix probe identifiers
|
108 |
+
# which require mapping to official gene symbols.
|
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 & 2. Identify the columns for the probe IDs and gene symbols in the annotation dataframe.
|
121 |
+
# In this dataset, they are stored in 'ID' and 'Gene Symbol'.
|
122 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
|
123 |
+
|
124 |
+
# 3. Convert probe-level measurements to gene-level expression data.
|
125 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
126 |
+
|
127 |
+
# Print the dimensions and the first 10 gene symbols to confirm
|
128 |
+
print("Mapped gene_data shape:", gene_data.shape)
|
129 |
+
print("First 10 gene symbols:", gene_data.index[:10])
|
130 |
+
# STEP7
|
131 |
+
|
132 |
+
# 1. Normalize the obtained gene data using the NCBI Gene synonym database
|
133 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
134 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
135 |
+
|
136 |
+
# 2. Link the clinical and genetic data
|
137 |
+
linked_data = geo_link_clinical_genetic_data(selected_features, normalized_gene_data)
|
138 |
+
|
139 |
+
# 3. Handle missing values systematically
|
140 |
+
linked_data_processed = handle_missing_values(linked_data, trait_col=trait)
|
141 |
+
|
142 |
+
# 4. Check for biased trait and remove any biased demographic features
|
143 |
+
trait_biased, linked_data_final = judge_and_remove_biased_features(linked_data_processed, trait)
|
144 |
+
|
145 |
+
# 5. Final quality validation and metadata saving
|
146 |
+
is_usable = validate_and_save_cohort_info(
|
147 |
+
is_final=True,
|
148 |
+
cohort=cohort,
|
149 |
+
info_path=json_path,
|
150 |
+
is_gene_available=True,
|
151 |
+
is_trait_available=True,
|
152 |
+
is_biased=trait_biased,
|
153 |
+
df=linked_data_final,
|
154 |
+
note="Dataset processed with GEO pipeline. Checked for missing values and bias."
|
155 |
+
)
|
156 |
+
|
157 |
+
# 6. If dataset is usable, save the final linked data
|
158 |
+
if is_usable:
|
159 |
+
linked_data_final.to_csv(out_data_file)
|
p1/preprocess/Atrial_Fibrillation/code/GSE143924.py
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atrial_Fibrillation"
|
6 |
+
cohort = "GSE143924"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE143924"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Atrial_Fibrillation/GSE143924.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Atrial_Fibrillation/gene_data/GSE143924.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Atrial_Fibrillation/clinical_data/GSE143924.csv"
|
16 |
+
json_path = "./output/preprocess/1/Atrial_Fibrillation/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 |
+
############################
|
37 |
+
# 1. Gene Expression Data Availability
|
38 |
+
############################
|
39 |
+
is_gene_available = True # Based on "Whole-tissue gene expression patterns" in the series summary
|
40 |
+
|
41 |
+
############################
|
42 |
+
# 2. Variable Availability and Data Type Conversion
|
43 |
+
############################
|
44 |
+
# From the sample characteristics dictionary:
|
45 |
+
# {0: ['tissue: epicardial adipose tissue'],
|
46 |
+
# 1: ['patient diagnosis: sinus rhythm after surgery',
|
47 |
+
# 'patient diagnosis: postoperative atrial fibrillation after surgery (POAF)']}
|
48 |
+
|
49 |
+
# The trait "Atrial_Fibrillation" can be inferred from row 1 since it contains
|
50 |
+
# "sinus rhythm after surgery" vs. "postoperative atrial fibrillation after surgery (POAF)".
|
51 |
+
trait_row = 1
|
52 |
+
|
53 |
+
# There's no mention of age or gender information in the dictionary,
|
54 |
+
# thus they are considered not available.
|
55 |
+
age_row = None
|
56 |
+
gender_row = None
|
57 |
+
|
58 |
+
# Data Type Conversions
|
59 |
+
def convert_trait(value: str) -> Optional[int]:
|
60 |
+
# Extract the value after the colon
|
61 |
+
parts = value.split(':', 1)
|
62 |
+
val_str = parts[1].strip() if len(parts) > 1 else value.strip()
|
63 |
+
|
64 |
+
# Map recognized patterns to 0 or 1
|
65 |
+
if val_str.lower() == 'sinus rhythm after surgery':
|
66 |
+
return 0
|
67 |
+
elif 'postoperative atrial fibrillation' in val_str.lower():
|
68 |
+
return 1
|
69 |
+
else:
|
70 |
+
return None
|
71 |
+
|
72 |
+
def convert_age(value: str) -> Optional[float]:
|
73 |
+
# No age data is truly available here; returning None
|
74 |
+
return None
|
75 |
+
|
76 |
+
def convert_gender(value: str) -> Optional[int]:
|
77 |
+
# No gender data is truly available here; returning None
|
78 |
+
return None
|
79 |
+
|
80 |
+
############################
|
81 |
+
# 3. Save Metadata (Initial Filtering)
|
82 |
+
############################
|
83 |
+
is_trait_available = trait_row is not None
|
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 |
+
############################
|
93 |
+
# 4. Clinical Feature Extraction
|
94 |
+
############################
|
95 |
+
if trait_row is not None:
|
96 |
+
# Suppose clinical_data is our input DataFrame of sample characteristics
|
97 |
+
selected_clinical = geo_select_clinical_features(
|
98 |
+
clinical_df=clinical_data,
|
99 |
+
trait=trait,
|
100 |
+
trait_row=trait_row,
|
101 |
+
convert_trait=convert_trait,
|
102 |
+
age_row=age_row,
|
103 |
+
convert_age=convert_age,
|
104 |
+
gender_row=gender_row,
|
105 |
+
convert_gender=convert_gender
|
106 |
+
)
|
107 |
+
|
108 |
+
# Preview the extracted clinical features
|
109 |
+
preview = preview_df(selected_clinical, n=5)
|
110 |
+
print("Selected Clinical Features Preview:", preview)
|
111 |
+
|
112 |
+
# Save the selected clinical data
|
113 |
+
selected_clinical.to_csv(out_clinical_data_file, index=False)
|
114 |
+
# STEP3
|
115 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
116 |
+
gene_data = get_genetic_data(matrix_file)
|
117 |
+
|
118 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
119 |
+
print(gene_data.index[:20])
|
120 |
+
# Based on biomedical knowledge, the listed gene identifiers appear to be recognized human gene symbols.
|
121 |
+
# Therefore, they do not require additional gene symbol mapping.
|
122 |
+
print("requires_gene_mapping = False")
|
123 |
+
# STEP5
|
124 |
+
|
125 |
+
# 1. Normalize the obtained gene data using the NCBI Gene synonym database
|
126 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
127 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
128 |
+
|
129 |
+
# 2. Link the clinical and genetic data
|
130 |
+
# Replace "selected_clinical_df" with the correct variable "selected_clinical"
|
131 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical, normalized_gene_data)
|
132 |
+
|
133 |
+
# 3. Handle missing values systematically
|
134 |
+
linked_data_processed = handle_missing_values(linked_data, trait_col=trait)
|
135 |
+
|
136 |
+
# 4. Check for biased trait and remove any biased demographic features
|
137 |
+
trait_biased, linked_data_final = judge_and_remove_biased_features(linked_data_processed, trait)
|
138 |
+
|
139 |
+
# 5. Final quality validation and metadata saving
|
140 |
+
is_usable = validate_and_save_cohort_info(
|
141 |
+
is_final=True,
|
142 |
+
cohort=cohort,
|
143 |
+
info_path=json_path,
|
144 |
+
is_gene_available=True,
|
145 |
+
is_trait_available=True,
|
146 |
+
is_biased=trait_biased,
|
147 |
+
df=linked_data_final,
|
148 |
+
note="Dataset processed with GEO pipeline. Checked for missing values and bias."
|
149 |
+
)
|
150 |
+
|
151 |
+
# 6. If dataset is usable, save the final linked data
|
152 |
+
if is_usable:
|
153 |
+
linked_data_final.to_csv(out_data_file)
|
p1/preprocess/Atrial_Fibrillation/code/GSE235307.py
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atrial_Fibrillation"
|
6 |
+
cohort = "GSE235307"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE235307"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Atrial_Fibrillation/GSE235307.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Atrial_Fibrillation/gene_data/GSE235307.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Atrial_Fibrillation/clinical_data/GSE235307.csv"
|
16 |
+
json_path = "./output/preprocess/1/Atrial_Fibrillation/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: Determine gene expression availability
|
37 |
+
is_gene_available = True # From the background information, this dataset involves gene expression analysis
|
38 |
+
|
39 |
+
# Step 2.1: Identify row indices for trait, age, and gender
|
40 |
+
trait_row = 5 # "cardiac rhythm after 1 year follow-up: Sinus rhythm / Atrial fibrillation"
|
41 |
+
age_row = 2 # "age: ##"
|
42 |
+
gender_row = 1 # "gender: Male / Female"
|
43 |
+
|
44 |
+
# Step 2.2: Define functions for data type conversion
|
45 |
+
def convert_trait(value: str):
|
46 |
+
"""
|
47 |
+
Convert the trait data into binary (0 or 1).
|
48 |
+
Expecting strings like 'cardiac rhythm after 1 year follow-up: Sinus rhythm'
|
49 |
+
or 'cardiac rhythm after 1 year follow-up: Atrial fibrillation'.
|
50 |
+
"""
|
51 |
+
parts = value.split(':')
|
52 |
+
if len(parts) < 2:
|
53 |
+
return None
|
54 |
+
val = parts[-1].strip().lower()
|
55 |
+
if 'atrial fibrillation' in val:
|
56 |
+
return 1
|
57 |
+
elif 'sinus rhythm' in val:
|
58 |
+
return 0
|
59 |
+
return None
|
60 |
+
|
61 |
+
def convert_age(value: str):
|
62 |
+
"""
|
63 |
+
Convert the age data into a continuous float.
|
64 |
+
Expecting strings like 'age: 64'.
|
65 |
+
"""
|
66 |
+
parts = value.split(':')
|
67 |
+
if len(parts) < 2:
|
68 |
+
return None
|
69 |
+
val = parts[-1].strip()
|
70 |
+
try:
|
71 |
+
return float(val)
|
72 |
+
except ValueError:
|
73 |
+
return None
|
74 |
+
|
75 |
+
def convert_gender(value: str):
|
76 |
+
"""
|
77 |
+
Convert gender data into binary (female=0, male=1).
|
78 |
+
Expecting strings like 'gender: Male' or 'gender: Female'.
|
79 |
+
"""
|
80 |
+
parts = value.split(':')
|
81 |
+
if len(parts) < 2:
|
82 |
+
return None
|
83 |
+
val = parts[-1].strip().lower()
|
84 |
+
if val == 'male':
|
85 |
+
return 1
|
86 |
+
elif val == 'female':
|
87 |
+
return 0
|
88 |
+
return None
|
89 |
+
|
90 |
+
# Step 3: Conduct initial filtering and save metadata
|
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=(trait_row is not None)
|
97 |
+
)
|
98 |
+
|
99 |
+
# Step 4: If trait data is available, extract clinical features and preview
|
100 |
+
if trait_row is not None:
|
101 |
+
selected_clinical_df = geo_select_clinical_features(
|
102 |
+
clinical_data, # Assume 'clinical_data' DataFrame is loaded from previous steps
|
103 |
+
trait=trait,
|
104 |
+
trait_row=trait_row,
|
105 |
+
convert_trait=convert_trait,
|
106 |
+
age_row=age_row,
|
107 |
+
convert_age=convert_age,
|
108 |
+
gender_row=gender_row,
|
109 |
+
convert_gender=convert_gender
|
110 |
+
)
|
111 |
+
print("Preview of selected clinical features:", preview_df(selected_clinical_df))
|
112 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
113 |
+
# STEP3
|
114 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
115 |
+
gene_data = get_genetic_data(matrix_file)
|
116 |
+
|
117 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
118 |
+
print(gene_data.index[:20])
|
119 |
+
# From examining the provided gene expression data index (4,5,6...23),
|
120 |
+
# these do not look like standard human gene symbols.
|
121 |
+
# They are more likely numeric probe IDs or array-specific identifiers.
|
122 |
+
# Therefore, mapping to recognized human gene symbols is required.
|
123 |
+
|
124 |
+
print("requires_gene_mapping = True")
|
125 |
+
# STEP5
|
126 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
127 |
+
gene_annotation = get_gene_annotation(soft_file)
|
128 |
+
|
129 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
130 |
+
print("Gene annotation preview:")
|
131 |
+
print(preview_df(gene_annotation))
|
132 |
+
# STEP: Gene Identifier Mapping
|
133 |
+
|
134 |
+
# 1. Decide which column in 'gene_annotation' matches the gene expression data ID and which column stores gene symbols.
|
135 |
+
# From the preview, 'ID' in the annotation appears to match the numeric IDs in the expression data,
|
136 |
+
# and 'GENE_SYMBOL' provides the corresponding gene symbols.
|
137 |
+
|
138 |
+
# 2. Get the gene mapping dataframe by extracting those columns.
|
139 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
|
140 |
+
|
141 |
+
# 3. Apply the mapping to convert probe-level expression to gene-level expression.
|
142 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
143 |
+
|
144 |
+
# For reference, let's print the shape and a small preview of the mapped gene_data.
|
145 |
+
print("Mapped gene_data shape:", gene_data.shape)
|
146 |
+
print("Preview of mapped gene_data:")
|
147 |
+
print(preview_df(gene_data))
|
148 |
+
# STEP7
|
149 |
+
|
150 |
+
# 1. Normalize the obtained gene data using the NCBI Gene synonym database
|
151 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
152 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
153 |
+
|
154 |
+
# 2. Link the clinical and genetic data
|
155 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
156 |
+
|
157 |
+
# 3. Handle missing values systematically
|
158 |
+
linked_data_processed = handle_missing_values(linked_data, trait_col=trait)
|
159 |
+
|
160 |
+
# 4. Check for biased trait and remove any biased demographic features
|
161 |
+
trait_biased, linked_data_final = judge_and_remove_biased_features(linked_data_processed, trait)
|
162 |
+
|
163 |
+
# 5. Final quality validation and metadata saving
|
164 |
+
is_usable = validate_and_save_cohort_info(
|
165 |
+
is_final=True,
|
166 |
+
cohort=cohort,
|
167 |
+
info_path=json_path,
|
168 |
+
is_gene_available=True,
|
169 |
+
is_trait_available=True,
|
170 |
+
is_biased=trait_biased,
|
171 |
+
df=linked_data_final,
|
172 |
+
note="Dataset processed with GEO pipeline. Checked for missing values and bias."
|
173 |
+
)
|
174 |
+
|
175 |
+
# 6. If dataset is usable, save the final linked data
|
176 |
+
if is_usable:
|
177 |
+
linked_data_final.to_csv(out_data_file)
|
p1/preprocess/Atrial_Fibrillation/code/GSE41177.py
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atrial_Fibrillation"
|
6 |
+
cohort = "GSE41177"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE41177"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Atrial_Fibrillation/GSE41177.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Atrial_Fibrillation/gene_data/GSE41177.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Atrial_Fibrillation/clinical_data/GSE41177.csv"
|
16 |
+
json_path = "./output/preprocess/1/Atrial_Fibrillation/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 # From the background stating "microarray analysis revealed ...", indicating gene expression data.
|
38 |
+
|
39 |
+
# 2. Variable Availability and Data Type Conversion
|
40 |
+
|
41 |
+
# 2.1 Data Availability
|
42 |
+
# Trait (Atrial_Fibrillation): All patients have AF (persistent AF), so there's no variation (constant). Hence, not available.
|
43 |
+
trait_row = None
|
44 |
+
|
45 |
+
# Age: Multiple unique age values are found in row 2.
|
46 |
+
age_row = 2
|
47 |
+
|
48 |
+
# Gender: Multiple unique gender values are found in row 1.
|
49 |
+
gender_row = 1
|
50 |
+
|
51 |
+
# 2.2 Data Type Conversion
|
52 |
+
|
53 |
+
def convert_trait(x: str) -> Optional[int]:
|
54 |
+
"""
|
55 |
+
Convert any given value of the trait 'Atrial_Fibrillation' to a binary value.
|
56 |
+
However, here it's not used because trait_row is None for this dataset (constant trait).
|
57 |
+
Example logic shown for completeness.
|
58 |
+
"""
|
59 |
+
if not x or ':' not in x:
|
60 |
+
return None
|
61 |
+
# If data indicated presence of AF, assign 1, otherwise 0.
|
62 |
+
# (In this dataset, it's constant, so this function is effectively unused.)
|
63 |
+
return 1
|
64 |
+
|
65 |
+
def convert_age(x: str) -> Optional[float]:
|
66 |
+
"""
|
67 |
+
Convert age string 'age: XXY' to a float.
|
68 |
+
If unknown, return None.
|
69 |
+
"""
|
70 |
+
if not x or ':' not in x:
|
71 |
+
return None
|
72 |
+
value = x.split(':', 1)[1].strip() # e.g. "62Y"
|
73 |
+
value = value.replace('Y', '').strip()
|
74 |
+
if not value.isdigit():
|
75 |
+
return None
|
76 |
+
return float(value)
|
77 |
+
|
78 |
+
def convert_gender(x: str) -> Optional[int]:
|
79 |
+
"""
|
80 |
+
Convert gender string 'gender: male/female' to a binary value:
|
81 |
+
female -> 0
|
82 |
+
male -> 1
|
83 |
+
If unknown, return None.
|
84 |
+
"""
|
85 |
+
if not x or ':' not in x:
|
86 |
+
return None
|
87 |
+
gender_str = x.split(':', 1)[1].strip().lower()
|
88 |
+
if 'female' in gender_str:
|
89 |
+
return 0
|
90 |
+
if 'male' in gender_str:
|
91 |
+
return 1
|
92 |
+
return None
|
93 |
+
|
94 |
+
# 3. Save Metadata (Initial filtering)
|
95 |
+
# Trait data is not available if trait_row is None.
|
96 |
+
is_trait_available = (trait_row is not None)
|
97 |
+
is_usable = validate_and_save_cohort_info(
|
98 |
+
is_final=False,
|
99 |
+
cohort=cohort,
|
100 |
+
info_path=json_path,
|
101 |
+
is_gene_available=is_gene_available,
|
102 |
+
is_trait_available=is_trait_available
|
103 |
+
)
|
104 |
+
|
105 |
+
# 4. Clinical Feature Extraction
|
106 |
+
# Skip if trait_row is None.
|
107 |
+
if trait_row is not None:
|
108 |
+
selected_clinical_df = geo_select_clinical_features(
|
109 |
+
clinical_df=clinical_data,
|
110 |
+
trait="Atrial_Fibrillation",
|
111 |
+
trait_row=trait_row,
|
112 |
+
convert_trait=convert_trait,
|
113 |
+
age_row=age_row,
|
114 |
+
convert_age=convert_age,
|
115 |
+
gender_row=gender_row,
|
116 |
+
convert_gender=convert_gender
|
117 |
+
)
|
118 |
+
# Preview
|
119 |
+
preview = preview_df(selected_clinical_df, n=5)
|
120 |
+
print("Preview of Selected Clinical Features:", preview)
|
121 |
+
|
122 |
+
# Save
|
123 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
124 |
+
# STEP3
|
125 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
126 |
+
gene_data = get_genetic_data(matrix_file)
|
127 |
+
|
128 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
129 |
+
print(gene_data.index[:20])
|
130 |
+
# These identifiers (e.g., "1007_s_at", "1053_at") are Affymetrix probe IDs rather than standard human gene symbols.
|
131 |
+
# Hence, we conclude that the data requires gene symbol mapping.
|
132 |
+
|
133 |
+
requires_gene_mapping = True
|
134 |
+
# STEP5
|
135 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
136 |
+
gene_annotation = get_gene_annotation(soft_file)
|
137 |
+
|
138 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
139 |
+
print("Gene annotation preview:")
|
140 |
+
print(preview_df(gene_annotation))
|
141 |
+
# STEP: Gene Identifier Mapping
|
142 |
+
|
143 |
+
# 1. Identify the relevant columns in the annotation dataframe:
|
144 |
+
# - 'ID' holds the same identifiers as gene_data.index (e.g., "1007_s_at")
|
145 |
+
# - 'Gene Symbol' holds the gene symbols.
|
146 |
+
|
147 |
+
# 2. Extract mapping columns:
|
148 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col="ID", gene_col="Gene Symbol")
|
149 |
+
|
150 |
+
# 3. Convert probe-level measurements to gene-level expression data:
|
151 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
152 |
+
# STEP7
|
153 |
+
|
154 |
+
import pandas as pd
|
155 |
+
|
156 |
+
# Since trait_row is None, we have no clinical data to link. According to the instructions, we skip linking
|
157 |
+
# and other steps requiring the trait. We only normalize and save gene data, then perform final validation
|
158 |
+
# to mark this dataset as not usable (due to missing trait data).
|
159 |
+
|
160 |
+
# 1. Normalize the obtained gene data using the NCBI Gene synonym database
|
161 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
162 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
163 |
+
|
164 |
+
# 2. Final quality validation and metadata saving (trait not available).
|
165 |
+
# Since is_final=True, we must provide dummy values for 'df' and 'is_biased'.
|
166 |
+
empty_df = pd.DataFrame() # Placeholder DataFrame
|
167 |
+
is_usable = validate_and_save_cohort_info(
|
168 |
+
is_final=True,
|
169 |
+
cohort=cohort,
|
170 |
+
info_path=json_path,
|
171 |
+
is_gene_available=True, # Gene data is available
|
172 |
+
is_trait_available=False, # Trait data is not available
|
173 |
+
is_biased=True, # Mark as biased/unusable since we're missing core trait data
|
174 |
+
df=empty_df, # Passing an empty df to satisfy function signature
|
175 |
+
note="No trait data available, skipping clinical linkage. Gene data extracted only."
|
176 |
+
)
|
177 |
+
|
178 |
+
# 3. Since the dataset is not usable, we do not proceed with saving any final linked data.
|
p1/preprocess/Atrial_Fibrillation/code/GSE47727.py
ADDED
@@ -0,0 +1,124 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atrial_Fibrillation"
|
6 |
+
cohort = "GSE47727"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atrial_Fibrillation"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atrial_Fibrillation/GSE47727"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Atrial_Fibrillation/GSE47727.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Atrial_Fibrillation/gene_data/GSE47727.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Atrial_Fibrillation/clinical_data/GSE47727.csv"
|
16 |
+
json_path = "./output/preprocess/1/Atrial_Fibrillation/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 # The platform (HumanHT-12 V3.0) indicates a typical gene expression microarray
|
38 |
+
|
39 |
+
# 2. Variable Availability
|
40 |
+
trait_row = None # No row found containing AF or any case/control labels
|
41 |
+
age_row = 0 # Key 0 has multiple unique values for age
|
42 |
+
gender_row = 1 # Key 1 has at least two distinct values (male/female)
|
43 |
+
|
44 |
+
# 2.2 Data Type Conversion
|
45 |
+
def convert_trait(value: str):
|
46 |
+
"""
|
47 |
+
Convert the trait value to a binary indicator (0 or 1).
|
48 |
+
This dataset has no trait info, so we'll implement a placeholder function.
|
49 |
+
"""
|
50 |
+
# Normally, we'd parse after the colon and map "AF" -> 1, "control" -> 0, else None
|
51 |
+
return None
|
52 |
+
|
53 |
+
def convert_age(value: str):
|
54 |
+
"""
|
55 |
+
Convert the 'age (yrs)' string to a float.
|
56 |
+
Returns None if the format is unexpected.
|
57 |
+
"""
|
58 |
+
try:
|
59 |
+
# Split at the colon, take the part after the colon, strip, and convert to float
|
60 |
+
parts = value.split(':')
|
61 |
+
if len(parts) < 2:
|
62 |
+
return None
|
63 |
+
return float(parts[1].strip())
|
64 |
+
except:
|
65 |
+
return None
|
66 |
+
|
67 |
+
def convert_gender(value: str):
|
68 |
+
"""
|
69 |
+
Convert gender to binary: female -> 0, male -> 1.
|
70 |
+
Returns None if the format is unexpected.
|
71 |
+
"""
|
72 |
+
parts = value.split(':')
|
73 |
+
if len(parts) < 2:
|
74 |
+
return None
|
75 |
+
gender_str = parts[1].strip().lower()
|
76 |
+
if gender_str == 'female':
|
77 |
+
return 0
|
78 |
+
elif gender_str == 'male':
|
79 |
+
return 1
|
80 |
+
else:
|
81 |
+
return None
|
82 |
+
|
83 |
+
# 3. Save Metadata (initial filtering)
|
84 |
+
is_trait_available = (trait_row is not None)
|
85 |
+
_ = validate_and_save_cohort_info(
|
86 |
+
is_final=False,
|
87 |
+
cohort=cohort,
|
88 |
+
info_path=json_path,
|
89 |
+
is_gene_available=is_gene_available,
|
90 |
+
is_trait_available=is_trait_available
|
91 |
+
)
|
92 |
+
|
93 |
+
# 4. Clinical Feature Extraction
|
94 |
+
# Skip this step because trait_row is None (no trait data available)
|
95 |
+
# STEP3
|
96 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
97 |
+
gene_data = get_genetic_data(matrix_file)
|
98 |
+
|
99 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
100 |
+
print(gene_data.index[:20])
|
101 |
+
# The IDs (e.g., "ILMN_1343291") appear to be Illumina probe IDs, not standard human gene symbols.
|
102 |
+
# Therefore, this data requires mapping to gene symbols.
|
103 |
+
|
104 |
+
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. Identify the columns in gene_annotation that match the probe IDs from gene_data (the 'ID' column),
|
115 |
+
# and the column that holds gene symbols (the 'Symbol' column).
|
116 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
|
117 |
+
|
118 |
+
# 2. Convert probe-level measurements to gene-level measurements.
|
119 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
120 |
+
|
121 |
+
# (Optional) Print some basic info for verification.
|
122 |
+
print("Mapped gene_data shape:", gene_data.shape)
|
123 |
+
print("First 20 gene symbols after mapping:")
|
124 |
+
print(gene_data.index[:20])
|
p1/preprocess/Atrial_Fibrillation/code/TCGA.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atrial_Fibrillation"
|
6 |
+
|
7 |
+
# Input paths
|
8 |
+
tcga_root_dir = "../DATA/TCGA"
|
9 |
+
|
10 |
+
# Output paths
|
11 |
+
out_data_file = "./output/preprocess/1/Atrial_Fibrillation/TCGA.csv"
|
12 |
+
out_gene_data_file = "./output/preprocess/1/Atrial_Fibrillation/gene_data/TCGA.csv"
|
13 |
+
out_clinical_data_file = "./output/preprocess/1/Atrial_Fibrillation/clinical_data/TCGA.csv"
|
14 |
+
json_path = "./output/preprocess/1/Atrial_Fibrillation/cohort_info.json"
|
15 |
+
|
16 |
+
import os
|
17 |
+
|
18 |
+
# Step 1: Check directories in tcga_root_dir for anything relevant to "Atrial_Fibrillation"
|
19 |
+
dir_list = os.listdir(tcga_root_dir)
|
20 |
+
matching_dir = None
|
21 |
+
|
22 |
+
# We'll perform a simple match check (case-insensitive)
|
23 |
+
# If we had any subdirectory name containing "atrial" or "fibrillation", we would choose it.
|
24 |
+
for d in dir_list:
|
25 |
+
if "atrial" in d.lower() or "fibrillation" in d.lower():
|
26 |
+
matching_dir = d
|
27 |
+
break
|
28 |
+
|
29 |
+
# If no suitable directory is found, mark trait as skipped
|
30 |
+
if matching_dir is None:
|
31 |
+
validate_and_save_cohort_info(
|
32 |
+
is_final=False,
|
33 |
+
cohort="TCGA",
|
34 |
+
info_path=json_path,
|
35 |
+
is_gene_available=False,
|
36 |
+
is_trait_available=False
|
37 |
+
)
|
38 |
+
else:
|
39 |
+
# Normally we'd proceed with file loading, but per instructions,
|
40 |
+
# no directory matches the trait. Thus this block won't execute.
|
41 |
+
pass
|
p1/preprocess/Atrial_Fibrillation/cohort_info.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"GSE47727": {"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}, "GSE41177": {"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": "No trait data available, skipping clinical linkage. Gene data extracted only."}, "GSE235307": {"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": 119, "note": "Dataset processed with GEO pipeline. Checked for missing values and bias."}, "GSE143924": {"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": 30, "note": "Dataset processed with GEO pipeline. Checked for missing values and bias."}, "GSE115574": {"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": 59, "note": "Dataset processed with GEO pipeline. Checked for missing values and bias."}, "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/Atrial_Fibrillation/gene_data/GSE143924.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Atrial_Fibrillation/gene_data/GSE41177.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE111175.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
GSM3024679,GSM3024680,GSM3024681,GSM3024682,GSM3024683,GSM3024684,GSM3024685,GSM3024686,GSM3024687,GSM3024688,GSM3024689,GSM3024690,GSM3024691,GSM3024692,GSM3024693,GSM3024694,GSM3024695,GSM3024696,GSM3024697,GSM3024698,GSM3024699,GSM3024700,GSM3024701,GSM3024702,GSM3024703,GSM3024704,GSM3024705,GSM3024706,GSM3024707,GSM3024708,GSM3024709,GSM3024710,GSM3024711,GSM3024712,GSM3024713,GSM3024714,GSM3024715,GSM3024716,GSM3024717,GSM3024718,GSM3024719,GSM3024720,GSM3024721,GSM3024722,GSM3024723,GSM3024724,GSM3024725,GSM3024726,GSM3024727,GSM3024728,GSM3024729,GSM3024730,GSM3024731,GSM3024732,GSM3024733,GSM3024734,GSM3024735,GSM3024736,GSM3024737,GSM3024738,GSM3024739,GSM3024740,GSM3024741,GSM3024742,GSM3024743,GSM3024744,GSM3024745,GSM3024746,GSM3024747,GSM3024748,GSM3024749,GSM3024750,GSM3024751,GSM3024752,GSM3024753,GSM3024754,GSM3024755,GSM3024756,GSM3024757,GSM3024758,GSM3024759,GSM3024760,GSM3024761,GSM3024762,GSM3024763,GSM3024764,GSM3024765,GSM3024766,GSM3024767,GSM3024768,GSM3024769,GSM3024770,GSM3024771,GSM3024772,GSM3024773,GSM3024774,GSM3024775,GSM3024776,GSM3024777,GSM3024778,GSM3024779,GSM3024780,GSM3024781,GSM3024782,GSM3024783,GSM3024784,GSM3024785,GSM3024786,GSM3024787,GSM3024788,GSM3024789,GSM3024790,GSM3024791,GSM3024792,GSM3024793,GSM3024794,GSM3024795,GSM3024796,GSM3024797,GSM3024798,GSM3024799,GSM3024800,GSM3024801,GSM3024802,GSM3024803,GSM3024804,GSM3024805,GSM3024806,GSM3024807,GSM3024808,GSM3024809,GSM3024810,GSM3024811,GSM3024812,GSM3024813,GSM3024814,GSM3024815,GSM3024816,GSM3024817,GSM3024818,GSM3024819
|
2 |
+
0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,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,1.0,0.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,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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 |
+
15.277,18.957,25.692,13.142,24.575,34.694,19.22,13.536,15.08,15.146,23.294,23.655,32.526,17.643,17.643,13.569,13.569,19.055,12.977,13.109,15.113,16.361,29.273,29.273,24.575,44.879,17.248,22.078,14.423,28.452,12.517,23.129,28.287,13.273,40.608,40.608,21.257,33.38,12.912,19.351,31.639,33.906,19.68,15.671,41.068,41.068,36.172,29.766,13.339,17.084,17.084,24.674,38.538,15.737,15.737,39.951,13.733,30.916,28.715,25.199,11.236,28.912,14.324,18.661,13.306,29.043,14.456,33.873,31.606,12.32,11.532,41.035,31.934,19.187,18.07,28.846,16.526,18.497,33.511,14.62,18.267,40.312,15.507,15.376,18.136,16.394,19.713,12.616,40.476,40.476,12.156,31.08,13.897,14.259,15.244,15.244,13.996,30.949,12.715,12.485,37.027,12.649,13.01,16.0,13.864,14.554,20.008,18.957,16.821,27.598,27.598,12.386,14.292,13.733,13.733,13.634,17.676,15.901,23.786,15.803,16.657,26.152,22.111,23.228,12.156,23.622,13.405,18.727,18.694,25.298,25.298,16.821,32.394,12.025,13.832,13.832,19.778,30.193,17.051,13.01,16.427
|
p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE113842.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
GSM3120900,GSM3120901,GSM3120902,GSM3120903,GSM3120904,GSM3120905,GSM3120906,GSM3120907,GSM3120908,GSM3120909,GSM3120910,GSM3120911,GSM3120912,GSM3120913,GSM3120914,GSM3120915,GSM3120916,GSM3120917,GSM3120918,GSM3120919,GSM3120920,GSM3120921,GSM3120922,GSM3120923,GSM3120924,GSM3120925,GSM3120926
|
2 |
+
0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,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
|
3 |
+
7.0,7.0,7.0,9.0,9.0,9.0,5.0,5.0,5.0,7.0,7.0,7.0,13.0,13.0,13.0,20.5,20.5,20.5,11.0,11.0,11.0,12.0,12.0,12.0,22.0,22.0,22.0
|
p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE123302.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
GSM3499537,GSM3499538,GSM3499539,GSM3499540,GSM3499541,GSM3499542,GSM3499543,GSM3499544,GSM3499545,GSM3499546,GSM3499547,GSM3499548,GSM3499549,GSM3499550,GSM3499551,GSM3499552,GSM3499553,GSM3499554,GSM3499555,GSM3499556,GSM3499557,GSM3499558,GSM3499559,GSM3499560,GSM3499561,GSM3499562,GSM3499563,GSM3499564,GSM3499565,GSM3499566,GSM3499567,GSM3499568,GSM3499569,GSM3499570,GSM3499571,GSM3499572,GSM3499573,GSM3499574,GSM3499575,GSM3499576,GSM3499577,GSM3499578,GSM3499579,GSM3499580,GSM3499581,GSM3499582,GSM3499583,GSM3499584,GSM3499585,GSM3499586,GSM3499587,GSM3499588,GSM3499589,GSM3499590,GSM3499591,GSM3499592,GSM3499593,GSM3499594,GSM3499595,GSM3499596,GSM3499597,GSM3499598,GSM3499599,GSM3499600,GSM3499601,GSM3499602,GSM3499603,GSM3499604,GSM3499605,GSM3499606,GSM3499607,GSM3499608,GSM3499609,GSM3499610,GSM3499611,GSM3499612,GSM3499613,GSM3499614,GSM3499615,GSM3499616,GSM3499617,GSM3499618,GSM3499619,GSM3499620,GSM3499621,GSM3499622,GSM3499623,GSM3499624,GSM3499625,GSM3499626,GSM3499627,GSM3499628,GSM3499629,GSM3499630,GSM3499631,GSM3499632,GSM3499633,GSM3499634,GSM3499635,GSM3499636,GSM3499637,GSM3499638,GSM3499639,GSM3499640,GSM3499641,GSM3499642,GSM3499643,GSM3499644,GSM3499645,GSM3499646,GSM3499647,GSM3499648,GSM3499649,GSM3499650,GSM3499651,GSM3499652,GSM3499653,GSM3499654,GSM3499655,GSM3499656,GSM3499657,GSM3499658,GSM3499659,GSM3499660,GSM3499661,GSM3499662,GSM3499663,GSM3499664,GSM3499665,GSM3499666,GSM3499667,GSM3499668,GSM3499669,GSM3499670,GSM3499671,GSM3499672,GSM3499673,GSM3499674,GSM3499675,GSM3499676,GSM3499677,GSM3499678,GSM3499679,GSM3499680,GSM3499681,GSM3499682,GSM3499683,GSM3499684,GSM3499685,GSM3499686,GSM3499687,GSM3499688,GSM3499689,GSM3499690,GSM3499691,GSM3499692,GSM3499693,GSM3499694,GSM3499695,GSM3499696,GSM3499697,GSM3499698,GSM3499699,GSM3499700,GSM3499701,GSM3499702,GSM3499703,GSM3499704,GSM3499705,GSM3499706,GSM3499707,GSM3499708,GSM3499709,GSM3499710,GSM3499711,GSM3499712,GSM3499713,GSM3499714,GSM3499715,GSM3499716,GSM3499717,GSM3499718,GSM3499719,GSM3499720,GSM3499721,GSM3499722,GSM3499723,GSM3499724,GSM3499725,GSM3499726,GSM3499727,GSM3499728,GSM3499729,GSM3499730,GSM3499731,GSM3499732,GSM3499733,GSM3499734,GSM3499735,GSM3499736,GSM3499737,GSM3499738,GSM3499739,GSM3499740,GSM3499741,GSM3499742,GSM3499743,GSM3499744,GSM3499745,GSM3499746,GSM3499747,GSM3499748,GSM3499749,GSM3499750,GSM3499751,GSM3499752,GSM3499753,GSM3499754,GSM3499755,GSM3499756,GSM3499757,GSM3499758,GSM3499759,GSM3499760
|
2 |
+
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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 |
+
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE148450.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
GSM4471661,GSM4471662,GSM4471663,GSM4471664,GSM4471665,GSM4471666,GSM4471667,GSM4471668,GSM4471669,GSM4471670,GSM4471671,GSM4471672,GSM4471673,GSM4471674,GSM4471675,GSM4471676,GSM4471677,GSM4471678,GSM4471679,GSM4471680,GSM4471681,GSM4471682,GSM4471683,GSM4471684,GSM4471685,GSM4471686,GSM4471687,GSM4471688,GSM4471689,GSM4471690,GSM4471691,GSM4471692,GSM4471693,GSM4471694,GSM4471695,GSM4471696,GSM4471697,GSM4471698,GSM4471699,GSM4471700,GSM4471701,GSM4471702,GSM4471703,GSM4471704,GSM4471705,GSM4471706,GSM4471707,GSM4471708,GSM4471709,GSM4471710,GSM4471711,GSM4471712,GSM4471713,GSM4471714,GSM4471715,GSM4471716,GSM4471717,GSM4471718,GSM4471719,GSM4471720,GSM4471721,GSM4471722,GSM4471723,GSM4471724,GSM4471725,GSM4471726,GSM4471727,GSM4471728,GSM4471729,GSM4471730,GSM4471731,GSM4471732,GSM4471733,GSM4471734,GSM4471735,GSM4471736,GSM4471737,GSM4471738,GSM4471739,GSM4471740,GSM4471741,GSM4471742,GSM4471743,GSM4471744,GSM4471745,GSM4471746,GSM4471747,GSM4471748,GSM4471749,GSM4471750,GSM4471751,GSM4471752,GSM4471753,GSM4471754,GSM4471755,GSM4471756,GSM4471757,GSM4471758,GSM4471759,GSM4471760,GSM4471761,GSM4471762,GSM4471763,GSM4471764,GSM4471765,GSM4471766,GSM4471767,GSM4471768,GSM4471769,GSM4471770,GSM4471771,GSM4471772,GSM4471773,GSM4471774,GSM4471775,GSM4471776,GSM4471777,GSM4471778,GSM4471779,GSM4471780,GSM4471781,GSM4471782,GSM4471783,GSM4471784,GSM4471785,GSM4471786,GSM4471787,GSM4471788,GSM4471789,GSM4471790,GSM4471791,GSM4471792,GSM4471793,GSM4471794,GSM4471795,GSM4471796,GSM4471797,GSM4471798,GSM4471799,GSM4471800,GSM4471801,GSM4471802,GSM4471803,GSM4471804,GSM4471805,GSM4471806,GSM4471807,GSM4471808,GSM4471809,GSM4471810,GSM4471811,GSM4471812,GSM4471813,GSM4471814,GSM4471815,GSM4471816,GSM4471817,GSM4471818,GSM4471819,GSM4471820,GSM4471821,GSM4471822,GSM4471823,GSM4471824,GSM4471825,GSM4471826,GSM4471827,GSM4471828,GSM4471829,GSM4471830,GSM4471831,GSM4471832,GSM4471833,GSM4471834,GSM4471835,GSM4471836,GSM4471837,GSM4471838,GSM4471839,GSM4471840,GSM4471841,GSM4471842,GSM4471843,GSM4471844,GSM4471845,GSM4471846,GSM4471847,GSM4471848,GSM4471849,GSM4471850,GSM4471851,GSM4471852,GSM4471853,GSM4471854,GSM4471855,GSM4471856,GSM4471857,GSM4471858,GSM4471859,GSM4471860,GSM4471861,GSM4471862,GSM4471863,GSM4471864,GSM4471865,GSM4471866,GSM4471867,GSM4471868,GSM4471869,GSM4471870,GSM4471871,GSM4471872,GSM4471873,GSM4471874
|
2 |
+
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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 |
+
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.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,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.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,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.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,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.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,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0
|
p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE42133.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM1033105,GSM1033106,GSM1033107,GSM1033108,GSM1033109,GSM1033110,GSM1033111,GSM1033112,GSM1033113,GSM1033114,GSM1033115,GSM1033116,GSM1033117,GSM1033118,GSM1033119,GSM1033120,GSM1033121,GSM1033122,GSM1033123,GSM1033124,GSM1033125,GSM1033126,GSM1033127,GSM1033128,GSM1033129,GSM1033130,GSM1033131,GSM1033132,GSM1033133,GSM1033134,GSM1033135,GSM1033136,GSM1033137,GSM1033138,GSM1033139,GSM1033140,GSM1033141,GSM1033142,GSM1033143,GSM1033144,GSM1033145,GSM1033146,GSM1033147,GSM1033148,GSM1033149,GSM1033150,GSM1033152,GSM1033153,GSM1033154,GSM1033155,GSM1033156,GSM1033157,GSM1033158,GSM1033159,GSM1033160,GSM1033161,GSM1033162,GSM1033163,GSM1033164,GSM1033165,GSM1033166,GSM1033167,GSM1033168,GSM1033169,GSM1033170,GSM1033171,GSM1033172,GSM1033173,GSM1033174,GSM1033175,GSM1033176,GSM1033177,GSM1033178,GSM1033179,GSM1033180,GSM1033181,GSM1033182,GSM1033183,GSM1033184,GSM1033185,GSM1033186,GSM1033187,GSM1033188,GSM1033189,GSM1033190,GSM1033191,GSM1033192,GSM1033193,GSM1033194,GSM1033195,GSM1033196,GSM1033197,GSM1033198,GSM1033199,GSM1033200,GSM1033201,GSM1033202,GSM1033203,GSM1033204,GSM1033205,GSM1033206,GSM1033207,GSM1033208,GSM1033209,GSM1033211,GSM1033212,GSM1033213,GSM1033214,GSM1033215,GSM1033216,GSM1033217,GSM1033218,GSM1033219,GSM1033220,GSM1033221,GSM1033222,GSM1033223,GSM1033224,GSM1033225,GSM1033227,GSM1033228,GSM1033229,GSM1033230,GSM1033231,GSM1033232,GSM1033233,GSM1033234,GSM1033235,GSM1033236,GSM1033237,GSM1033238,GSM1033239,GSM1033240,GSM1033241,GSM1033242,GSM1033243,GSM1033244,GSM1033245,GSM1033246,GSM1033247,GSM1033248,GSM1033249,GSM1033250,GSM1033251,GSM1033253,GSM1033254,GSM1033255
|
2 |
+
1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.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,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0
|
p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE65106.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GSM1587362,GSM1587363,GSM1587364,GSM1587365,GSM1587366,GSM1587367,GSM1587368,GSM1587369,GSM1587370,GSM1587371,GSM1587372,GSM1587373,GSM1587374,GSM1587375,GSM1587376,GSM1587377,GSM1587378,GSM1587379,GSM1587380,GSM1587381,GSM1587382,GSM1587383,GSM1587384,GSM1587385,GSM1587386,GSM1587387,GSM1587388,GSM1587389,GSM1587390,GSM1587391,GSM1587392,GSM1587393,GSM1587394,GSM1587395,GSM1587396,GSM1587397,GSM1587398,GSM1587399,GSM1587400,GSM1587401,GSM1587402,GSM1587403,GSM1587404,GSM1587405,GSM1587406,GSM1587407,GSM1587408,GSM1587409,GSM1587410,GSM1587411,GSM1587412,GSM1587413,GSM1587414,GSM1587415,GSM1587416,GSM1587417,GSM1587418,GSM1587419,GSM1587420
|
2 |
+
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,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,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,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
|
3 |
+
8.0,8.0,7.0,7.0,9.0,9.0,10.0,10.0,16.0,16.0,7.0,7.0,7.0,7.0,10.0,10.0,,,,,8.0,8.0,7.0,7.0,9.0,10.0,10.0,16.0,16.0,7.0,7.0,7.0,10.0,8.0,8.0,7.0,7.0,9.0,10.0,10.0,16.0,16.0,7.0,7.0,7.0,10.0,8.0,8.0,7.0,7.0,9.0,10.0,10.0,16.0,16.0,7.0,7.0,7.0,10.0
|
4 |
+
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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/Autism_spectrum_disorder_(ASD)/clinical_data/GSE87847.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
GSM2341810,GSM2341811,GSM2341812,GSM2341813,GSM2341814,GSM2341815,GSM2341816,GSM2341817,GSM2341818,GSM2341819,GSM2341820,GSM2341821,GSM2341822,GSM2341823,GSM2341824,GSM2341825,GSM2341826,GSM2341827,GSM2341828,GSM2341829,GSM2341830,GSM2341831,GSM2341832,GSM2341833,GSM2341834,GSM2341835,GSM2341836,GSM2341837,GSM2341838,GSM2341839,GSM2341840,GSM2341841,GSM2341842,GSM2341843,GSM2341844,GSM2341845,GSM2341846,GSM2341847,GSM2341848,GSM2341849,GSM2341850,GSM2341851,GSM2341852,GSM2341853,GSM2341854,GSM2341855,GSM2341856,GSM2341857,GSM2341858,GSM2341859,GSM2341860,GSM2341861,GSM2341862,GSM2341863,GSM2341864,GSM2341865,GSM2341866,GSM2341867,GSM2341868,GSM2341869,GSM2341870,GSM2341871,GSM2341872,GSM2341873,GSM2341874,GSM2341875,GSM2341876,GSM2341877,GSM2341878,GSM2341879,GSM2341880,GSM2341881,GSM2341882,GSM2341883,GSM2341884,GSM2341885,GSM2341886,GSM2341887,GSM2341888,GSM2341889,GSM2341890,GSM2341891,GSM2341892,GSM2341893,GSM2341894,GSM2341895,GSM2341896,GSM2341897,GSM2341898,GSM2341899,GSM2341900,GSM2341901,GSM2341902
|
2 |
+
1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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
|
3 |
+
1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Autism_spectrum_disorder_(ASD)/clinical_data/GSE89594.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GSM2384988,GSM2384989,GSM2384990,GSM2384991,GSM2384992,GSM2384993,GSM2384994,GSM2384995,GSM2384996,GSM2384997,GSM2384998,GSM2384999,GSM2385000,GSM2385001,GSM2385002,GSM2385003,GSM2385004,GSM2385005,GSM2385006,GSM2385007,GSM2385008,GSM2385009,GSM2385010,GSM2385011,GSM2385012,GSM2385013,GSM2385014,GSM2385015,GSM2385016,GSM2385017,GSM2385018,GSM2385019,GSM2385020,GSM2385021,GSM2385022,GSM2385023,GSM2385024,GSM2385025,GSM2385026,GSM2385027,GSM2385028,GSM2385029,GSM2385030,GSM2385031,GSM2385032,GSM2385033,GSM2385034,GSM2385035,GSM2385036,GSM2385037,GSM2385038,GSM2385039,GSM2385040,GSM2385041,GSM2385042,GSM2385043,GSM2385044,GSM2385045,GSM2385046,GSM2385047,GSM2385048,GSM2385049,GSM2385050,GSM2385051,GSM2385052,GSM2385053,GSM2385054,GSM2385055,GSM2385056,GSM2385057,GSM2385058,GSM2385059,GSM2385060,GSM2385061,GSM2385062,GSM2385063,GSM2385064,GSM2385065,GSM2385066,GSM2385067,GSM2385068,GSM2385069,GSM2385070,GSM2385071,GSM2385072,GSM2385073,GSM2385074,GSM2385075,GSM2385076,GSM2385077,GSM2385078,GSM2385079,GSM2385080,GSM2385081
|
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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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
|
3 |
+
22.0,23.0,24.0,24.0,33.0,22.0,24.0,21.0,24.0,20.0,28.0,21.0,21.0,22.0,25.0,23.0,20.0,21.0,20.0,32.0,36.0,24.0,21.0,30.0,28.0,22.0,24.0,21.0,22.0,20.0,27.0,22.0,23.0,20.0,31.0,27.0,32.0,20.0,36.0,22.0,28.0,25.0,35.0,22.0,22.0,10.0,16.0,10.0,33.0,21.0,11.0,10.0,35.0,12.0,38.0,24.0,34.0,32.0,21.0,29.0,20.0,19.0,24.0,13.0,23.0,15.0,43.0,10.0,13.0,16.0,27.0,24.0,11.0,24.0,32.0,24.0,27.0,16.0,14.0,11.0,24.0,28.0,17.0,15.0,34.0,39.0,12.0,15.0,21.0,29.0,23.0,26.0,19.0,21.0
|
4 |
+
0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,0.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,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.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,1.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Autism_spectrum_disorder_(ASD)/code/GSE111175.py
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Autism_spectrum_disorder_(ASD)"
|
6 |
+
cohort = "GSE111175"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Autism_spectrum_disorder_(ASD)"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Autism_spectrum_disorder_(ASD)/GSE111175"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Autism_spectrum_disorder_(ASD)/GSE111175.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Autism_spectrum_disorder_(ASD)/gene_data/GSE111175.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Autism_spectrum_disorder_(ASD)/clinical_data/GSE111175.csv"
|
16 |
+
json_path = "./output/preprocess/1/Autism_spectrum_disorder_(ASD)/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 description mentioning "Leukocyte gene expression levels"
|
38 |
+
|
39 |
+
# 2. Variable Availability and Data Type Conversion
|
40 |
+
|
41 |
+
# From the sample characteristics dictionary, we see that:
|
42 |
+
# - The "diagnosis" information is in key 3 with multiple values (ASD, TD, LD, etc.),
|
43 |
+
# so trait_row = 3.
|
44 |
+
# - The "age" information is in key 2 with multiple numeric values,
|
45 |
+
# so age_row = 2.
|
46 |
+
# - The "gender" information is in key 1, but it seems only "M" is present (a single unique value),
|
47 |
+
# so it is not useful for association studies. We'll set gender_row = None.
|
48 |
+
|
49 |
+
trait_row = 3
|
50 |
+
age_row = 2
|
51 |
+
gender_row = None
|
52 |
+
|
53 |
+
# 2.2 Data Type Conversion
|
54 |
+
def convert_trait(x: str):
|
55 |
+
"""
|
56 |
+
Convert diagnosis info into a binary value (0 or 1), focusing on whether
|
57 |
+
the individual is on the autism spectrum.
|
58 |
+
'ASD', 'PDDNOS', 'AutFeat' are mapped to 1,
|
59 |
+
'TD', 'LD', 'PreemieNoDelay' are mapped to 0,
|
60 |
+
otherwise None.
|
61 |
+
"""
|
62 |
+
# Extract the part after the colon
|
63 |
+
parts = x.split(':', 1)
|
64 |
+
if len(parts) < 2:
|
65 |
+
return None
|
66 |
+
value = parts[1].strip().lower()
|
67 |
+
|
68 |
+
if value in ["asd", "pddnos", "autfeat"]:
|
69 |
+
return 1
|
70 |
+
elif value in ["td", "ld", "preemienodelay"]:
|
71 |
+
return 0
|
72 |
+
else:
|
73 |
+
return None
|
74 |
+
|
75 |
+
def convert_age(x: str):
|
76 |
+
"""
|
77 |
+
Convert age info into a continuous float.
|
78 |
+
If parsing fails, return None.
|
79 |
+
"""
|
80 |
+
parts = x.split(':', 1)
|
81 |
+
if len(parts) < 2:
|
82 |
+
return None
|
83 |
+
value = parts[1].strip()
|
84 |
+
try:
|
85 |
+
return float(value)
|
86 |
+
except ValueError:
|
87 |
+
return None
|
88 |
+
|
89 |
+
def convert_gender(x: str):
|
90 |
+
"""
|
91 |
+
Convert gender info into a binary value (0 or 1).
|
92 |
+
Female (F) -> 0, Male (M) -> 1, otherwise None.
|
93 |
+
"""
|
94 |
+
parts = x.split(':', 1)
|
95 |
+
if len(parts) < 2:
|
96 |
+
return None
|
97 |
+
value = parts[1].strip().lower()
|
98 |
+
|
99 |
+
if value in ["m", "male"]:
|
100 |
+
return 1
|
101 |
+
elif value in ["f", "female"]:
|
102 |
+
return 0
|
103 |
+
else:
|
104 |
+
return None
|
105 |
+
|
106 |
+
# 3. Save Metadata with initial filtering
|
107 |
+
is_trait_available = (trait_row is not None)
|
108 |
+
is_usable = validate_and_save_cohort_info(
|
109 |
+
is_final=False,
|
110 |
+
cohort=cohort,
|
111 |
+
info_path=json_path,
|
112 |
+
is_gene_available=is_gene_available,
|
113 |
+
is_trait_available=is_trait_available
|
114 |
+
)
|
115 |
+
|
116 |
+
# 4. Clinical Feature Extraction (only if trait_row is not None)
|
117 |
+
if trait_row is not None:
|
118 |
+
selected_features = geo_select_clinical_features(
|
119 |
+
clinical_data,
|
120 |
+
trait=trait,
|
121 |
+
trait_row=trait_row,
|
122 |
+
convert_trait=convert_trait,
|
123 |
+
age_row=age_row,
|
124 |
+
convert_age=convert_age,
|
125 |
+
gender_row=gender_row,
|
126 |
+
convert_gender=convert_gender if gender_row is not None else None
|
127 |
+
)
|
128 |
+
|
129 |
+
# Preview the extracted features
|
130 |
+
preview = preview_df(selected_features)
|
131 |
+
print("Preview of selected clinical features:", preview)
|
132 |
+
|
133 |
+
# Save the clinical data to CSV
|
134 |
+
selected_features.to_csv(out_clinical_data_file, index=False)
|
135 |
+
# STEP3
|
136 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
137 |
+
gene_data = get_genetic_data(matrix_file)
|
138 |
+
|
139 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
140 |
+
print(gene_data.index[:20])
|
141 |
+
# The given gene identifiers are Illumina probe IDs, not standard human gene symbols.
|
142 |
+
# Therefore, they need to be mapped to human gene symbols.
|
143 |
+
print("requires_gene_mapping = True")
|
144 |
+
# STEP5
|
145 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
146 |
+
gene_annotation = get_gene_annotation(soft_file)
|
147 |
+
|
148 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
149 |
+
print("Gene annotation preview:")
|
150 |
+
print(preview_df(gene_annotation))
|
151 |
+
# STEP: Gene Identifier Mapping
|
152 |
+
|
153 |
+
# 1. Determine which columns in the gene_annotation dataframe correspond to the probe IDs and gene symbols.
|
154 |
+
# From our annotation preview, we see "ID" holds the same Illumina probe IDs, and "Symbol" holds the gene symbols.
|
155 |
+
|
156 |
+
# 2. Build the gene mapping dataframe.
|
157 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
|
158 |
+
|
159 |
+
# 3. Convert probe-level measurements to gene-level measurements by applying the gene mapping.
|
160 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
161 |
+
|
162 |
+
# Print output to verify the new gene_data.
|
163 |
+
print("Mapped gene_data shape:", gene_data.shape)
|
164 |
+
print("First 20 gene symbols in the mapped data:\n", gene_data.index[:20])
|
165 |
+
# STEP7
|
166 |
+
|
167 |
+
# 1. Normalize the obtained gene data using the NCBI Gene synonym database
|
168 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
169 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
170 |
+
|
171 |
+
# 2. Link the clinical and genetic data
|
172 |
+
linked_data = geo_link_clinical_genetic_data(selected_features, normalized_gene_data)
|
173 |
+
|
174 |
+
# 3. Handle missing values systematically
|
175 |
+
linked_data_processed = handle_missing_values(linked_data, trait_col=trait)
|
176 |
+
|
177 |
+
# 4. Check for biased trait and remove any biased demographic features
|
178 |
+
trait_biased, linked_data_final = judge_and_remove_biased_features(linked_data_processed, trait)
|
179 |
+
|
180 |
+
# 5. Final quality validation and metadata saving
|
181 |
+
is_usable = validate_and_save_cohort_info(
|
182 |
+
is_final=True,
|
183 |
+
cohort=cohort,
|
184 |
+
info_path=json_path,
|
185 |
+
is_gene_available=True,
|
186 |
+
is_trait_available=True,
|
187 |
+
is_biased=trait_biased,
|
188 |
+
df=linked_data_final,
|
189 |
+
note="Dataset processed with GEO pipeline. Checked for missing values and bias."
|
190 |
+
)
|
191 |
+
|
192 |
+
# 6. If dataset is usable, save the final linked data
|
193 |
+
if is_usable:
|
194 |
+
linked_data_final.to_csv(out_data_file)
|