Liu-Hy commited on
Commit
24fe0da
·
verified ·
1 Parent(s): 0815237

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +28 -0
  2. p1/preprocess/Chronic_kidney_disease/gene_data/TCGA.csv +3 -0
  3. p1/preprocess/Colon_and_Rectal_Cancer/TCGA.csv +3 -0
  4. p1/preprocess/Colon_and_Rectal_Cancer/gene_data/TCGA.csv +3 -0
  5. p1/preprocess/Craniosynostosis/GSE27976.csv +3 -0
  6. p1/preprocess/Craniosynostosis/gene_data/GSE27976.csv +3 -0
  7. p1/preprocess/Crohns_Disease/gene_data/GSE186582.csv +3 -0
  8. p1/preprocess/Depression/gene_data/GSE135524.csv +3 -0
  9. p1/preprocess/Depression/gene_data/GSE81761.csv +3 -0
  10. p1/preprocess/Duchenne_Muscular_Dystrophy/GSE79263.csv +3 -0
  11. p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE109178.csv +3 -0
  12. p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE13608.csv +3 -0
  13. p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE79263.csv +3 -0
  14. p1/preprocess/Eczema/GSE182740.csv +3 -0
  15. p1/preprocess/Eczema/GSE32924.csv +0 -0
  16. p1/preprocess/Eczema/GSE57225.csv +3 -0
  17. p1/preprocess/Eczema/gene_data/GSE120899.csv +0 -0
  18. p1/preprocess/Eczema/gene_data/GSE150797.csv +3 -0
  19. p1/preprocess/Eczema/gene_data/GSE182740.csv +3 -0
  20. p1/preprocess/Eczema/gene_data/GSE32924.csv +0 -0
  21. p1/preprocess/Eczema/gene_data/GSE57225.csv +3 -0
  22. p1/preprocess/Eczema/gene_data/GSE61225.csv +3 -0
  23. p1/preprocess/Endometrioid_Cancer/GSE40785.csv +0 -0
  24. p1/preprocess/Endometrioid_Cancer/GSE65986.csv +0 -0
  25. p1/preprocess/Endometrioid_Cancer/GSE68600.csv +0 -0
  26. p1/preprocess/Endometrioid_Cancer/GSE73551.csv +3 -0
  27. p1/preprocess/Endometrioid_Cancer/clinical_data/GSE40785.csv +2 -0
  28. p1/preprocess/Endometrioid_Cancer/clinical_data/GSE65986.csv +3 -0
  29. p1/preprocess/Endometrioid_Cancer/clinical_data/GSE66667.csv +2 -0
  30. p1/preprocess/Endometrioid_Cancer/clinical_data/GSE68600.csv +2 -0
  31. p1/preprocess/Endometrioid_Cancer/clinical_data/GSE73551.csv +2 -0
  32. p1/preprocess/Endometrioid_Cancer/clinical_data/GSE73637.csv +2 -0
  33. p1/preprocess/Endometrioid_Cancer/code/GSE120490.py +163 -0
  34. p1/preprocess/Endometrioid_Cancer/code/GSE40785.py +181 -0
  35. p1/preprocess/Endometrioid_Cancer/code/GSE65986.py +193 -0
  36. p1/preprocess/Endometrioid_Cancer/code/GSE66667.py +185 -0
  37. p1/preprocess/Endometrioid_Cancer/code/GSE68600.py +189 -0
  38. p1/preprocess/Endometrioid_Cancer/code/GSE73551.py +176 -0
  39. p1/preprocess/Endometrioid_Cancer/code/GSE73614.py +190 -0
  40. p1/preprocess/Endometrioid_Cancer/code/GSE73637.py +287 -0
  41. p1/preprocess/Endometrioid_Cancer/code/GSE94523.py +70 -0
  42. p1/preprocess/Endometrioid_Cancer/code/GSE94524.py +74 -0
  43. p1/preprocess/Endometrioid_Cancer/code/TCGA.py +111 -0
  44. p1/preprocess/Endometrioid_Cancer/cohort_info.json +1 -0
  45. p1/preprocess/Endometrioid_Cancer/gene_data/GSE120490.csv +3 -0
  46. p1/preprocess/Endometrioid_Cancer/gene_data/GSE40785.csv +0 -0
  47. p1/preprocess/Endometrioid_Cancer/gene_data/GSE65986.csv +0 -0
  48. p1/preprocess/Endometrioid_Cancer/gene_data/GSE66667.csv +0 -0
  49. p1/preprocess/Endometrioid_Cancer/gene_data/GSE68600.csv +0 -0
  50. p1/preprocess/Endometrioid_Cancer/gene_data/GSE73551.csv +3 -0
.gitattributes CHANGED
@@ -1048,3 +1048,31 @@ p1/preprocess/Cystic_Fibrosis/gene_data/GSE67698.csv filter=lfs diff=lfs merge=l
1048
  p1/preprocess/Cystic_Fibrosis/gene_data/GSE71799.csv filter=lfs diff=lfs merge=lfs -text
1049
  p1/preprocess/Depression/gene_data/GSE138297.csv filter=lfs diff=lfs merge=lfs -text
1050
  p1/preprocess/Depression/gene_data/GSE149980.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1048
  p1/preprocess/Cystic_Fibrosis/gene_data/GSE71799.csv filter=lfs diff=lfs merge=lfs -text
1049
  p1/preprocess/Depression/gene_data/GSE138297.csv filter=lfs diff=lfs merge=lfs -text
1050
  p1/preprocess/Depression/gene_data/GSE149980.csv filter=lfs diff=lfs merge=lfs -text
1051
+ p1/preprocess/Depression/gene_data/GSE135524.csv filter=lfs diff=lfs merge=lfs -text
1052
+ p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE109178.csv filter=lfs diff=lfs merge=lfs -text
1053
+ p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE13608.csv filter=lfs diff=lfs merge=lfs -text
1054
+ p1/preprocess/Colon_and_Rectal_Cancer/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1055
+ p1/preprocess/Craniosynostosis/GSE27976.csv filter=lfs diff=lfs merge=lfs -text
1056
+ p1/preprocess/Craniosynostosis/gene_data/GSE27976.csv filter=lfs diff=lfs merge=lfs -text
1057
+ p1/preprocess/Depression/gene_data/GSE81761.csv filter=lfs diff=lfs merge=lfs -text
1058
+ p1/preprocess/Colon_and_Rectal_Cancer/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1059
+ p1/preprocess/Duchenne_Muscular_Dystrophy/GSE79263.csv filter=lfs diff=lfs merge=lfs -text
1060
+ p1/preprocess/Eczema/GSE182740.csv filter=lfs diff=lfs merge=lfs -text
1061
+ p1/preprocess/Eczema/GSE57225.csv filter=lfs diff=lfs merge=lfs -text
1062
+ p1/preprocess/Crohns_Disease/gene_data/GSE186582.csv filter=lfs diff=lfs merge=lfs -text
1063
+ p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE79263.csv filter=lfs diff=lfs merge=lfs -text
1064
+ p1/preprocess/Eczema/gene_data/GSE182740.csv filter=lfs diff=lfs merge=lfs -text
1065
+ p1/preprocess/Eczema/gene_data/GSE57225.csv filter=lfs diff=lfs merge=lfs -text
1066
+ p1/preprocess/Endometrioid_Cancer/GSE73551.csv filter=lfs diff=lfs merge=lfs -text
1067
+ p1/preprocess/Eczema/gene_data/GSE61225.csv filter=lfs diff=lfs merge=lfs -text
1068
+ p1/preprocess/Eczema/gene_data/GSE150797.csv filter=lfs diff=lfs merge=lfs -text
1069
+ p1/preprocess/Endometrioid_Cancer/gene_data/GSE73551.csv filter=lfs diff=lfs merge=lfs -text
1070
+ p1/preprocess/Endometrioid_Cancer/gene_data/GSE73637.csv filter=lfs diff=lfs merge=lfs -text
1071
+ p1/preprocess/Endometriosis/GSE73622.csv filter=lfs diff=lfs merge=lfs -text
1072
+ p1/preprocess/Endometrioid_Cancer/gene_data/GSE73614.csv filter=lfs diff=lfs merge=lfs -text
1073
+ p1/preprocess/Endometriosis/GSE145702.csv filter=lfs diff=lfs merge=lfs -text
1074
+ p1/preprocess/Endometriosis/gene_data/GSE145702.csv filter=lfs diff=lfs merge=lfs -text
1075
+ p1/preprocess/Endometrioid_Cancer/gene_data/GSE120490.csv filter=lfs diff=lfs merge=lfs -text
1076
+ p1/preprocess/Chronic_kidney_disease/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
1077
+ p1/preprocess/Endometriosis/gene_data/GSE165004.csv filter=lfs diff=lfs merge=lfs -text
1078
+ p1/preprocess/Endometriosis/gene_data/GSE73622.csv filter=lfs diff=lfs merge=lfs -text
p1/preprocess/Chronic_kidney_disease/gene_data/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad56d64496541ee0872327215eca3da6769d5e7ccee6a3d8759e9c00555c00ed
3
+ size 182067513
p1/preprocess/Colon_and_Rectal_Cancer/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c5390e6daf5e3e47bb2c3812fe5afc0432b495fa8f86816dbdef6f026e048eb
3
+ size 126039154
p1/preprocess/Colon_and_Rectal_Cancer/gene_data/TCGA.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12ad01388efefe4f4b1c0553956a6584709216157e914efc50afbd3ab6db088f
3
+ size 126034303
p1/preprocess/Craniosynostosis/GSE27976.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:557ff216dbfb89b8495832e041de2ba238ab1d53ac0c276a5e1bf2e4b7ab7f35
3
+ size 84076597
p1/preprocess/Craniosynostosis/gene_data/GSE27976.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:16279c820c79d0c94bb8ba0cbab22d0bf85779ec2ffd3a6b35e1178e1d1bb0d5
3
+ size 84073337
p1/preprocess/Crohns_Disease/gene_data/GSE186582.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a9c7f53a5f6ea3c35153efb348986dccceb6882564285f9c3b52df03b7521f5
3
+ size 80350269
p1/preprocess/Depression/gene_data/GSE135524.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da8beefb314eeab7395b333e8a7b2136ad6af14fc7414ef9a6ee911a2d4fc085
3
+ size 18896895
p1/preprocess/Depression/gene_data/GSE81761.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:80d271a331e56d79d6ae609b699491af556ac5efb7e7466dd13a554ce437216e
3
+ size 21422884
p1/preprocess/Duchenne_Muscular_Dystrophy/GSE79263.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b04c843ca8a1a37ee127d045d3eae0f8cd110d80e4f168d0829d3a275ea6e2d
3
+ size 22002744
p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE109178.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b3bf5fe2136dab438c44d5884d783e459a41ddee7375966ec649904d339b1a6
3
+ size 10804879
p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE13608.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ac51962b6fe19aedebf4a486659790dbdc0831f54aa25eb8883971ca8a2b9f7f
3
+ size 11626290
p1/preprocess/Duchenne_Muscular_Dystrophy/gene_data/GSE79263.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3795bd2996cbb1a8bc0192d993a9a679e691c5496793d969c09eaf9c76d0b51b
3
+ size 24035990
p1/preprocess/Eczema/GSE182740.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0279f7574c1e3094045ed43719b8b520f6b8a32194b9ec4d755d264ecfcb2af5
3
+ size 16722900
p1/preprocess/Eczema/GSE32924.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Eczema/GSE57225.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:611c42ec645481fd1d05c821e06cc5c04a2ead1c5c5075a7cf6091e0e4a561cf
3
+ size 15231598
p1/preprocess/Eczema/gene_data/GSE120899.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Eczema/gene_data/GSE150797.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3de8e5b459707fa792e521653fea9e87b73d2dc5680f556235ba6c1b37be4e29
3
+ size 28353275
p1/preprocess/Eczema/gene_data/GSE182740.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:095173af41a72566b017be3af9b37ffcce35a7b1300de4acb4731e97fb40270d
3
+ size 16722597
p1/preprocess/Eczema/gene_data/GSE32924.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Eczema/gene_data/GSE57225.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:04e68c8383ece4574a117f19746426af4d18aff14370c16c48c34694742b4f4f
3
+ size 15230778
p1/preprocess/Eczema/gene_data/GSE61225.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:48bc07e8b37b35fecb1c6a1c1a4ba16583326afa9becbd526d97f068140712ad
3
+ size 15566705
p1/preprocess/Endometrioid_Cancer/GSE40785.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Endometrioid_Cancer/GSE65986.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Endometrioid_Cancer/GSE68600.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Endometrioid_Cancer/GSE73551.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d4c290838f5d518e6242d47cad1fd2f7170339fdb7b700f1ad1c9a79e681d9d2
3
+ size 14282175
p1/preprocess/Endometrioid_Cancer/clinical_data/GSE40785.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ GSM1001395,GSM1001396,GSM1001397,GSM1001398,GSM1001399,GSM1001400,GSM1001401,GSM1001402,GSM1001403,GSM1001404,GSM1001405,GSM1001406,GSM1001407,GSM1001408,GSM1001409,GSM1001410,GSM1001411,GSM1001412,GSM1001413,GSM1001414,GSM1001415,GSM1001416,GSM1001417,GSM1001418,GSM1001419,GSM1001420,GSM1001421,GSM1001422,GSM1001423,GSM1001424,GSM1001425,GSM1001426,GSM1001427,GSM1001428,GSM1001429,GSM1001430,GSM1001431
2
+ 0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,,0.0,0.0,1.0,,0.0,0.0,1.0,0.0,0.0,0.0,0.0,,0.0,0.0,,,0.0,0.0,,,1.0,1.0,0.0,0.0,0.0,0.0,0.0
p1/preprocess/Endometrioid_Cancer/clinical_data/GSE65986.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ GSM1612097,GSM1612098,GSM1612099,GSM1612100,GSM1612101,GSM1612102,GSM1612103,GSM1612104,GSM1612105,GSM1612106,GSM1612107,GSM1612108,GSM1612109,GSM1612110,GSM1612111,GSM1612112,GSM1612113,GSM1612114,GSM1612115,GSM1612116,GSM1612117,GSM1612118,GSM1612119,GSM1612120,GSM1612121,GSM1612122,GSM1612123,GSM1612124,GSM1612125,GSM1612126,GSM1612127,GSM1612128,GSM1612129,GSM1612130,GSM1612131,GSM1612132,GSM1612133,GSM1612134,GSM1612135,GSM1612136,GSM1612137,GSM1612138,GSM1612139,GSM1612140,GSM1612141,GSM1612142,GSM1612143,GSM1612144,GSM1612145,GSM1612146,GSM1612147,GSM1612148,GSM1612149,GSM1612150,GSM1612151
2
+ 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,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
3
+ 64.0,57.0,59.0,50.0,52.0,66.0,67.0,37.0,53.0,46.0,57.0,51.0,55.0,39.0,71.0,54.0,64.0,53.0,45.0,80.0,55.0,64.0,74.0,67.0,39.0,43.0,39.0,49.0,61.0,64.0,61.0,32.0,69.0,45.0,52.0,74.0,33.0,41.0,71.0,67.0,58.0,58.0,44.0,56.0,56.0,69.0,49.0,74.0,56.0,58.0,68.0,64.0,63.0,38.0,62.0
p1/preprocess/Endometrioid_Cancer/clinical_data/GSE66667.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ GSM1627456,GSM1627457,GSM1627458,GSM1627459,GSM1627460,GSM1627461,GSM1627462,GSM1627463,GSM1627464,GSM1627465,GSM1627466,GSM1627467,GSM1627468,GSM1627469,GSM1627470,GSM1627471,GSM1627472,GSM1627473,GSM1627474,GSM1627475,GSM1627476,GSM1627477,GSM1627478,GSM1627479,GSM1627480,GSM1627481,GSM1627482,GSM1627483,GSM1627484,GSM1627485,GSM1627486,GSM1627487,GSM1627488,GSM1627489,GSM1627490,GSM1627491
2
+ 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
p1/preprocess/Endometrioid_Cancer/clinical_data/GSE68600.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ GSM1676602,GSM1676603,GSM1676604,GSM1676605,GSM1676606,GSM1676607,GSM1676608,GSM1676609,GSM1676610,GSM1676611,GSM1676612,GSM1676613,GSM1676614,GSM1676615,GSM1676616,GSM1676617,GSM1676618,GSM1676619,GSM1676620,GSM1676621,GSM1676622,GSM1676623,GSM1676624,GSM1676625,GSM1676626,GSM1676627,GSM1676628,GSM1676629,GSM1676630,GSM1676631,GSM1676632,GSM1676633,GSM1676634,GSM1676635,GSM1676636,GSM1676637,GSM1676638,GSM1676639,GSM1676640,GSM1676641,GSM1676642,GSM1676643,GSM1676644,GSM1676645,GSM1676646,GSM1676647,GSM1676648,GSM1676649,GSM1676650,GSM1676651,GSM1676652,GSM1676653,GSM1676654,GSM1676655,GSM1676656,GSM1676657,GSM1676658,GSM1676659,GSM1676660,GSM1676661,GSM1676662,GSM1676663,GSM1676664,GSM1676665,GSM1676666,GSM1676667,GSM1676668,GSM1676669,GSM1676670,GSM1676671,GSM1676672,GSM1676673,GSM1676674,GSM1676675,GSM1676676,GSM1676677,GSM1676678,GSM1676679,GSM1676680,GSM1676681,GSM1676682,GSM1676683,GSM1676684,GSM1676685,GSM1676686,GSM1676687,GSM1676688,GSM1676689,GSM1676690,GSM1676691,GSM1676692,GSM1676693,GSM1676694,GSM1676695,GSM1676696,GSM1676697,GSM1676698,GSM1676699,GSM1676700,GSM1676701,GSM1676702,GSM1676703,GSM1676704,GSM1676705,GSM1676706,GSM1676707,GSM1676708,GSM1676709,GSM1676710,GSM1676711,GSM1676712,GSM1676713,GSM1676714
2
+ 0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,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,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0
p1/preprocess/Endometrioid_Cancer/clinical_data/GSE73551.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ GSM1897741,GSM1897744,GSM1897746,GSM1897748,GSM1897750,GSM1897752,GSM1897753,GSM1897755,GSM1897757,GSM1897759,GSM1897761,GSM1897763,GSM1897765,GSM1897767,GSM1897769,GSM1897770,GSM1897772,GSM1897774,GSM1897776,GSM1897778,GSM1897780,GSM1897782,GSM1897784,GSM1897786,GSM1897787,GSM1897789,GSM1897792,GSM1897794,GSM1897795,GSM1897797,GSM1897799,GSM1897801,GSM1897802,GSM1897804,GSM1897806,GSM1897808,GSM1897810,GSM1897812,GSM1897814,GSM1897816,GSM1897818,GSM1897820,GSM1897822,GSM1897823,GSM1897825,GSM1897827,GSM1897829,GSM1897831,GSM1897833,GSM1897835
2
+ 0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
p1/preprocess/Endometrioid_Cancer/clinical_data/GSE73637.csv ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17
2
+ 0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,,,,,,,,
p1/preprocess/Endometrioid_Cancer/code/GSE120490.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE120490"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE120490"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE120490.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE120490.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE120490.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Gene Expression Data Availability
37
+ is_gene_available = True # Based on "transcriptomic analysis using the Affymetrix U133 Plus 2.0 microarray platform"
38
+
39
+ # 2. Variable Availability and Conversion
40
+ # This dataset does not provide any row for trait, age, or gender.
41
+ # So all row indicators are None.
42
+ trait_row = None
43
+ age_row = None
44
+ gender_row = None
45
+
46
+ # Define dummy conversion functions, since none of these variables is available.
47
+ def convert_trait(value: str):
48
+ return None
49
+
50
+ def convert_age(value: str):
51
+ return None
52
+
53
+ def convert_gender(value: str):
54
+ return None
55
+
56
+ # 3. Save Metadata (Initial Filtering)
57
+ is_trait_available = (trait_row is not None)
58
+ validate_and_save_cohort_info(
59
+ is_final=False,
60
+ cohort=cohort,
61
+ info_path=json_path,
62
+ is_gene_available=is_gene_available,
63
+ is_trait_available=is_trait_available
64
+ )
65
+
66
+ # 4. Since trait_row is None, we skip clinical feature extraction.
67
+ # STEP3
68
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
69
+ gene_data = get_genetic_data(matrix_file)
70
+
71
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
72
+ print(gene_data.index[:20])
73
+ print("requires_gene_mapping = True")
74
+ # STEP5
75
+ import pandas as pd
76
+ import io
77
+
78
+ # 1. Extract the lines that do NOT start with '^', '!', or '#', but do NOT parse them into a DataFrame yet.
79
+ annotation_text, _ = filter_content_by_prefix(
80
+ source=soft_file,
81
+ prefixes_a=['^', '!', '#'],
82
+ unselect=True,
83
+ source_type='file',
84
+ return_df_a=False,
85
+ return_df_b=False
86
+ )
87
+
88
+ # 2. Manually parse the filtered text into a DataFrame, specifying engine="python" to avoid buffer overflow issues.
89
+ gene_annotation = pd.read_csv(
90
+ io.StringIO(annotation_text),
91
+ delimiter='\t',
92
+ on_bad_lines='skip',
93
+ engine='python'
94
+ )
95
+
96
+ print("Gene annotation preview:")
97
+ print(preview_df(gene_annotation))
98
+ # STEP6: Gene Identifier Mapping
99
+
100
+ # 1. Identify the columns for gene IDs and gene symbols in the gene_annotation dataframe.
101
+ # From our observations, the "ID" column matches the row index of the gene_data expression,
102
+ # and the "Gene Symbol" column in the annotation holds the associated gene symbols.
103
+
104
+ # 2. Extract the mapping between probes and gene symbols and store it in mapping_df.
105
+ mapping_df = get_gene_mapping(gene_annotation, "ID", "Gene Symbol")
106
+
107
+ # 3. Apply the mapping to convert probe-level expression values into gene-level expression data.
108
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
109
+
110
+ # Confirm the resulting gene_data shape or a snippet if needed (commented out):
111
+ # print(gene_data.shape)
112
+ # print(gene_data.head())
113
+ import os
114
+ import pandas as pd
115
+
116
+ # STEP7
117
+
118
+ # 1) Normalize gene symbols and save
119
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
120
+ normalized_gene_data.to_csv(out_gene_data_file)
121
+
122
+ # Check whether we actually have a clinical CSV file (i.e., trait data) from Step 2
123
+ if os.path.exists(out_clinical_data_file):
124
+ # 2) Link the clinical and gene expression data
125
+ selected_clinical_df = pd.read_csv(out_clinical_data_file, index_col=0)
126
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
127
+
128
+ # 3) Handle missing values
129
+ final_data = handle_missing_values(linked_data, trait_col=trait)
130
+
131
+ # 4) Evaluate bias in the trait
132
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
133
+
134
+ # 5) Final validation (trait is available)
135
+ is_usable = validate_and_save_cohort_info(
136
+ is_final=True,
137
+ cohort=cohort,
138
+ info_path=json_path,
139
+ is_gene_available=True,
140
+ is_trait_available=True,
141
+ is_biased=trait_biased,
142
+ df=final_data,
143
+ note="Trait data successfully extracted in Step 2."
144
+ )
145
+
146
+ # 6) If the dataset is usable, save
147
+ if is_usable:
148
+ final_data.to_csv(out_data_file)
149
+
150
+ else:
151
+ # If the clinical file does not exist, the trait is unavailable
152
+ # Perform final validation indicating that we lack trait data
153
+ empty_df = pd.DataFrame()
154
+ validate_and_save_cohort_info(
155
+ is_final=True,
156
+ cohort=cohort,
157
+ info_path=json_path,
158
+ is_gene_available=True,
159
+ is_trait_available=False,
160
+ is_biased=True, # Arbitrary non-None to skip usage
161
+ df=empty_df,
162
+ note="No trait data was found; linking and final dataset output are skipped."
163
+ )
p1/preprocess/Endometrioid_Cancer/code/GSE40785.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE40785"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE40785"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE40785.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE40785.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE40785.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Determine if the dataset contains gene expression data
37
+ # Based on the series description, there are gene probes and expression profiling.
38
+ # So we conclude it likely has suitable gene expression data (not just miRNA or methylation).
39
+ is_gene_available = True
40
+
41
+ # 2. Determine availability of trait, age, and gender
42
+ # From the dictionary, we see various "histology:" entries at key=1, including "histology: Endometrioid".
43
+ # This indicates trait data is present (key=1). No mention of age or gender data was found in the dictionary.
44
+ trait_row = 1
45
+ age_row = None
46
+ gender_row = None
47
+
48
+ # 2.2 Data Type Conversion
49
+ # We'll define functions that convert the raw strings to appropriate data types.
50
+ # Trait: We'll treat "Endometrioid" or values containing "Endometrioid" as 1, and anything else as 0.
51
+ def convert_trait(value: str) -> Optional[int]:
52
+ if not isinstance(value, str):
53
+ return None
54
+ # Split on colon if present
55
+ parts = value.split(':', 1)
56
+ val = parts[-1].strip().lower() # value after colon, or the entire string if no colon
57
+ if 'endometrioid' in val:
58
+ return 1
59
+ elif 'histology' in val or 'mucinous' in val or 'clear cell' in val or 'serous' in val:
60
+ return 0
61
+ return None # for unknown cases
62
+
63
+ # Since we don't have age_row or gender_row, we only define simple converters returning None if called.
64
+ def convert_age(value: str) -> Optional[float]:
65
+ return None
66
+
67
+ def convert_gender(value: str) -> Optional[int]:
68
+ return None
69
+
70
+ # 3. Conduct initial filtering on dataset usability and save metadata
71
+ is_trait_available = (trait_row is not None)
72
+ is_usable_flag = validate_and_save_cohort_info(
73
+ is_final=False,
74
+ cohort=cohort,
75
+ info_path=json_path,
76
+ is_gene_available=is_gene_available,
77
+ is_trait_available=is_trait_available
78
+ )
79
+
80
+ # 4. Clinical Feature Extraction (only if trait_row is not None)
81
+ if trait_row is not None:
82
+ # Assume "clinical_data" is the DataFrame obtained previously
83
+ selected_clinical_df = geo_select_clinical_features(
84
+ clinical_data,
85
+ trait=trait,
86
+ trait_row=trait_row,
87
+ convert_trait=convert_trait,
88
+ age_row=age_row,
89
+ convert_age=convert_age,
90
+ gender_row=gender_row,
91
+ convert_gender=convert_gender
92
+ )
93
+ # Preview the selected clinical features
94
+ clinical_preview = preview_df(selected_clinical_df)
95
+ print("Preview of Clinical Features:", clinical_preview)
96
+
97
+ # Save the extracted clinical features to CSV
98
+ selected_clinical_df.to_csv(out_clinical_data_file, index=False)
99
+ # STEP3
100
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
101
+ gene_data = get_genetic_data(matrix_file)
102
+
103
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
104
+ print(gene_data.index[:20])
105
+ # Based on the given gene expression data indices (e.g., "ILMN_1343291"), these are Illumina probe IDs,
106
+ # not standard human gene symbols. Hence, gene mapping is required.
107
+ print("requires_gene_mapping = True")
108
+ # STEP5
109
+ import pandas as pd
110
+ import io
111
+
112
+ # 1. Extract the lines that do NOT start with '^', '!', or '#', but do NOT parse them into a DataFrame yet.
113
+ annotation_text, _ = filter_content_by_prefix(
114
+ source=soft_file,
115
+ prefixes_a=['^', '!', '#'],
116
+ unselect=True,
117
+ source_type='file',
118
+ return_df_a=False,
119
+ return_df_b=False
120
+ )
121
+
122
+ # 2. Manually parse the filtered text into a DataFrame, specifying engine="python" to avoid buffer overflow issues.
123
+ gene_annotation = pd.read_csv(
124
+ io.StringIO(annotation_text),
125
+ delimiter='\t',
126
+ on_bad_lines='skip',
127
+ engine='python'
128
+ )
129
+
130
+ print("Gene annotation preview:")
131
+ print(preview_df(gene_annotation))
132
+ # STEP: Gene Identifier Mapping
133
+
134
+ # 1 & 2. Determine columns for probe IDs ("ID") and gene symbols ("Symbol") from our annotation.
135
+ # Then extract a gene mapping DataFrame with two columns: [ID, Gene].
136
+ mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
137
+
138
+ # 3. Convert probe-level measurements to gene-level expression using the mapping.
139
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
140
+
141
+ # (Optional) Let's preview and then save the resulting gene-level expression data.
142
+ print("Preview of gene-level expression data:", preview_df(gene_data))
143
+ gene_data.to_csv(out_gene_data_file)
144
+ import pandas as pd
145
+
146
+ # STEP7
147
+
148
+ # 1) Normalize gene symbols and save
149
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
150
+ normalized_gene_data.to_csv(out_gene_data_file)
151
+
152
+ # Read back the clinical dataframe saved in Step 2.
153
+ # According to Step 2, we saved 1 row (the trait) × N columns (the samples) without the row index.
154
+ selected_clinical_df = pd.read_csv(out_clinical_data_file) # shape: (1, number_of_samples)
155
+ # Rename the row index to the trait (e.g., "Eczema")
156
+ selected_clinical_df.index = [trait]
157
+
158
+ # 2) Link the clinical and gene expression data
159
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
160
+
161
+ # 3) Handle missing values using the trait column
162
+ final_data = handle_missing_values(linked_data, trait_col=trait)
163
+
164
+ # 4) Evaluate bias in the trait (and remove biased demographic features if they existed)
165
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
166
+
167
+ # 5) Final validation. Since we do have trait data, set is_trait_available=True
168
+ is_usable = validate_and_save_cohort_info(
169
+ is_final=True,
170
+ cohort=cohort,
171
+ info_path=json_path,
172
+ is_gene_available=True,
173
+ is_trait_available=True,
174
+ is_biased=trait_biased,
175
+ df=final_data,
176
+ note="Trait data successfully extracted from Step 2."
177
+ )
178
+
179
+ # 6) If the dataset is deemed usable, save final linked data
180
+ if is_usable:
181
+ final_data.to_csv(out_data_file)
p1/preprocess/Endometrioid_Cancer/code/GSE65986.py ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE65986"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE65986"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE65986.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE65986.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE65986.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Determine if gene expression data is available
37
+ # From the background info: "Gene expression ... was analyzed by Affymetrix U133plus2 array."
38
+ # Hence, it is gene expression rather than miRNA or methylation data.
39
+ is_gene_available = True
40
+
41
+ # 2. Identify data availability for trait, age, gender, and define conversion functions
42
+
43
+ # Observed keys in the sample characteristics dictionary:
44
+ # 0 -> histology: [Clear, Endometrioid, Serous]
45
+ # 1 -> age: [64, 57, ...]
46
+ # 2 -> Stage: ...
47
+ # 3 -> pfs: ...
48
+ # 4 -> prognosis: ...
49
+ # There is no key containing gender data, and it is likely all female since this is an ovarian cancer study.
50
+
51
+ trait_row = 0 # row 0 has multiple values including "Endometrioid", so it is not constant and is relevant to our trait.
52
+ age_row = 1 # row 1 has multiple age values, so it is valid.
53
+ gender_row = None # no gender info is available or it is constant (all female), so treat as not available.
54
+
55
+ def convert_trait(value: str):
56
+ """Convert the 'histology' entries to a binary trait.
57
+ 'Endometrioid' -> 1, others -> 0."""
58
+ val = value.split(':')[-1].strip().lower()
59
+ if val == 'endometrioid':
60
+ return 1
61
+ elif val in ['clear', 'serous']:
62
+ return 0
63
+ return None # unknown or unexpected text
64
+
65
+ def convert_age(value: str):
66
+ """Convert 'age' entries to a continuous numeric type."""
67
+ val = value.split(':')[-1].strip()
68
+ try:
69
+ return float(val)
70
+ except:
71
+ return None
72
+
73
+ def convert_gender(value: str):
74
+ """Convert 'gender' entries to binary: female->0, male->1.
75
+ Although not used here, define for completeness."""
76
+ val = value.split(':')[-1].strip().lower()
77
+ if val == 'female':
78
+ return 0
79
+ elif val == 'male':
80
+ return 1
81
+ return None
82
+
83
+ # 3. Save metadata after initial filtering
84
+ is_trait_available = (trait_row is not None)
85
+ is_usable = validate_and_save_cohort_info(
86
+ is_final=False,
87
+ cohort=cohort,
88
+ info_path=json_path,
89
+ is_gene_available=is_gene_available,
90
+ is_trait_available=is_trait_available
91
+ )
92
+
93
+ # 4. Clinical feature extraction if trait data is available
94
+ if trait_row is not None:
95
+ selected_clinical_df = geo_select_clinical_features(
96
+ clinical_data, # clinical_data is assumed to be already loaded from a previous step
97
+ trait,
98
+ trait_row,
99
+ convert_trait,
100
+ age_row=age_row,
101
+ convert_age=convert_age,
102
+ gender_row=gender_row,
103
+ convert_gender=convert_gender
104
+ )
105
+ # Preview and save
106
+ print("Preview of selected clinical features:\n", preview_df(selected_clinical_df))
107
+ selected_clinical_df.to_csv(out_clinical_data_file, index=False)
108
+ # STEP3
109
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
110
+ gene_data = get_genetic_data(matrix_file)
111
+
112
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
113
+ print(gene_data.index[:20])
114
+ # These IDs are Affymetrix probe set identifiers, not standard gene symbols.
115
+ # They require mapping to gene symbols.
116
+
117
+ print("requires_gene_mapping = True")
118
+ # STEP5
119
+ import pandas as pd
120
+ import io
121
+
122
+ # 1. Extract the lines that do NOT start with '^', '!', or '#', but do NOT parse them into a DataFrame yet.
123
+ annotation_text, _ = filter_content_by_prefix(
124
+ source=soft_file,
125
+ prefixes_a=['^', '!', '#'],
126
+ unselect=True,
127
+ source_type='file',
128
+ return_df_a=False,
129
+ return_df_b=False
130
+ )
131
+
132
+ # 2. Manually parse the filtered text into a DataFrame, specifying engine="python" to avoid buffer overflow issues.
133
+ gene_annotation = pd.read_csv(
134
+ io.StringIO(annotation_text),
135
+ delimiter='\t',
136
+ on_bad_lines='skip',
137
+ engine='python'
138
+ )
139
+
140
+ print("Gene annotation preview:")
141
+ print(preview_df(gene_annotation))
142
+ # STEP: Gene Identifier Mapping
143
+
144
+ # 1. Identify the corresponding columns in the annotation dataframe for probe IDs and gene symbols
145
+ probe_col = "ID"
146
+ gene_symbol_col = "Gene Symbol"
147
+
148
+ # 2. Get the gene mapping dataframe
149
+ mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
150
+
151
+ # 3. Convert probe-level measurements to gene expression data
152
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
153
+
154
+ # (Optional) Print shape and preview if desired
155
+ print("Mapped gene_data dimensions:", gene_data.shape)
156
+ print("Preview of mapped gene_data:\n", gene_data.iloc[:5, :5])
157
+ import pandas as pd
158
+
159
+ # STEP7
160
+
161
+ # 1) Normalize gene symbols and save
162
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
163
+ normalized_gene_data.to_csv(out_gene_data_file)
164
+
165
+ # 2) Read the clinical dataframe with header=0 to ensure the first row is recognized as column headers,
166
+ # leaving two rows of data to be indexed as [trait, "Age"].
167
+ selected_clinical_df = pd.read_csv(out_clinical_data_file, header=0)
168
+ selected_clinical_df.index = [trait, "Age"]
169
+
170
+ # 3) Link the clinical and gene expression data
171
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
172
+
173
+ # 4) Handle missing values using the trait column
174
+ final_data = handle_missing_values(linked_data, trait_col=trait)
175
+
176
+ # 5) Evaluate bias in the trait (and remove biased demographic features if they existed)
177
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
178
+
179
+ # 6) Final validation. Since we do have trait data, set is_trait_available=True
180
+ is_usable = validate_and_save_cohort_info(
181
+ is_final=True,
182
+ cohort=cohort,
183
+ info_path=json_path,
184
+ is_gene_available=True,
185
+ is_trait_available=True,
186
+ is_biased=trait_biased,
187
+ df=final_data,
188
+ note="Trait and Age data in the first two rows of the clinical CSV."
189
+ )
190
+
191
+ # 7) If the dataset is deemed usable, save final linked data
192
+ if is_usable:
193
+ final_data.to_csv(out_data_file)
p1/preprocess/Endometrioid_Cancer/code/GSE66667.py ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE66667"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE66667"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE66667.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE66667.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE66667.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Gene Expression Data Availability
37
+ # From the background info, microarrays were used to measure global gene expression, so:
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # The sample characteristics dictionary reveals that 'histology' (key=0) varies
42
+ # and includes "Endometrioid". Hence we use key 0 as trait_row.
43
+ # No age or gender info is present, so set those to None.
44
+
45
+ trait_row = 0
46
+ age_row = None
47
+ gender_row = None
48
+
49
+ def convert_trait(value: str) -> Optional[int]:
50
+ """
51
+ Convert the histology field to a binary indicator:
52
+ 1 if it matches 'Endometrioid', otherwise 0.
53
+ Unknown values => None (not expected here, but safe fallback).
54
+ """
55
+ parts = value.split(":", 1)
56
+ val = parts[1].strip() if len(parts) > 1 else value
57
+ if "endometrioid" in val.lower():
58
+ return 1
59
+ else:
60
+ return 0
61
+
62
+ # Age and gender are not available
63
+ convert_age = None
64
+ convert_gender = None
65
+
66
+ # Determine if trait data is available
67
+ is_trait_available = (trait_row is not None)
68
+
69
+ # 3. Save Metadata (initial filtering)
70
+ validate_and_save_cohort_info(
71
+ is_final=False,
72
+ cohort=cohort,
73
+ info_path=json_path,
74
+ is_gene_available=is_gene_available,
75
+ is_trait_available=is_trait_available
76
+ )
77
+
78
+ # 4. Clinical Feature Extraction (only if trait data is available)
79
+ if trait_row is not None:
80
+ df_clinical_selected = geo_select_clinical_features(
81
+ clinical_data,
82
+ trait,
83
+ trait_row,
84
+ convert_trait,
85
+ age_row,
86
+ convert_age,
87
+ gender_row,
88
+ convert_gender
89
+ )
90
+ # Preview and save
91
+ preview_result = preview_df(df_clinical_selected)
92
+ print("Clinical features preview:", preview_result)
93
+
94
+ df_clinical_selected.to_csv(out_clinical_data_file, index=False)
95
+ # STEP3
96
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
97
+ gene_data = get_genetic_data(matrix_file)
98
+
99
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
100
+ print(gene_data.index[:20])
101
+ # Based on the given probe IDs (e.g., "1007_s_at", "1053_at"), they appear to be Affymetrix probe set IDs
102
+ # (or similar microarray probe identifiers). These are not standard human gene symbols and therefore
103
+ # require mapping to gene symbols.
104
+
105
+ print("requires_gene_mapping = True")
106
+ # STEP5
107
+ import pandas as pd
108
+ import io
109
+
110
+ # 1. Extract the lines that do NOT start with '^', '!', or '#', but do NOT parse them into a DataFrame yet.
111
+ annotation_text, _ = filter_content_by_prefix(
112
+ source=soft_file,
113
+ prefixes_a=['^', '!', '#'],
114
+ unselect=True,
115
+ source_type='file',
116
+ return_df_a=False,
117
+ return_df_b=False
118
+ )
119
+
120
+ # 2. Manually parse the filtered text into a DataFrame, specifying engine="python" to avoid buffer overflow issues.
121
+ gene_annotation = pd.read_csv(
122
+ io.StringIO(annotation_text),
123
+ delimiter='\t',
124
+ on_bad_lines='skip',
125
+ engine='python'
126
+ )
127
+
128
+ print("Gene annotation preview:")
129
+ print(preview_df(gene_annotation))
130
+ # STEP: Gene Identifier Mapping
131
+
132
+ # 1. Determine the columns corresponding to the probe IDs ("ID") and gene symbols ("Gene Symbol").
133
+ # From the preview, the annotation column for the microarray IDs is "ID",
134
+ # and the column for gene symbols is "Gene Symbol".
135
+
136
+ prob_col = "ID"
137
+ gene_col = "Gene Symbol"
138
+
139
+ # 2. Build a gene mapping dataframe from the annotation
140
+ mapping_df = get_gene_mapping(gene_annotation, prob_col=prob_col, gene_col=gene_col)
141
+
142
+ # 3. Convert probe-level measurements to gene-level expression using the mapping
143
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
144
+
145
+ # Print some basic info about the new gene_data
146
+ print("Mapped gene expression data shape:", gene_data.shape)
147
+ print("First few gene IDs after mapping:", gene_data.index[:10])
148
+ import pandas as pd
149
+
150
+ # STEP7
151
+
152
+ # 1) Normalize gene symbols and save
153
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
154
+ normalized_gene_data.to_csv(out_gene_data_file)
155
+
156
+ # Read back the clinical dataframe saved in Step 2.
157
+ # According to Step 2, we saved 1 row (the trait) × N columns (the samples) without the row index.
158
+ selected_clinical_df = pd.read_csv(out_clinical_data_file) # shape: (1, number_of_samples)
159
+ # Rename the row index to the trait (e.g., "Eczema")
160
+ selected_clinical_df.index = [trait]
161
+
162
+ # 2) Link the clinical and gene expression data
163
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
164
+
165
+ # 3) Handle missing values using the trait column
166
+ final_data = handle_missing_values(linked_data, trait_col=trait)
167
+
168
+ # 4) Evaluate bias in the trait (and remove biased demographic features if they existed)
169
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
170
+
171
+ # 5) Final validation. Since we do have trait data, set is_trait_available=True
172
+ is_usable = validate_and_save_cohort_info(
173
+ is_final=True,
174
+ cohort=cohort,
175
+ info_path=json_path,
176
+ is_gene_available=True,
177
+ is_trait_available=True,
178
+ is_biased=trait_biased,
179
+ df=final_data,
180
+ note="Trait data successfully extracted from Step 2."
181
+ )
182
+
183
+ # 6) If the dataset is deemed usable, save final linked data
184
+ if is_usable:
185
+ final_data.to_csv(out_data_file)
p1/preprocess/Endometrioid_Cancer/code/GSE68600.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE68600"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE68600"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE68600.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE68600.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE68600.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Gene Expression Data Availability
37
+ is_gene_available = True # "Assay Type: Gene Expression" indicates gene expression data is likely present.
38
+
39
+ # 2. Variable Availability and Data Type Conversion
40
+ # Observing the sample characteristics dictionary:
41
+ # - trait ("Endometrioid_Cancer") can be inferred from row 4 (histology).
42
+ # - age is not found => age_row = None.
43
+ # - gender appears to be uniformly female => no variability => gender_row = None.
44
+
45
+ trait_row = 4
46
+ age_row = None
47
+ gender_row = None
48
+
49
+ # Define data-conversion functions:
50
+ def convert_trait(sample_value: str):
51
+ """
52
+ Convert sample_value into a binary representation:
53
+ 1 if 'endometrioid' is found in the histology,
54
+ 0 if it is any other histology,
55
+ None if it can't be parsed.
56
+ """
57
+ parts = sample_value.split(':', 1)
58
+ if len(parts) < 2:
59
+ return None
60
+ val = parts[1].strip().lower()
61
+ # Mark samples with 'endometrioid' as 1, all others as 0
62
+ if 'endometrioid' in val:
63
+ return 1
64
+ else:
65
+ return 0
66
+
67
+ def convert_age(sample_value: str):
68
+ # Age data is not available in this dataset, so return None
69
+ return None
70
+
71
+ def convert_gender(sample_value: str):
72
+ # Gender is uniformly female, so it's not useful for analysis. Return None.
73
+ return None
74
+
75
+ # Determine whether trait data is available
76
+ is_trait_available = (trait_row is not None)
77
+
78
+ # 3. Save Metadata (Initial Filtering)
79
+ dataset_passed_filtering = validate_and_save_cohort_info(
80
+ is_final=False,
81
+ cohort=cohort,
82
+ info_path=json_path,
83
+ is_gene_available=is_gene_available,
84
+ is_trait_available=is_trait_available
85
+ )
86
+
87
+ # 4. Clinical Feature Extraction (only if trait data is available)
88
+ if trait_row is not None:
89
+ # 'clinical_data' is assumed to be the DataFrame containing the sample characteristics
90
+ selected_clinical_df = geo_select_clinical_features(
91
+ clinical_df=clinical_data,
92
+ trait=trait,
93
+ trait_row=trait_row,
94
+ convert_trait=convert_trait,
95
+ age_row=age_row,
96
+ convert_age=convert_age,
97
+ gender_row=gender_row,
98
+ convert_gender=convert_gender
99
+ )
100
+
101
+ # Preview the extracted clinical data
102
+ print(preview_df(selected_clinical_df))
103
+
104
+ # Save the extracted clinical features to CSV
105
+ selected_clinical_df.to_csv(out_clinical_data_file, index=False)
106
+ # STEP3
107
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
108
+ gene_data = get_genetic_data(matrix_file)
109
+
110
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
111
+ print(gene_data.index[:20])
112
+ # Based on the identifiers, these appear to be Affymetrix probe IDs rather than standard gene symbols.
113
+ # Therefore, they require mapping to gene symbols.
114
+ requires_gene_mapping = True
115
+ # STEP5
116
+ import pandas as pd
117
+ import io
118
+
119
+ # 1. Extract the lines that do NOT start with '^', '!', or '#', but do NOT parse them into a DataFrame yet.
120
+ annotation_text, _ = filter_content_by_prefix(
121
+ source=soft_file,
122
+ prefixes_a=['^', '!', '#'],
123
+ unselect=True,
124
+ source_type='file',
125
+ return_df_a=False,
126
+ return_df_b=False
127
+ )
128
+
129
+ # 2. Manually parse the filtered text into a DataFrame, specifying engine="python" to avoid buffer overflow issues.
130
+ gene_annotation = pd.read_csv(
131
+ io.StringIO(annotation_text),
132
+ delimiter='\t',
133
+ on_bad_lines='skip',
134
+ engine='python'
135
+ )
136
+
137
+ print("Gene annotation preview:")
138
+ print(preview_df(gene_annotation))
139
+ # Gene Identifier Mapping
140
+ prob_col = 'ID'
141
+ gene_col = 'Gene Symbol'
142
+
143
+ # 1 & 2. Identify the columns for the probe IDs and gene symbols, then retrieve the mapping dataframe
144
+ mapping_df = get_gene_mapping(gene_annotation, prob_col=prob_col, gene_col=gene_col)
145
+
146
+ # 3. Convert probe-level data to gene-level data
147
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
148
+
149
+ # (Optional) Print a brief preview of the mapped gene_data
150
+ print("Mapped gene expression data shape:", gene_data.shape)
151
+ print("First 5 genes:\n", gene_data.head(5))
152
+ import pandas as pd
153
+
154
+ # STEP7
155
+
156
+ # 1) Normalize gene symbols and save
157
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
158
+ normalized_gene_data.to_csv(out_gene_data_file)
159
+
160
+ # Read back the clinical dataframe saved in Step 2.
161
+ # According to Step 2, we saved 1 row (the trait) × N columns (the samples) without the row index.
162
+ selected_clinical_df = pd.read_csv(out_clinical_data_file) # shape: (1, number_of_samples)
163
+ # Rename the row index to the trait (e.g., "Eczema")
164
+ selected_clinical_df.index = [trait]
165
+
166
+ # 2) Link the clinical and gene expression data
167
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
168
+
169
+ # 3) Handle missing values using the trait column
170
+ final_data = handle_missing_values(linked_data, trait_col=trait)
171
+
172
+ # 4) Evaluate bias in the trait (and remove biased demographic features if they existed)
173
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
174
+
175
+ # 5) Final validation. Since we do have trait data, set is_trait_available=True
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=final_data,
184
+ note="Trait data successfully extracted from Step 2."
185
+ )
186
+
187
+ # 6) If the dataset is deemed usable, save final linked data
188
+ if is_usable:
189
+ final_data.to_csv(out_data_file)
p1/preprocess/Endometrioid_Cancer/code/GSE73551.py ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE73551"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE73551"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE73551.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE73551.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE73551.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Gene Expression Data Availability
37
+ # Based on the background information, this dataset is likely gene expression data
38
+ is_gene_available = True
39
+
40
+ # 2. Variable Availability and Data Type Conversion
41
+ # From the sample characteristics, row 0 has multiple "cell type" entries
42
+ # that include "ENDOMETRIOID". We'll treat that as the trait row for Endometrioid_Cancer.
43
+ trait_row = 0
44
+
45
+ # No age or gender information is available or inferred from the sample characteristics
46
+ age_row = None
47
+ gender_row = None
48
+
49
+ # For the trait, we convert "ENDOMETRIOID" to 1 and all other cell types to 0.
50
+ def convert_trait(value: str):
51
+ parts = value.split(':', 1)
52
+ val = parts[1].strip().lower() if len(parts) > 1 else parts[0].strip().lower()
53
+ return 1 if val == "endometrioid" else 0
54
+
55
+ # Since age and gender data are not available, these functions will return None.
56
+ def convert_age(value: str):
57
+ return None
58
+
59
+ def convert_gender(value: str):
60
+ return None
61
+
62
+ # 3. Save Metadata (Initial filtering)
63
+ is_trait_available = (trait_row is not None)
64
+ validate_and_save_cohort_info(
65
+ is_final=False,
66
+ cohort=cohort,
67
+ info_path=json_path,
68
+ is_gene_available=is_gene_available,
69
+ is_trait_available=is_trait_available
70
+ )
71
+
72
+ # 4. Clinical Feature Extraction (only if trait data is available)
73
+ if trait_row is not None:
74
+ selected_clinical_df = geo_select_clinical_features(
75
+ clinical_df=clinical_data,
76
+ trait=trait,
77
+ trait_row=trait_row,
78
+ convert_trait=convert_trait,
79
+ age_row=age_row,
80
+ convert_age=convert_age,
81
+ gender_row=gender_row,
82
+ convert_gender=convert_gender
83
+ )
84
+
85
+ # Preview the selected clinical features
86
+ preview = preview_df(selected_clinical_df)
87
+ print("Preview of selected clinical features:", preview)
88
+
89
+ # Save extracted clinical features to CSV
90
+ selected_clinical_df.to_csv(out_clinical_data_file, index=False)
91
+ # STEP3
92
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
93
+ gene_data = get_genetic_data(matrix_file)
94
+
95
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
96
+ print(gene_data.index[:20])
97
+ # Based on the listed identifiers (1,2,3, etc.), they are not standard human gene symbols.
98
+ # These identifiers likely need to be mapped to recognized gene symbols.
99
+ print("requires_gene_mapping = True")
100
+ # STEP5
101
+ import pandas as pd
102
+ import io
103
+
104
+ # 1. Extract the lines that do NOT start with '^', '!', or '#', but do NOT parse them into a DataFrame yet.
105
+ annotation_text, _ = filter_content_by_prefix(
106
+ source=soft_file,
107
+ prefixes_a=['^', '!', '#'],
108
+ unselect=True,
109
+ source_type='file',
110
+ return_df_a=False,
111
+ return_df_b=False
112
+ )
113
+
114
+ # 2. Manually parse the filtered text into a DataFrame, specifying engine="python" to avoid buffer overflow issues.
115
+ gene_annotation = pd.read_csv(
116
+ io.StringIO(annotation_text),
117
+ delimiter='\t',
118
+ on_bad_lines='skip',
119
+ engine='python'
120
+ )
121
+
122
+ print("Gene annotation preview:")
123
+ print(preview_df(gene_annotation))
124
+ # STEP: Gene Identifier Mapping
125
+
126
+ # 1 & 2. Identify the columns in the gene_annotation that correspond to the gene expression row IDs ("ID")
127
+ # and the human gene symbols ("GeneSymbol"). Extract them into a mapping dataframe.
128
+ mapping_df = get_gene_mapping(
129
+ annotation=gene_annotation,
130
+ prob_col='ID', # Matches the row IDs in our gene_data
131
+ gene_col='GeneSymbol' # Stores the human gene symbols
132
+ )
133
+
134
+ # 3. Convert probe-level measurements to gene-level expression data using apply_gene_mapping
135
+ gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
136
+
137
+ # Just display the first few rows for observation
138
+ print(gene_data.head(5))
139
+ import pandas as pd
140
+
141
+ # STEP7
142
+
143
+ # 1) Normalize gene symbols and save
144
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
145
+ normalized_gene_data.to_csv(out_gene_data_file)
146
+
147
+ # Read back the clinical dataframe saved in Step 2.
148
+ # According to Step 2, we saved 1 row (the trait) × N columns (the samples) without the row index.
149
+ selected_clinical_df = pd.read_csv(out_clinical_data_file) # shape: (1, number_of_samples)
150
+ # Rename the row index to the trait (e.g., "Eczema")
151
+ selected_clinical_df.index = [trait]
152
+
153
+ # 2) Link the clinical and gene expression data
154
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
155
+
156
+ # 3) Handle missing values using the trait column
157
+ final_data = handle_missing_values(linked_data, trait_col=trait)
158
+
159
+ # 4) Evaluate bias in the trait (and remove biased demographic features if they existed)
160
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
161
+
162
+ # 5) Final validation. Since we do have trait data, set is_trait_available=True
163
+ is_usable = validate_and_save_cohort_info(
164
+ is_final=True,
165
+ cohort=cohort,
166
+ info_path=json_path,
167
+ is_gene_available=True,
168
+ is_trait_available=True,
169
+ is_biased=trait_biased,
170
+ df=final_data,
171
+ note="Trait data successfully extracted from Step 2."
172
+ )
173
+
174
+ # 6) If the dataset is deemed usable, save final linked data
175
+ if is_usable:
176
+ final_data.to_csv(out_data_file)
p1/preprocess/Endometrioid_Cancer/code/GSE73614.py ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE73614"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE73614"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE73614.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE73614.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE73614.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Determine if the dataset contains gene expression data
37
+ is_gene_available = True # Based on background info describing transcriptional profiling
38
+
39
+ # 2. Identify the availability of trait, age, and gender
40
+ # From the sample characteristics dictionary, we only see {0: ['tissue: ovarian']}.
41
+ # This has no variation (same value for all samples) and does not provide the Endometrioid_Cancer distinction.
42
+ # Hence, there's no useful variable for trait, age, or gender.
43
+ trait_row = None
44
+ age_row = None
45
+ gender_row = None
46
+
47
+ # 2.2. Define type-conversion functions.
48
+ def convert_trait(value: str) -> Optional[int]:
49
+ """
50
+ Binary conversion for 'Endometrioid_Cancer':
51
+ Return 1 if the value indicates endometrioid, 0 if indicates something else,
52
+ None if unknown.
53
+ """
54
+ parts = value.split(':', 1)
55
+ val = parts[-1].strip().lower() if len(parts) > 1 else value.strip().lower()
56
+ if 'endometrioid' in val:
57
+ return 1
58
+ elif 'serous' in val or 'clear' in val or 'ovarian' in val:
59
+ return 0
60
+ return None
61
+
62
+ def convert_age(value: str) -> Optional[float]:
63
+ """
64
+ Continuous conversion for age:
65
+ Try to parse a number from the string, return None if parsing fails.
66
+ """
67
+ parts = value.split(':', 1)
68
+ val_str = parts[-1].strip() if len(parts) > 1 else value.strip()
69
+ try:
70
+ return float(val_str)
71
+ except ValueError:
72
+ return None
73
+
74
+ def convert_gender(value: str) -> Optional[int]:
75
+ """
76
+ Binary conversion for gender:
77
+ Return 0 for female, 1 for male, None if unknown.
78
+ """
79
+ parts = value.split(':', 1)
80
+ val = parts[-1].strip().lower() if len(parts) > 1 else value.strip().lower()
81
+ if val in ['female', 'f']:
82
+ return 0
83
+ elif val in ['male', 'm']:
84
+ return 1
85
+ return None
86
+
87
+ # 3. Conduct initial filtering and save metadata
88
+ is_trait_available = (trait_row is not None)
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=is_trait_available
95
+ )
96
+
97
+ # 4. Since trait_row is None, we skip the clinical feature extraction step
98
+ # STEP3
99
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
100
+ gene_data = get_genetic_data(matrix_file)
101
+
102
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
103
+ print(gene_data.index[:20])
104
+ requires_gene_mapping = True
105
+ # STEP5
106
+ import pandas as pd
107
+ import io
108
+
109
+ # 1. Extract the lines that do NOT start with '^', '!', or '#', but do NOT parse them into a DataFrame yet.
110
+ annotation_text, _ = filter_content_by_prefix(
111
+ source=soft_file,
112
+ prefixes_a=['^', '!', '#'],
113
+ unselect=True,
114
+ source_type='file',
115
+ return_df_a=False,
116
+ return_df_b=False
117
+ )
118
+
119
+ # 2. Manually parse the filtered text into a DataFrame, specifying engine="python" to avoid buffer overflow issues.
120
+ gene_annotation = pd.read_csv(
121
+ io.StringIO(annotation_text),
122
+ delimiter='\t',
123
+ on_bad_lines='skip',
124
+ engine='python'
125
+ )
126
+
127
+ print("Gene annotation preview:")
128
+ print(preview_df(gene_annotation))
129
+ # STEP: Gene Identifier Mapping
130
+
131
+ # 1. Determine which columns match the gene expression dataset and the gene symbols
132
+ probe_col = "ID"
133
+ symbol_col = "GENE_SYMBOL"
134
+
135
+ # 2. Extract the gene identifier and gene symbol columns to form a mapping dataframe
136
+ mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=symbol_col)
137
+
138
+ # 3. Convert the probe-level expression data to gene-level expression data
139
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
140
+
141
+ print("Gene mapping completed. Final gene_data shape:", gene_data.shape)
142
+ import os
143
+ import pandas as pd
144
+
145
+ # STEP7
146
+
147
+ # 1) Normalize gene symbols in our gene_data and save the result
148
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
149
+ normalized_gene_data.to_csv(out_gene_data_file)
150
+
151
+ # 2) Check if the clinical data file (trait data) exists
152
+ if not os.path.exists(out_clinical_data_file):
153
+ print(f"File not found: {out_clinical_data_file}. No trait data is available for this cohort.")
154
+ # Perform an initial/partial validation because trait data is missing
155
+ is_usable = validate_and_save_cohort_info(
156
+ is_final=False,
157
+ cohort=cohort,
158
+ info_path=json_path,
159
+ is_gene_available=True,
160
+ is_trait_available=False
161
+ )
162
+ else:
163
+ # 3) Trait data is present, so read it and link with gene data
164
+ selected_clinical_df = pd.read_csv(out_clinical_data_file)
165
+ # Rename the single row index to match the trait name
166
+ selected_clinical_df.index = [trait]
167
+
168
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
169
+
170
+ # 4) Handle missing values, using the trait column name
171
+ final_data = handle_missing_values(linked_data, trait_col=trait)
172
+
173
+ # 5) Check whether the trait (and optional demographics) are severely biased
174
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
175
+
176
+ # 6) Conduct final validation
177
+ is_usable = validate_and_save_cohort_info(
178
+ is_final=True,
179
+ cohort=cohort,
180
+ info_path=json_path,
181
+ is_gene_available=True,
182
+ is_trait_available=True,
183
+ is_biased=trait_biased,
184
+ df=final_data,
185
+ note="Trait data successfully extracted and processed."
186
+ )
187
+
188
+ # 7) If the dataset is deemed usable, save the final linked data
189
+ if is_usable:
190
+ final_data.to_csv(out_data_file)
p1/preprocess/Endometrioid_Cancer/code/GSE73637.py ADDED
@@ -0,0 +1,287 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE73637"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE73637"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE73637.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE73637.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE73637.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ import pandas as pd
37
+
38
+ # 1. Determine if gene expression data is available
39
+ # Based on background info, this dataset uses gene expression for GECA analysis.
40
+ is_gene_available = True
41
+
42
+ # 2. Identify data availability and define row indices
43
+ # From the sample characteristics dictionary, histopathology is stored in row 3,
44
+ # which includes “Endometrioid” among other values (i.e., multiple categories).
45
+ # There's no mention of age or gender, so age_row and gender_row are None.
46
+
47
+ trait_row = 3 # row containing histopathology with "Endometrioid"
48
+ age_row = None
49
+ gender_row = None
50
+
51
+ # 2.2 Define data type conversion functions
52
+ def convert_trait(value: str):
53
+ """
54
+ Convert histopathology values to binary, indicating whether
55
+ 'Endometrioid' is present (1) or not (0). Unknown/unexpected
56
+ values become None.
57
+ """
58
+ parts = value.split(':', 1)
59
+ if len(parts) == 2:
60
+ val_str = parts[1].strip().lower()
61
+ else:
62
+ val_str = parts[0].strip().lower()
63
+
64
+ # Heuristic: Any mention of 'endometrioid' or 'endometroid' is mapped to 1
65
+ # Otherwise, map known terms to 0, else None.
66
+ if 'endometrioid' in val_str or 'endometroid' in val_str:
67
+ return 1
68
+ elif any(keyword in val_str for keyword in ['serous', 'carcinoma', 'clear cell', 'adenocarcinoma']):
69
+ return 0
70
+ else:
71
+ return None
72
+
73
+ def convert_age(value: str):
74
+ # No age data available; return None
75
+ return None
76
+
77
+ def convert_gender(value: str):
78
+ # No gender data available; return None
79
+ return None
80
+
81
+ # 3. Perform initial filtering and save metadata
82
+ is_trait_available = trait_row is not None
83
+ validate_and_save_cohort_info(
84
+ is_final=False,
85
+ cohort=cohort,
86
+ info_path=json_path,
87
+ is_gene_available=is_gene_available,
88
+ is_trait_available=is_trait_available
89
+ )
90
+
91
+ # 4. If trait_row is available, extract clinical data and save
92
+ if trait_row is not None:
93
+ # Suppose 'clinical_data' is the DataFrame that holds the sample characteristics
94
+ # in the same format as shown in the "Sample Characteristics Dictionary".
95
+ data_dict = {
96
+ 0: ['cell type: ovarian cells'],
97
+ 1: [
98
+ 'cell line: COV504',
99
+ 'cell line: COV362',
100
+ 'cell line: UWB1.289+BRCA1',
101
+ 'cell line: OV56',
102
+ 'cell line: UWB1.289',
103
+ 'cell line: COV318',
104
+ 'cell line: NCI/ADR-RES',
105
+ 'cell line: OVCAR3',
106
+ 'cell line: OVCAR4',
107
+ 'cell line: OVCAR8',
108
+ 'cell line: IGR-OV1',
109
+ 'cell line: SK-OV-3',
110
+ 'cell line: OVCAR5',
111
+ 'cell line: ES-2',
112
+ 'cell line: TOV-21G',
113
+ 'cell line: TOV-112D',
114
+ 'cell line: PEO1',
115
+ 'cell line: PEO4'
116
+ ],
117
+ 2: ['tumor site of origin: Ovarian'],
118
+ 3: [
119
+ 'histopathology: Serous',
120
+ 'histopathology: Endometrioid',
121
+ 'histopathology: Poorly differentiated serous',
122
+ 'histopathology: Undifferentiated carcinoma',
123
+ 'histopathology: Poorly differentiated carcinoma',
124
+ 'histopathology: Moderately differentiated carcinoma',
125
+ 'histopathology: Endometroid with serous/clear cell',
126
+ 'histopathology: Well-differentiated adenocarcinoma',
127
+ 'histopathology: Poorly differentiated clear cell',
128
+ 'histopathology: Clear Cell'
129
+ ]
130
+ }
131
+ # Convert the dictionary to a DataFrame similar to how GEO data often appear
132
+ clinical_data = pd.DataFrame.from_dict(data_dict, orient='index').fillna('')
133
+
134
+ selected_clinical_df = geo_select_clinical_features(
135
+ clinical_df=clinical_data,
136
+ trait=trait,
137
+ trait_row=trait_row,
138
+ convert_trait=convert_trait,
139
+ age_row=age_row,
140
+ convert_age=convert_age,
141
+ gender_row=gender_row,
142
+ convert_gender=convert_gender
143
+ )
144
+
145
+ # Preview the extracted DataFrame
146
+ preview_result = preview_df(selected_clinical_df)
147
+ print("Preview of selected clinical features:", preview_result)
148
+
149
+ # Save clinical data to CSV
150
+ selected_clinical_df.to_csv(out_clinical_data_file, index=False)
151
+ # STEP3
152
+ # 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
153
+ gene_data = get_genetic_data(matrix_file)
154
+
155
+ # 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
156
+ print(gene_data.index[:20])
157
+ # Based on the output, the gene identifiers are numeric (e.g., '1', '2', '3', etc.),
158
+ # which indicates they are not human gene symbols and likely require mapping.
159
+ # Therefore:
160
+
161
+ requires_gene_mapping = True
162
+ # STEP5
163
+ import pandas as pd
164
+ import io
165
+
166
+ # 1. Extract the lines that do NOT start with '^', '!', or '#', but do NOT parse them into a DataFrame yet.
167
+ annotation_text, _ = filter_content_by_prefix(
168
+ source=soft_file,
169
+ prefixes_a=['^', '!', '#'],
170
+ unselect=True,
171
+ source_type='file',
172
+ return_df_a=False,
173
+ return_df_b=False
174
+ )
175
+
176
+ # 2. Manually parse the filtered text into a DataFrame, specifying engine="python" to avoid buffer overflow issues.
177
+ gene_annotation = pd.read_csv(
178
+ io.StringIO(annotation_text),
179
+ delimiter='\t',
180
+ on_bad_lines='skip',
181
+ engine='python'
182
+ )
183
+
184
+ print("Gene annotation preview:")
185
+ print(preview_df(gene_annotation))
186
+ # STEP: Gene Identifier Mapping
187
+
188
+ # 1. Decide which columns correspond to the gene expression ID and the gene symbol
189
+ # From the previews, "ID" matches the numeric identifiers in gene_data,
190
+ # and "GeneSymbol" stores the actual gene symbols.
191
+
192
+ # 2. Get a gene mapping DataFrame
193
+ mapping_df = get_gene_mapping(gene_annotation, prob_col="ID", gene_col="GeneSymbol")
194
+
195
+ # 3. Convert probe-level measurements to gene-level expression data
196
+ gene_data = apply_gene_mapping(gene_data, mapping_df)
197
+ import pandas as pd
198
+
199
+ # STEP7
200
+
201
+ # 1) Normalize gene symbols and save
202
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
203
+ normalized_gene_data.to_csv(out_gene_data_file)
204
+
205
+ # 2) Read back the clinical DataFrame we saved in Step 2.
206
+ # Since we saved a single row with no header or index, we read with header=None to keep that row as data.
207
+ selected_clinical_df = pd.read_csv(out_clinical_data_file, header=None)
208
+
209
+ # If the number of columns aligns with the gene expression DataFrame's columns (i.e., same samples),
210
+ # rename the clinical DataFrame columns accordingly to achieve correct sample alignment.
211
+ if selected_clinical_df.shape[1] == normalized_gene_data.shape[1]:
212
+ selected_clinical_df.columns = normalized_gene_data.columns
213
+
214
+ # Set the row index to the trait name (e.g., "Endometrioid_Cancer")
215
+ selected_clinical_df.index = [trait]
216
+
217
+ # 3) Link the clinical and gene expression data
218
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
219
+
220
+ # 4) Handle missing values using the trait column
221
+ final_data = handle_missing_values(linked_data, trait_col=trait)
222
+
223
+ # 5) Evaluate bias in the trait (and remove biased demographic features if present)
224
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
225
+
226
+ # 6) Final validation. We do have trait data, so set is_trait_available=True
227
+ is_usable = validate_and_save_cohort_info(
228
+ is_final=True,
229
+ cohort=cohort,
230
+ info_path=json_path,
231
+ is_gene_available=True,
232
+ is_trait_available=True,
233
+ is_biased=trait_biased,
234
+ df=final_data,
235
+ note="Aligned columns in clinical DataFrame to match gene expression samples."
236
+ )
237
+
238
+ # 7) If the dataset is deemed usable, save final linked data
239
+ if is_usable:
240
+ final_data.to_csv(out_data_file)
241
+ import pandas as pd
242
+
243
+ # STEP8
244
+ # 1) Normalize gene symbols and save
245
+ normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
246
+ normalized_gene_data.to_csv(out_gene_data_file)
247
+
248
+ # 2) Read back the clinical DataFrame saved in Step 2 (one or more rows × number_of_samples columns, no header).
249
+ selected_clinical_df = pd.read_csv(out_clinical_data_file, header=None)
250
+
251
+ # In case there are empty columns (e.g., trailing commas), drop them
252
+ selected_clinical_df = selected_clinical_df.dropna(axis=1, how='all')
253
+
254
+ # If the number of columns matches the number of samples (columns) in the gene data, rename to align sample IDs
255
+ if selected_clinical_df.shape[1] == normalized_gene_data.shape[1]:
256
+ selected_clinical_df.columns = normalized_gene_data.columns
257
+ else:
258
+ print(f"Warning: Mismatch in shape. Clinical data has {selected_clinical_df.shape[1]} columns, "
259
+ f"while gene data has {normalized_gene_data.shape[1]} columns. Linking may fail.")
260
+
261
+ # Set the row index to the trait, so we can keep track of it
262
+ selected_clinical_df.index = [trait]
263
+
264
+ # 2) Link the clinical and gene expression data
265
+ linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
266
+
267
+ # 3) Handle missing values using the trait column
268
+ final_data = handle_missing_values(linked_data, trait_col=trait)
269
+
270
+ # 4) Evaluate bias in the trait (and remove biased demographic features if present)
271
+ trait_biased, final_data = judge_and_remove_biased_features(final_data, trait)
272
+
273
+ # 5) Final validation
274
+ is_usable = validate_and_save_cohort_info(
275
+ is_final=True,
276
+ cohort=cohort,
277
+ info_path=json_path,
278
+ is_gene_available=True,
279
+ is_trait_available=True,
280
+ is_biased=trait_biased,
281
+ df=final_data,
282
+ note="Ensured clinical and gene sample columns were aligned if possible."
283
+ )
284
+
285
+ # 6) If the dataset is usable, save the final linked data
286
+ if is_usable:
287
+ final_data.to_csv(out_data_file)
p1/preprocess/Endometrioid_Cancer/code/GSE94523.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE94523"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE94523"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE94523.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE94523.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE94523.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Gene Expression Data Availability
37
+ is_gene_available = True # Microarray expression implies gene expression data
38
+
39
+ # 2. Variable Availability and Data Type Conversion
40
+
41
+ # From the sample characteristics {0: ['tissue: endometrioid adenocarcinoma']},
42
+ # we see there's only one unique value: "endometrioid adenocarcinoma".
43
+ # This is constant for all samples, so it's not useful for association.
44
+ trait_row = None # Not available because there's no variation
45
+ age_row = None # No information about age
46
+ gender_row = None # No information about gender
47
+
48
+ # Define the conversion functions (though we won't actually use them for None rows).
49
+ def convert_trait(value: str):
50
+ # Since data is not available, return None
51
+ return None
52
+
53
+ def convert_age(value: str):
54
+ return None
55
+
56
+ def convert_gender(value: str):
57
+ return None
58
+
59
+ # 3. Save Metadata (initial filtering)
60
+ is_trait_available = (trait_row is not None)
61
+ dataset_usable = validate_and_save_cohort_info(
62
+ is_final=False,
63
+ cohort=cohort,
64
+ info_path=json_path,
65
+ is_gene_available=is_gene_available,
66
+ is_trait_available=is_trait_available
67
+ )
68
+
69
+ # 4. Clinical Feature Extraction
70
+ # Skip, because trait_row is None
p1/preprocess/Endometrioid_Cancer/code/GSE94524.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+ cohort = "GSE94524"
7
+
8
+ # Input paths
9
+ in_trait_dir = "../DATA/GEO/Endometrioid_Cancer"
10
+ in_cohort_dir = "../DATA/GEO/Endometrioid_Cancer/GSE94524"
11
+
12
+ # Output paths
13
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/GSE94524.csv"
14
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/GSE94524.csv"
15
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/GSE94524.csv"
16
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
17
+
18
+ # STEP1
19
+ from tools.preprocess import *
20
+ # 1. Identify the paths to the SOFT file and the matrix file
21
+ soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
22
+
23
+ # 2. Read the matrix file to obtain background information and sample characteristics data
24
+ background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
25
+ clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
26
+ background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
27
+
28
+ # 3. Obtain the sample characteristics dictionary from the clinical dataframe
29
+ sample_characteristics_dict = get_unique_values_by_row(clinical_data)
30
+
31
+ # 4. Explicitly print out all the background information and the sample characteristics dictionary
32
+ print("Background Information:")
33
+ print(background_info)
34
+ print("Sample Characteristics Dictionary:")
35
+ print(sample_characteristics_dict)
36
+ # 1. Gene Expression Data Availability
37
+ is_gene_available = True # Based on the background info, assume gene expression data is available.
38
+
39
+ # 2. Variable Availability and Data Type Conversion
40
+
41
+ # 2.1 Identify row keys (None if not available or constant)
42
+ # The sample characteristics dictionary only has one key, 0, whose value is
43
+ # "tissue: endometrioid adenocarcinoma" (single unique value).
44
+ # Therefore, no meaningful variation for trait, age, or gender.
45
+ trait_row = None
46
+ age_row = None
47
+ gender_row = None
48
+
49
+ # 2.2 Define conversion functions
50
+ def convert_trait(value: str) -> int:
51
+ # No data available, but if needed, here's a placeholder.
52
+ return None
53
+
54
+ def convert_age(value: str) -> float:
55
+ # No data available, but if needed, here's a placeholder.
56
+ return None
57
+
58
+ def convert_gender(value: str) -> int:
59
+ # No data available, but if needed, here's a placeholder.
60
+ return None
61
+
62
+ # 3. Save Metadata (initial filtering) - trait is unavailable if trait_row is None
63
+ is_trait_available = (trait_row is not None)
64
+
65
+ is_usable = validate_and_save_cohort_info(
66
+ is_final=False,
67
+ cohort=cohort,
68
+ info_path=json_path,
69
+ is_gene_available=is_gene_available,
70
+ is_trait_available=is_trait_available
71
+ )
72
+
73
+ # 4. Clinical Feature Extraction
74
+ # Skip because trait_row is None (no available clinical variation).
p1/preprocess/Endometrioid_Cancer/code/TCGA.py ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Path Configuration
2
+ from tools.preprocess import *
3
+
4
+ # Processing context
5
+ trait = "Endometrioid_Cancer"
6
+
7
+ # Input paths
8
+ tcga_root_dir = "../DATA/TCGA"
9
+
10
+ # Output paths
11
+ out_data_file = "./output/preprocess/1/Endometrioid_Cancer/TCGA.csv"
12
+ out_gene_data_file = "./output/preprocess/1/Endometrioid_Cancer/gene_data/TCGA.csv"
13
+ out_clinical_data_file = "./output/preprocess/1/Endometrioid_Cancer/clinical_data/TCGA.csv"
14
+ json_path = "./output/preprocess/1/Endometrioid_Cancer/cohort_info.json"
15
+
16
+ import os
17
+ import pandas as pd
18
+
19
+ # 1. Identify subdirectories under tcga_root_dir
20
+ subdirectories = os.listdir(tcga_root_dir)
21
+
22
+ trait_subdir = None
23
+ for d in subdirectories:
24
+ lower_d = d.lower()
25
+ # Check for "endometrioid" or "ucec" to match "TCGA_Endometrioid_Cancer_(UCEC)"
26
+ if "endometrioid" in lower_d or "ucec" in lower_d:
27
+ trait_subdir = d
28
+ break
29
+
30
+ # If none found, skip this trait
31
+ if not trait_subdir:
32
+ print(f"No suitable subdirectory found for trait '{trait}'. Skipping...")
33
+ is_gene_available = False
34
+ is_trait_available = False
35
+ validate_and_save_cohort_info(
36
+ is_final=False,
37
+ cohort="TCGA",
38
+ info_path=json_path,
39
+ is_gene_available=is_gene_available,
40
+ is_trait_available=is_trait_available
41
+ )
42
+ else:
43
+ # 2. Identify paths to the clinical and genetic data files
44
+ full_subdir_path = os.path.join(tcga_root_dir, trait_subdir)
45
+ clinical_path, genetic_path = tcga_get_relevant_filepaths(full_subdir_path)
46
+
47
+ # 3. Load data into DataFrames
48
+ clinical_df = pd.read_csv(clinical_path, index_col=0, sep='\t')
49
+ genetic_df = pd.read_csv(genetic_path, index_col=0, sep='\t')
50
+
51
+ # 4. Print the column names of the clinical data for inspection
52
+ print("Clinical Data Columns:")
53
+ print(clinical_df.columns.tolist())
54
+ # Identify candidate columns
55
+ candidate_age_cols = ['age_at_initial_pathologic_diagnosis', 'days_to_birth']
56
+ candidate_gender_cols = ['gender']
57
+
58
+ # Extract the candidate columns
59
+ df_age = clinical_df[candidate_age_cols] if candidate_age_cols else pd.DataFrame()
60
+ df_gender = clinical_df[candidate_gender_cols] if candidate_gender_cols else pd.DataFrame()
61
+
62
+ # Preview the extracted columns
63
+ age_preview = preview_df(df_age, n=5, max_items=200) if not df_age.empty else {}
64
+ gender_preview = preview_df(df_gender, n=5, max_items=200) if not df_gender.empty else {}
65
+
66
+ # Print the results
67
+ print("candidate_age_cols =", candidate_age_cols)
68
+ print("candidate_gender_cols =", candidate_gender_cols)
69
+ print(age_preview)
70
+ print(gender_preview)
71
+ age_col = "age_at_initial_pathologic_diagnosis"
72
+ gender_col = "gender"
73
+
74
+ print("Selected age column:", age_col)
75
+ print("Selected gender column:", gender_col)
76
+ # 1) Extract and standardize clinical features
77
+ selected_clinical_df = tcga_select_clinical_features(
78
+ clinical_df=clinical_df,
79
+ trait=trait,
80
+ age_col=age_col,
81
+ gender_col=gender_col
82
+ )
83
+
84
+ # 2) Normalize gene symbols
85
+ normalized_gene_df = normalize_gene_symbols_in_index(genetic_df)
86
+ normalized_gene_df.to_csv(out_gene_data_file)
87
+
88
+ # 3) Link clinical and genetic data
89
+ linked_data = selected_clinical_df.join(normalized_gene_df.T, how='inner')
90
+
91
+ # 4) Handle missing values
92
+ linked_data_clean = handle_missing_values(linked_data, trait)
93
+
94
+ # 5) Determine biased features
95
+ trait_biased, linked_data_no_bias = judge_and_remove_biased_features(linked_data_clean, trait)
96
+
97
+ # 6) Final quality validation
98
+ is_usable = validate_and_save_cohort_info(
99
+ is_final=True,
100
+ cohort="TCGA",
101
+ info_path=json_path,
102
+ is_gene_available=True,
103
+ is_trait_available=True,
104
+ is_biased=trait_biased,
105
+ df=linked_data_no_bias,
106
+ note="Endometrioid Cancer TCGA cohort processed successfully."
107
+ )
108
+
109
+ # 7) Save usable data
110
+ if is_usable:
111
+ linked_data_no_bias.to_csv(out_data_file)
p1/preprocess/Endometrioid_Cancer/cohort_info.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"GSE94524": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE94523": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE73637": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "Trait data successfully extracted from Step 2."}, "GSE73614": {"is_usable": false, "is_gene_available": true, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": null}, "GSE73551": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": false, "has_gender": false, "sample_size": 50, "note": "Trait data successfully extracted from Step 2."}, "GSE68600": {"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": 113, "note": "Trait data successfully extracted from Step 2."}, "GSE66667": {"is_usable": false, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": true, "has_age": false, "has_gender": false, "sample_size": 36, "note": "Trait data successfully extracted from Step 2."}, "GSE65986": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": false, "sample_size": 55, "note": "Trait and Age data in the first two rows of the clinical CSV."}, "GSE40785": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": false, "has_gender": false, "sample_size": 30, "note": "Trait data successfully extracted from Step 2."}, "GSE120490": {"is_usable": false, "is_gene_available": false, "is_trait_available": false, "is_available": false, "is_biased": null, "has_age": null, "has_gender": null, "sample_size": null, "note": "No trait data was found; linking and final dataset output are skipped."}, "TCGA": {"is_usable": true, "is_gene_available": true, "is_trait_available": true, "is_available": true, "is_biased": false, "has_age": true, "has_gender": false, "sample_size": 201, "note": "Endometrioid Cancer TCGA cohort processed successfully."}}
p1/preprocess/Endometrioid_Cancer/gene_data/GSE120490.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c2759aa8e42735d02ef9d461e653d8193afbf79f2bc172dbf0a1ffec969bbfd
3
+ size 38249974
p1/preprocess/Endometrioid_Cancer/gene_data/GSE40785.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Endometrioid_Cancer/gene_data/GSE65986.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Endometrioid_Cancer/gene_data/GSE66667.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Endometrioid_Cancer/gene_data/GSE68600.csv ADDED
The diff for this file is too large to render. See raw diff
 
p1/preprocess/Endometrioid_Cancer/gene_data/GSE73551.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:521c3184f53a970bae9c21a469f19dc9d3761202131547c1bef3be922fb6503f
3
+ size 14281959