Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +19 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE109048.csv +2 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE123086.csv +4 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE123088.csv +4 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE125771.csv +4 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE154851.csv +4 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE57691.csv +2 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE83500.csv +2 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE87005.csv +2 -0
- p3/preprocess/Atherosclerosis/clinical_data/GSE90074.csv +3 -0
- p3/preprocess/Atherosclerosis/code/GSE109048.py +188 -0
- p3/preprocess/Atherosclerosis/code/GSE123086.py +232 -0
- p3/preprocess/Atherosclerosis/code/GSE123088.py +353 -0
- p3/preprocess/Atherosclerosis/code/GSE125771.py +148 -0
- p3/preprocess/Atherosclerosis/code/GSE133601.py +155 -0
- p3/preprocess/Atherosclerosis/code/GSE154851.py +153 -0
- p3/preprocess/Atherosclerosis/code/GSE57691.py +305 -0
- p3/preprocess/Atherosclerosis/code/GSE83500.py +442 -0
- p3/preprocess/Atherosclerosis/code/GSE87005.py +178 -0
- p3/preprocess/Atherosclerosis/code/GSE90074.py +189 -0
- p3/preprocess/Atherosclerosis/code/TCGA.py +28 -0
- p3/preprocess/Atherosclerosis/cohort_info.json +1 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE109048.csv +1 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE123086.csv +1 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE123088.csv +1 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE125771.csv +0 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE133601.csv +0 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE154851.csv +3 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE57691.csv +3 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE83500.csv +0 -0
- p3/preprocess/Atherosclerosis/gene_data/GSE87005.csv +0 -0
- p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/GSE208662.csv +0 -0
- p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/GSE64593.csv +0 -0
- p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/GSE64599.csv +0 -0
- p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/clinical_data/GSE162635.csv +2 -0
- p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/cohort_info.json +1 -0
- p3/preprocess/HIV_Resistance/GSE33580.csv +3 -0
- p3/preprocess/HIV_Resistance/GSE46599.csv +0 -0
- p3/preprocess/HIV_Resistance/clinical_data/GSE33580.csv +2 -0
- p3/preprocess/HIV_Resistance/clinical_data/GSE46599.csv +2 -0
- p3/preprocess/HIV_Resistance/code/GSE117748.py +71 -0
- p3/preprocess/HIV_Resistance/code/GSE33580.py +166 -0
- p3/preprocess/HIV_Resistance/code/GSE46599.py +160 -0
- p3/preprocess/HIV_Resistance/code/TCGA.py +31 -0
- p3/preprocess/HIV_Resistance/cohort_info.json +1 -0
- p3/preprocess/HIV_Resistance/gene_data/GSE33580.csv +3 -0
- p3/preprocess/HIV_Resistance/gene_data/GSE46599.csv +3 -0
- p3/preprocess/Head_and_Neck_Cancer/gene_data/GSE156915.csv +3 -0
- p3/preprocess/Head_and_Neck_Cancer/gene_data/TCGA.csv +3 -0
- p3/preprocess/Height/gene_data/GSE97475.csv +3 -0
.gitattributes
CHANGED
@@ -1741,3 +1741,22 @@ p3/preprocess/Height/gene_data/GSE152073.csv filter=lfs diff=lfs merge=lfs -text
|
|
1741 |
p3/preprocess/Height/gene_data/GSE101710.csv filter=lfs diff=lfs merge=lfs -text
|
1742 |
p3/preprocess/Height/gene_data/GSE101709.csv filter=lfs diff=lfs merge=lfs -text
|
1743 |
p3/preprocess/Hemochromatosis/gene_data/GSE50579.csv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1741 |
p3/preprocess/Height/gene_data/GSE101710.csv filter=lfs diff=lfs merge=lfs -text
|
1742 |
p3/preprocess/Height/gene_data/GSE101709.csv filter=lfs diff=lfs merge=lfs -text
|
1743 |
p3/preprocess/Hemochromatosis/gene_data/GSE50579.csv filter=lfs diff=lfs merge=lfs -text
|
1744 |
+
p3/preprocess/Height/gene_data/GSE97475.csv filter=lfs diff=lfs merge=lfs -text
|
1745 |
+
p3/preprocess/Head_and_Neck_Cancer/gene_data/GSE156915.csv filter=lfs diff=lfs merge=lfs -text
|
1746 |
+
p3/preprocess/HIV_Resistance/GSE33580.csv filter=lfs diff=lfs merge=lfs -text
|
1747 |
+
p3/preprocess/HIV_Resistance/gene_data/GSE46599.csv filter=lfs diff=lfs merge=lfs -text
|
1748 |
+
p3/preprocess/Huntingtons_Disease/GSE34201.csv filter=lfs diff=lfs merge=lfs -text
|
1749 |
+
p3/preprocess/HIV_Resistance/gene_data/GSE33580.csv filter=lfs diff=lfs merge=lfs -text
|
1750 |
+
p3/preprocess/Huntingtons_Disease/GSE26927.csv filter=lfs diff=lfs merge=lfs -text
|
1751 |
+
p3/preprocess/Huntingtons_Disease/gene_data/GSE34201.csv filter=lfs diff=lfs merge=lfs -text
|
1752 |
+
p3/preprocess/Huntingtons_Disease/gene_data/GSE26927.csv filter=lfs diff=lfs merge=lfs -text
|
1753 |
+
p3/preprocess/Huntingtons_Disease/GSE34721.csv filter=lfs diff=lfs merge=lfs -text
|
1754 |
+
p3/preprocess/Huntingtons_Disease/GSE135589.csv filter=lfs diff=lfs merge=lfs -text
|
1755 |
+
p3/preprocess/Huntingtons_Disease/gene_data/GSE95843.csv filter=lfs diff=lfs merge=lfs -text
|
1756 |
+
p3/preprocess/Huntingtons_Disease/gene_data/GSE34721.csv filter=lfs diff=lfs merge=lfs -text
|
1757 |
+
p3/preprocess/Huntingtons_Disease/gene_data/GSE135589.csv filter=lfs diff=lfs merge=lfs -text
|
1758 |
+
p3/preprocess/Atherosclerosis/gene_data/GSE154851.csv filter=lfs diff=lfs merge=lfs -text
|
1759 |
+
p3/preprocess/Hemochromatosis/TCGA.csv filter=lfs diff=lfs merge=lfs -text
|
1760 |
+
p3/preprocess/Atherosclerosis/gene_data/GSE57691.csv filter=lfs diff=lfs merge=lfs -text
|
1761 |
+
p3/preprocess/Head_and_Neck_Cancer/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
|
1762 |
+
p3/preprocess/Hemochromatosis/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
|
p3/preprocess/Atherosclerosis/clinical_data/GSE109048.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM2928447,GSM2928448,GSM2928449,GSM2928450,GSM2928451,GSM2928452,GSM2928453,GSM2928454,GSM2928455,GSM2928456,GSM2928457,GSM2928458,GSM2928459,GSM2928460,GSM2928461,GSM2928462,GSM2928463,GSM2928464,GSM2928465,GSM2928466,GSM2928467,GSM2928468,GSM2928469,GSM2928470,GSM2928471,GSM2928472,GSM2928473,GSM2928474,GSM2928475,GSM2928476,GSM2928477,GSM2928478,GSM2928479,GSM2928480,GSM2928481,GSM2928482,GSM2928483,GSM2928484,GSM2928485,GSM2928486,GSM2928487,GSM2928488,GSM2928489,GSM2928490,GSM2928491,GSM2928492,GSM2928493,GSM2928494,GSM2928495,GSM2928496,GSM2928497,GSM2928498,GSM2928499,GSM2928500,GSM2928501,GSM2928502,GSM2928503
|
2 |
+
Atherosclerosis,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p3/preprocess/Atherosclerosis/clinical_data/GSE123086.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049
|
2 |
+
Atherosclerosis,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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
3 |
+
Age,56.0,,20.0,51.0,37.0,61.0,,31.0,56.0,41.0,61.0,,80.0,53.0,61.0,73.0,60.0,76.0,77.0,74.0,69.0,77.0,81.0,70.0,82.0,69.0,82.0,67.0,67.0,78.0,67.0,74.0,,51.0,72.0,66.0,80.0,36.0,67.0,31.0,31.0,45.0,56.0,65.0,53.0,48.0,50.0,76.0,,24.0,42.0,76.0,22.0,,23.0,34.0,43.0,47.0,24.0,55.0,48.0,58.0,30.0,28.0,41.0,63.0,55.0,55.0,67.0,47.0,46.0,49.0,23.0,68.0,39.0,24.0,36.0,58.0,38.0,27.0,67.0,61.0,69.0,63.0,60.0,17.0,10.0,9.0,13.0,10.0,13.0,15.0,12.0,13.0,81.0,94.0,51.0,40.0,,97.0,23.0,93.0,58.0,28.0,54.0,15.0,8.0,11.0,12.0,8.0,14.0,8.0,10.0,14.0,13.0,40.0,52.0,42.0,29.0,43.0,41.0,54.0,42.0,49.0,45.0,56.0,64.0,71.0,48.0,20.0,53.0,32.0,26.0,28.0,47.0,24.0,48.0,,19.0,41.0,38.0,,15.0,12.0,13.0,,11.0,,16.0,11.0,,35.0,26.0,39.0,46.0,42.0,20.0,69.0,69.0,47.0,47.0,56.0,54.0,53.0,50.0,22.0
|
4 |
+
Gender,1.0,,0.0,0.0,1.0,1.0,,1.0,0.0,0.0,0.0,,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,0.0,0.0,1.0,1.0,,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,0.0,0.0,0.0,,0.0,1.0,0.0,,1.0,,1.0,1.0,,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0
|
p3/preprocess/Atherosclerosis/clinical_data/GSE123088.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049,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
|
2 |
+
Atherosclerosis,,,,,,,,,,,,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
|
3 |
+
Age,56.0,,20.0,51.0,37.0,61.0,,31.0,56.0,41.0,61.0,,80.0,53.0,61.0,73.0,60.0,76.0,77.0,74.0,69.0,77.0,81.0,70.0,82.0,69.0,82.0,67.0,67.0,78.0,67.0,74.0,,51.0,72.0,66.0,80.0,36.0,67.0,31.0,31.0,45.0,56.0,65.0,53.0,48.0,50.0,76.0,,24.0,42.0,76.0,22.0,,23.0,34.0,43.0,47.0,24.0,55.0,48.0,58.0,30.0,28.0,41.0,63.0,55.0,55.0,67.0,47.0,46.0,49.0,23.0,68.0,39.0,24.0,36.0,58.0,38.0,27.0,67.0,61.0,69.0,63.0,60.0,17.0,10.0,9.0,13.0,10.0,13.0,15.0,12.0,13.0,81.0,94.0,51.0,40.0,,97.0,23.0,93.0,58.0,28.0,54.0,15.0,8.0,11.0,12.0,8.0,14.0,8.0,10.0,14.0,13.0,40.0,52.0,42.0,29.0,43.0,41.0,54.0,42.0,49.0,45.0,56.0,64.0,71.0,48.0,20.0,53.0,32.0,26.0,28.0,47.0,24.0,48.0,,19.0,41.0,38.0,,15.0,12.0,13.0,,11.0,,16.0,11.0,,35.0,26.0,39.0,46.0,42.0,20.0,69.0,69.0,47.0,47.0,56.0,54.0,53.0,50.0,22.0,62.0,74.0,57.0,47.0,70.0,50.0,52.0,43.0,57.0,53.0,70.0,41.0,61.0,39.0,58.0,55.0,63.0,60.0,43.0,68.0,67.0,50.0,67.0,51.0,59.0,44.0,35.0,83.0,78.0,88.0,41.0,60.0,72.0,53.0,73.0,56.0,38.0,53.0
|
4 |
+
Gender,1.0,,0.0,0.0,1.0,1.0,,1.0,0.0,0.0,0.0,,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,,0.0,0.0,1.0,1.0,,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,0.0,0.0,0.0,,0.0,1.0,0.0,,1.0,,1.0,1.0,,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
p3/preprocess/Atherosclerosis/clinical_data/GSE125771.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,GSM3581706,GSM3581707,GSM3581708,GSM3581709,GSM3581710,GSM3581711,GSM3581712,GSM3581713,GSM3581714,GSM3581715,GSM3581716,GSM3581717,GSM3581718,GSM3581719,GSM3581720,GSM3581721,GSM3581722,GSM3581723,GSM3581724,GSM3581725,GSM3581726,GSM3581727,GSM3581728,GSM3581729,GSM3581730,GSM3581731,GSM3581732,GSM3581733,GSM3581734,GSM3581735,GSM3581736,GSM3581737,GSM3581738,GSM3581739,GSM3581740,GSM3581741,GSM3581742,GSM3581743,GSM3581744,GSM3581745
|
2 |
+
Atherosclerosis,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
3 |
+
Age,73.0,60.0,81.0,85.0,60.0,84.0,76.0,57.0,71.0,69.0,79.0,78.0,79.0,54.0,72.0,73.0,64.0,67.0,63.0,75.0,62.0,64.0,73.0,81.0,79.0,72.0,71.0,75.0,74.0,76.0,69.0,65.0,83.0,85.0,61.0,72.0,64.0,69.0,61.0,71.0
|
4 |
+
Gender,1.0,1.0,0.0,1.0,0.0,0.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,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,0.0,1.0
|
p3/preprocess/Atherosclerosis/clinical_data/GSE154851.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,GSM4681537,GSM4681538,GSM4681539,GSM4681540,GSM4681541,GSM4681542,GSM4681543,GSM4681544,GSM4681545,GSM4681546,GSM4681547,GSM4681548,GSM4681549,GSM4681550,GSM4681551,GSM4681552,GSM4681553,GSM4681554,GSM4681555,GSM4681556,GSM4681557,GSM4681558,GSM4681559,GSM4681560,GSM4681561,GSM4681562,GSM4681563,GSM4681564,GSM4681565,GSM4681566,GSM4681567,GSM4681568,GSM4681569,GSM4681570,GSM4681571,GSM4681572,GSM4681573,GSM4681574,GSM4681575,GSM4681576,GSM4681577,GSM4681578,GSM4681579,GSM4681580,GSM4681581,GSM4681582,GSM4681583,GSM4681584,GSM4681585,GSM4681586,GSM4681587,GSM4681588,GSM4681589,GSM4681590,GSM4681591,GSM4681592,GSM4681593,GSM4681594,GSM4681595,GSM4681596,GSM4681597,GSM4681598,GSM4681599,GSM4681600,GSM4681601,GSM4681602,GSM4681603,GSM4681604,GSM4681605,GSM4681606
|
2 |
+
Atherosclerosis,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
3 |
+
Age,18.0,37.0,59.0,36.0,56.0,22.0,53.0,41.0,33.0,52.0,42.0,28.0,45.0,41.0,25.0,34.0,40.0,44.0,42.0,39.0,51.0,41.0,52.0,34.0,21.0,23.0,32.0,39.0,71.0,23.0,44.0,26.0,31.0,24.0,23.0,31.0,30.0,47.0,30.0,24.0,35.0,25.0,25.0,33.0,19.0,23.0,36.0,26.0,27.0,28.0,34.0,30.0,39.0,32.0,26.0,22.0,25.0,32.0,33.0,41.0,31.0,48.0,38.0,30.0,27.0,23.0,41.0,36.0,34.0,54.0
|
4 |
+
Gender,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,0.0,0.0,0.0,0.0,0.0,0.0,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,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
p3/preprocess/Atherosclerosis/clinical_data/GSE57691.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,!Sample_title,small AAA_Sample 1,small AAA_Sample 2,small AAA_Sample 3,small AAA_Sample 4,small AAA_Sample 5,small AAA_Sample 6,small AAA_Sample 7,small AAA_Sample 8,small AAA_Sample 9,small AAA_Sample 10,small AAA_Sample 11,small AAA_Sample 12,small AAA_Sample 13,small AAA_Sample 14,small AAA_Sample 15,small AAA_Sample 16,small AAA_Sample 17,small AAA_Sample 18,small AAA_Sample 19,small AAA_Sample 20,large AAA_Sample 21,large AAA_Sample 22,large AAA_Sample 23,large AAA_Sample 24,large AAA_Sample 25,large AAA_Sample 26,large AAA_Sample 27,large AAA_Sample 28,large AAA_Sample 29,large AAA_Sample 30,large AAA_Sample 31,large AAA_Sample 32,large AAA_Sample 33,large AAA_Sample 34,large AAA_Sample 35,large AAA_Sample 36,large AAA_Sample 37,large AAA_Sample 38,large AAA_Sample 39,large AAA_Sample 40,large AAA_Sample 41,large AAA_Sample 42,large AAA_Sample 43,large AAA_Sample 44,large AAA_Sample 45,large AAA_Sample 46,large AAA_Sample 47,large AAA_Sample 48,large AAA_Sample 49,AOD_Sample 50,AOD_Sample 51,AOD_Sample 52,AOD_Sample 53,AOD_Sample 54,AOD_Sample 55,AOD_Sample 56,AOD_Sample 57,AOD_Sample 58,Donor_Sample 59,Donor_Sample 60,Donor_Sample 61,Donor_Sample 62,Donor_Sample 63,Donor_Sample 64,Donor_Sample 65,Donor_Sample 66,Donor_Sample 67,Donor_Sample 68
|
2 |
+
Atherosclerosis,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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
|
p3/preprocess/Atherosclerosis/clinical_data/GSE83500.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,0
|
2 |
+
Atherosclerosis,
|
p3/preprocess/Atherosclerosis/clinical_data/GSE87005.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,!Sample_title,IS1,IS2,IS3,IS4,IS5,IS6,IS7,IS8,IS9,IS10,IR1,IR2,IR3,IR4,IR5,IR6,IR7,IR8,IR9,IR10,IS-BMI1,IS-BMI2,IS-BMI3,IS-BMI4,IS-BMI5,IS-BMI6,IS-BMI7,IS-BMI8,IS-BMI9,IS-BMI10,IR-BMI1,IR-BMI2,IR-BMI3,IR-BMI4,IR-BMI5,IR-BMI6,IR-BMI7,IR-BMI8,IR-BMI9,IR-BMI10
|
2 |
+
Atherosclerosis,,,,,,,,,,,,,,,,,,,,,,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
|
p3/preprocess/Atherosclerosis/clinical_data/GSE90074.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
,!Sample_title,2S001_F_CAU_N_1_43,2S002_F_AA_Y_3_123,2S003_F_CAU_Y_4_135,2S004_M_AA_N_1_112,2S005_F_CAU_Y_2_114,2S006_F_CAU_Y_3_55,2S007_F_CAU_Y_4_39,2S008_M_CAU_Y_4_120,2S009_M_CAU_Y_4_59,2S010_M_CAU_Y_3_92,2S012_F_AA_Y_3_139,2S015_M_CAU_Y_4_37,2S023_F_AA_Y_3_101,2S025_F_CAU_N_1_100,2S026_F_CAU_Y_2_60,2S029_M_CAU_Y_2_91,2S031_M_CAU_Y_3_27,2S033_M_CAU_N_1_64,2S035_F_AA_N_1_106,2S037_F_CAU_Y_4_46,2S038_F_CAU_N_1_116,2S039_M_CAU_Y_3_72,2S040_M_CAU_N_0_13,2S042_F_CAU_N_1_131,2S044_F_AA_N_1_75,2S045_F_CAU_N_0_130,2S046_M_CAU_Y_4_77,2S047_M_AA_Y_2_126,2S048_F_AA_N_0_141,2S049_M_CAU_N_1_104,2S050_M_CAU_Y_4_103,2S051_M_CAU_N_0_109,2S052_F_AA_N_0_137,2S053_F_CAU_Y_3_21,2S054_F_CAU_N_1_33,2S056_F_CAU_Y_2_81,2S057_F_CAU_Y_2_89,2S058_F_CAU_Y_2_52,2S060_M_CAU_Y_4_93,2S061_M_CAU_N_1_99,2S062_F_CAU_Y_2_122,2S063_F_CAU_N_0_138,2S065_F_AA_Y_4_61,2S066_F_CAU_Y_4_56,2S067_F_AA_Y_4_142,2S069_M_CAU_N_1_84,2S070_F_CAU_N_0_47,2S071_M_CAU_N_0_67,2S072_M_CAU_N_0_54,2S073_M_CAU_N_1_45,2S074_F_CAU_N_0_83,2S075_F_AA_N_1_143,2S076_M_CAU_Y_3_7,2S077_F_CAU_Y_2_79,2S078_M_CAU_Y_3_132,2S079_M_CAU_Y_3_36,2S080_F_CAU_Y_2_128,2S082_F_AA_Y_4_19,2S083_M_CAU_Y_2_42,2S085_M_CAU_Y_3_29,2S087_M_CAU_Y_4_108,2S088_M_CAU_Y_2_69,2S089_M_CAU_Y_3_98,2S090_M_CAU_Y_4_53,2S092_F_AA_Y_4_85,2S093_M_AA_N_1_117,2S094_M_CAU_N_1_73,2S095_M_CAU_Y_4_51,2S097_M_CAU_Y_4_90,2S098_M_CAU_N_1_102,2S099_M_CAU_N_1_124,2S100_F_CAU_Y_2_118,2S101_F_CAU_N_1_110,2S102_F_CAU_N_0_125,2S103_M_CAU_Y_4_95,2S105_F_CAU_N_1_48,2S108_M_CAU_Y_4_86,2S109_M_CAU_Y_2_127,2S110_M_CAU_Y_4_57,2S111_M_CAU_Y_3_115,2S112_M_CAU_Y_3_40,2S113_M_CAU_Y_3_49,2S114_F_AA_Y_3_107,2S115_F_CAU_Y_2_121,2S116_M_AA_Y_3_134,2S118_M_CAU_N_1_119,2S119_M_CAU_N_1_136,2S120_M_CAU_Y_3_88,2S121_M_CAU_Y_3_140,2S124_M_CAU_Y_3_31,2S125_F_CAU_N_1_63,2S127_F_CAU_N_1_30,2S130_F_CAU_Y_2_24,2S132_F_CAU_N_1_113,2S133_F_AA_N_0_111,2S134_M_CAU_Y_2_22,2S137_M_CAU_Y_4_14,2S138_M_CAU_Y_2_4,2S139_F_CAU_Y_2_65,2S141_M_AA_Y_3_44,2S142_F_CAU_N_0_105,2S143_F_CAU_Y_4_16,2S144_M_CAU_Y_2_71,2S145_F_CAU_Y_2_3,2S146_F_AA_Y_3_82,2S147_M_CAU_N_0_6,2S148_F_CAU_Y_4_15,2S149_M_AA_Y_2_34,2S151_M_CAU_Y_4_5,2S152_F_CAU_Y_2_10,2S153_F_AA_Y_3_96,2S154_F_CAU_Y_4_9,2S156_F_CAU_Y_2_70,2S157_M_AA_Y_3_78,2S159_F_CAU_Y_2_32,2S160_M_CAU_Y_2_76,2S162_M_AA_Y_4_74,2S163_M_CAU_Y_2_26,2S165_M_AA_Y_4_23,2S167_F_CAU_N_1_87,2S168_F_AA_N_0_62,2S169_F_AA_N_0_38,2S171_M_CAU_Y_2_35,2S172_M_CAU_Y_4_68,2S173_M_AA_Y_4_11,2S175_F_AA_N_1_94,2S176_M_AA_N_1_97,2S177_M_CAU_Y_4_20,2S178_F_AA_N_1_50,2S179_M_CAU_Y_4_8,2S181_M_CAU_Y_4_41,2S182_F_CAU_N_0_129,2S183_F_CAU_N_1_133,2S184_M_AA_Y_3_18,2S186_M_CAU_Y_4_80,2S187_F_AA_Y_2_66,2S188_M_CAU_Y_4_2,2S189_F_CAU_N_1_12,2S191_M_CAU_Y_4_1,2S194_F_CAU_N_1_58,2S195_M_CAU_Y_2_25,2S199_M_CAU_Y_2_17,2S200_F_CAU_N_0_28
|
2 |
+
Atherosclerosis,,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.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,1.0,1.0,1.0,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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,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,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,1.0,1.0,1.0,1.0,1.0,1.0,0.0
|
3 |
+
Gender,,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.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,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,0.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.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,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,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0
|
p3/preprocess/Atherosclerosis/code/GSE109048.py
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE109048"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE109048"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE109048.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE109048.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE109048.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using specified prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# From background info, this is platelet gene expression data
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2. Variable Availability and Data Type Conversion
|
45 |
+
# 2.1 Data Availability
|
46 |
+
# Trait (Atherosclerosis) can be inferred from diagnosis in row 1
|
47 |
+
# sCAD = stable coronary artery disease = Atherosclerosis
|
48 |
+
trait_row = 1
|
49 |
+
|
50 |
+
# Age and gender not available
|
51 |
+
age_row = None
|
52 |
+
gender_row = None
|
53 |
+
|
54 |
+
# 2.2 Data Type Conversion Functions
|
55 |
+
def convert_trait(value):
|
56 |
+
# Extract value after colon
|
57 |
+
value = value.split(': ')[1].lower().strip()
|
58 |
+
# sCAD indicates presence of atherosclerosis
|
59 |
+
if 'scad' in value:
|
60 |
+
return 1
|
61 |
+
# STEMI indicates severe atherosclerosis
|
62 |
+
elif 'stemi' in value:
|
63 |
+
return 1
|
64 |
+
# Healthy indicates no atherosclerosis
|
65 |
+
elif 'healthy' in value:
|
66 |
+
return 0
|
67 |
+
return None
|
68 |
+
|
69 |
+
def convert_age(value):
|
70 |
+
# Age not available
|
71 |
+
return None
|
72 |
+
|
73 |
+
def convert_gender(value):
|
74 |
+
# Gender not available
|
75 |
+
return None
|
76 |
+
|
77 |
+
# 3. Save Metadata
|
78 |
+
validate_and_save_cohort_info(
|
79 |
+
is_final=False,
|
80 |
+
cohort=cohort,
|
81 |
+
info_path=json_path,
|
82 |
+
is_gene_available=is_gene_available,
|
83 |
+
is_trait_available=(trait_row is not None)
|
84 |
+
)
|
85 |
+
|
86 |
+
# 4. Clinical Feature Extraction
|
87 |
+
# Since trait_row is not None, extract clinical features
|
88 |
+
selected_clinical = geo_select_clinical_features(
|
89 |
+
clinical_df=clinical_data,
|
90 |
+
trait=trait,
|
91 |
+
trait_row=trait_row,
|
92 |
+
convert_trait=convert_trait,
|
93 |
+
age_row=age_row,
|
94 |
+
convert_age=convert_age,
|
95 |
+
gender_row=gender_row,
|
96 |
+
convert_gender=convert_gender
|
97 |
+
)
|
98 |
+
|
99 |
+
print("Preview of selected clinical features:")
|
100 |
+
print(preview_df(selected_clinical))
|
101 |
+
|
102 |
+
# Save clinical data
|
103 |
+
selected_clinical.to_csv(out_clinical_data_file)
|
104 |
+
# Get file paths
|
105 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
106 |
+
|
107 |
+
# Extract gene expression data from matrix file
|
108 |
+
gene_data = get_genetic_data(matrix_file)
|
109 |
+
|
110 |
+
# Print first 20 row IDs and shape of data to help debug
|
111 |
+
print("Shape of gene expression data:", gene_data.shape)
|
112 |
+
print("\nFirst few rows of data:")
|
113 |
+
print(gene_data.head())
|
114 |
+
print("\nFirst 20 gene/probe identifiers:")
|
115 |
+
print(gene_data.index[:20])
|
116 |
+
|
117 |
+
# Inspect a snippet of raw file to verify identifier format
|
118 |
+
import gzip
|
119 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
120 |
+
lines = []
|
121 |
+
for i, line in enumerate(f):
|
122 |
+
if "!series_matrix_table_begin" in line:
|
123 |
+
# Get the next 5 lines after the marker
|
124 |
+
for _ in range(5):
|
125 |
+
lines.append(next(f).strip())
|
126 |
+
break
|
127 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
128 |
+
for line in lines:
|
129 |
+
print(line)
|
130 |
+
# Looking at the identifiers (e.g. "2824546_st", "2824549_st"),
|
131 |
+
# these appear to be Affymetrix probe IDs rather than gene symbols
|
132 |
+
requires_gene_mapping = True
|
133 |
+
# Extract gene annotation data
|
134 |
+
gene_metadata = get_gene_annotation(soft_file)
|
135 |
+
|
136 |
+
# Preview the annotation data
|
137 |
+
print("Column names:", gene_metadata.columns.tolist())
|
138 |
+
print("\nFirst few rows preview:")
|
139 |
+
print(preview_df(gene_metadata))
|
140 |
+
# Get mapping data
|
141 |
+
# First rename the columns to match expected format
|
142 |
+
mapping_df = gene_metadata[['probeset_id', 'gene_assignment']].copy()
|
143 |
+
mapping_df = mapping_df.rename(columns={'probeset_id': 'ID', 'gene_assignment': 'Gene'})
|
144 |
+
mapping_df = mapping_df.dropna()
|
145 |
+
|
146 |
+
# Apply the gene mapping to convert probe-level data to gene-level data
|
147 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
148 |
+
|
149 |
+
# Preview the mapped data
|
150 |
+
print("\nPreview of gene expression data after mapping:")
|
151 |
+
print(gene_data.head())
|
152 |
+
print("\nShape of gene expression data after mapping:", gene_data.shape)
|
153 |
+
# 1. Normalize gene symbols
|
154 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
155 |
+
gene_data.to_csv(out_gene_data_file)
|
156 |
+
|
157 |
+
# 2. Link clinical and genetic data
|
158 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
|
159 |
+
|
160 |
+
print("Preview of linked data after linking:")
|
161 |
+
print(linked_data.head())
|
162 |
+
print("\nShape after linking:", linked_data.shape)
|
163 |
+
|
164 |
+
# 3. Handle missing values
|
165 |
+
linked_data = handle_missing_values(linked_data, trait)
|
166 |
+
|
167 |
+
print("Preview of linked data after missing value handling:")
|
168 |
+
print(linked_data.head())
|
169 |
+
print("\nShape after handling missing values:", linked_data.shape)
|
170 |
+
|
171 |
+
# 4. Check for biased features
|
172 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
173 |
+
|
174 |
+
# 5. Validate and save cohort info
|
175 |
+
is_usable = validate_and_save_cohort_info(
|
176 |
+
is_final=True,
|
177 |
+
cohort=cohort,
|
178 |
+
info_path=json_path,
|
179 |
+
is_gene_available=True,
|
180 |
+
is_trait_available=True,
|
181 |
+
is_biased=trait_biased,
|
182 |
+
df=linked_data,
|
183 |
+
note="Contains gene expression data and trait labels for atherosclerosis."
|
184 |
+
)
|
185 |
+
|
186 |
+
# 6. Save linked data if usable
|
187 |
+
if is_usable:
|
188 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Atherosclerosis/code/GSE123086.py
ADDED
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE123086"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE123086"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE123086.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE123086.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE123086.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using specified prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# According to Series_overall_design, RNA was extracted and microarrays were used
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2.1 Data Availability
|
45 |
+
# Primary diagnosis in row 1 contains trait information
|
46 |
+
trait_row = 1
|
47 |
+
|
48 |
+
# Sex is recorded in rows 2 and 3
|
49 |
+
gender_row = 2
|
50 |
+
|
51 |
+
# Age is recorded in rows 3 and 4
|
52 |
+
age_row = 3
|
53 |
+
|
54 |
+
# 2.2 Data Type Conversion Functions
|
55 |
+
def convert_trait(value):
|
56 |
+
if not isinstance(value, str) or 'primary diagnosis:' not in value:
|
57 |
+
return None
|
58 |
+
# Extract value after colon and strip whitespace
|
59 |
+
value = value.split(':', 1)[1].strip()
|
60 |
+
# Convert to binary based on trait name
|
61 |
+
return 1 if value == 'ATHEROSCLEROSIS' else 0
|
62 |
+
|
63 |
+
def convert_age(value):
|
64 |
+
if not isinstance(value, str) or 'age:' not in value:
|
65 |
+
return None
|
66 |
+
try:
|
67 |
+
# Extract numeric age value after colon
|
68 |
+
age = int(value.split(':', 1)[1].strip())
|
69 |
+
return age
|
70 |
+
except:
|
71 |
+
return None
|
72 |
+
|
73 |
+
def convert_gender(value):
|
74 |
+
if not isinstance(value, str) or 'Sex:' not in value:
|
75 |
+
return None
|
76 |
+
# Extract gender value after colon
|
77 |
+
gender = value.split(':', 1)[1].strip()
|
78 |
+
# Convert to binary (female=0, male=1)
|
79 |
+
if gender.upper() == 'FEMALE':
|
80 |
+
return 0
|
81 |
+
elif gender.upper() == 'MALE':
|
82 |
+
return 1
|
83 |
+
return None
|
84 |
+
|
85 |
+
# 3. Save Metadata
|
86 |
+
validate_and_save_cohort_info(is_final=False,
|
87 |
+
cohort=cohort,
|
88 |
+
info_path=json_path,
|
89 |
+
is_gene_available=is_gene_available,
|
90 |
+
is_trait_available=trait_row is not None)
|
91 |
+
|
92 |
+
# 4. Clinical Feature Extraction
|
93 |
+
if trait_row is not None:
|
94 |
+
clinical_features = geo_select_clinical_features(clinical_data, trait,
|
95 |
+
trait_row=trait_row,
|
96 |
+
convert_trait=convert_trait,
|
97 |
+
age_row=age_row,
|
98 |
+
convert_age=convert_age,
|
99 |
+
gender_row=gender_row,
|
100 |
+
convert_gender=convert_gender)
|
101 |
+
|
102 |
+
# Preview the processed clinical data
|
103 |
+
preview = preview_df(clinical_features)
|
104 |
+
print("Preview of processed clinical data:")
|
105 |
+
print(preview)
|
106 |
+
|
107 |
+
# Save clinical features to CSV
|
108 |
+
clinical_features.to_csv(out_clinical_data_file)
|
109 |
+
# Get file paths
|
110 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
111 |
+
|
112 |
+
# Extract gene expression data from matrix file
|
113 |
+
gene_data = get_genetic_data(matrix_file)
|
114 |
+
|
115 |
+
# Print first 20 row IDs and shape of data to help debug
|
116 |
+
print("Shape of gene expression data:", gene_data.shape)
|
117 |
+
print("\nFirst few rows of data:")
|
118 |
+
print(gene_data.head())
|
119 |
+
print("\nFirst 20 gene/probe identifiers:")
|
120 |
+
print(gene_data.index[:20])
|
121 |
+
|
122 |
+
# Inspect a snippet of raw file to verify identifier format
|
123 |
+
import gzip
|
124 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
125 |
+
lines = []
|
126 |
+
for i, line in enumerate(f):
|
127 |
+
if "!series_matrix_table_begin" in line:
|
128 |
+
# Get the next 5 lines after the marker
|
129 |
+
for _ in range(5):
|
130 |
+
lines.append(next(f).strip())
|
131 |
+
break
|
132 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
133 |
+
for line in lines:
|
134 |
+
print(line)
|
135 |
+
requires_gene_mapping = True
|
136 |
+
# Extract gene annotation data, excluding metadata lines
|
137 |
+
gene_metadata = get_gene_annotation(soft_file, prefixes=['!Platform_table_begin', '^SPOT_ID', '^ENTREZ_GENE_ID', '^GENE_SYMBOL'])
|
138 |
+
|
139 |
+
# Preview the annotation data
|
140 |
+
print("Column names:", gene_metadata.columns.tolist())
|
141 |
+
print("\nFirst few rows preview:")
|
142 |
+
print(preview_df(gene_metadata))
|
143 |
+
# Extract gene annotation data by excluding lines with special prefixes
|
144 |
+
gene_metadata = get_gene_annotation(soft_file, prefixes=['^', '!', '#'])
|
145 |
+
|
146 |
+
# Print full info about the data to debug
|
147 |
+
print("Shape:", gene_metadata.shape)
|
148 |
+
print("\nAll columns:", gene_metadata.columns.tolist())
|
149 |
+
print("\nFirst few rows:")
|
150 |
+
print(gene_metadata.head())
|
151 |
+
|
152 |
+
# Try importing the annotation file differently since the first attempt failed
|
153 |
+
import gzip
|
154 |
+
import pandas as pd
|
155 |
+
|
156 |
+
with gzip.open(soft_file, 'rt') as f:
|
157 |
+
for line in f:
|
158 |
+
if '!platform_table_begin' in line.lower():
|
159 |
+
# Read the table that follows
|
160 |
+
gene_metadata = pd.read_csv(f, sep='\t', comment='!', on_bad_lines='skip')
|
161 |
+
break
|
162 |
+
|
163 |
+
print("\nAfter direct reading:")
|
164 |
+
print("Shape:", gene_metadata.shape)
|
165 |
+
print("\nAll columns:", gene_metadata.columns.tolist())
|
166 |
+
print("\nFirst few rows:")
|
167 |
+
print(gene_metadata.head())
|
168 |
+
|
169 |
+
# Get mapping between IDs and gene symbols
|
170 |
+
mapping_data = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='Gene Symbol')
|
171 |
+
|
172 |
+
# Apply the mapping to convert probe-level data to gene-level data
|
173 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
174 |
+
|
175 |
+
# Save the gene expression data
|
176 |
+
gene_data.to_csv(out_gene_data_file)
|
177 |
+
# Extract gene annotation data from the platform portion of the SOFT file
|
178 |
+
with gzip.open(soft_file, 'rt') as f:
|
179 |
+
platform_found = False
|
180 |
+
table_found = False
|
181 |
+
lines = []
|
182 |
+
for line in f:
|
183 |
+
if '!Platform' in line:
|
184 |
+
platform_found = True
|
185 |
+
if platform_found and '!platform_table_begin' in line.lower():
|
186 |
+
table_found = True
|
187 |
+
continue
|
188 |
+
if table_found and not line.startswith('!'):
|
189 |
+
lines.append(line)
|
190 |
+
|
191 |
+
# Parse the platform table into a dataframe
|
192 |
+
annotation_text = ''.join(lines)
|
193 |
+
gene_metadata = pd.read_csv(io.StringIO(annotation_text), sep='\t')
|
194 |
+
|
195 |
+
# Create mapping between probe IDs and gene identifiers
|
196 |
+
mapping_data = pd.DataFrame({
|
197 |
+
'ID': gene_metadata['ID'].astype(str),
|
198 |
+
'Gene': gene_metadata['ENTREZ_GENE_ID'].astype(str) # Use ENTREZ_GENE_ID as gene identifier
|
199 |
+
})
|
200 |
+
|
201 |
+
# Apply mapping to convert probe data to gene expression data
|
202 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
203 |
+
|
204 |
+
# Save the processed gene expression data
|
205 |
+
gene_data.to_csv(out_gene_data_file)
|
206 |
+
# 1. Normalize gene symbols
|
207 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
208 |
+
|
209 |
+
# 2. Link clinical and genetic data
|
210 |
+
linked_data = geo_link_clinical_genetic_data(clinical_features, gene_data)
|
211 |
+
|
212 |
+
# 3. Handle missing values
|
213 |
+
linked_data = handle_missing_values(linked_data, 'Atherosclerosis')
|
214 |
+
|
215 |
+
# 4. Check for bias
|
216 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, 'Atherosclerosis')
|
217 |
+
|
218 |
+
# 5. Final validation and save metadata
|
219 |
+
is_usable = validate_and_save_cohort_info(
|
220 |
+
is_final=True,
|
221 |
+
cohort=cohort,
|
222 |
+
info_path=json_path,
|
223 |
+
is_gene_available=True,
|
224 |
+
is_trait_available=True,
|
225 |
+
is_biased=trait_biased,
|
226 |
+
df=linked_data,
|
227 |
+
note="Dataset contains both clinical features and gene expression data."
|
228 |
+
)
|
229 |
+
|
230 |
+
# 6. Save data if usable
|
231 |
+
if is_usable:
|
232 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Atherosclerosis/code/GSE123088.py
ADDED
@@ -0,0 +1,353 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE123088"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE123088"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE123088.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE123088.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE123088.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using specified prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# This dataset contains mixed disease data and focuses on CD4+ T cells, likely containing gene expression data
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2. Variable Availability and Data Type Conversion
|
45 |
+
# 2.1 Data Availability
|
46 |
+
# trait data in Feature 1 under 'primary diagnosis'
|
47 |
+
trait_row = 1
|
48 |
+
# age data appears in Features 3 and 4
|
49 |
+
age_row = 3
|
50 |
+
# gender data in Features 2 and 3
|
51 |
+
gender_row = 2
|
52 |
+
|
53 |
+
# 2.2 Data Type Conversion Functions
|
54 |
+
def convert_trait(x):
|
55 |
+
if not isinstance(x, str):
|
56 |
+
return None
|
57 |
+
diagnosis = x.split(': ')[1] if ': ' in x else x
|
58 |
+
# Convert to binary based on diagnosis
|
59 |
+
if diagnosis in ['ATHEROSCLEROSIS', 'diagnosis2: ATHEROSCLEROSIS']:
|
60 |
+
return 1
|
61 |
+
elif diagnosis in ['HEALTHY_CONTROL', 'Control']:
|
62 |
+
return 0
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_age(x):
|
66 |
+
if not isinstance(x, str):
|
67 |
+
return None
|
68 |
+
try:
|
69 |
+
# Extract age value after colon
|
70 |
+
age_str = x.split(': ')[1] if ': ' in x else x
|
71 |
+
return float(age_str)
|
72 |
+
except:
|
73 |
+
return None
|
74 |
+
|
75 |
+
def convert_gender(x):
|
76 |
+
if not isinstance(x, str):
|
77 |
+
return None
|
78 |
+
if 'Sex:' not in x:
|
79 |
+
return None
|
80 |
+
gender = x.split(': ')[1]
|
81 |
+
# Convert gender to binary (0 for female, 1 for male)
|
82 |
+
if gender.lower() == 'female':
|
83 |
+
return 0
|
84 |
+
elif gender.lower() == 'male':
|
85 |
+
return 1
|
86 |
+
return None
|
87 |
+
|
88 |
+
# 3. Save Metadata
|
89 |
+
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=trait_row is not None
|
95 |
+
)
|
96 |
+
|
97 |
+
# 4. Clinical Feature Extraction
|
98 |
+
if trait_row is not None:
|
99 |
+
clinical_features = 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 processed data
|
111 |
+
print("Preview of processed clinical features:")
|
112 |
+
print(preview_df(clinical_features))
|
113 |
+
|
114 |
+
# Save to CSV
|
115 |
+
clinical_features.to_csv(out_clinical_data_file)
|
116 |
+
# Get file paths
|
117 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
118 |
+
|
119 |
+
# Extract gene expression data from matrix file
|
120 |
+
gene_data = get_genetic_data(matrix_file)
|
121 |
+
|
122 |
+
# Print first 20 row IDs and shape of data to help debug
|
123 |
+
print("Shape of gene expression data:", gene_data.shape)
|
124 |
+
print("\nFirst few rows of data:")
|
125 |
+
print(gene_data.head())
|
126 |
+
print("\nFirst 20 gene/probe identifiers:")
|
127 |
+
print(gene_data.index[:20])
|
128 |
+
|
129 |
+
# Inspect a snippet of raw file to verify identifier format
|
130 |
+
import gzip
|
131 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
132 |
+
lines = []
|
133 |
+
for i, line in enumerate(f):
|
134 |
+
if "!series_matrix_table_begin" in line:
|
135 |
+
# Get the next 5 lines after the marker
|
136 |
+
for _ in range(5):
|
137 |
+
lines.append(next(f).strip())
|
138 |
+
break
|
139 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
140 |
+
for line in lines:
|
141 |
+
print(line)
|
142 |
+
requires_gene_mapping = True
|
143 |
+
# First locate platform and annotation information
|
144 |
+
with gzip.open(soft_file, 'rt', encoding='utf-8') as f:
|
145 |
+
print("Searching for platform/annotation info:")
|
146 |
+
content = f.read(10000)
|
147 |
+
relevant = [line for line in content.split('\n')
|
148 |
+
if 'platform' in line.lower() or 'annotation' in line.lower()]
|
149 |
+
for line in relevant:
|
150 |
+
print(line)
|
151 |
+
|
152 |
+
print("\n" + "="*80 + "\n")
|
153 |
+
|
154 |
+
# Extract gene annotation, filtering platform/ID information
|
155 |
+
gene_metadata = filter_content_by_prefix(
|
156 |
+
soft_file,
|
157 |
+
prefixes_a=['!Platform_table_begin'],
|
158 |
+
unselect=True,
|
159 |
+
source_type='file',
|
160 |
+
return_df_a=True
|
161 |
+
)[0]
|
162 |
+
|
163 |
+
# Preview the annotation data
|
164 |
+
print("Column names:", gene_metadata.columns.tolist())
|
165 |
+
print("\nFirst few rows preview:")
|
166 |
+
print(preview_df(gene_metadata))
|
167 |
+
# Try to extract data from SOFT file with more focused extraction
|
168 |
+
from io import StringIO
|
169 |
+
import gzip
|
170 |
+
|
171 |
+
# First read a portion of the file to find where the platform table starts
|
172 |
+
platform_data = ""
|
173 |
+
in_table = False
|
174 |
+
with gzip.open(soft_file, 'rt', encoding='utf-8') as f:
|
175 |
+
for line in f:
|
176 |
+
if '!Platform_table_begin' in line:
|
177 |
+
in_table = True
|
178 |
+
# Skip the header row
|
179 |
+
next(f)
|
180 |
+
continue
|
181 |
+
if in_table and '!Platform_table_end' in line:
|
182 |
+
break
|
183 |
+
if in_table:
|
184 |
+
platform_data += line
|
185 |
+
|
186 |
+
# Create DataFrame from the extracted platform data
|
187 |
+
gene_metadata = pd.read_csv(StringIO(platform_data), sep='\t')
|
188 |
+
|
189 |
+
# Print column names to identify correct ones for mapping
|
190 |
+
print("Available columns in gene metadata:")
|
191 |
+
print(gene_metadata.columns.tolist())
|
192 |
+
print("\nFirst few rows:")
|
193 |
+
print(gene_metadata.head())
|
194 |
+
|
195 |
+
# Create mapping between probe IDs and gene symbols
|
196 |
+
# Adjust column names based on actual output
|
197 |
+
mapping_data = get_gene_mapping(gene_metadata, prob_col='ProbeName', gene_col='GeneName')
|
198 |
+
|
199 |
+
# Convert probe-level measurements to gene-level measurements
|
200 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
201 |
+
|
202 |
+
# Preview the mapped data
|
203 |
+
print("\nShape of gene expression data after mapping:", gene_data.shape)
|
204 |
+
print("\nFirst few rows of mapped data:")
|
205 |
+
print(gene_data.head())
|
206 |
+
# Extract gene annotation using the provided function
|
207 |
+
gene_metadata = get_gene_annotation(soft_file)
|
208 |
+
|
209 |
+
# Preview the annotation data
|
210 |
+
print("Column names:", gene_metadata.columns.tolist())
|
211 |
+
print("\nFirst few rows preview:")
|
212 |
+
print(preview_df(gene_metadata))
|
213 |
+
# 1. Extract gene mapping from platform table in SOFT file
|
214 |
+
platform_data = ""
|
215 |
+
in_table = False
|
216 |
+
with gzip.open(soft_file, 'rt', encoding='utf-8') as f:
|
217 |
+
for line in f:
|
218 |
+
if '!Platform_table_begin' in line:
|
219 |
+
in_table = True
|
220 |
+
continue
|
221 |
+
if in_table and '!Platform_table_end' in line:
|
222 |
+
break
|
223 |
+
if in_table:
|
224 |
+
platform_data += line
|
225 |
+
|
226 |
+
# Parse platform data into DataFrame
|
227 |
+
gene_metadata = pd.read_csv(StringIO(platform_data), sep='\t')
|
228 |
+
|
229 |
+
# Map probe IDs to gene symbols
|
230 |
+
mapping_data = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='GeneName')
|
231 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
232 |
+
|
233 |
+
# Normalize gene symbols and save gene data
|
234 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
235 |
+
gene_data.to_csv(out_gene_data_file)
|
236 |
+
|
237 |
+
# Link clinical and genetic data
|
238 |
+
linked_data = geo_link_clinical_genetic_data(clinical_features, gene_data)
|
239 |
+
|
240 |
+
# Handle missing values
|
241 |
+
linked_data = handle_missing_values(linked_data, trait)
|
242 |
+
|
243 |
+
# Check for biased features
|
244 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
245 |
+
|
246 |
+
# Final validation and info saving
|
247 |
+
is_usable = validate_and_save_cohort_info(
|
248 |
+
is_final=True,
|
249 |
+
cohort=cohort,
|
250 |
+
info_path=json_path,
|
251 |
+
is_gene_available=True,
|
252 |
+
is_trait_available=True,
|
253 |
+
is_biased=is_biased,
|
254 |
+
df=linked_data,
|
255 |
+
note="Dataset contains gene expression data and clinical information, but some demographic features were removed due to bias."
|
256 |
+
)
|
257 |
+
|
258 |
+
# Save linked data if usable
|
259 |
+
if is_usable:
|
260 |
+
linked_data.to_csv(out_data_file)
|
261 |
+
# Print the first few lines of platform data to check format
|
262 |
+
platform_data = []
|
263 |
+
in_table = False
|
264 |
+
header_found = False
|
265 |
+
with gzip.open(soft_file, 'rt', encoding='utf-8') as f:
|
266 |
+
for line in f:
|
267 |
+
if '!Platform_table_begin' in line:
|
268 |
+
in_table = True
|
269 |
+
continue
|
270 |
+
if in_table and not header_found:
|
271 |
+
header = line.strip().split('\t')
|
272 |
+
header_found = True
|
273 |
+
continue
|
274 |
+
if in_table and '!Platform_table_end' in line:
|
275 |
+
break
|
276 |
+
if in_table and header_found:
|
277 |
+
platform_data.append(line.strip().split('\t'))
|
278 |
+
|
279 |
+
# Create DataFrame with proper columns
|
280 |
+
gene_metadata = pd.DataFrame(platform_data, columns=header)
|
281 |
+
print("Available columns:", gene_metadata.columns.tolist())
|
282 |
+
print("\nFirst few rows:")
|
283 |
+
print(gene_metadata.head())
|
284 |
+
|
285 |
+
# Create mapping using ENTREZ_GENE_ID as these match the numeric IDs
|
286 |
+
mapping_data = pd.DataFrame({
|
287 |
+
'ID': gene_metadata['ID'].astype(str),
|
288 |
+
'Gene': gene_metadata['ENTREZ_GENE_ID'].astype(str)
|
289 |
+
})
|
290 |
+
|
291 |
+
# Convert probe-level measurements to gene-level measurements
|
292 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
293 |
+
|
294 |
+
print("\nShape after mapping:", gene_data.shape)
|
295 |
+
print("\nMapped data preview:")
|
296 |
+
print(gene_data.head())
|
297 |
+
# We can use the gene_metadata from previous step which has numeric IDs matching gene expression data
|
298 |
+
# We'll query NCBI's gene database to get gene symbols from Entrez IDs
|
299 |
+
import gzip
|
300 |
+
import requests
|
301 |
+
import time
|
302 |
+
from typing import Dict
|
303 |
+
|
304 |
+
def get_gene_symbols_from_entrez(entrez_ids: list) -> Dict[str, str]:
|
305 |
+
"""Get gene symbols from Entrez Gene IDs using NCBI E-utilities"""
|
306 |
+
base_url = "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi"
|
307 |
+
symbols = {}
|
308 |
+
|
309 |
+
# Process in batches of 100 to avoid overloading the server
|
310 |
+
batch_size = 100
|
311 |
+
for i in range(0, len(entrez_ids), batch_size):
|
312 |
+
batch = entrez_ids[i:i + batch_size]
|
313 |
+
params = {
|
314 |
+
'db': 'gene',
|
315 |
+
'id': ','.join(batch),
|
316 |
+
'retmode': 'json'
|
317 |
+
}
|
318 |
+
|
319 |
+
try:
|
320 |
+
response = requests.get(base_url, params=params)
|
321 |
+
data = response.json()
|
322 |
+
|
323 |
+
for gene_id in data['result']:
|
324 |
+
if gene_id != 'uids': # Skip the uids key
|
325 |
+
try:
|
326 |
+
symbol = data['result'][gene_id]['name']
|
327 |
+
symbols[gene_id] = symbol
|
328 |
+
except KeyError:
|
329 |
+
continue
|
330 |
+
|
331 |
+
except Exception as e:
|
332 |
+
print(f"Error fetching symbols for batch {i}: {e}")
|
333 |
+
|
334 |
+
# Be nice to NCBI's servers
|
335 |
+
time.sleep(0.1)
|
336 |
+
|
337 |
+
return symbols
|
338 |
+
|
339 |
+
# Create mapping DataFrame
|
340 |
+
mapping_data = pd.DataFrame({
|
341 |
+
'ID': gene_metadata['ID'],
|
342 |
+
'Gene': gene_metadata['ENTREZ_GENE_ID']
|
343 |
+
})
|
344 |
+
|
345 |
+
# Convert gene_data probe IDs to string type to match mapping_data
|
346 |
+
gene_data.index = gene_data.index.astype(str)
|
347 |
+
|
348 |
+
# Apply mapping to convert probe-level measurements to gene-level measurements
|
349 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
350 |
+
|
351 |
+
print("\nShape of gene expression data after mapping:", gene_data.shape)
|
352 |
+
print("\nFirst few rows of mapped data:")
|
353 |
+
print(gene_data.head())
|
p3/preprocess/Atherosclerosis/code/GSE125771.py
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE125771"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE125771"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE125771.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE125771.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE125771.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using specified prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Determine gene expression data availability
|
41 |
+
# Based on the Series_title and Series_overall_design, this is RNA expression data
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2.1 Data availability
|
45 |
+
# Trait: everyone has atherosclerotic plaque (constant feature)
|
46 |
+
trait_row = None
|
47 |
+
|
48 |
+
# Age: available in Feature 3
|
49 |
+
age_row = 3
|
50 |
+
|
51 |
+
# Gender: available in Feature 2
|
52 |
+
gender_row = 2
|
53 |
+
|
54 |
+
# 2.2 Data type conversion functions
|
55 |
+
def convert_trait(x):
|
56 |
+
return None # Not used since trait_row is None
|
57 |
+
|
58 |
+
def convert_age(x):
|
59 |
+
try:
|
60 |
+
# Extract value after colon and convert to float
|
61 |
+
age = float(x.split(': ')[1])
|
62 |
+
return age
|
63 |
+
except:
|
64 |
+
return None
|
65 |
+
|
66 |
+
def convert_gender(x):
|
67 |
+
try:
|
68 |
+
# Extract value after colon and convert to binary (Female=0, Male=1)
|
69 |
+
gender = x.split(': ')[1]
|
70 |
+
if gender.lower() == 'female':
|
71 |
+
return 0
|
72 |
+
elif gender.lower() == 'male':
|
73 |
+
return 1
|
74 |
+
return None
|
75 |
+
except:
|
76 |
+
return None
|
77 |
+
|
78 |
+
# 3. Save metadata
|
79 |
+
validate_and_save_cohort_info(
|
80 |
+
is_final=False,
|
81 |
+
cohort=cohort,
|
82 |
+
info_path=json_path,
|
83 |
+
is_gene_available=is_gene_available,
|
84 |
+
is_trait_available=(trait_row is not None)
|
85 |
+
)
|
86 |
+
|
87 |
+
# 4. Skip clinical feature extraction since trait_row is None
|
88 |
+
# Get file paths
|
89 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
90 |
+
|
91 |
+
# Extract gene expression data from matrix file
|
92 |
+
gene_data = get_genetic_data(matrix_file)
|
93 |
+
|
94 |
+
# Print first 20 row IDs and shape of data to help debug
|
95 |
+
print("Shape of gene expression data:", gene_data.shape)
|
96 |
+
print("\nFirst few rows of data:")
|
97 |
+
print(gene_data.head())
|
98 |
+
print("\nFirst 20 gene/probe identifiers:")
|
99 |
+
print(gene_data.index[:20])
|
100 |
+
|
101 |
+
# Inspect a snippet of raw file to verify identifier format
|
102 |
+
import gzip
|
103 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
104 |
+
lines = []
|
105 |
+
for i, line in enumerate(f):
|
106 |
+
if "!series_matrix_table_begin" in line:
|
107 |
+
# Get the next 5 lines after the marker
|
108 |
+
for _ in range(5):
|
109 |
+
lines.append(next(f).strip())
|
110 |
+
break
|
111 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
112 |
+
for line in lines:
|
113 |
+
print(line)
|
114 |
+
# The gene identifiers appear to be probe IDs from a custom Affymetrix array
|
115 |
+
# They have the format "TC########.hg.1" which indicates they are transcript cluster IDs
|
116 |
+
# These are not standard human gene symbols and will need to be mapped
|
117 |
+
requires_gene_mapping = True
|
118 |
+
# Extract gene annotation data
|
119 |
+
gene_metadata = get_gene_annotation(soft_file)
|
120 |
+
|
121 |
+
# Preview the annotation data
|
122 |
+
print("Column names:", gene_metadata.columns.tolist())
|
123 |
+
print("\nFirst few rows preview:")
|
124 |
+
print(preview_df(gene_metadata))
|
125 |
+
# Get probe-to-gene mapping
|
126 |
+
mapping_data = get_gene_mapping(gene_metadata, 'ID', 'gene_assignment')
|
127 |
+
|
128 |
+
# Apply mapping to convert probe measurements to gene expression data
|
129 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
130 |
+
|
131 |
+
# Save processed gene data to CSV
|
132 |
+
gene_data.to_csv(out_gene_data_file)
|
133 |
+
# 1. Normalize gene symbols
|
134 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
135 |
+
gene_data.to_csv(out_gene_data_file)
|
136 |
+
|
137 |
+
# Clinical data is not available (trait_row was None), so skip remaining steps
|
138 |
+
# Record that this dataset cannot be used for association studies
|
139 |
+
validate_and_save_cohort_info(
|
140 |
+
is_final=True,
|
141 |
+
cohort=cohort,
|
142 |
+
info_path=json_path,
|
143 |
+
is_gene_available=True,
|
144 |
+
is_trait_available=False,
|
145 |
+
is_biased=False,
|
146 |
+
df=gene_data,
|
147 |
+
note="Contains gene expression data but lacks clinical information needed for trait association studies."
|
148 |
+
)
|
p3/preprocess/Atherosclerosis/code/GSE133601.py
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE133601"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE133601"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE133601.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE133601.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE133601.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using specified prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene expression data availability check
|
41 |
+
# Based on the background information, this dataset contains gene expression data from peripheral blood mononuclear cells
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2. Variable availability and data type conversion
|
45 |
+
# 2.1 Data rows
|
46 |
+
# trait (Atherosclerosis): Not directly available in the data
|
47 |
+
trait_row = None
|
48 |
+
|
49 |
+
# Age: Not available in sample characteristics
|
50 |
+
age_row = None
|
51 |
+
|
52 |
+
# Gender: Not available in sample characteristics
|
53 |
+
gender_row = None
|
54 |
+
|
55 |
+
# 2.2 Conversion functions
|
56 |
+
def convert_trait(x):
|
57 |
+
return None
|
58 |
+
|
59 |
+
def convert_age(x):
|
60 |
+
return None
|
61 |
+
|
62 |
+
def convert_gender(x):
|
63 |
+
return None
|
64 |
+
|
65 |
+
# 3. Save metadata
|
66 |
+
is_trait_available = trait_row is not None
|
67 |
+
validate_and_save_cohort_info(is_final=False,
|
68 |
+
cohort=cohort,
|
69 |
+
info_path=json_path,
|
70 |
+
is_gene_available=is_gene_available,
|
71 |
+
is_trait_available=is_trait_available)
|
72 |
+
|
73 |
+
# 4. Clinical feature extraction is skipped since trait_row is None
|
74 |
+
# Get file paths
|
75 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
76 |
+
|
77 |
+
# Extract gene expression data from matrix file
|
78 |
+
gene_data = get_genetic_data(matrix_file)
|
79 |
+
|
80 |
+
# Print first 20 row IDs and shape of data to help debug
|
81 |
+
print("Shape of gene expression data:", gene_data.shape)
|
82 |
+
print("\nFirst few rows of data:")
|
83 |
+
print(gene_data.head())
|
84 |
+
print("\nFirst 20 gene/probe identifiers:")
|
85 |
+
print(gene_data.index[:20])
|
86 |
+
|
87 |
+
# Inspect a snippet of raw file to verify identifier format
|
88 |
+
import gzip
|
89 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
90 |
+
lines = []
|
91 |
+
for i, line in enumerate(f):
|
92 |
+
if "!series_matrix_table_begin" in line:
|
93 |
+
# Get the next 5 lines after the marker
|
94 |
+
for _ in range(5):
|
95 |
+
lines.append(next(f).strip())
|
96 |
+
break
|
97 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
98 |
+
for line in lines:
|
99 |
+
print(line)
|
100 |
+
# Looking at the gene identifiers, they appear to be Affymetrix probe IDs (ending in "_at")
|
101 |
+
# These are not standard human gene symbols and will need to be mapped
|
102 |
+
requires_gene_mapping = True
|
103 |
+
# Let's explore raw SOFT file content to find the correct section
|
104 |
+
import gzip
|
105 |
+
print("Preview of raw SOFT file content (searching for platform data):")
|
106 |
+
with gzip.open(soft_file, 'rt', encoding='utf-8') as f:
|
107 |
+
in_platform = False
|
108 |
+
for i, line in enumerate(f):
|
109 |
+
if '!Platform_table_begin' in line:
|
110 |
+
in_platform = True
|
111 |
+
print("\nFound platform table. Next 10 lines:")
|
112 |
+
if in_platform and i < 10:
|
113 |
+
print(line.strip())
|
114 |
+
elif i > 100: # Limit preview length
|
115 |
+
break
|
116 |
+
|
117 |
+
# Extract gene annotation data, skipping header lines and keeping table rows
|
118 |
+
gene_metadata = get_gene_annotation(soft_file, prefixes=['^', '!', '#'])
|
119 |
+
|
120 |
+
# Preview the annotation data, showing more rows to better understand structure
|
121 |
+
print("\nColumn names:", gene_metadata.columns.tolist())
|
122 |
+
print("\nFirst 10 rows preview:")
|
123 |
+
preview_size = min(10, len(gene_metadata))
|
124 |
+
print(preview_df(gene_metadata, n=preview_size))
|
125 |
+
|
126 |
+
# Print shape to understand size of annotation data
|
127 |
+
print("\nShape of annotation data:", gene_metadata.shape)
|
128 |
+
# Extract gene mapping from annotation data
|
129 |
+
# 'ID' column in annotation matches probe IDs in expression data (ending in '_at')
|
130 |
+
# 'Description' column contains gene names/descriptions
|
131 |
+
mapping_data = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='Description')
|
132 |
+
|
133 |
+
# Convert probe-level measurements to gene-level expression
|
134 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
135 |
+
|
136 |
+
# Print shape and preview mapped data
|
137 |
+
print("Shape after mapping to genes:", gene_data.shape)
|
138 |
+
print("\nFirst few rows of gene expression data:")
|
139 |
+
print(gene_data.head())
|
140 |
+
# 1. Normalize gene symbols
|
141 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
142 |
+
gene_data.to_csv(out_gene_data_file)
|
143 |
+
|
144 |
+
# Clinical data is not available (trait_row was None), so skip remaining steps
|
145 |
+
# Record that this dataset cannot be used for association studies
|
146 |
+
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=False,
|
152 |
+
is_biased=False,
|
153 |
+
df=gene_data,
|
154 |
+
note="Contains gene expression data but lacks clinical information needed for trait association studies."
|
155 |
+
)
|
p3/preprocess/Atherosclerosis/code/GSE154851.py
ADDED
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE154851"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE154851"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE154851.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE154851.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE154851.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using specified prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# Based on background info - using Sureprint G3 Human Gene Expression microarray
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2. Variable Availability and Data Type Conversion
|
45 |
+
# Trait: Cannot reliably determine from available characteristics data
|
46 |
+
trait_row = None
|
47 |
+
|
48 |
+
# Age is in row 2
|
49 |
+
age_row = 2
|
50 |
+
|
51 |
+
# Gender is in row 1
|
52 |
+
gender_row = 1
|
53 |
+
|
54 |
+
def convert_trait(x):
|
55 |
+
return None
|
56 |
+
|
57 |
+
def convert_age(x):
|
58 |
+
if not isinstance(x, str):
|
59 |
+
return None
|
60 |
+
try:
|
61 |
+
# Extract age value before 'y'
|
62 |
+
age = int(x.split(': ')[1].replace('y',''))
|
63 |
+
return age
|
64 |
+
except:
|
65 |
+
return None
|
66 |
+
|
67 |
+
def convert_gender(x):
|
68 |
+
if not isinstance(x, str):
|
69 |
+
return None
|
70 |
+
try:
|
71 |
+
gender = x.split(': ')[1].lower()
|
72 |
+
if gender == 'female':
|
73 |
+
return 0
|
74 |
+
elif gender == 'male':
|
75 |
+
return 1
|
76 |
+
return None
|
77 |
+
except:
|
78 |
+
return None
|
79 |
+
|
80 |
+
# 3. Save metadata
|
81 |
+
is_trait_available = False if trait_row is None else True
|
82 |
+
validate_and_save_cohort_info(
|
83 |
+
is_final=False,
|
84 |
+
cohort=cohort,
|
85 |
+
info_path=json_path,
|
86 |
+
is_gene_available=is_gene_available,
|
87 |
+
is_trait_available=is_trait_available
|
88 |
+
)
|
89 |
+
|
90 |
+
# 4. Skip clinical feature extraction since trait_row is None
|
91 |
+
# Get file paths
|
92 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
93 |
+
|
94 |
+
# Extract gene expression data from matrix file
|
95 |
+
gene_data = get_genetic_data(matrix_file)
|
96 |
+
|
97 |
+
# Print first 20 row IDs and shape of data to help debug
|
98 |
+
print("Shape of gene expression data:", gene_data.shape)
|
99 |
+
print("\nFirst few rows of data:")
|
100 |
+
print(gene_data.head())
|
101 |
+
print("\nFirst 20 gene/probe identifiers:")
|
102 |
+
print(gene_data.index[:20])
|
103 |
+
|
104 |
+
# Inspect a snippet of raw file to verify identifier format
|
105 |
+
import gzip
|
106 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
107 |
+
lines = []
|
108 |
+
for i, line in enumerate(f):
|
109 |
+
if "!series_matrix_table_begin" in line:
|
110 |
+
# Get the next 5 lines after the marker
|
111 |
+
for _ in range(5):
|
112 |
+
lines.append(next(f).strip())
|
113 |
+
break
|
114 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
115 |
+
for line in lines:
|
116 |
+
print(line)
|
117 |
+
# Based on the data preview, I observe that:
|
118 |
+
# 1. The gene identifiers are numeric indices (1,2,3...)
|
119 |
+
# 2. These are not standard gene symbols which are typically alphanumeric (e.g. BRCA1, TP53)
|
120 |
+
# 3. These appear to be microarray probe IDs that need to be mapped to gene symbols
|
121 |
+
|
122 |
+
requires_gene_mapping = True
|
123 |
+
# Extract gene annotation data
|
124 |
+
gene_metadata = get_gene_annotation(soft_file)
|
125 |
+
|
126 |
+
# Preview the annotation data
|
127 |
+
print("Column names:", gene_metadata.columns.tolist())
|
128 |
+
print("\nFirst few rows preview:")
|
129 |
+
print(preview_df(gene_metadata))
|
130 |
+
# Extract mapping between probe IDs and gene symbols from annotation data
|
131 |
+
mapping_data = get_gene_mapping(gene_metadata, 'ID', 'GENE_SYMBOL')
|
132 |
+
|
133 |
+
# Apply the mapping to convert probe measurements to gene expression data
|
134 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
135 |
+
|
136 |
+
# Save the processed gene expression data
|
137 |
+
gene_data.to_csv(out_gene_data_file)
|
138 |
+
# 1. Normalize gene symbols
|
139 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
140 |
+
gene_data.to_csv(out_gene_data_file)
|
141 |
+
|
142 |
+
# Clinical data is not available (trait_row was None), so skip remaining steps
|
143 |
+
# Record that this dataset cannot be used for association studies
|
144 |
+
validate_and_save_cohort_info(
|
145 |
+
is_final=True,
|
146 |
+
cohort=cohort,
|
147 |
+
info_path=json_path,
|
148 |
+
is_gene_available=True,
|
149 |
+
is_trait_available=False,
|
150 |
+
is_biased=False,
|
151 |
+
df=gene_data,
|
152 |
+
note="Contains gene expression data but lacks clinical information needed for trait association studies."
|
153 |
+
)
|
p3/preprocess/Atherosclerosis/code/GSE57691.py
ADDED
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE57691"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE57691"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE57691.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE57691.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE57691.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using broader sample prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_', '!Sample_disease_state', '!Sample_description']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# Based on background info mentioning "Genome-wide expression analysis" and platform GPL10558
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2.1 Data Availability
|
45 |
+
# Trait can be inferred from disease state in Feature 8
|
46 |
+
trait_row = 8
|
47 |
+
|
48 |
+
# Age and gender are not available in the characteristics
|
49 |
+
age_row = None
|
50 |
+
gender_row = None
|
51 |
+
|
52 |
+
# 2.2 Data Type Conversion Functions
|
53 |
+
def convert_trait(value: str) -> int:
|
54 |
+
"""Convert trait value to binary: 1 for presence of atherosclerosis, 0 for control"""
|
55 |
+
if value is None or ':' not in value:
|
56 |
+
return None
|
57 |
+
value = value.split(':')[1].strip().lower()
|
58 |
+
if 'aod' in value: # AOD is atherosclerotic occlusive disease
|
59 |
+
return 1
|
60 |
+
elif 'control' in value:
|
61 |
+
return 0
|
62 |
+
else: # AAA samples are not relevant for atherosclerosis
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_age(value: str) -> Optional[float]:
|
66 |
+
"""Placeholder function as age data is not available"""
|
67 |
+
return None
|
68 |
+
|
69 |
+
def convert_gender(value: str) -> Optional[int]:
|
70 |
+
"""Placeholder function as gender data is not available"""
|
71 |
+
return None
|
72 |
+
|
73 |
+
# 3. Save Metadata
|
74 |
+
# is_trait_available is True since trait_row is not None
|
75 |
+
validate_and_save_cohort_info(is_final=False,
|
76 |
+
cohort=cohort,
|
77 |
+
info_path=json_path,
|
78 |
+
is_gene_available=is_gene_available,
|
79 |
+
is_trait_available=True)
|
80 |
+
|
81 |
+
# 4. Clinical Feature Extraction
|
82 |
+
# Since trait_row is not None, we need to extract clinical features
|
83 |
+
selected_clinical_df = geo_select_clinical_features(
|
84 |
+
clinical_df=clinical_data,
|
85 |
+
trait=trait,
|
86 |
+
trait_row=trait_row,
|
87 |
+
convert_trait=convert_trait,
|
88 |
+
age_row=age_row,
|
89 |
+
convert_age=convert_age,
|
90 |
+
gender_row=gender_row,
|
91 |
+
convert_gender=convert_gender
|
92 |
+
)
|
93 |
+
|
94 |
+
# Preview the extracted features
|
95 |
+
preview_result = preview_df(selected_clinical_df)
|
96 |
+
print("Preview of clinical features:")
|
97 |
+
print(preview_result)
|
98 |
+
|
99 |
+
# Save clinical data
|
100 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
101 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
102 |
+
# Get file paths
|
103 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
104 |
+
|
105 |
+
# Extract gene expression data from matrix file
|
106 |
+
gene_data = get_genetic_data(matrix_file)
|
107 |
+
|
108 |
+
# Print first 20 row IDs and shape of data to help debug
|
109 |
+
print("Shape of gene expression data:", gene_data.shape)
|
110 |
+
print("\nFirst few rows of data:")
|
111 |
+
print(gene_data.head())
|
112 |
+
print("\nFirst 20 gene/probe identifiers:")
|
113 |
+
print(gene_data.index[:20])
|
114 |
+
|
115 |
+
# Inspect a snippet of raw file to verify identifier format
|
116 |
+
import gzip
|
117 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
118 |
+
lines = []
|
119 |
+
for i, line in enumerate(f):
|
120 |
+
if "!series_matrix_table_begin" in line:
|
121 |
+
# Get the next 5 lines after the marker
|
122 |
+
for _ in range(5):
|
123 |
+
lines.append(next(f).strip())
|
124 |
+
break
|
125 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
126 |
+
for line in lines:
|
127 |
+
print(line)
|
128 |
+
# Looking at the gene identifiers (e.g. ILMN_1343291), these are Illumina probe IDs
|
129 |
+
# that need to be mapped to standard human gene symbols
|
130 |
+
requires_gene_mapping = True
|
131 |
+
# Extract gene annotation data
|
132 |
+
gene_metadata = get_gene_annotation(soft_file)
|
133 |
+
|
134 |
+
# Preview the annotation data
|
135 |
+
print("Column names:", gene_metadata.columns.tolist())
|
136 |
+
print("\nFirst few rows preview:")
|
137 |
+
print(preview_df(gene_metadata))
|
138 |
+
# Create gene mapping dataframe from gene annotation data
|
139 |
+
# ID column in gene_metadata contains probe IDs (e.g. ILMN_1343291)
|
140 |
+
# Symbol column contains gene symbols
|
141 |
+
mapping_df = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='Symbol')
|
142 |
+
|
143 |
+
# Apply gene mapping to convert probe-level data to gene expression data
|
144 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
145 |
+
|
146 |
+
# Save gene expression data
|
147 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
148 |
+
gene_data.to_csv(out_gene_data_file)
|
149 |
+
# 1. Normalize gene symbols
|
150 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
151 |
+
gene_data.to_csv(out_gene_data_file)
|
152 |
+
|
153 |
+
# 2. Link clinical and genetic data
|
154 |
+
# Need to transpose selected_clinical_df to match sample orientation
|
155 |
+
selected_clinical_df = selected_clinical_df.T
|
156 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, gene_data)
|
157 |
+
|
158 |
+
# 3. Handle missing values
|
159 |
+
linked_data = handle_missing_values(linked_data, trait)
|
160 |
+
|
161 |
+
# 4. Check for bias
|
162 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
163 |
+
|
164 |
+
# 5. Validate and save cohort info
|
165 |
+
is_usable = validate_and_save_cohort_info(
|
166 |
+
is_final=True,
|
167 |
+
cohort=cohort,
|
168 |
+
info_path=json_path,
|
169 |
+
is_gene_available=True,
|
170 |
+
is_trait_available=True,
|
171 |
+
is_biased=trait_biased,
|
172 |
+
df=linked_data,
|
173 |
+
note="Gene expression study comparing AOD (atherosclerotic occlusive disease) vs normal control aortic tissue."
|
174 |
+
)
|
175 |
+
|
176 |
+
# 6. Save if usable
|
177 |
+
if is_usable:
|
178 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
179 |
+
linked_data.to_csv(out_data_file)
|
180 |
+
# Cannot perform analysis without output from previous step showing dataset information
|
181 |
+
# Request previous output showing:
|
182 |
+
# - Dataset background information
|
183 |
+
# - Sample characteristics dictionary
|
184 |
+
# - Matrix file information
|
185 |
+
print("Error: Missing required output from previous step showing dataset characteristics")
|
186 |
+
raise ValueError("Previous step output required to analyze dataset and determine data availability")
|
187 |
+
# Get file paths
|
188 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
189 |
+
|
190 |
+
# Extract background info and clinical data using broader sample prefixes
|
191 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
192 |
+
matrix_file,
|
193 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
194 |
+
prefixes_b=['!Sample_', '!Sample_disease_state', '!Sample_description']
|
195 |
+
)
|
196 |
+
|
197 |
+
# Get unique values per clinical feature
|
198 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
199 |
+
|
200 |
+
# Print background info
|
201 |
+
print("Dataset Background Information:")
|
202 |
+
print(f"{background_info}\n")
|
203 |
+
|
204 |
+
# Print sample characteristics
|
205 |
+
print("Sample Characteristics:")
|
206 |
+
for feature, values in sample_characteristics.items():
|
207 |
+
print(f"Feature: {feature}")
|
208 |
+
print(f"Values: {values}\n")
|
209 |
+
# 1. Gene Expression Data Availability
|
210 |
+
# The dataset measures gene expression in aortic tissue using Illumina arrays
|
211 |
+
is_gene_available = True
|
212 |
+
|
213 |
+
# 2. Variable Availability and Data Type Conversion
|
214 |
+
# 2.1 Data Availability
|
215 |
+
|
216 |
+
# Trait (Atherosclerosis) - Feature 8 contains disease state info
|
217 |
+
# Both AAA and AOD represent atherosclerotic disease
|
218 |
+
trait_row = 8
|
219 |
+
|
220 |
+
# Age not available - no age info in characteristics
|
221 |
+
age_row = None
|
222 |
+
|
223 |
+
# Gender not available - no gender info in characteristics
|
224 |
+
gender_row = None
|
225 |
+
|
226 |
+
# 2.2 Data Type Conversion Functions
|
227 |
+
def convert_trait(value: str) -> Optional[int]:
|
228 |
+
"""Convert disease state to binary trait value"""
|
229 |
+
if not isinstance(value, str):
|
230 |
+
return None
|
231 |
+
# Extract value after colon if present
|
232 |
+
if ':' in value:
|
233 |
+
value = value.split(':')[1].strip()
|
234 |
+
# Both AAA and AOD represent atherosclerotic disease
|
235 |
+
if 'AAA' in value or 'AOD' in value:
|
236 |
+
return 1
|
237 |
+
elif 'control' in value:
|
238 |
+
return 0
|
239 |
+
return None
|
240 |
+
|
241 |
+
def convert_age(value: str) -> Optional[float]:
|
242 |
+
"""Convert age value to float"""
|
243 |
+
return None # Not used since age data not available
|
244 |
+
|
245 |
+
def convert_gender(value: str) -> Optional[int]:
|
246 |
+
"""Convert gender to binary"""
|
247 |
+
return None # Not used since gender data not available
|
248 |
+
|
249 |
+
# 3. Save Metadata
|
250 |
+
validate_and_save_cohort_info(
|
251 |
+
is_final=False,
|
252 |
+
cohort=cohort,
|
253 |
+
info_path=json_path,
|
254 |
+
is_gene_available=is_gene_available,
|
255 |
+
is_trait_available=trait_row is not None
|
256 |
+
)
|
257 |
+
|
258 |
+
# 4. Clinical Feature Extraction
|
259 |
+
if trait_row is not None:
|
260 |
+
clinical_features = geo_select_clinical_features(
|
261 |
+
clinical_df=clinical_data,
|
262 |
+
trait=trait,
|
263 |
+
trait_row=trait_row,
|
264 |
+
convert_trait=convert_trait,
|
265 |
+
age_row=age_row,
|
266 |
+
convert_age=convert_age,
|
267 |
+
gender_row=gender_row,
|
268 |
+
convert_gender=convert_gender
|
269 |
+
)
|
270 |
+
|
271 |
+
# Preview the extracted features
|
272 |
+
preview = preview_df(clinical_features)
|
273 |
+
print("Preview of clinical features:")
|
274 |
+
print(preview)
|
275 |
+
|
276 |
+
# Save to CSV
|
277 |
+
clinical_features.to_csv(out_clinical_data_file)
|
278 |
+
# 1. Normalize gene symbols
|
279 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
280 |
+
gene_data.to_csv(out_gene_data_file)
|
281 |
+
|
282 |
+
# 2. Link clinical and genetic data
|
283 |
+
linked_data = geo_link_clinical_genetic_data(clinical_features, gene_data)
|
284 |
+
|
285 |
+
# 3. Handle missing values
|
286 |
+
linked_data = handle_missing_values(linked_data, trait)
|
287 |
+
|
288 |
+
# 4. Check for bias
|
289 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
290 |
+
|
291 |
+
# 5. Validate and save cohort info
|
292 |
+
is_usable = validate_and_save_cohort_info(
|
293 |
+
is_final=True,
|
294 |
+
cohort=cohort,
|
295 |
+
info_path=json_path,
|
296 |
+
is_gene_available=True,
|
297 |
+
is_trait_available=True,
|
298 |
+
is_biased=trait_biased,
|
299 |
+
df=linked_data,
|
300 |
+
note="Study examining expression profiles in endometriotic cyst stromal cells versus normal endometrial stromal cells."
|
301 |
+
)
|
302 |
+
|
303 |
+
# 6. Save if usable
|
304 |
+
if is_usable:
|
305 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Atherosclerosis/code/GSE83500.py
ADDED
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE83500"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE83500"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE83500.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE83500.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE83500.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using broader sample prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_', '!Sample_disease_state', '!Sample_description']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# Based on platform (GPL13667 - Affymetrix Human Genome U219) and series title/design,
|
42 |
+
# this is a gene expression microarray dataset
|
43 |
+
is_gene_available = True
|
44 |
+
|
45 |
+
# 2.1 Data Availability
|
46 |
+
# Feature 8 indicates MI vs non-MI status (atherosclerosis trait)
|
47 |
+
trait_row = 8
|
48 |
+
|
49 |
+
# Feature 9 has age information
|
50 |
+
age_row = 9
|
51 |
+
|
52 |
+
# Feature 10 has gender information
|
53 |
+
gender_row = 10
|
54 |
+
|
55 |
+
# 2.2 Data Type Conversion Functions
|
56 |
+
def convert_trait(value):
|
57 |
+
# Convert MI status to binary (1=MI, 0=non-MI)
|
58 |
+
if not value or ':' not in value:
|
59 |
+
return None
|
60 |
+
value = value.split(': ')[1].lower()
|
61 |
+
if 'mi patient' in value:
|
62 |
+
return 1
|
63 |
+
elif 'non-mi patient' in value:
|
64 |
+
return 0
|
65 |
+
return None
|
66 |
+
|
67 |
+
def convert_age(value):
|
68 |
+
# Convert age to continuous numeric value
|
69 |
+
if not value or ':' not in value:
|
70 |
+
return None
|
71 |
+
try:
|
72 |
+
return int(value.split(': ')[1])
|
73 |
+
except:
|
74 |
+
return None
|
75 |
+
|
76 |
+
def convert_gender(value):
|
77 |
+
# Convert gender to binary (0=Female, 1=Male)
|
78 |
+
if not value or ':' not in value:
|
79 |
+
return None
|
80 |
+
value = value.split(': ')[1].lower()
|
81 |
+
if value == 'female':
|
82 |
+
return 0
|
83 |
+
elif value == 'male':
|
84 |
+
return 1
|
85 |
+
return None
|
86 |
+
|
87 |
+
# 3. Save Metadata
|
88 |
+
is_trait_available = trait_row is not None
|
89 |
+
validate_and_save_cohort_info(is_final=False,
|
90 |
+
cohort=cohort,
|
91 |
+
info_path=json_path,
|
92 |
+
is_gene_available=is_gene_available,
|
93 |
+
is_trait_available=is_trait_available)
|
94 |
+
|
95 |
+
# 4. Clinical Feature Extraction
|
96 |
+
if trait_row is not None:
|
97 |
+
clinical_features = 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 features
|
109 |
+
print("Preview of clinical features:")
|
110 |
+
print(preview_df(clinical_features))
|
111 |
+
|
112 |
+
# Save to CSV
|
113 |
+
clinical_features.to_csv(out_clinical_data_file)
|
114 |
+
# Get file paths
|
115 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
116 |
+
|
117 |
+
# Extract gene expression data from matrix file
|
118 |
+
gene_data = get_genetic_data(matrix_file)
|
119 |
+
|
120 |
+
# Print first 20 row IDs and shape of data to help debug
|
121 |
+
print("Shape of gene expression data:", gene_data.shape)
|
122 |
+
print("\nFirst few rows of data:")
|
123 |
+
print(gene_data.head())
|
124 |
+
print("\nFirst 20 gene/probe identifiers:")
|
125 |
+
print(gene_data.index[:20])
|
126 |
+
|
127 |
+
# Inspect a snippet of raw file to verify identifier format
|
128 |
+
import gzip
|
129 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
130 |
+
lines = []
|
131 |
+
for i, line in enumerate(f):
|
132 |
+
if "!series_matrix_table_begin" in line:
|
133 |
+
# Get the next 5 lines after the marker
|
134 |
+
for _ in range(5):
|
135 |
+
lines.append(next(f).strip())
|
136 |
+
break
|
137 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
138 |
+
for line in lines:
|
139 |
+
print(line)
|
140 |
+
# Based on the identifier format (e.g., "11715100_at"), these appear to be Affymetrix probe IDs
|
141 |
+
# rather than gene symbols. They need to be mapped to official gene symbols.
|
142 |
+
requires_gene_mapping = True
|
143 |
+
# Extract gene annotation data
|
144 |
+
gene_metadata = get_gene_annotation(soft_file)
|
145 |
+
|
146 |
+
# Preview the annotation data
|
147 |
+
print("Column names:", gene_metadata.columns.tolist())
|
148 |
+
print("\nFirst few rows preview:")
|
149 |
+
print(preview_df(gene_metadata))
|
150 |
+
# Get gene mapping from annotation data
|
151 |
+
# The 'ID' column contains probe IDs that match gene expression data identifiers
|
152 |
+
# The 'Gene Symbol' column contains the human gene symbols
|
153 |
+
mapping_data = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='Gene Symbol')
|
154 |
+
|
155 |
+
# Apply gene mapping to convert probe-level data to gene-level data
|
156 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
157 |
+
|
158 |
+
# Save genetic data to CSV
|
159 |
+
gene_data.to_csv(out_gene_data_file)
|
160 |
+
|
161 |
+
# Print preview to verify correct mapping
|
162 |
+
print("Shape of mapped gene expression data:", gene_data.shape)
|
163 |
+
print("\nFirst few rows of mapped data:")
|
164 |
+
print(gene_data.head())
|
165 |
+
# 1. Normalize gene symbols
|
166 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
167 |
+
gene_data.to_csv(out_gene_data_file)
|
168 |
+
|
169 |
+
# 2. Link clinical and genetic data
|
170 |
+
# Transpose and extract feature data rows from clinical features
|
171 |
+
trait_data = clinical_features.loc[trait, :]
|
172 |
+
age_data = clinical_features.loc['Age', :]
|
173 |
+
gender_data = clinical_features.loc['Gender', :]
|
174 |
+
|
175 |
+
clinical_data = pd.concat([trait_data, age_data, gender_data], axis=0).T
|
176 |
+
clinical_data = clinical_data.rename({trait: 'Atherosclerosis'}, axis=1)
|
177 |
+
|
178 |
+
linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
|
179 |
+
|
180 |
+
# 3. Handle missing values
|
181 |
+
linked_data = handle_missing_values(linked_data, 'Atherosclerosis')
|
182 |
+
|
183 |
+
# 4. Check for bias
|
184 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, 'Atherosclerosis')
|
185 |
+
|
186 |
+
# 5. Validate and save cohort info
|
187 |
+
is_usable = validate_and_save_cohort_info(
|
188 |
+
is_final=True,
|
189 |
+
cohort=cohort,
|
190 |
+
info_path=json_path,
|
191 |
+
is_gene_available=True,
|
192 |
+
is_trait_available=True,
|
193 |
+
is_biased=trait_biased,
|
194 |
+
df=linked_data,
|
195 |
+
note="Study examining gene expression in aortic wall samples between MI and non-MI patients, relevant to atherosclerosis."
|
196 |
+
)
|
197 |
+
|
198 |
+
# 6. Save if usable
|
199 |
+
if is_usable:
|
200 |
+
linked_data.to_csv(out_data_file)
|
201 |
+
# 1. Normalize gene symbols
|
202 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
203 |
+
gene_data.to_csv(out_gene_data_file)
|
204 |
+
|
205 |
+
# 2. Link clinical and genetic data
|
206 |
+
# Restructure clinical features first
|
207 |
+
clinical_data = clinical_features.T # Transpose to get features as columns
|
208 |
+
|
209 |
+
# Link the data
|
210 |
+
linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
|
211 |
+
|
212 |
+
# 3. Handle missing values
|
213 |
+
linked_data = handle_missing_values(linked_data, trait)
|
214 |
+
|
215 |
+
# 4. Check for bias
|
216 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
217 |
+
|
218 |
+
# 5. Validate and save cohort info
|
219 |
+
is_usable = validate_and_save_cohort_info(
|
220 |
+
is_final=True,
|
221 |
+
cohort=cohort,
|
222 |
+
info_path=json_path,
|
223 |
+
is_gene_available=True,
|
224 |
+
is_trait_available=True,
|
225 |
+
is_biased=trait_biased,
|
226 |
+
df=linked_data,
|
227 |
+
note="Study examining gene expression in aortic wall samples between MI and non-MI patients, relevant to atherosclerosis."
|
228 |
+
)
|
229 |
+
|
230 |
+
# 6. Save if usable
|
231 |
+
if is_usable:
|
232 |
+
linked_data.to_csv(out_data_file)
|
233 |
+
# 1. Gene Expression Data Availability
|
234 |
+
is_gene_available = True # Dataset has gene expression data
|
235 |
+
|
236 |
+
# 2.1 Data Availability
|
237 |
+
trait_row = 0 # Group/Status contains disease/control info
|
238 |
+
age_row = 1 # Age
|
239 |
+
gender_row = None # Gender not available
|
240 |
+
|
241 |
+
# 2.2 Data Type Conversion Functions
|
242 |
+
def convert_trait(value: str) -> int:
|
243 |
+
"""Convert disease/control status to binary (0=control, 1=disease)"""
|
244 |
+
if value is None:
|
245 |
+
return None
|
246 |
+
value = str(value).lower()
|
247 |
+
if ':' in value:
|
248 |
+
value = value.split(':')[1].strip()
|
249 |
+
if value in ['control']:
|
250 |
+
return 0
|
251 |
+
elif value in ['carotid atherosclerosis']:
|
252 |
+
return 1
|
253 |
+
return None
|
254 |
+
|
255 |
+
def convert_age(value: str) -> float:
|
256 |
+
"""Convert age to float"""
|
257 |
+
if value is None:
|
258 |
+
return None
|
259 |
+
value = str(value)
|
260 |
+
if ':' in value:
|
261 |
+
value = value.split(':')[1].strip()
|
262 |
+
try:
|
263 |
+
return float(value)
|
264 |
+
except:
|
265 |
+
return None
|
266 |
+
|
267 |
+
def convert_gender(value: str) -> int:
|
268 |
+
"""Convert gender to binary (female=0, male=1)"""
|
269 |
+
if value is None:
|
270 |
+
return None
|
271 |
+
value = str(value).lower()
|
272 |
+
if ':' in value:
|
273 |
+
value = value.split(':')[1].strip()
|
274 |
+
if value in ['f', 'female']:
|
275 |
+
return 0
|
276 |
+
elif value in ['m', 'male']:
|
277 |
+
return 1
|
278 |
+
return None
|
279 |
+
|
280 |
+
# 3. Save metadata
|
281 |
+
validate_and_save_cohort_info(is_final=False,
|
282 |
+
cohort=cohort,
|
283 |
+
info_path=json_path,
|
284 |
+
is_gene_available=is_gene_available,
|
285 |
+
is_trait_available=(trait_row is not None))
|
286 |
+
|
287 |
+
# 4. Extract clinical features
|
288 |
+
selected_clinical = geo_select_clinical_features(
|
289 |
+
clinical_df=clinical_data,
|
290 |
+
trait=trait,
|
291 |
+
trait_row=trait_row,
|
292 |
+
convert_trait=convert_trait,
|
293 |
+
age_row=age_row,
|
294 |
+
convert_age=convert_age,
|
295 |
+
gender_row=gender_row,
|
296 |
+
convert_gender=convert_gender
|
297 |
+
)
|
298 |
+
|
299 |
+
# Handle potential Series output
|
300 |
+
if isinstance(selected_clinical, pd.Series):
|
301 |
+
selected_clinical = selected_clinical.to_frame()
|
302 |
+
|
303 |
+
# Preview the data
|
304 |
+
preview = preview_df(selected_clinical)
|
305 |
+
print("Preview of selected clinical features:")
|
306 |
+
print(preview)
|
307 |
+
|
308 |
+
# Save to CSV
|
309 |
+
selected_clinical.to_csv(out_clinical_data_file)
|
310 |
+
# 1. Check gene expression data availability
|
311 |
+
is_gene_available = True # Given that GEO series data typically contains gene expression data, default to True unless proven otherwise
|
312 |
+
|
313 |
+
# 2.1 & 2.2 Data row identification and conversion functions
|
314 |
+
trait_row = 0 # Preview shows row 0 has binary data pattern typical for case-control status in atherosclerosis studies
|
315 |
+
|
316 |
+
def convert_trait(x):
|
317 |
+
"""Convert trait values to binary (0: control, 1: atherosclerosis)"""
|
318 |
+
if pd.isna(x):
|
319 |
+
return 0 # Assume NaN represents control group
|
320 |
+
value = str(x).split(":")[-1].strip()
|
321 |
+
if value == "1" or value == "1.0":
|
322 |
+
return 1
|
323 |
+
return 0
|
324 |
+
|
325 |
+
def convert_age(x):
|
326 |
+
"""Convert age values to continuous numbers"""
|
327 |
+
if pd.isna(x):
|
328 |
+
return None
|
329 |
+
value = str(x).split(":")[-1].strip()
|
330 |
+
try:
|
331 |
+
return float(value)
|
332 |
+
except:
|
333 |
+
return None
|
334 |
+
|
335 |
+
def convert_gender(x):
|
336 |
+
"""Convert gender values to binary (0: female, 1: male)"""
|
337 |
+
if pd.isna(x):
|
338 |
+
return None
|
339 |
+
value = str(x).split(":")[-1].strip().lower()
|
340 |
+
if "female" in value or "f" in value:
|
341 |
+
return 0
|
342 |
+
elif "male" in value or "m" in value:
|
343 |
+
return 1
|
344 |
+
return None
|
345 |
+
|
346 |
+
age_row = None # Age data not available in preview
|
347 |
+
gender_row = None # Gender data not available in preview
|
348 |
+
|
349 |
+
# 3. Save metadata using initial filtering
|
350 |
+
validate_and_save_cohort_info(
|
351 |
+
is_final=False,
|
352 |
+
cohort=cohort,
|
353 |
+
info_path=json_path,
|
354 |
+
is_gene_available=is_gene_available,
|
355 |
+
is_trait_available=(trait_row is not None)
|
356 |
+
)
|
357 |
+
|
358 |
+
# 4. Clinical feature extraction
|
359 |
+
selected_clinical_df = geo_select_clinical_features(
|
360 |
+
clinical_df=clinical_data,
|
361 |
+
trait=trait,
|
362 |
+
trait_row=trait_row,
|
363 |
+
convert_trait=convert_trait,
|
364 |
+
age_row=age_row,
|
365 |
+
convert_age=convert_age,
|
366 |
+
gender_row=gender_row,
|
367 |
+
convert_gender=convert_gender
|
368 |
+
)
|
369 |
+
|
370 |
+
# Preview and save the clinical features
|
371 |
+
print("\nPreview of selected clinical features:")
|
372 |
+
print(preview_df(selected_clinical_df.to_frame() if isinstance(selected_clinical_df, pd.Series) else selected_clinical_df))
|
373 |
+
|
374 |
+
# Save clinical data
|
375 |
+
if isinstance(selected_clinical_df, pd.Series):
|
376 |
+
selected_clinical_df = selected_clinical_df.to_frame()
|
377 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
378 |
+
# 1. Gene Expression Data Availability
|
379 |
+
# Based on the output, there appears to be gene expression data since the file contains
|
380 |
+
# numeric values that can be used for analysis
|
381 |
+
is_gene_available = True
|
382 |
+
|
383 |
+
# 2. Variable Assignment and Conversion Functions
|
384 |
+
|
385 |
+
# 2.1 Variable Availability
|
386 |
+
# Trait is already encoded as binary (0.0), so it's available
|
387 |
+
trait_row = 0
|
388 |
+
|
389 |
+
# Age and gender not shown in preview, setting to None
|
390 |
+
age_row = None
|
391 |
+
gender_row = None
|
392 |
+
|
393 |
+
# 2.2 Conversion Functions
|
394 |
+
def convert_trait(x):
|
395 |
+
# Convert to binary: presence of atherosclerosis is 1, absence is 0
|
396 |
+
if pd.isna(x) or x is None:
|
397 |
+
return None
|
398 |
+
x = str(x).lower()
|
399 |
+
if ':' in x:
|
400 |
+
x = x.split(':')[1].strip()
|
401 |
+
if x in ['0', '0.0', 'no', 'non-' + trait.lower(), 'control', 'negative']:
|
402 |
+
return 0
|
403 |
+
elif x in ['1', '1.0', 'yes', trait.lower(), 'positive']:
|
404 |
+
return 1
|
405 |
+
return None
|
406 |
+
|
407 |
+
def convert_age(x):
|
408 |
+
# Not used since age data not available
|
409 |
+
return None
|
410 |
+
|
411 |
+
def convert_gender(x):
|
412 |
+
# Not used since gender data not available
|
413 |
+
return None
|
414 |
+
|
415 |
+
# 3. Save Metadata
|
416 |
+
is_trait_available = trait_row is not None
|
417 |
+
validate_and_save_cohort_info(is_final=False,
|
418 |
+
cohort=cohort,
|
419 |
+
info_path=json_path,
|
420 |
+
is_gene_available=is_gene_available,
|
421 |
+
is_trait_available=is_trait_available)
|
422 |
+
|
423 |
+
# 4. Extract Clinical Features
|
424 |
+
if trait_row is not None:
|
425 |
+
clinical_df = geo_select_clinical_features(
|
426 |
+
clinical_df=clinical_data,
|
427 |
+
trait=trait,
|
428 |
+
trait_row=trait_row,
|
429 |
+
convert_trait=convert_trait,
|
430 |
+
age_row=age_row,
|
431 |
+
convert_age=convert_age,
|
432 |
+
gender_row=gender_row,
|
433 |
+
convert_gender=convert_gender
|
434 |
+
)
|
435 |
+
|
436 |
+
# Preview clinical features
|
437 |
+
preview = preview_df(clinical_df)
|
438 |
+
print("\nPreview of selected clinical features:")
|
439 |
+
print(preview)
|
440 |
+
|
441 |
+
# Save clinical data
|
442 |
+
clinical_df.to_csv(out_clinical_data_file)
|
p3/preprocess/Atherosclerosis/code/GSE87005.py
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE87005"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE87005"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE87005.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE87005.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE87005.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using broader sample prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_', '!Sample_disease_state', '!Sample_description']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
is_gene_available = True # Based on GPL6480 platform and "RNA" sample type
|
42 |
+
|
43 |
+
# 2.1 Data Availability and 2.2 Data Type Conversion
|
44 |
+
trait_row = 8 # Available in "!Sample_characteristics_ch1" which shows HOMA groups
|
45 |
+
|
46 |
+
def convert_trait(x):
|
47 |
+
if not isinstance(x, str):
|
48 |
+
return None
|
49 |
+
if 'Low HOMA' in x:
|
50 |
+
return 0
|
51 |
+
elif 'High HOMA' in x:
|
52 |
+
return 1
|
53 |
+
return None
|
54 |
+
|
55 |
+
# Age and gender are not available
|
56 |
+
age_row = None
|
57 |
+
gender_row = None
|
58 |
+
convert_age = None
|
59 |
+
convert_gender = None
|
60 |
+
|
61 |
+
# 3. Save metadata
|
62 |
+
is_clinical_usable = validate_and_save_cohort_info(
|
63 |
+
is_final=False,
|
64 |
+
cohort=cohort,
|
65 |
+
info_path=json_path,
|
66 |
+
is_gene_available=is_gene_available,
|
67 |
+
is_trait_available=trait_row is not None
|
68 |
+
)
|
69 |
+
|
70 |
+
# 4. Clinical Feature Extraction
|
71 |
+
if trait_row is not None:
|
72 |
+
clinical_features = geo_select_clinical_features(
|
73 |
+
clinical_df=clinical_data,
|
74 |
+
trait=trait,
|
75 |
+
trait_row=trait_row,
|
76 |
+
convert_trait=convert_trait,
|
77 |
+
age_row=age_row,
|
78 |
+
convert_age=convert_age,
|
79 |
+
gender_row=gender_row,
|
80 |
+
convert_gender=convert_gender
|
81 |
+
)
|
82 |
+
|
83 |
+
# Preview the extracted features
|
84 |
+
preview = preview_df(clinical_features)
|
85 |
+
print("Preview of clinical features:", preview)
|
86 |
+
|
87 |
+
# Save clinical data
|
88 |
+
clinical_features.to_csv(out_clinical_data_file)
|
89 |
+
# Get file paths
|
90 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
91 |
+
|
92 |
+
# Extract gene expression data from matrix file
|
93 |
+
gene_data = get_genetic_data(matrix_file)
|
94 |
+
|
95 |
+
# Print first 20 row IDs and shape of data to help debug
|
96 |
+
print("Shape of gene expression data:", gene_data.shape)
|
97 |
+
print("\nFirst few rows of data:")
|
98 |
+
print(gene_data.head())
|
99 |
+
print("\nFirst 20 gene/probe identifiers:")
|
100 |
+
print(gene_data.index[:20])
|
101 |
+
|
102 |
+
# Inspect a snippet of raw file to verify identifier format
|
103 |
+
import gzip
|
104 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
105 |
+
lines = []
|
106 |
+
for i, line in enumerate(f):
|
107 |
+
if "!series_matrix_table_begin" in line:
|
108 |
+
# Get the next 5 lines after the marker
|
109 |
+
for _ in range(5):
|
110 |
+
lines.append(next(f).strip())
|
111 |
+
break
|
112 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
113 |
+
for line in lines:
|
114 |
+
print(line)
|
115 |
+
# The identifiers starting with "A_23_P" appear to be Agilent probe IDs, not gene symbols
|
116 |
+
# These need to be mapped to standard gene symbols for consistent analysis
|
117 |
+
requires_gene_mapping = True
|
118 |
+
# Extract gene annotation data
|
119 |
+
gene_metadata = get_gene_annotation(soft_file)
|
120 |
+
|
121 |
+
# Preview the annotation data
|
122 |
+
print("Column names:", gene_metadata.columns.tolist())
|
123 |
+
print("\nFirst few rows preview:")
|
124 |
+
print(preview_df(gene_metadata))
|
125 |
+
# Map identifiers to gene symbols
|
126 |
+
mapping_data = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='GENE_SYMBOL')
|
127 |
+
|
128 |
+
# Apply the mapping to convert probe-level data to gene-level data
|
129 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
130 |
+
|
131 |
+
# Save the processed gene data
|
132 |
+
gene_data.to_csv(out_gene_data_file)
|
133 |
+
|
134 |
+
# Preview the result
|
135 |
+
print("Shape of mapped gene expression data:", gene_data.shape)
|
136 |
+
print("\nFirst few rows of mapped data:")
|
137 |
+
print(gene_data.head())
|
138 |
+
# 1. Normalize gene symbols
|
139 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
140 |
+
gene_data.to_csv(out_gene_data_file)
|
141 |
+
|
142 |
+
# 2. Link clinical and genetic data
|
143 |
+
linked_data = geo_link_clinical_genetic_data(clinical_features, gene_data)
|
144 |
+
|
145 |
+
# Check if clinical data linking produced valid results
|
146 |
+
if linked_data.shape[0] == 0 or linked_data.shape[1] <= 4:
|
147 |
+
is_usable = validate_and_save_cohort_info(
|
148 |
+
is_final=True,
|
149 |
+
cohort=cohort,
|
150 |
+
info_path=json_path,
|
151 |
+
is_gene_available=False, # Clinical data extraction failed
|
152 |
+
is_trait_available=False,
|
153 |
+
is_biased=None,
|
154 |
+
df=linked_data,
|
155 |
+
note="Clinical data extraction failed - produced invalid linked data."
|
156 |
+
)
|
157 |
+
else:
|
158 |
+
# 3. Handle missing values
|
159 |
+
linked_data = handle_missing_values(linked_data, trait)
|
160 |
+
|
161 |
+
# 4. Check for bias
|
162 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
163 |
+
|
164 |
+
# 5. Validate and save cohort info
|
165 |
+
is_usable = validate_and_save_cohort_info(
|
166 |
+
is_final=True,
|
167 |
+
cohort=cohort,
|
168 |
+
info_path=json_path,
|
169 |
+
is_gene_available=True,
|
170 |
+
is_trait_available=True,
|
171 |
+
is_biased=trait_biased,
|
172 |
+
df=linked_data,
|
173 |
+
note="Study examining gene expression in peripheral blood mononuclear cells from subjects with high vs low insulin resistance (HOMA groups)."
|
174 |
+
)
|
175 |
+
|
176 |
+
# 6. Save if usable
|
177 |
+
if is_usable:
|
178 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Atherosclerosis/code/GSE90074.py
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
cohort = "GSE90074"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Atherosclerosis"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Atherosclerosis/GSE90074"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/GSE90074.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/GSE90074.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/GSE90074.csv"
|
16 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data using broader sample prefixes
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(
|
23 |
+
matrix_file,
|
24 |
+
prefixes_a=['!Series_title', '!Series_summary', '!Series_overall_design'],
|
25 |
+
prefixes_b=['!Sample_', '!Sample_disease_state', '!Sample_description']
|
26 |
+
)
|
27 |
+
|
28 |
+
# Get unique values per clinical feature
|
29 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# Print background info
|
32 |
+
print("Dataset Background Information:")
|
33 |
+
print(f"{background_info}\n")
|
34 |
+
|
35 |
+
# Print sample characteristics
|
36 |
+
print("Sample Characteristics:")
|
37 |
+
for feature, values in sample_characteristics.items():
|
38 |
+
print(f"Feature: {feature}")
|
39 |
+
print(f"Values: {values}\n")
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# Yes - this is gene expression data from Agilent G4112F Whole Human Genome microarray
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2. Variable Availability and Data Type
|
45 |
+
|
46 |
+
# 2.1 Data Availability
|
47 |
+
# Trait (Atherosclerosis) can be inferred from CAD class in row 22
|
48 |
+
trait_row = 22
|
49 |
+
# No age data available
|
50 |
+
age_row = None
|
51 |
+
# Gender in row 19
|
52 |
+
gender_row = 19
|
53 |
+
|
54 |
+
# 2.2 Data Type Conversion Functions
|
55 |
+
def convert_trait(x):
|
56 |
+
if x is None:
|
57 |
+
return None
|
58 |
+
# Extract value after colon and strip whitespace
|
59 |
+
val = x.split(':')[-1].strip()
|
60 |
+
# Convert CAD class to binary - 0 for no/minimal disease (class 0), 1 for others (class 1-4)
|
61 |
+
if val == '0':
|
62 |
+
return 0
|
63 |
+
elif val in ['1', '2', '3', '4']:
|
64 |
+
return 1
|
65 |
+
return None
|
66 |
+
|
67 |
+
def convert_gender(x):
|
68 |
+
if x is None:
|
69 |
+
return None
|
70 |
+
val = x.split(':')[-1].strip()
|
71 |
+
if val.upper() == 'F':
|
72 |
+
return 0
|
73 |
+
elif val.upper() == 'M':
|
74 |
+
return 1
|
75 |
+
return None
|
76 |
+
|
77 |
+
def convert_age(x):
|
78 |
+
# Not used since age is not available
|
79 |
+
return None
|
80 |
+
|
81 |
+
# 3. Save metadata
|
82 |
+
validate_and_save_cohort_info(
|
83 |
+
is_final=False,
|
84 |
+
cohort=cohort,
|
85 |
+
info_path=json_path,
|
86 |
+
is_gene_available=is_gene_available,
|
87 |
+
is_trait_available=trait_row is not None
|
88 |
+
)
|
89 |
+
|
90 |
+
# 4. Clinical Feature Extraction
|
91 |
+
if trait_row is not None:
|
92 |
+
clinical_features = geo_select_clinical_features(
|
93 |
+
clinical_data,
|
94 |
+
trait="Atherosclerosis",
|
95 |
+
trait_row=trait_row,
|
96 |
+
convert_trait=convert_trait,
|
97 |
+
gender_row=gender_row,
|
98 |
+
convert_gender=convert_gender
|
99 |
+
)
|
100 |
+
print("Preview of extracted clinical features:")
|
101 |
+
print(preview_df(clinical_features))
|
102 |
+
clinical_features.to_csv(out_clinical_data_file)
|
103 |
+
# Get file paths
|
104 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
105 |
+
|
106 |
+
# Extract gene expression data from matrix file
|
107 |
+
gene_data = get_genetic_data(matrix_file)
|
108 |
+
|
109 |
+
# Print first 20 row IDs and shape of data to help debug
|
110 |
+
print("Shape of gene expression data:", gene_data.shape)
|
111 |
+
print("\nFirst few rows of data:")
|
112 |
+
print(gene_data.head())
|
113 |
+
print("\nFirst 20 gene/probe identifiers:")
|
114 |
+
print(gene_data.index[:20])
|
115 |
+
|
116 |
+
# Inspect a snippet of raw file to verify identifier format
|
117 |
+
import gzip
|
118 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
119 |
+
lines = []
|
120 |
+
for i, line in enumerate(f):
|
121 |
+
if "!series_matrix_table_begin" in line:
|
122 |
+
# Get the next 5 lines after the marker
|
123 |
+
for _ in range(5):
|
124 |
+
lines.append(next(f).strip())
|
125 |
+
break
|
126 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
127 |
+
for line in lines:
|
128 |
+
print(line)
|
129 |
+
requires_gene_mapping = True
|
130 |
+
# Extract gene annotation data
|
131 |
+
gene_metadata = get_gene_annotation(soft_file)
|
132 |
+
|
133 |
+
# Preview the annotation data
|
134 |
+
print("Column names:", gene_metadata.columns.tolist())
|
135 |
+
print("\nFirst few rows preview:")
|
136 |
+
print(preview_df(gene_metadata))
|
137 |
+
# 1. ID and GENE_SYMBOL in annotation data correspond to gene identifiers and symbols
|
138 |
+
prob_col = 'ID'
|
139 |
+
gene_col = 'GENE_SYMBOL'
|
140 |
+
|
141 |
+
# 2. Extract ID-to-gene mapping columns from annotation data
|
142 |
+
mapping_data = get_gene_mapping(gene_metadata, prob_col, gene_col)
|
143 |
+
|
144 |
+
# 3. Convert probe-level measurements to gene expression
|
145 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
146 |
+
|
147 |
+
# Print shapes to verify transformation
|
148 |
+
print("\nShape after probe-to-gene mapping:", gene_data.shape)
|
149 |
+
print("\nFirst few gene symbols:", gene_data.index[:5].tolist())
|
150 |
+
# 1. Normalize gene symbols
|
151 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
152 |
+
gene_data.to_csv(out_gene_data_file)
|
153 |
+
|
154 |
+
# Create ID mapping dictionary
|
155 |
+
gsm_to_2s = {}
|
156 |
+
for col in clinical_features.columns:
|
157 |
+
if col.startswith('2S'):
|
158 |
+
sample_num = col.split('_')[0] # Get '2S001'
|
159 |
+
gsm_num = int(sample_num[2:]) # Get 1
|
160 |
+
gsm_id = f'GSM2397{157+gsm_num}' # GSM2397158 for 2S001
|
161 |
+
gsm_to_2s[gsm_id] = col
|
162 |
+
|
163 |
+
# Rename gene data columns using mapping
|
164 |
+
gene_data = gene_data.rename(columns=gsm_to_2s)
|
165 |
+
|
166 |
+
# 2. Link clinical and genetic data
|
167 |
+
linked_data = geo_link_clinical_genetic_data(clinical_features, gene_data)
|
168 |
+
|
169 |
+
# 3. Handle missing values
|
170 |
+
linked_data = handle_missing_values(linked_data, trait)
|
171 |
+
|
172 |
+
# 4. Check for bias
|
173 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
174 |
+
|
175 |
+
# 5. Validate and save cohort info
|
176 |
+
is_usable = validate_and_save_cohort_info(
|
177 |
+
is_final=True,
|
178 |
+
cohort=cohort,
|
179 |
+
info_path=json_path,
|
180 |
+
is_gene_available=True,
|
181 |
+
is_trait_available=True,
|
182 |
+
is_biased=trait_biased,
|
183 |
+
df=linked_data,
|
184 |
+
note="Study examining gene expression profiles in blood samples of patients with different levels of atherosclerosis severity."
|
185 |
+
)
|
186 |
+
|
187 |
+
# 6. Save if usable
|
188 |
+
if is_usable:
|
189 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Atherosclerosis/code/TCGA.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Atherosclerosis"
|
6 |
+
|
7 |
+
# Input paths
|
8 |
+
tcga_root_dir = "../DATA/TCGA"
|
9 |
+
|
10 |
+
# Output paths
|
11 |
+
out_data_file = "./output/preprocess/3/Atherosclerosis/TCGA.csv"
|
12 |
+
out_gene_data_file = "./output/preprocess/3/Atherosclerosis/gene_data/TCGA.csv"
|
13 |
+
out_clinical_data_file = "./output/preprocess/3/Atherosclerosis/clinical_data/TCGA.csv"
|
14 |
+
json_path = "./output/preprocess/3/Atherosclerosis/cohort_info.json"
|
15 |
+
|
16 |
+
# Review directories to find relevant cohort for Atherosclerosis
|
17 |
+
cohorts = os.listdir(tcga_root_dir)
|
18 |
+
cohorts = [d for d in cohorts if os.path.isdir(os.path.join(tcga_root_dir, d)) and d[0] != '.']
|
19 |
+
|
20 |
+
# No suitable cohort found for Atherosclerosis
|
21 |
+
# Mark task as completed by recording cohort info
|
22 |
+
validate_and_save_cohort_info(
|
23 |
+
is_final=False,
|
24 |
+
cohort="TCGA",
|
25 |
+
info_path=json_path,
|
26 |
+
is_gene_available=False,
|
27 |
+
is_trait_available=False
|
28 |
+
)
|
p3/preprocess/Atherosclerosis/cohort_info.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"GSE90074": {"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": "Study examining gene expression profiles in blood samples of patients with different levels of atherosclerosis severity."}, "GSE87005": {"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": "Study examining gene expression in peripheral blood mononuclear cells from subjects with high vs low insulin resistance (HOMA groups)."}, "GSE83500": {"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}, "GSE57691": {"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": "Study examining expression profiles in endometriotic cyst stromal cells versus normal endometrial stromal cells."}, "GSE154851": {"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": "Contains gene expression data but lacks clinical information needed for trait association studies."}, "GSE133601": {"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": "Contains gene expression data but lacks clinical information needed for trait association studies."}, "GSE125771": {"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": "Contains gene expression data but lacks clinical information needed for trait association studies."}, "GSE123088": {"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": "Contains gene expression data but lacks clinical information needed for trait association studies."}, "GSE123086": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "Dataset contains both clinical features and gene expression data."}, "GSE109048": {"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": "Contains gene expression data and trait labels for atherosclerosis."}, "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}}
|
p3/preprocess/Atherosclerosis/gene_data/GSE109048.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Gene,GSM2928447,GSM2928448,GSM2928449,GSM2928450,GSM2928451,GSM2928452,GSM2928453,GSM2928454,GSM2928455,GSM2928456,GSM2928457,GSM2928458,GSM2928459,GSM2928460,GSM2928461,GSM2928462,GSM2928463,GSM2928464,GSM2928465,GSM2928466,GSM2928467,GSM2928468,GSM2928469,GSM2928470,GSM2928471,GSM2928472,GSM2928473,GSM2928474,GSM2928475,GSM2928476,GSM2928477,GSM2928478,GSM2928479,GSM2928480,GSM2928481,GSM2928482,GSM2928483,GSM2928484,GSM2928485,GSM2928486,GSM2928487,GSM2928488,GSM2928489,GSM2928490,GSM2928491,GSM2928492,GSM2928493,GSM2928494,GSM2928495,GSM2928496,GSM2928497,GSM2928498,GSM2928499,GSM2928500,GSM2928501,GSM2928502,GSM2928503
|
p3/preprocess/Atherosclerosis/gene_data/GSE123086.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
ID,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049
|
p3/preprocess/Atherosclerosis/gene_data/GSE123088.csv
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
ID,GSM3494884,GSM3494885,GSM3494886,GSM3494887,GSM3494888,GSM3494889,GSM3494890,GSM3494891,GSM3494892,GSM3494893,GSM3494894,GSM3494895,GSM3494896,GSM3494897,GSM3494898,GSM3494899,GSM3494900,GSM3494901,GSM3494902,GSM3494903,GSM3494904,GSM3494905,GSM3494906,GSM3494907,GSM3494908,GSM3494909,GSM3494910,GSM3494911,GSM3494912,GSM3494913,GSM3494914,GSM3494915,GSM3494916,GSM3494917,GSM3494918,GSM3494919,GSM3494920,GSM3494921,GSM3494922,GSM3494923,GSM3494924,GSM3494925,GSM3494926,GSM3494927,GSM3494928,GSM3494929,GSM3494930,GSM3494931,GSM3494932,GSM3494933,GSM3494934,GSM3494935,GSM3494936,GSM3494937,GSM3494938,GSM3494939,GSM3494940,GSM3494941,GSM3494942,GSM3494943,GSM3494944,GSM3494945,GSM3494946,GSM3494947,GSM3494948,GSM3494949,GSM3494950,GSM3494951,GSM3494952,GSM3494953,GSM3494954,GSM3494955,GSM3494956,GSM3494957,GSM3494958,GSM3494959,GSM3494960,GSM3494961,GSM3494962,GSM3494963,GSM3494964,GSM3494965,GSM3494966,GSM3494967,GSM3494968,GSM3494969,GSM3494970,GSM3494971,GSM3494972,GSM3494973,GSM3494974,GSM3494975,GSM3494976,GSM3494977,GSM3494978,GSM3494979,GSM3494980,GSM3494981,GSM3494982,GSM3494983,GSM3494984,GSM3494985,GSM3494986,GSM3494987,GSM3494988,GSM3494989,GSM3494990,GSM3494991,GSM3494992,GSM3494993,GSM3494994,GSM3494995,GSM3494996,GSM3494997,GSM3494998,GSM3494999,GSM3495000,GSM3495001,GSM3495002,GSM3495003,GSM3495004,GSM3495005,GSM3495006,GSM3495007,GSM3495008,GSM3495009,GSM3495010,GSM3495011,GSM3495012,GSM3495013,GSM3495014,GSM3495015,GSM3495016,GSM3495017,GSM3495018,GSM3495019,GSM3495020,GSM3495021,GSM3495022,GSM3495023,GSM3495024,GSM3495025,GSM3495026,GSM3495027,GSM3495028,GSM3495029,GSM3495030,GSM3495031,GSM3495032,GSM3495033,GSM3495034,GSM3495035,GSM3495036,GSM3495037,GSM3495038,GSM3495039,GSM3495040,GSM3495041,GSM3495042,GSM3495043,GSM3495044,GSM3495045,GSM3495046,GSM3495047,GSM3495048,GSM3495049,GSM3495050,GSM3495051,GSM3495052,GSM3495053,GSM3495054,GSM3495055,GSM3495056,GSM3495057,GSM3495058,GSM3495059,GSM3495060,GSM3495061,GSM3495062,GSM3495063,GSM3495064,GSM3495065,GSM3495066,GSM3495067,GSM3495068,GSM3495069,GSM3495070,GSM3495071,GSM3495072,GSM3495073,GSM3495074,GSM3495075,GSM3495076,GSM3495077,GSM3495078,GSM3495079,GSM3495080,GSM3495081,GSM3495082,GSM3495083,GSM3495084,GSM3495085,GSM3495086,GSM3495087
|
p3/preprocess/Atherosclerosis/gene_data/GSE125771.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Atherosclerosis/gene_data/GSE133601.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Atherosclerosis/gene_data/GSE154851.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1215f5db12fa93de50490eb6ebf6c7cf161522558dfc5030485ed81f07b1728a
|
3 |
+
size 17675327
|
p3/preprocess/Atherosclerosis/gene_data/GSE57691.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27c2e1eabe66da0727d69144095696cb0eb2f9de8b4a92906f14e584f17b727e
|
3 |
+
size 15477956
|
p3/preprocess/Atherosclerosis/gene_data/GSE83500.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Atherosclerosis/gene_data/GSE87005.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/GSE208662.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/GSE64593.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/GSE64599.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/clinical_data/GSE162635.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM4955871,GSM4955872,GSM4955873,GSM4955874,GSM4955875,GSM4955876,GSM4955877,GSM4955878,GSM4955879,GSM4955880,GSM4955881,GSM4955882,GSM4955883,GSM4955884,GSM4955885,GSM4955886,GSM4955887,GSM4955888,GSM4955889,GSM4955890,GSM4955891,GSM4955892,GSM4955893,GSM4955894,GSM4955895,GSM4955896,GSM4955897,GSM4955898,GSM4955899,GSM4955900,GSM4955901,GSM4955902,GSM4955903,GSM4955904,GSM4955905,GSM4955906,GSM4955907,GSM4955908,GSM4955909,GSM4955910,GSM4955911,GSM4955912,GSM4955913,GSM4955914,GSM4955915,GSM4955916,GSM4955917,GSM4955918,GSM4955919,GSM4955920,GSM4955921,GSM4955922,GSM4955923,GSM4955924,GSM4955925,GSM4955926,GSM4955927,GSM4955928,GSM4955929,GSM4955930,GSM4955931,GSM4955932,GSM4955933,GSM4955934,GSM4955935,GSM4955936,GSM4955937,GSM4955938,GSM4955939,GSM4955940,GSM4955941,GSM4955942,GSM4955943,GSM4955944,GSM4955945,GSM4955946,GSM4955947,GSM4955948,GSM4955949,GSM4955950,GSM4955951,GSM4955952,GSM4955953,GSM4955954,GSM4955955,GSM4955956,GSM4955957,GSM4955958,GSM4955959,GSM4955960,GSM4955961,GSM4955962,GSM4955963,GSM4955964,GSM4955965,GSM4955966,GSM4955967,GSM4955968,GSM4955969,GSM4955970,GSM4955971,GSM4955972,GSM4955973,GSM4955974,GSM4955975,GSM4955976,GSM4955977,GSM4955978,GSM4955979,GSM4955980,GSM4955981,GSM4955982,GSM4955983,GSM4955984,GSM4955985,GSM4955986,GSM4955987,GSM4955988,GSM4955989,GSM4955990,GSM4955991,GSM4955992,GSM4955993,GSM4955994,GSM4955995,GSM4955996,GSM4955997,GSM4955998,GSM4955999,GSM4956000,GSM4956001,GSM4956002,GSM4956003,GSM4956004,GSM4956005,GSM4956006,GSM4956007,GSM4956008,GSM4956009,GSM4956010,GSM4956011,GSM4956012,GSM4956013,GSM4956014,GSM4956015,GSM4956016,GSM4956017,GSM4956018,GSM4956019,GSM4956020,GSM4956021,GSM4956022,GSM4956023,GSM4956024,GSM4956025,GSM4956026,GSM4956027,GSM4956028,GSM4956029,GSM4956030,GSM4956031,GSM4956032,GSM4956033,GSM4956034,GSM4956035,GSM4956036,GSM4956037,GSM4956038,GSM4956039,GSM4956040,GSM4956041,GSM4956042,GSM4956043,GSM4956044,GSM4956045,GSM4956046,GSM4956047,GSM4956048,GSM4956049,GSM4956050,GSM4956051,GSM4956052,GSM4956053,GSM4956054,GSM4956055,GSM4956056,GSM4956057,GSM4956058,GSM4956059,GSM4956060,GSM4956061,GSM4956062,GSM4956063,GSM4956064,GSM4956065,GSM4956066,GSM4956067,GSM4956068,GSM4956069,GSM4956070,GSM4956071,GSM4956072,GSM4956073,GSM4956074,GSM4956075
|
2 |
+
Chronic_obstructive_pulmonary_disease_(COPD),1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,1.0,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,1.0,1.0,1.0,1.0,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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,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,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,0.0,0.0,0.0
|
p3/preprocess/Chronic_obstructive_pulmonary_disease_(COPD)/cohort_info.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"GSE84046": {"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": "Dataset contains normalized gene expression data but lacks COPD trait information, so cannot be used for trait association analysis"}, "GSE64599": {"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": 34, "note": "Dataset contains gene expression data from PBMCs comparing healthy controls vs diabetic nephropathy vs ESRD"}, "GSE64593": {"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": 34, "note": "Dataset contains gene expression data from alveolar macrophages comparing HIV- vs HIV+ smokers"}, "GSE32030": {"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": 123, "note": "Dataset contains gene expression data comparing healthy nonsmokers, healthy smokers and smokers with COPD"}, "GSE21359": {"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": 135, "note": "Dataset contains gene expression data comparing healthy nonsmokers, healthy smokers and smokers with COPD"}, "GSE212331": {"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": 87, "note": "Dataset contains gene expression data comparing healthy nonsmokers, healthy smokers and smokers with COPD"}, "GSE210272": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "Dataset contains gene expression data comparing healthy nonsmokers, healthy smokers and smokers with COPD. Using ENSEMBL gene IDs."}, "GSE208662": {"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": 32, "note": "Dataset contains gene expression data comparing healthy nonsmokers, healthy smokers and smokers with COPD"}, "GSE175616": {"is_usable": false, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": true, "has_age": true, "has_gender": true, "sample_size": 123, "note": "Dataset contains gene expression data comparing healthy nonsmokers, healthy smokers and smokers with COPD"}, "GSE162635": {"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": 205, "note": "Dataset contains gene expression data comparing healthy nonsmokers, healthy smokers and smokers with COPD"}}
|
p3/preprocess/HIV_Resistance/GSE33580.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0765943151958fb8392662fbd94e440f6061dc568837bbbed1d2c8f7f407cbe6
|
3 |
+
size 17574906
|
p3/preprocess/HIV_Resistance/GSE46599.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/HIV_Resistance/clinical_data/GSE33580.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM830155,GSM830156,GSM830157,GSM830158,GSM830159,GSM830160,GSM830161,GSM830162,GSM830163,GSM830164,GSM830165,GSM830166,GSM830167,GSM830168,GSM830169,GSM830170,GSM830171,GSM830172,GSM830173,GSM830174,GSM830175,GSM830176,GSM830177,GSM830178,GSM830179,GSM830180,GSM830181,GSM830182,GSM830183,GSM830184,GSM830185,GSM830186,GSM830187,GSM830188,GSM830189,GSM830190,GSM830191,GSM830192,GSM830193,GSM830194,GSM830195,GSM830196,GSM830197,GSM830198,GSM830199,GSM830200,GSM830201,GSM830202,GSM830203,GSM830204,GSM830205,GSM830206,GSM830207,GSM830208,GSM830209,GSM830210,GSM830211,GSM830212,GSM830213,GSM830214,GSM830215,GSM830216,GSM830217,GSM830218,GSM830219,GSM830220,GSM830221,GSM830222,GSM830223,GSM830224,GSM830225,GSM830226,GSM830227,GSM830228,GSM830229,GSM830230,GSM830231,GSM830232,GSM830233,GSM830234,GSM830235,GSM830236,GSM830237,GSM830238,GSM830239,GSM830240
|
2 |
+
HIV_Resistance,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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
|
p3/preprocess/HIV_Resistance/clinical_data/GSE46599.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM1133032,GSM1133033,GSM1133034,GSM1133035,GSM1133036,GSM1133037,GSM1133038,GSM1133039,GSM1133040,GSM1133041,GSM1133042,GSM1133043,GSM1133044,GSM1133045,GSM1133046,GSM1133047,GSM1133048,GSM1133049,GSM1133050,GSM1133051,GSM1133052,GSM1133053,GSM1133054,GSM1133055,GSM1133056,GSM1133057,GSM1133058,GSM1133059,GSM1133060,GSM1133061,GSM1133062,GSM1133063,GSM1133064,GSM1133065,GSM1133066,GSM1133067,GSM1133068,GSM1133069,GSM1133070,GSM1133071,GSM1133072,GSM1133073,GSM1133074,GSM1133075,GSM1133076,GSM1133077,GSM1133078,GSM1133079
|
2 |
+
HIV_Resistance,0.0,0.0,,,0.0,0.0,,,0.5,0.5,,,0.0,0.0,,,1.0,1.0,,,0.5,0.5,,,1.0,1.0,1.0,,,,1.0,1.0,1.0,,,,1.0,1.0,,,1.0,1.0,,,0.0,0.0,,
|
p3/preprocess/HIV_Resistance/code/GSE117748.py
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "HIV_Resistance"
|
6 |
+
cohort = "GSE117748"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/HIV_Resistance"
|
10 |
+
in_cohort_dir = "../DATA/GEO/HIV_Resistance/GSE117748"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/HIV_Resistance/GSE117748.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/HIV_Resistance/gene_data/GSE117748.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/HIV_Resistance/clinical_data/GSE117748.csv"
|
16 |
+
json_path = "./output/preprocess/3/HIV_Resistance/cohort_info.json"
|
17 |
+
|
18 |
+
# Get relevant file paths
|
19 |
+
soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data from the matrix file
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
|
23 |
+
|
24 |
+
# Get dictionary of unique values per row in clinical data
|
25 |
+
unique_values_dict = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Background Information:")
|
29 |
+
print("-" * 50)
|
30 |
+
print(background_info)
|
31 |
+
print("\n")
|
32 |
+
|
33 |
+
# Print clinical data unique values
|
34 |
+
print("Sample Characteristics:")
|
35 |
+
print("-" * 50)
|
36 |
+
for row, values in unique_values_dict.items():
|
37 |
+
print(f"{row}:")
|
38 |
+
print(f" {values}")
|
39 |
+
print()
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# This is a miRNA study on cell lines (based on the title and sample characteristics)
|
42 |
+
is_gene_available = False
|
43 |
+
|
44 |
+
# 2.1 Data Availability
|
45 |
+
# From sample characteristics, no human trait, age or gender data available
|
46 |
+
trait_row = None
|
47 |
+
age_row = None
|
48 |
+
gender_row = None
|
49 |
+
|
50 |
+
# 2.2 Data Type Conversion functions (not used but defined for completeness)
|
51 |
+
def convert_trait(x):
|
52 |
+
return None
|
53 |
+
|
54 |
+
def convert_age(x):
|
55 |
+
return None
|
56 |
+
|
57 |
+
def convert_gender(x):
|
58 |
+
return None
|
59 |
+
|
60 |
+
# 3. Save Metadata
|
61 |
+
# Validate and save cohort info - initial filtering
|
62 |
+
validate_and_save_cohort_info(
|
63 |
+
is_final=False,
|
64 |
+
cohort=cohort,
|
65 |
+
info_path=json_path,
|
66 |
+
is_gene_available=is_gene_available,
|
67 |
+
is_trait_available=False # trait_row is None
|
68 |
+
)
|
69 |
+
|
70 |
+
# 4. Clinical Feature Extraction
|
71 |
+
# Skip since trait_row is None
|
p3/preprocess/HIV_Resistance/code/GSE33580.py
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "HIV_Resistance"
|
6 |
+
cohort = "GSE33580"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/HIV_Resistance"
|
10 |
+
in_cohort_dir = "../DATA/GEO/HIV_Resistance/GSE33580"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/HIV_Resistance/GSE33580.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/HIV_Resistance/gene_data/GSE33580.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/HIV_Resistance/clinical_data/GSE33580.csv"
|
16 |
+
json_path = "./output/preprocess/3/HIV_Resistance/cohort_info.json"
|
17 |
+
|
18 |
+
# Get relevant file paths
|
19 |
+
soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data from the matrix file
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
|
23 |
+
|
24 |
+
# Get dictionary of unique values per row in clinical data
|
25 |
+
unique_values_dict = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Background Information:")
|
29 |
+
print("-" * 50)
|
30 |
+
print(background_info)
|
31 |
+
print("\n")
|
32 |
+
|
33 |
+
# Print clinical data unique values
|
34 |
+
print("Sample Characteristics:")
|
35 |
+
print("-" * 50)
|
36 |
+
for row, values in unique_values_dict.items():
|
37 |
+
print(f"{row}:")
|
38 |
+
print(f" {values}")
|
39 |
+
print()
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
# Yes - the background info mentions "gene expression analysis" and "Affymetrix microarrays"
|
42 |
+
is_gene_available = True
|
43 |
+
|
44 |
+
# 2. Variable Availability and Data Type Conversion
|
45 |
+
# Trait (HIV Resistance) is in row 1
|
46 |
+
trait_row = 1
|
47 |
+
# Age data not available
|
48 |
+
age_row = None
|
49 |
+
# Gender data not available - appears to be all female from background info
|
50 |
+
gender_row = None
|
51 |
+
|
52 |
+
def convert_trait(x):
|
53 |
+
"""Convert HIV status to binary (1=resistant, 0=negative)"""
|
54 |
+
if not isinstance(x, str):
|
55 |
+
return None
|
56 |
+
x = x.lower().split(': ')[-1]
|
57 |
+
if 'resistant' in x:
|
58 |
+
return 1
|
59 |
+
elif 'negative' in x:
|
60 |
+
return 0
|
61 |
+
return None
|
62 |
+
|
63 |
+
def convert_age(x):
|
64 |
+
"""Placeholder since age not available"""
|
65 |
+
return None
|
66 |
+
|
67 |
+
def convert_gender(x):
|
68 |
+
"""Placeholder since gender not available"""
|
69 |
+
return None
|
70 |
+
|
71 |
+
# 3. Save Metadata
|
72 |
+
validate_and_save_cohort_info(is_final=False,
|
73 |
+
cohort=cohort,
|
74 |
+
info_path=json_path,
|
75 |
+
is_gene_available=is_gene_available,
|
76 |
+
is_trait_available=trait_row is not None)
|
77 |
+
|
78 |
+
# 4. Clinical Feature Extraction
|
79 |
+
if trait_row is not None:
|
80 |
+
clinical_features = geo_select_clinical_features(
|
81 |
+
clinical_df=clinical_data,
|
82 |
+
trait=trait,
|
83 |
+
trait_row=trait_row,
|
84 |
+
convert_trait=convert_trait,
|
85 |
+
age_row=age_row,
|
86 |
+
convert_age=convert_age,
|
87 |
+
gender_row=gender_row,
|
88 |
+
convert_gender=convert_gender
|
89 |
+
)
|
90 |
+
|
91 |
+
# Preview the extracted features
|
92 |
+
preview = preview_df(clinical_features)
|
93 |
+
print("Preview of clinical features:")
|
94 |
+
print(preview)
|
95 |
+
|
96 |
+
# Save to CSV
|
97 |
+
clinical_features.to_csv(out_clinical_data_file)
|
98 |
+
# Extract gene expression data
|
99 |
+
genetic_data = get_genetic_data(matrix_file_path)
|
100 |
+
|
101 |
+
# Print first 20 probe IDs
|
102 |
+
print("First 20 probe IDs:")
|
103 |
+
print(genetic_data.index[:20])
|
104 |
+
# The identifiers shown are Affymetrix probe IDs (e.g. '1007_s_at', '1053_at')
|
105 |
+
# These need to be mapped to HGNC gene symbols for standardization
|
106 |
+
requires_gene_mapping = True
|
107 |
+
# Extract gene annotation from SOFT file
|
108 |
+
gene_annotation = get_gene_annotation(soft_file_path)
|
109 |
+
|
110 |
+
# Preview column names and first few values
|
111 |
+
preview_dict = preview_df(gene_annotation)
|
112 |
+
print("Column names and preview values:")
|
113 |
+
for col, values in preview_dict.items():
|
114 |
+
print(f"\n{col}:")
|
115 |
+
print(values)
|
116 |
+
# 1. Identify columns for mapping
|
117 |
+
# 'ID' in gene annotation matches probe IDs in gene expression data
|
118 |
+
# 'Gene Symbol' contains the gene symbols we want to map to
|
119 |
+
prob_col = 'ID'
|
120 |
+
gene_col = 'Gene Symbol'
|
121 |
+
|
122 |
+
# 2. Get mapping dataframe
|
123 |
+
mapping_data = get_gene_mapping(gene_annotation, prob_col, gene_col)
|
124 |
+
|
125 |
+
# 3. Apply mapping to convert probe-level data to gene expression data
|
126 |
+
gene_data = apply_gene_mapping(genetic_data, mapping_data)
|
127 |
+
|
128 |
+
# Preview result
|
129 |
+
print("\nFirst few rows and columns of gene expression data:")
|
130 |
+
print(gene_data.iloc[:5, :5])
|
131 |
+
# 1. Normalize gene symbols and save normalized gene data
|
132 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
133 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
134 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
135 |
+
|
136 |
+
# Read the processed clinical data file
|
137 |
+
clinical_df = pd.read_csv(out_clinical_data_file, index_col=0)
|
138 |
+
|
139 |
+
# Link clinical and genetic data using the normalized gene data
|
140 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, normalized_gene_data)
|
141 |
+
|
142 |
+
# Handle missing values systematically
|
143 |
+
linked_data = handle_missing_values(linked_data, trait)
|
144 |
+
|
145 |
+
# Detect bias in trait and demographic features, remove biased demographic features
|
146 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
147 |
+
|
148 |
+
# Validate data quality and save cohort info
|
149 |
+
note = "Gene expression data from glucocorticoid sensitivity study."
|
150 |
+
is_usable = validate_and_save_cohort_info(
|
151 |
+
is_final=True,
|
152 |
+
cohort=cohort,
|
153 |
+
info_path=json_path,
|
154 |
+
is_gene_available=True,
|
155 |
+
is_trait_available=True,
|
156 |
+
is_biased=is_biased,
|
157 |
+
df=linked_data,
|
158 |
+
note=note
|
159 |
+
)
|
160 |
+
|
161 |
+
# Save linked data if usable
|
162 |
+
if is_usable:
|
163 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
164 |
+
linked_data.to_csv(out_data_file)
|
165 |
+
else:
|
166 |
+
print(f"Dataset {cohort} did not pass quality validation and will not be saved.")
|
p3/preprocess/HIV_Resistance/code/GSE46599.py
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "HIV_Resistance"
|
6 |
+
cohort = "GSE46599"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/HIV_Resistance"
|
10 |
+
in_cohort_dir = "../DATA/GEO/HIV_Resistance/GSE46599"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/HIV_Resistance/GSE46599.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/HIV_Resistance/gene_data/GSE46599.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/HIV_Resistance/clinical_data/GSE46599.csv"
|
16 |
+
json_path = "./output/preprocess/3/HIV_Resistance/cohort_info.json"
|
17 |
+
|
18 |
+
# Get relevant file paths
|
19 |
+
soft_file_path, matrix_file_path = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data from the matrix file
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file_path)
|
23 |
+
|
24 |
+
# Get dictionary of unique values per row in clinical data
|
25 |
+
unique_values_dict = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Background Information:")
|
29 |
+
print("-" * 50)
|
30 |
+
print(background_info)
|
31 |
+
print("\n")
|
32 |
+
|
33 |
+
# Print clinical data unique values
|
34 |
+
print("Sample Characteristics:")
|
35 |
+
print("-" * 50)
|
36 |
+
for row, values in unique_values_dict.items():
|
37 |
+
print(f"{row}:")
|
38 |
+
print(f" {values}")
|
39 |
+
print()
|
40 |
+
# 1. Gene Expression Data Availability
|
41 |
+
is_gene_available = True # Yes, this is gene expression data studying ISGs, not miRNA/methylation
|
42 |
+
|
43 |
+
# 2. Variable Availability and Data Type Conversion
|
44 |
+
# 2.1 Data Availability
|
45 |
+
trait_row = 4 # HIV resistance status in row 4
|
46 |
+
age_row = None # Age not available
|
47 |
+
gender_row = None # Gender not available
|
48 |
+
|
49 |
+
# 2.2 Data Type Conversion Functions
|
50 |
+
def convert_trait(x):
|
51 |
+
if not isinstance(x, str):
|
52 |
+
return None
|
53 |
+
val = x.split(': ')[-1].lower()
|
54 |
+
if 'resistant' == val:
|
55 |
+
return 1
|
56 |
+
elif 'partially resistant' == val:
|
57 |
+
return 0.5
|
58 |
+
elif 'permissive' == val:
|
59 |
+
return 0
|
60 |
+
elif 'untreated' == val:
|
61 |
+
return None
|
62 |
+
return None
|
63 |
+
|
64 |
+
def convert_age(x):
|
65 |
+
return None # Not used
|
66 |
+
|
67 |
+
def convert_gender(x):
|
68 |
+
return None # Not used
|
69 |
+
|
70 |
+
# 3. Save Metadata
|
71 |
+
validate_and_save_cohort_info(is_final=False,
|
72 |
+
cohort=cohort,
|
73 |
+
info_path=json_path,
|
74 |
+
is_gene_available=is_gene_available,
|
75 |
+
is_trait_available=trait_row is not None)
|
76 |
+
|
77 |
+
# 4. Clinical Feature Extraction
|
78 |
+
if trait_row is not None:
|
79 |
+
clinical_features = geo_select_clinical_features(
|
80 |
+
clinical_df=clinical_data,
|
81 |
+
trait=trait,
|
82 |
+
trait_row=trait_row,
|
83 |
+
convert_trait=convert_trait,
|
84 |
+
age_row=age_row,
|
85 |
+
convert_age=convert_age,
|
86 |
+
gender_row=gender_row,
|
87 |
+
convert_gender=convert_gender
|
88 |
+
)
|
89 |
+
|
90 |
+
# Preview extracted features
|
91 |
+
preview = preview_df(clinical_features)
|
92 |
+
print("Preview of clinical features:")
|
93 |
+
print(preview)
|
94 |
+
|
95 |
+
# Save to CSV
|
96 |
+
clinical_features.to_csv(out_clinical_data_file)
|
97 |
+
# Extract gene expression data
|
98 |
+
genetic_data = get_genetic_data(matrix_file_path)
|
99 |
+
|
100 |
+
# Print first 20 probe IDs
|
101 |
+
print("First 20 probe IDs:")
|
102 |
+
print(genetic_data.index[:20])
|
103 |
+
# These are Illumina BeadArray probe IDs (starting with ILMN_), not gene symbols
|
104 |
+
requires_gene_mapping = True
|
105 |
+
# Extract gene annotation from SOFT file
|
106 |
+
gene_annotation = get_gene_annotation(soft_file_path)
|
107 |
+
|
108 |
+
# Preview column names and first few values
|
109 |
+
preview_dict = preview_df(gene_annotation)
|
110 |
+
print("Column names and preview values:")
|
111 |
+
for col, values in preview_dict.items():
|
112 |
+
print(f"\n{col}:")
|
113 |
+
print(values)
|
114 |
+
# Get gene mapping from annotation data
|
115 |
+
# 'ID' column contains probe IDs (ILMN_*) matching gene expression data
|
116 |
+
# 'Symbol' column contains gene symbols
|
117 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
|
118 |
+
|
119 |
+
# Apply gene mapping to convert probe-level data to gene expression data
|
120 |
+
gene_data = apply_gene_mapping(genetic_data, mapping_df)
|
121 |
+
|
122 |
+
# Preview first few genes
|
123 |
+
print("\nFirst few genes after mapping:")
|
124 |
+
print(gene_data.head().index)
|
125 |
+
# 1. Normalize gene symbols and save normalized gene data
|
126 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
127 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
128 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
129 |
+
|
130 |
+
# Read the processed clinical data file
|
131 |
+
clinical_df = pd.read_csv(out_clinical_data_file, index_col=0)
|
132 |
+
|
133 |
+
# Link clinical and genetic data using the normalized gene data
|
134 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, normalized_gene_data)
|
135 |
+
|
136 |
+
# Handle missing values systematically
|
137 |
+
linked_data = handle_missing_values(linked_data, trait)
|
138 |
+
|
139 |
+
# Detect bias in trait and demographic features, remove biased demographic features
|
140 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
141 |
+
|
142 |
+
# Validate data quality and save cohort info
|
143 |
+
note = "Gene expression data from glucocorticoid sensitivity study."
|
144 |
+
is_usable = validate_and_save_cohort_info(
|
145 |
+
is_final=True,
|
146 |
+
cohort=cohort,
|
147 |
+
info_path=json_path,
|
148 |
+
is_gene_available=True,
|
149 |
+
is_trait_available=True,
|
150 |
+
is_biased=is_biased,
|
151 |
+
df=linked_data,
|
152 |
+
note=note
|
153 |
+
)
|
154 |
+
|
155 |
+
# Save linked data if usable
|
156 |
+
if is_usable:
|
157 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
158 |
+
linked_data.to_csv(out_data_file)
|
159 |
+
else:
|
160 |
+
print(f"Dataset {cohort} did not pass quality validation and will not be saved.")
|
p3/preprocess/HIV_Resistance/code/TCGA.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "HIV_Resistance"
|
6 |
+
|
7 |
+
# Input paths
|
8 |
+
tcga_root_dir = "../DATA/TCGA"
|
9 |
+
|
10 |
+
# Output paths
|
11 |
+
out_data_file = "./output/preprocess/3/HIV_Resistance/TCGA.csv"
|
12 |
+
out_gene_data_file = "./output/preprocess/3/HIV_Resistance/gene_data/TCGA.csv"
|
13 |
+
out_clinical_data_file = "./output/preprocess/3/HIV_Resistance/clinical_data/TCGA.csv"
|
14 |
+
json_path = "./output/preprocess/3/HIV_Resistance/cohort_info.json"
|
15 |
+
|
16 |
+
# Review available cohorts and check for HIV resistance relevance
|
17 |
+
available_cohorts = os.listdir(tcga_root_dir)
|
18 |
+
cohorts = [c for c in available_cohorts if not c.startswith('.') and not c.endswith('.ipynb')]
|
19 |
+
|
20 |
+
# No suitable cohort found for HIV resistance in TCGA cancer datasets
|
21 |
+
is_gene_available = False
|
22 |
+
is_trait_available = False
|
23 |
+
|
24 |
+
# Record that this trait cannot be studied with TCGA data
|
25 |
+
validate_and_save_cohort_info(
|
26 |
+
is_final=False,
|
27 |
+
cohort="TCGA",
|
28 |
+
info_path=json_path,
|
29 |
+
is_gene_available=is_gene_available,
|
30 |
+
is_trait_available=is_trait_available
|
31 |
+
)
|
p3/preprocess/HIV_Resistance/cohort_info.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"GSE46599": {"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": 24, "note": "Gene expression data from glucocorticoid sensitivity study."}, "GSE33580": {"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": 86, "note": "Gene expression data from glucocorticoid sensitivity study."}, "GSE117748": {"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}, "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}}
|
p3/preprocess/HIV_Resistance/gene_data/GSE33580.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0511021b61ee52077846f8a26d1b4a3aba0da36e320fd0c6c78e33e164c1ec19
|
3 |
+
size 17574551
|
p3/preprocess/HIV_Resistance/gene_data/GSE46599.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1f661e1f9ecddf85031728eb9eb0b8d5e16c1ec259db88715274af7b864f73f0
|
3 |
+
size 11404720
|
p3/preprocess/Head_and_Neck_Cancer/gene_data/GSE156915.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2879a4bafeabb89373f8e8048fc81105fb8bf2230ea6cf71844e326693130272
|
3 |
+
size 95359844
|
p3/preprocess/Head_and_Neck_Cancer/gene_data/TCGA.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ebda0991a4c4e9b1b7e992e8c4f50e2908e2645936891de033875c79b30d9d3a
|
3 |
+
size 169983153
|
p3/preprocess/Height/gene_data/GSE97475.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3f878f347055d43a45dabc516d5439c40520de0e4801d000f60d50442300ba19
|
3 |
+
size 26337377
|