Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +29 -0
- p1/preprocess/Rheumatoid_Arthritis/GSE236924.csv +3 -0
- p1/preprocess/Rheumatoid_Arthritis/gene_data/GSE236924.csv +3 -0
- p1/preprocess/Rheumatoid_Arthritis/gene_data/GSE97475.csv +3 -0
- p1/preprocess/Sarcoma/GSE197147.csv +3 -0
- p1/preprocess/Sarcoma/gene_data/GSE197147.csv +3 -0
- p1/preprocess/Schizophrenia/GSE145554.csv +3 -0
- p1/preprocess/Schizophrenia/gene_data/GSE145554.csv +3 -0
- p1/preprocess/Sickle_Cell_Anemia/GSE117613.csv +3 -0
- p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE117613.csv +3 -0
- p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE46471.csv +0 -0
- p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE84633.csv +3 -0
- p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE84634.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/GSE135809.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/GSE143153.csv +0 -0
- p1/preprocess/Sjögrens_Syndrome/GSE40611.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/GSE51092.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/GSE66795.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/GSE84844.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/GSE93683.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/GSE94510.csv +0 -0
- p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE135809.csv +2 -0
- p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE143153.csv +4 -0
- p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE40611.csv +2 -0
- p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE51092.csv +2 -0
- p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE66795.csv +2 -0
- p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE84844.csv +4 -0
- p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE93683.csv +2 -0
- p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE94510.csv +2 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE135809.py +172 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE140161.py +152 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE143153.py +180 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE40611.py +157 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE51092.py +167 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE66795.py +150 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE84844.py +186 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE93683.py +147 -0
- p1/preprocess/Sjögrens_Syndrome/code/GSE94510.py +165 -0
- p1/preprocess/Sjögrens_Syndrome/code/TCGA.py +66 -0
- p1/preprocess/Sjögrens_Syndrome/gene_data/GSE135809.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/gene_data/GSE143153.csv +0 -0
- p1/preprocess/Sjögrens_Syndrome/gene_data/GSE40611.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/gene_data/GSE51092.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/gene_data/GSE84844.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/gene_data/GSE93683.csv +3 -0
- p1/preprocess/Sjögrens_Syndrome/gene_data/GSE94510.csv +0 -0
- p1/preprocess/Stomach_Cancer/GSE208099.csv +0 -0
- p1/preprocess/Stomach_Cancer/clinical_data/GSE208099.csv +3 -0
- p1/preprocess/Stomach_Cancer/code/GSE118916.py +116 -0
- p1/preprocess/Stomach_Cancer/code/GSE128459.py +140 -0
.gitattributes
CHANGED
@@ -832,3 +832,32 @@ p1/preprocess/Rheumatoid_Arthritis/gene_data/GSE176440.csv filter=lfs diff=lfs m
|
|
832 |
p1/preprocess/Psoriatic_Arthritis/gene_data/GSE57386.csv filter=lfs diff=lfs merge=lfs -text
|
833 |
p1/preprocess/Rectal_Cancer/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
|
834 |
p1/preprocess/Polycystic_Ovary_Syndrome/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
832 |
p1/preprocess/Psoriatic_Arthritis/gene_data/GSE57386.csv filter=lfs diff=lfs merge=lfs -text
|
833 |
p1/preprocess/Rectal_Cancer/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
|
834 |
p1/preprocess/Polycystic_Ovary_Syndrome/gene_data/TCGA.csv filter=lfs diff=lfs merge=lfs -text
|
835 |
+
p1/preprocess/Sarcoma/GSE197147.csv filter=lfs diff=lfs merge=lfs -text
|
836 |
+
p1/preprocess/Schizophrenia/GSE145554.csv filter=lfs diff=lfs merge=lfs -text
|
837 |
+
p1/preprocess/Sickle_Cell_Anemia/GSE117613.csv filter=lfs diff=lfs merge=lfs -text
|
838 |
+
p1/preprocess/Rheumatoid_Arthritis/gene_data/GSE97475.csv filter=lfs diff=lfs merge=lfs -text
|
839 |
+
p1/preprocess/Sarcoma/gene_data/GSE197147.csv filter=lfs diff=lfs merge=lfs -text
|
840 |
+
p1/preprocess/Rheumatoid_Arthritis/GSE236924.csv filter=lfs diff=lfs merge=lfs -text
|
841 |
+
p1/preprocess/Schizophrenia/gene_data/GSE145554.csv filter=lfs diff=lfs merge=lfs -text
|
842 |
+
p1/preprocess/Sjögrens_Syndrome/GSE135809.csv filter=lfs diff=lfs merge=lfs -text
|
843 |
+
p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE117613.csv filter=lfs diff=lfs merge=lfs -text
|
844 |
+
p1/preprocess/Rheumatoid_Arthritis/gene_data/GSE236924.csv filter=lfs diff=lfs merge=lfs -text
|
845 |
+
p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE84633.csv filter=lfs diff=lfs merge=lfs -text
|
846 |
+
p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE84634.csv filter=lfs diff=lfs merge=lfs -text
|
847 |
+
p1/preprocess/Sjögrens_Syndrome/GSE40611.csv filter=lfs diff=lfs merge=lfs -text
|
848 |
+
p1/preprocess/Sjögrens_Syndrome/GSE93683.csv filter=lfs diff=lfs merge=lfs -text
|
849 |
+
p1/preprocess/Sjögrens_Syndrome/GSE84844.csv filter=lfs diff=lfs merge=lfs -text
|
850 |
+
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE40611.csv filter=lfs diff=lfs merge=lfs -text
|
851 |
+
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE135809.csv filter=lfs diff=lfs merge=lfs -text
|
852 |
+
p1/preprocess/Sjögrens_Syndrome/GSE51092.csv filter=lfs diff=lfs merge=lfs -text
|
853 |
+
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE93683.csv filter=lfs diff=lfs merge=lfs -text
|
854 |
+
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE84844.csv filter=lfs diff=lfs merge=lfs -text
|
855 |
+
p1/preprocess/Stomach_Cancer/gene_data/GSE147163.csv filter=lfs diff=lfs merge=lfs -text
|
856 |
+
p1/preprocess/Stomach_Cancer/gene_data/GSE128459.csv filter=lfs diff=lfs merge=lfs -text
|
857 |
+
p1/preprocess/Sjögrens_Syndrome/GSE66795.csv filter=lfs diff=lfs merge=lfs -text
|
858 |
+
p1/preprocess/Stomach_Cancer/gene_data/GSE172197.csv filter=lfs diff=lfs merge=lfs -text
|
859 |
+
p1/preprocess/Stomach_Cancer/gene_data/GSE161533.csv filter=lfs diff=lfs merge=lfs -text
|
860 |
+
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE51092.csv filter=lfs diff=lfs merge=lfs -text
|
861 |
+
p1/preprocess/Stomach_Cancer/gene_data/GSE98708.csv filter=lfs diff=lfs merge=lfs -text
|
862 |
+
p1/preprocess/Stomach_Cancer/gene_data/GSE183136.csv filter=lfs diff=lfs merge=lfs -text
|
863 |
+
p1/preprocess/Stomach_Cancer/gene_data/GSE130823.csv filter=lfs diff=lfs merge=lfs -text
|
p1/preprocess/Rheumatoid_Arthritis/GSE236924.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:490c09bff2351ae16affdf8355e6e3d734513dbf864ca024fddb2ccffaa38dca
|
3 |
+
size 35075181
|
p1/preprocess/Rheumatoid_Arthritis/gene_data/GSE236924.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c0889c2bc648b2b6bc1acfce5a519a7c835ddb2679c77ba3da20898108bfd49e
|
3 |
+
size 35074636
|
p1/preprocess/Rheumatoid_Arthritis/gene_data/GSE97475.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3f878f347055d43a45dabc516d5439c40520de0e4801d000f60d50442300ba19
|
3 |
+
size 26337377
|
p1/preprocess/Sarcoma/GSE197147.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:58a557bffa82aad9a6a1429a1845020b51678c56e9c08cf37afa90b229b9455c
|
3 |
+
size 24566728
|
p1/preprocess/Sarcoma/gene_data/GSE197147.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8d5097da945a3aa774cf6e1fda0eeddaebca8f1dc17f502e0c58d49a4fb3187f
|
3 |
+
size 24566408
|
p1/preprocess/Schizophrenia/GSE145554.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66f04d20a68dcd294b83eb437ba0d260f72f310ef0e51c9259391c7a2de9d2bd
|
3 |
+
size 16475871
|
p1/preprocess/Schizophrenia/gene_data/GSE145554.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7f389a67158c1ed8534c5ac8ab923221cb4788be22f825167d4a8d17dd40e04a
|
3 |
+
size 16475298
|
p1/preprocess/Sickle_Cell_Anemia/GSE117613.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:32c9618c357a52084c8c3c9a4d64d0ec2dab0bd25e60a4c417d8f999dc7a1584
|
3 |
+
size 11936971
|
p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE117613.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8f42c7ebdadc8d55b92d6c01b2dbe8a0cd9c61a2b80b4c3db078a25bb33bffe6
|
3 |
+
size 11936309
|
p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE46471.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE84633.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:935ee14529c87d2cc114bd6bf28f4dfe80c3fbe053430299830389502ef4bf4d
|
3 |
+
size 10811308
|
p1/preprocess/Sickle_Cell_Anemia/gene_data/GSE84634.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0a369d322c0de49786b07ab9a91b3ffeb24639bb2a6dbbed8bbf1c09dddb80d1
|
3 |
+
size 11282737
|
p1/preprocess/Sjögrens_Syndrome/GSE135809.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cc0c968270cdbd04f0d87ade3ac7880cb4dd593511f1669241f6c4ad429fe94d
|
3 |
+
size 12770637
|
p1/preprocess/Sjögrens_Syndrome/GSE143153.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Sjögrens_Syndrome/GSE40611.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5f0b0e925490712841e234d43fa388d8375f89de4e23566062a7b2532d83e3dc
|
3 |
+
size 10809062
|
p1/preprocess/Sjögrens_Syndrome/GSE51092.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:23316b7e08fff51f3f269244caad33a89871d5fae5beb19fbe5d4af150d64aca
|
3 |
+
size 27673960
|
p1/preprocess/Sjögrens_Syndrome/GSE66795.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:246a229b95528951b1596a2c80cffc82a9653b6709e58515b4510e9fa59c8ba6
|
3 |
+
size 41210575
|
p1/preprocess/Sjögrens_Syndrome/GSE84844.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:02383be042482af46c28d426f54351445d891e0d6625f5c22a28cf7ba416b28d
|
3 |
+
size 15946595
|
p1/preprocess/Sjögrens_Syndrome/GSE93683.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:37bde4c050775167a06592eec42c0997e71d2e91f178c297b333a2ba2463a3e4
|
3 |
+
size 12769618
|
p1/preprocess/Sjögrens_Syndrome/GSE94510.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE135809.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM4030545,GSM4030546,GSM4030547,GSM4030548,GSM4030549,GSM4030550,GSM4030551,GSM4030552,GSM4030553,GSM4030554,GSM4030555,GSM4030556,GSM4030557,GSM4030558,GSM4030559,GSM4030560,GSM4030561,GSM4030562,GSM4030563,GSM4030564,GSM4030565,GSM4030566,GSM4030567,GSM4030568,GSM4030569,GSM4030570,GSM4030571,GSM4030572,GSM4030573,GSM4030574,GSM4030575,GSM4030576,GSM4030577,GSM4030578,GSM4030579,GSM4030580,GSM4030581,GSM4030582,GSM4030583,GSM4030584,GSM4030585,GSM4030586,GSM4030587,GSM4030588,GSM4030589,GSM4030590,GSM4030591,GSM4030592
|
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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE143153.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GSM4251021,GSM4251022,GSM4251023,GSM4251024,GSM4251025,GSM4251026,GSM4251027,GSM4251028,GSM4251029,GSM4251030,GSM4251031,GSM4251032,GSM4251033,GSM4251034,GSM4251035,GSM4251036,GSM4251037,GSM4251038,GSM4251039,GSM4251040,GSM4251041,GSM4251042,GSM4251043,GSM4251044,GSM4251045,GSM4251046,GSM4251047,GSM4251048,GSM4251049,GSM4251050,GSM4251051,GSM4251052
|
2 |
+
1.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
3 |
+
56.0,51.0,37.0,40.0,41.0,50.0,38.0,50.0,58.0,55.0,35.0,43.0,62.0,46.0,58.0,40.0,66.0,35.0,58.0,60.0,63.0,56.0,19.0,64.0,71.0,30.0,31.0,45.0,38.0,43.0,37.0,41.0
|
4 |
+
1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0
|
p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE40611.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM997850,GSM997851,GSM997852,GSM997853,GSM997854,GSM997855,GSM997856,GSM997857,GSM997858,GSM997859,GSM997860,GSM997861,GSM997862,GSM997863,GSM997864,GSM997865,GSM997866,GSM997867,GSM997868,GSM997869,GSM997870,GSM997871,GSM997872,GSM997873,GSM997874,GSM997875,GSM997876,GSM997877,GSM997878,GSM997879,GSM997880,GSM997881,GSM997882,GSM997883,GSM997884,GSM997885,GSM997886,GSM997887,GSM997888,GSM997889,GSM997890,GSM997891,GSM997892,GSM997893,GSM997894,GSM997895,GSM997896,GSM997897,GSM997898
|
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,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,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE51092.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM1238429,GSM1238430,GSM1238431,GSM1238432,GSM1238433,GSM1238434,GSM1238435,GSM1238436,GSM1238437,GSM1238438,GSM1238439,GSM1238440,GSM1238441,GSM1238442,GSM1238443,GSM1238444,GSM1238445,GSM1238446,GSM1238447,GSM1238448,GSM1238449,GSM1238450,GSM1238451,GSM1238452,GSM1238453,GSM1238454,GSM1238455,GSM1238456,GSM1238457,GSM1238458,GSM1238459,GSM1238460,GSM1238461,GSM1238462,GSM1238463,GSM1238464,GSM1238465,GSM1238466,GSM1238467,GSM1238468,GSM1238469,GSM1238470,GSM1238471,GSM1238472,GSM1238473,GSM1238474,GSM1238475,GSM1238476,GSM1238477,GSM1238478,GSM1238479,GSM1238480,GSM1238481,GSM1238482,GSM1238483,GSM1238484,GSM1238485,GSM1238486,GSM1238487,GSM1238488,GSM1238489,GSM1238490,GSM1238491,GSM1238492,GSM1238493,GSM1238494,GSM1238495,GSM1238496,GSM1238497,GSM1238498,GSM1238499,GSM1238500,GSM1238501,GSM1238502,GSM1238503,GSM1238504,GSM1238505,GSM1238506,GSM1238507,GSM1238508,GSM1238509,GSM1238510,GSM1238511,GSM1238512,GSM1238513,GSM1238514,GSM1238515,GSM1238516,GSM1238517,GSM1238518,GSM1238519,GSM1238520,GSM1238521,GSM1238522,GSM1238523,GSM1238524,GSM1238525,GSM1238526,GSM1238527,GSM1238528,GSM1238529,GSM1238530,GSM1238531,GSM1238532,GSM1238533,GSM1238534,GSM1238535,GSM1238536,GSM1238537,GSM1238538,GSM1238539,GSM1238540,GSM1238541,GSM1238542,GSM1238543,GSM1238544,GSM1238545,GSM1238546,GSM1238547,GSM1238548,GSM1238549,GSM1238550,GSM1238551,GSM1238552,GSM1238553,GSM1238554,GSM1238555,GSM1238556,GSM1238557,GSM1238558,GSM1238559,GSM1238560,GSM1238561,GSM1238562,GSM1238563,GSM1238564,GSM1238565,GSM1238566,GSM1238567,GSM1238568,GSM1238569,GSM1238570,GSM1238571,GSM1238572,GSM1238573,GSM1238574,GSM1238575,GSM1238576,GSM1238577,GSM1238578,GSM1238579,GSM1238580,GSM1238581,GSM1238582,GSM1238583,GSM1238584,GSM1238585,GSM1238586,GSM1238587,GSM1238588,GSM1238589,GSM1238590,GSM1238591,GSM1238592,GSM1238593,GSM1238594,GSM1238595,GSM1238596,GSM1238598,GSM1238599,GSM1238601,GSM1238603,GSM1238605,GSM1238607,GSM1238608,GSM1238610,GSM1238611,GSM1238612,GSM1238613,GSM1238614,GSM1238615,GSM1238616,GSM1238617,GSM1238618,GSM1238619,GSM1238620,GSM1238621,GSM1238622,GSM1238623,GSM1238624,GSM1238625,GSM1238626,GSM1238627,GSM1238628,GSM1238629,GSM1238630,GSM1238631,GSM1238632,GSM1238633,GSM1238634,GSM1238635,GSM1238636,GSM1238637,GSM1238638,GSM1238639,GSM1238640,GSM1238641,GSM1238642,GSM1238643,GSM1238644,GSM1238645,GSM1238646,GSM1238647,GSM1238648,GSM1238649,GSM1238650,GSM1238651,GSM1238652,GSM1238653,GSM1238654,GSM1238655,GSM1238656
|
2 |
+
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE66795.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM1632237,GSM1632238,GSM1632239,GSM1632240,GSM1632241,GSM1632242,GSM1632243,GSM1632244,GSM1632245,GSM1632246,GSM1632247,GSM1632248,GSM1632249,GSM1632250,GSM1632251,GSM1632252,GSM1632253,GSM1632254,GSM1632255,GSM1632256,GSM1632257,GSM1632258,GSM1632259,GSM1632260,GSM1632261,GSM1632262,GSM1632263,GSM1632264,GSM1632265,GSM1632266,GSM1632267,GSM1632268,GSM1632269,GSM1632270,GSM1632271,GSM1632272,GSM1632273,GSM1632274,GSM1632275,GSM1632276,GSM1632277,GSM1632278,GSM1632279,GSM1632280,GSM1632281,GSM1632282,GSM1632283,GSM1632284,GSM1632285,GSM1632286,GSM1632287,GSM1632288,GSM1632289,GSM1632290,GSM1632291,GSM1632292,GSM1632293,GSM1632294,GSM1632295,GSM1632296,GSM1632297,GSM1632298,GSM1632299,GSM1632300,GSM1632301,GSM1632302,GSM1632303,GSM1632304,GSM1632305,GSM1632306,GSM1632307,GSM1632308,GSM1632309,GSM1632310,GSM1632311,GSM1632312,GSM1632313,GSM1632314,GSM1632315,GSM1632316,GSM1632317,GSM1632318,GSM1632319,GSM1632320,GSM1632321,GSM1632322,GSM1632323,GSM1632324,GSM1632325,GSM1632326,GSM1632327,GSM1632328,GSM1632329,GSM1632330,GSM1632331,GSM1632332,GSM1632333,GSM1632334,GSM1632335,GSM1632336,GSM1632337,GSM1632338,GSM1632339,GSM1632340,GSM1632341,GSM1632342,GSM1632343,GSM1632344,GSM1632345,GSM1632346,GSM1632347,GSM1632348,GSM1632349,GSM1632350,GSM1632351,GSM1632352,GSM1632353,GSM1632354,GSM1632355,GSM1632356,GSM1632357,GSM1632358,GSM1632359,GSM1632360,GSM1632361,GSM1632362,GSM1632363,GSM1632364,GSM1632365,GSM1632366,GSM1632367,GSM1632368,GSM1632369,GSM1632370,GSM1632371,GSM1632372,GSM1632373,GSM1632374,GSM1632375,GSM1632376,GSM1632377,GSM1632378,GSM1632379,GSM1632380,GSM1632381,GSM1632382,GSM1632383,GSM1632384,GSM1632385,GSM1632386,GSM1632387,GSM1632388,GSM1632389,GSM1632390,GSM1632391,GSM1632392,GSM1632393,GSM1632394,GSM1632395,GSM1632396
|
2 |
+
0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,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,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE84844.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GSM2252121,GSM2252122,GSM2252123,GSM2252124,GSM2252125,GSM2252126,GSM2252127,GSM2252128,GSM2252129,GSM2252130,GSM2252131,GSM2252132,GSM2252133,GSM2252134,GSM2252135,GSM2252136,GSM2252137,GSM2252138,GSM2252139,GSM2252140,GSM2252141,GSM2252142,GSM2252143,GSM2252144,GSM2252145,GSM2252146,GSM2252147,GSM2252148,GSM2252149,GSM2252150,GSM2252151,GSM2252152,GSM2252153,GSM2252154,GSM2252155,GSM2252156,GSM2252157,GSM2252158,GSM2252159,GSM2252160,GSM2252161,GSM2252162,GSM2252163,GSM2252164,GSM2252165,GSM2252166,GSM2252167,GSM2252168,GSM2252169,GSM2252170,GSM2252171,GSM2252172,GSM2252173,GSM2252174,GSM2252175,GSM2252176,GSM2252177,GSM2252178,GSM2252179,GSM2252180
|
2 |
+
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
3 |
+
45.0,40.0,54.0,50.0,31.0,44.0,43.0,25.0,29.0,38.0,28.0,31.0,31.0,30.0,30.0,44.0,24.0,38.0,52.0,49.0,26.0,52.0,48.0,55.0,33.0,33.0,44.0,44.0,42.0,47.0,39.0,63.0,68.0,71.0,46.0,62.0,71.0,60.0,66.0,70.0,75.0,70.0,66.0,47.0,63.0,56.0,59.0,70.0,48.0,47.0,71.0,59.0,71.0,66.0,66.0,53.0,54.0,34.0,76.0,65.0
|
4 |
+
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE93683.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM2460433,GSM2460434,GSM2460435,GSM2460436,GSM2460437,GSM2460438,GSM2460439,GSM2460440,GSM2460441,GSM2460442,GSM2460443,GSM2460444,GSM2460445,GSM2460446,GSM2460447,GSM2460448,GSM2460449,GSM2460450,GSM2460451,GSM2460452,GSM2460453,GSM2460454,GSM2460455,GSM2460456,GSM2460457,GSM2460458,GSM2460459,GSM2460460,GSM2460461,GSM2460462,GSM2460463,GSM2460464,GSM2460465,GSM2460466,GSM2460467,GSM2460468,GSM2460469,GSM2460470,GSM2460471,GSM2460472,GSM2460473,GSM2460474,GSM2460475,GSM2460476,GSM2460477,GSM2460478,GSM2460479,GSM2460480
|
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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Sjögrens_Syndrome/clinical_data/GSE94510.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
GSM2477208,GSM2477209,GSM2477210,GSM2477211,GSM2477212,GSM2477213,GSM2477214,GSM2477215,GSM2477216,GSM2477217,GSM2477218,GSM2477219,GSM2477220,GSM2477221,GSM2477222,GSM2477223,GSM2477224,GSM2477225,GSM2477226,GSM2477227,GSM2477228,GSM2477229,GSM2477230,GSM2477231,GSM2477232,GSM2477233,GSM2477234,GSM2477235,GSM2477236,GSM2477237,GSM2477238,GSM2477239,GSM2477240,GSM2477241,GSM2477242,GSM2477243
|
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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Sjögrens_Syndrome/code/GSE135809.py
ADDED
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE135809"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE135809"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE135809.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE135809.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE135809.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP1
|
19 |
+
from tools.preprocess import *
|
20 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
21 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
22 |
+
|
23 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
24 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
25 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
27 |
+
|
28 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
29 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
32 |
+
print("Background Information:")
|
33 |
+
print(background_info)
|
34 |
+
print("Sample Characteristics Dictionary:")
|
35 |
+
print(sample_characteristics_dict)
|
36 |
+
# Step 1: Determine whether gene expression data is available.
|
37 |
+
is_gene_available = True # Based on the background info ("Transcriptome data" and differential gene expression)
|
38 |
+
|
39 |
+
# Step 2: Identify data availability and create conversion functions.
|
40 |
+
|
41 |
+
# From the sample characteristics dictionary, the only row that clearly distinguishes
|
42 |
+
# patients (pSS) from healthy controls (HC) is row 1 via "subject id: HC-..." or "subject id: pSS-...".
|
43 |
+
trait_row = 1 # We can parse 'HC' => 0, 'pSS' => 1
|
44 |
+
age_row = None # No age information is provided
|
45 |
+
gender_row = None # No gender information is provided
|
46 |
+
|
47 |
+
def convert_trait(value: str) -> Optional[int]:
|
48 |
+
"""
|
49 |
+
Convert 'subject id: HC-1' or 'subject id: pSS-1' to binary trait:
|
50 |
+
0 for healthy control (HC), 1 for pSS.
|
51 |
+
"""
|
52 |
+
# Extract substring after the colon
|
53 |
+
parts = value.split(":")
|
54 |
+
if len(parts) < 2:
|
55 |
+
return None
|
56 |
+
val = parts[1].strip()
|
57 |
+
|
58 |
+
# Check prefix
|
59 |
+
if val.startswith("HC"):
|
60 |
+
return 0
|
61 |
+
elif val.startswith("pSS"):
|
62 |
+
return 1
|
63 |
+
else:
|
64 |
+
return None
|
65 |
+
|
66 |
+
def convert_age(value: str) -> Optional[float]:
|
67 |
+
"""
|
68 |
+
Placeholder function. No age data available, so this always returns None.
|
69 |
+
"""
|
70 |
+
return None
|
71 |
+
|
72 |
+
def convert_gender(value: str) -> Optional[int]:
|
73 |
+
"""
|
74 |
+
Placeholder function. No gender data available, so this always returns None.
|
75 |
+
"""
|
76 |
+
return None
|
77 |
+
|
78 |
+
# Step 3: Conduct initial filtering and save metadata.
|
79 |
+
# Trait data availability is determined by whether trait_row is None.
|
80 |
+
is_trait_available = (trait_row is not None)
|
81 |
+
|
82 |
+
dataset_passed_filter = validate_and_save_cohort_info(
|
83 |
+
is_final=False,
|
84 |
+
cohort=cohort,
|
85 |
+
info_path=json_path,
|
86 |
+
is_gene_available=is_gene_available,
|
87 |
+
is_trait_available=is_trait_available
|
88 |
+
)
|
89 |
+
|
90 |
+
# Step 4: If trait data is available, extract clinical features.
|
91 |
+
if trait_row is not None:
|
92 |
+
# Assume 'clinical_data' DataFrame exists in the environment from previous step.
|
93 |
+
selected_clinical_df = geo_select_clinical_features(
|
94 |
+
clinical_data,
|
95 |
+
trait=trait,
|
96 |
+
trait_row=trait_row,
|
97 |
+
convert_trait=convert_trait,
|
98 |
+
age_row=age_row,
|
99 |
+
convert_age=convert_age,
|
100 |
+
gender_row=gender_row,
|
101 |
+
convert_gender=convert_gender
|
102 |
+
)
|
103 |
+
|
104 |
+
# Preview the extracted clinical features
|
105 |
+
preview_dict = preview_df(selected_clinical_df, n=5, max_items=200)
|
106 |
+
print("Preview of selected clinical features:", preview_dict)
|
107 |
+
|
108 |
+
# Save the clinical data to CSV
|
109 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
110 |
+
# STEP3
|
111 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
112 |
+
gene_data = get_genetic_data(matrix_file)
|
113 |
+
|
114 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
115 |
+
print(gene_data.index[:20])
|
116 |
+
# The gene identifiers shown (e.g., '1007_s_at', '1053_at') are Affymetrix probe IDs, not standard gene symbols.
|
117 |
+
# Therefore, they require mapping to human gene symbols.
|
118 |
+
print("\nrequires_gene_mapping = True")
|
119 |
+
# STEP5
|
120 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
121 |
+
gene_annotation = get_gene_annotation(soft_file)
|
122 |
+
|
123 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
124 |
+
print("Gene annotation preview:")
|
125 |
+
print(preview_df(gene_annotation))
|
126 |
+
# STEP: Gene Identifier Mapping
|
127 |
+
|
128 |
+
# 1. Identify which columns in the gene annotation dataframe correspond to the probe identifiers
|
129 |
+
# (same IDs as in gene expression data) and which correspond to gene symbols.
|
130 |
+
# From the preview, the "ID" column matches the probe IDs (like '1007_s_at' etc.),
|
131 |
+
# and "Gene Symbol" contains the gene symbols (e.g., 'DDR1 // MIR4640' etc.).
|
132 |
+
|
133 |
+
# 2. Extract and build a mapping dataframe (probe -> gene symbol).
|
134 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
|
135 |
+
|
136 |
+
# 3. Apply the mapping to convert probe-level data into gene-level data, dividing shared probe values
|
137 |
+
# equally among target genes and summing where probes map to the same gene.
|
138 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
139 |
+
|
140 |
+
# For inspection, print out the shape and a sample of the new index (gene symbols).
|
141 |
+
print("Mapped gene_data shape:", gene_data.shape)
|
142 |
+
print("First 20 genes in gene_data index:", list(gene_data.index[:20]))
|
143 |
+
# STEP7
|
144 |
+
|
145 |
+
# 1. Normalize the obtained gene data and save
|
146 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
147 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
148 |
+
|
149 |
+
# 2. Link clinical and gene expression data on sample IDs
|
150 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
151 |
+
|
152 |
+
# 3. Handle missing values systematically using the trait column name in the 'trait' variable
|
153 |
+
linked_data = handle_missing_values(linked_data, trait)
|
154 |
+
|
155 |
+
# 4. Check for biased features (trait, age, gender) using the same trait column name
|
156 |
+
is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
157 |
+
|
158 |
+
# 5. Final quality validation and record metadata
|
159 |
+
is_usable = validate_and_save_cohort_info(
|
160 |
+
is_final=True,
|
161 |
+
cohort=cohort,
|
162 |
+
info_path=json_path,
|
163 |
+
is_gene_available=True,
|
164 |
+
is_trait_available=True,
|
165 |
+
is_biased=is_trait_biased,
|
166 |
+
df=linked_data,
|
167 |
+
note=f"Preprocessed with trait column named '{trait}'."
|
168 |
+
)
|
169 |
+
|
170 |
+
# 6. If usable, save linked data
|
171 |
+
if is_usable:
|
172 |
+
linked_data.to_csv(out_data_file, index=True)
|
p1/preprocess/Sjögrens_Syndrome/code/GSE140161.py
ADDED
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE140161"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE140161"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE140161.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE140161.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE140161.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/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 |
+
# Based on background info, this dataset uses Affymetrix chips on whole blood transcriptome,
|
38 |
+
# which strongly suggests gene expression data is available.
|
39 |
+
is_gene_available = True
|
40 |
+
|
41 |
+
# 2. Identify availability of trait, age, and gender data from the sample characteristics dictionary.
|
42 |
+
# From the dictionary:
|
43 |
+
# 0: ['tissue: Whole blood'] (irrelevant or constant)
|
44 |
+
# 1: ['Sex: female', 'Sex: male'] (2 unique values => available; we'll treat as gender)
|
45 |
+
# 2: ['antissa status: Positive', 'antissa status: Negative']
|
46 |
+
# 3: ['antissb status: Negative', 'antissb status: Positive']
|
47 |
+
# 4: ['disease state: Sjögren’s syndrome'] (only one unique value => effectively not available)
|
48 |
+
#
|
49 |
+
# Thus:
|
50 |
+
trait_row = None # Only one unique value for the disease state => not a usable variable
|
51 |
+
age_row = None # No age info in the dictionary
|
52 |
+
gender_row = 1 # "Sex: female"/"Sex: male" => usable
|
53 |
+
|
54 |
+
# 2.2. Define data conversion functions
|
55 |
+
def convert_trait(value: str):
|
56 |
+
# Not used in this dataset (trait_row=None), but defined for completeness
|
57 |
+
val = value.split(':')[-1].strip().lower()
|
58 |
+
# A generic conversion if there were varied trait statuses:
|
59 |
+
if val == "sjögren’s syndrome":
|
60 |
+
return 1
|
61 |
+
elif val == "":
|
62 |
+
return None
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_age(value: str):
|
66 |
+
# Not used in this dataset (age_row=None), but defined for completeness
|
67 |
+
val = value.split(':')[-1].strip()
|
68 |
+
# Attempt numeric conversion
|
69 |
+
try:
|
70 |
+
return float(val)
|
71 |
+
except ValueError:
|
72 |
+
return None
|
73 |
+
|
74 |
+
def convert_gender(value: str):
|
75 |
+
val = value.split(':')[-1].strip().lower()
|
76 |
+
if val == "female":
|
77 |
+
return 0
|
78 |
+
elif val == "male":
|
79 |
+
return 1
|
80 |
+
return None
|
81 |
+
|
82 |
+
# 3. Save initial metadata using validate_and_save_cohort_info
|
83 |
+
# The trait is considered available only if trait_row is not None.
|
84 |
+
is_trait_available = (trait_row is not None)
|
85 |
+
validate_and_save_cohort_info(
|
86 |
+
is_final=False,
|
87 |
+
cohort=cohort,
|
88 |
+
info_path=json_path,
|
89 |
+
is_gene_available=is_gene_available,
|
90 |
+
is_trait_available=is_trait_available
|
91 |
+
)
|
92 |
+
|
93 |
+
# 4. If trait data is available (trait_row != None), then extract clinical data. Here, trait_row = None, so skip.
|
94 |
+
# STEP3
|
95 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
96 |
+
gene_data = get_genetic_data(matrix_file)
|
97 |
+
|
98 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
99 |
+
print(gene_data.index[:20])
|
100 |
+
# Based on the observed IDs (e.g., '23064070'), they do not match standard human gene symbols.
|
101 |
+
# Hence, they likely require a mapping step to convert these IDs to recognized gene symbols.
|
102 |
+
print("The given gene identifiers appear to be probe IDs or numeric identifiers, not standard gene symbols.")
|
103 |
+
print("requires_gene_mapping = True")
|
104 |
+
# STEP5
|
105 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
106 |
+
gene_annotation = get_gene_annotation(soft_file)
|
107 |
+
|
108 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
109 |
+
print("Gene annotation preview:")
|
110 |
+
print(preview_df(gene_annotation))
|
111 |
+
# STEP: Gene Identifier Mapping
|
112 |
+
|
113 |
+
# 1. Identify which columns in the gene_annotation DataFrame correspond to the probe IDs in gene_data
|
114 |
+
# and which columns contain the gene symbols. From the preview, column "ID" in gene_annotation
|
115 |
+
# stores probe identifiers (e.g., "TC0100006437.hg.1"), and "SPOT_ID.1" contains text that includes
|
116 |
+
# the gene symbol (e.g., "ISG15", "KLHL17", etc.).
|
117 |
+
|
118 |
+
# 2. Create a gene mapping dataframe by extracting these two columns and naming them properly.
|
119 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='SPOT_ID.1')
|
120 |
+
|
121 |
+
# 3. Convert the probe-level expression data (gene_data) into gene-level data using this mapping.
|
122 |
+
# This will distribute the expression values across multiple genes if a probe maps to multiple symbols,
|
123 |
+
# and sum up values for genes covered by multiple probes.
|
124 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
125 |
+
# STEP 7
|
126 |
+
|
127 |
+
# Since trait_row is None, we do NOT have trait data available. Thus, we cannot link clinical data
|
128 |
+
# or perform trait-based missing-value handling or bias analysis. We will, however, normalize gene
|
129 |
+
# symbols and then finalize the dataset's metadata accordingly.
|
130 |
+
|
131 |
+
# 1. Normalize the obtained gene data and save
|
132 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
133 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
134 |
+
|
135 |
+
# 2. Since trait data is unavailable (trait_row=None), we skip linking with clinical data
|
136 |
+
# and subsequent steps requiring trait information.
|
137 |
+
|
138 |
+
# 3. Perform final quality validation and record metadata.
|
139 |
+
# Because is_final=True, we must provide a DataFrame and a boolean is_biased value.
|
140 |
+
# Even though trait is unavailable, we pass normalized_gene_data as df and set is_biased=False.
|
141 |
+
is_usable = validate_and_save_cohort_info(
|
142 |
+
is_final=True,
|
143 |
+
cohort=cohort,
|
144 |
+
info_path=json_path,
|
145 |
+
is_gene_available=True,
|
146 |
+
is_trait_available=False,
|
147 |
+
is_biased=False,
|
148 |
+
df=normalized_gene_data,
|
149 |
+
note="No trait data available; final gene data saved alone."
|
150 |
+
)
|
151 |
+
|
152 |
+
# 4. Since trait data is unavailable, we do not produce or save any linked data for association studies.
|
p1/preprocess/Sjögrens_Syndrome/code/GSE143153.py
ADDED
@@ -0,0 +1,180 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE143153"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE143153"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE143153.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE143153.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE143153.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/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) Set is_gene_available based on dataset examination
|
37 |
+
is_gene_available = True # Since the data is from "Agilent Whole Human Genome" microarray
|
38 |
+
|
39 |
+
# 2.1) Determine data availability for trait, age, and gender
|
40 |
+
# From the sample characteristics dictionary, we've identified:
|
41 |
+
# - 'aecg disease classification' at row 1 for trait
|
42 |
+
# - 'age' at row 2
|
43 |
+
# - 'sex' at row 3
|
44 |
+
trait_row = 1
|
45 |
+
age_row = 2
|
46 |
+
gender_row = 3
|
47 |
+
|
48 |
+
# 2.2) Define data type conversion functions
|
49 |
+
def convert_trait(value: str) -> Optional[int]:
|
50 |
+
"""
|
51 |
+
Converts trait data ('Primary SS', 'non-SS') to binary (1 or 0).
|
52 |
+
Unrecognized or empty values become None.
|
53 |
+
"""
|
54 |
+
# Extract the substring after the colon
|
55 |
+
parts = value.split(':')
|
56 |
+
label = parts[-1].strip().lower() if len(parts) >= 2 else None
|
57 |
+
|
58 |
+
if label == 'primary ss':
|
59 |
+
return 1
|
60 |
+
elif label == 'non-ss':
|
61 |
+
return 0
|
62 |
+
else:
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_age(value: str) -> Optional[float]:
|
66 |
+
"""
|
67 |
+
Converts age data to a continuous numeric value.
|
68 |
+
Unrecognized or empty values become None.
|
69 |
+
"""
|
70 |
+
parts = value.split(':')
|
71 |
+
label = parts[-1].strip() if len(parts) >= 2 else None
|
72 |
+
|
73 |
+
try:
|
74 |
+
return float(label)
|
75 |
+
except ValueError:
|
76 |
+
return None
|
77 |
+
|
78 |
+
def convert_gender(value: str) -> Optional[int]:
|
79 |
+
"""
|
80 |
+
Converts gender data ('M' or 'F') to binary (1 for male, 0 for female).
|
81 |
+
Unrecognized or empty values become None.
|
82 |
+
"""
|
83 |
+
parts = value.split(':')
|
84 |
+
label = parts[-1].strip().lower() if len(parts) >= 2 else None
|
85 |
+
|
86 |
+
if label == 'm':
|
87 |
+
return 1
|
88 |
+
elif label == 'f':
|
89 |
+
return 0
|
90 |
+
else:
|
91 |
+
return None
|
92 |
+
|
93 |
+
# 3) Conduct initial filtering with validate_and_save_cohort_info
|
94 |
+
# Trait availability is determined by whether trait_row is None.
|
95 |
+
is_trait_available = (trait_row is not None)
|
96 |
+
|
97 |
+
is_usable = validate_and_save_cohort_info(
|
98 |
+
is_final=False,
|
99 |
+
cohort=cohort,
|
100 |
+
info_path=json_path,
|
101 |
+
is_gene_available=is_gene_available,
|
102 |
+
is_trait_available=is_trait_available
|
103 |
+
)
|
104 |
+
|
105 |
+
# 4) If trait data is available, extract clinical features
|
106 |
+
# (the 'clinical_data' dataframe is assumed to be available in the environment)
|
107 |
+
if trait_row is not None:
|
108 |
+
selected_clinical_df = geo_select_clinical_features(
|
109 |
+
clinical_df=clinical_data,
|
110 |
+
trait=trait,
|
111 |
+
trait_row=trait_row,
|
112 |
+
convert_trait=convert_trait,
|
113 |
+
age_row=age_row,
|
114 |
+
convert_age=convert_age,
|
115 |
+
gender_row=gender_row,
|
116 |
+
convert_gender=convert_gender
|
117 |
+
)
|
118 |
+
preview = preview_df(selected_clinical_df)
|
119 |
+
print("Clinical Data Preview:", preview)
|
120 |
+
|
121 |
+
# Save the selected clinical features
|
122 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
123 |
+
# STEP3
|
124 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
125 |
+
gene_data = get_genetic_data(matrix_file)
|
126 |
+
|
127 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
128 |
+
print(gene_data.index[:20])
|
129 |
+
# Based on the index shown (numeric IDs rather than standard human gene symbols),
|
130 |
+
# these identifiers are not human gene symbols. Therefore, gene mapping is required.
|
131 |
+
print("requires_gene_mapping = True")
|
132 |
+
# STEP5
|
133 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
134 |
+
gene_annotation = get_gene_annotation(soft_file)
|
135 |
+
|
136 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
137 |
+
print("Gene annotation preview:")
|
138 |
+
print(preview_df(gene_annotation))
|
139 |
+
# STEP6: Gene Identifier Mapping
|
140 |
+
|
141 |
+
# 1) From the preview, the "ID" column in gene_annotation corresponds to the numeric probe IDs
|
142 |
+
# in the gene expression data, and "GeneName" holds the associated gene symbols.
|
143 |
+
mapping_df = get_gene_mapping(annotation=gene_annotation, prob_col='ID', gene_col='GeneName')
|
144 |
+
|
145 |
+
# 2) Apply the probe-to-gene mapping to convert the probe-level expression data into gene-level expression data
|
146 |
+
gene_data = apply_gene_mapping(expression_df=gene_data, mapping_df=mapping_df)
|
147 |
+
|
148 |
+
# For observation, print the shape of the mapped gene_data and the first few gene symbols
|
149 |
+
print("Mapped gene_data shape:", gene_data.shape)
|
150 |
+
print("Example gene symbols in the index:", list(gene_data.index[:10]))
|
151 |
+
# STEP7
|
152 |
+
|
153 |
+
# 1. Normalize the obtained gene data and save
|
154 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
155 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
156 |
+
|
157 |
+
# 2. Link clinical and gene expression data on sample IDs
|
158 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical_df, normalized_gene_data)
|
159 |
+
|
160 |
+
# 3. Handle missing values systematically using the trait column name in the 'trait' variable
|
161 |
+
linked_data = handle_missing_values(linked_data, trait)
|
162 |
+
|
163 |
+
# 4. Check for biased features (trait, age, gender) using the same trait column name
|
164 |
+
is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
165 |
+
|
166 |
+
# 5. Final quality validation and record metadata
|
167 |
+
is_usable = validate_and_save_cohort_info(
|
168 |
+
is_final=True,
|
169 |
+
cohort=cohort,
|
170 |
+
info_path=json_path,
|
171 |
+
is_gene_available=True,
|
172 |
+
is_trait_available=True,
|
173 |
+
is_biased=is_trait_biased,
|
174 |
+
df=linked_data,
|
175 |
+
note=f"Preprocessed with trait column named '{trait}'."
|
176 |
+
)
|
177 |
+
|
178 |
+
# 6. If usable, save linked data
|
179 |
+
if is_usable:
|
180 |
+
linked_data.to_csv(out_data_file, index=True)
|
p1/preprocess/Sjögrens_Syndrome/code/GSE40611.py
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE40611"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE40611"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE40611.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE40611.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE40611.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP1
|
19 |
+
from tools.preprocess import *
|
20 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
21 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
22 |
+
|
23 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
24 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
25 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
27 |
+
|
28 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
29 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
32 |
+
print("Background Information:")
|
33 |
+
print(background_info)
|
34 |
+
print("Sample Characteristics Dictionary:")
|
35 |
+
print(sample_characteristics_dict)
|
36 |
+
# Step 1: Determine if the dataset likely contains gene expression data
|
37 |
+
# Based on the background info (Affymetrix U133 plus 2.0 microarray), we set:
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# Step 2.1: Identify availability of trait, age, and gender data in the sample characteristics
|
41 |
+
# The sample characteristics dictionary has:
|
42 |
+
# {0: ['disease status: Control', 'disease status: pSS', 'disease status: Sicca'],
|
43 |
+
# 1: ['batch: 1', 'batch: 2', 'batch: 3']}
|
44 |
+
# We see that row 0 contains "pSS", "Control", and "Sicca", useful for the 'trait'. No rows correspond to age or gender.
|
45 |
+
trait_row = 0
|
46 |
+
age_row = None
|
47 |
+
gender_row = None
|
48 |
+
|
49 |
+
# Step 2.2: Define conversion functions for trait, age, and gender.
|
50 |
+
|
51 |
+
def convert_trait(value: str):
|
52 |
+
"""
|
53 |
+
Convert raw disease status (after the last colon) to a binary indicator.
|
54 |
+
'pSS' -> 1, 'Control' or 'Sicca' -> 0, Others -> None
|
55 |
+
"""
|
56 |
+
if not value:
|
57 |
+
return None
|
58 |
+
val = value.split(':')[-1].strip().lower()
|
59 |
+
if 'pss' in val:
|
60 |
+
return 1
|
61 |
+
elif 'control' in val or 'sicca' in val:
|
62 |
+
return 0
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_age(value: str):
|
66 |
+
"""
|
67 |
+
This dataset does not provide age information, so return None.
|
68 |
+
"""
|
69 |
+
return None
|
70 |
+
|
71 |
+
def convert_gender(value: str):
|
72 |
+
"""
|
73 |
+
This dataset does not provide gender information, so return None.
|
74 |
+
"""
|
75 |
+
return None
|
76 |
+
|
77 |
+
# Step 3: Conduct initial filtering and save metadata
|
78 |
+
is_trait_available = (trait_row is not None)
|
79 |
+
_ = validate_and_save_cohort_info(
|
80 |
+
is_final=False,
|
81 |
+
cohort=cohort,
|
82 |
+
info_path=json_path,
|
83 |
+
is_gene_available=is_gene_available,
|
84 |
+
is_trait_available=is_trait_available
|
85 |
+
)
|
86 |
+
|
87 |
+
# Step 4: If trait data is available, extract clinical features, preview, and save
|
88 |
+
if trait_row is not None:
|
89 |
+
df_clinical = geo_select_clinical_features(
|
90 |
+
clinical_df=clinical_data,
|
91 |
+
trait=trait,
|
92 |
+
trait_row=trait_row,
|
93 |
+
convert_trait=convert_trait,
|
94 |
+
age_row=age_row,
|
95 |
+
convert_age=convert_age,
|
96 |
+
gender_row=gender_row,
|
97 |
+
convert_gender=convert_gender
|
98 |
+
)
|
99 |
+
preview_result = preview_df(df_clinical)
|
100 |
+
print("Clinical Data Preview:", preview_result)
|
101 |
+
|
102 |
+
df_clinical.to_csv(out_clinical_data_file, index=False)
|
103 |
+
# STEP3
|
104 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
105 |
+
gene_data = get_genetic_data(matrix_file)
|
106 |
+
|
107 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
108 |
+
print(gene_data.index[:20])
|
109 |
+
# These are Affymetrix probe IDs, not human gene symbols, so they need to be mapped
|
110 |
+
requires_gene_mapping = True
|
111 |
+
# STEP5
|
112 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
113 |
+
gene_annotation = get_gene_annotation(soft_file)
|
114 |
+
|
115 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
116 |
+
print("Gene annotation preview:")
|
117 |
+
print(preview_df(gene_annotation))
|
118 |
+
# Gene Identifier Mapping
|
119 |
+
|
120 |
+
# 1. Identify the columns in the annotation that match the probe IDs and the gene symbols
|
121 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
|
122 |
+
|
123 |
+
# 2. Convert probe-level measurements to gene-level expression data
|
124 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
125 |
+
# STEP7
|
126 |
+
|
127 |
+
# 1. Normalize the obtained gene data and save
|
128 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
129 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
130 |
+
|
131 |
+
# Use the clinical dataframe from STEP 2 (df_clinical) instead of the undefined selected_clinical_df
|
132 |
+
clinical_selected_df = df_clinical
|
133 |
+
|
134 |
+
# 2. Link clinical and gene expression data on sample IDs
|
135 |
+
linked_data = geo_link_clinical_genetic_data(clinical_selected_df, normalized_gene_data)
|
136 |
+
|
137 |
+
# 3. Handle missing values systematically using the trait column name in the 'trait' variable
|
138 |
+
linked_data = handle_missing_values(linked_data, trait)
|
139 |
+
|
140 |
+
# 4. Check for biased features (trait, age, gender) using the same trait column name
|
141 |
+
is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
142 |
+
|
143 |
+
# 5. Final quality validation and record metadata
|
144 |
+
is_usable = validate_and_save_cohort_info(
|
145 |
+
is_final=True,
|
146 |
+
cohort=cohort,
|
147 |
+
info_path=json_path,
|
148 |
+
is_gene_available=True,
|
149 |
+
is_trait_available=True,
|
150 |
+
is_biased=is_trait_biased,
|
151 |
+
df=linked_data,
|
152 |
+
note=f"Preprocessed with trait column named '{trait}'."
|
153 |
+
)
|
154 |
+
|
155 |
+
# 6. If usable, save linked data
|
156 |
+
if is_usable:
|
157 |
+
linked_data.to_csv(out_data_file, index=True)
|
p1/preprocess/Sjögrens_Syndrome/code/GSE51092.py
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE51092"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE51092"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE51092.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE51092.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE51092.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP1
|
19 |
+
from tools.preprocess import *
|
20 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
21 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
22 |
+
|
23 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
24 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
25 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
27 |
+
|
28 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
29 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
32 |
+
print("Background Information:")
|
33 |
+
print(background_info)
|
34 |
+
print("Sample Characteristics Dictionary:")
|
35 |
+
print(sample_characteristics_dict)
|
36 |
+
# Step 1: Determine if gene expression data is available
|
37 |
+
# Based on the background info mentioning gene expression data, we set:
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# Step 2: Assess availability of trait, age, and gender variables
|
41 |
+
# From the sample characteristics dictionary, only one key (0) exists, which records disease state.
|
42 |
+
# We map it as the trait row because it has two distinct values ("none" and "Sjögrens syndrome").
|
43 |
+
# No other keys exist for age or gender.
|
44 |
+
trait_row = 0
|
45 |
+
age_row = None
|
46 |
+
gender_row = None
|
47 |
+
|
48 |
+
# Data type conversion functions
|
49 |
+
|
50 |
+
def convert_trait(value: str):
|
51 |
+
"""
|
52 |
+
Convert the trait field to binary:
|
53 |
+
'disease state: none' -> 0
|
54 |
+
'disease state: Sjögrens syndrome' -> 1
|
55 |
+
Otherwise, return None.
|
56 |
+
"""
|
57 |
+
# Extract the substring after the first colon if it exists
|
58 |
+
parts = value.split(':', 1)
|
59 |
+
if len(parts) < 2:
|
60 |
+
return None
|
61 |
+
raw_val = parts[1].strip().lower()
|
62 |
+
if "none" in raw_val:
|
63 |
+
return 0
|
64 |
+
elif "sjögrens syndrome" in raw_val:
|
65 |
+
return 1
|
66 |
+
return None
|
67 |
+
|
68 |
+
def convert_age(value: str):
|
69 |
+
# Age data is not available in this dataset, so we return None
|
70 |
+
return None
|
71 |
+
|
72 |
+
def convert_gender(value: str):
|
73 |
+
# Gender data is not available, so return None
|
74 |
+
return None
|
75 |
+
|
76 |
+
# Step 3: Save metadata with initial filtering
|
77 |
+
# Trait availability is determined by trait_row != None.
|
78 |
+
is_trait_available = (trait_row is not None)
|
79 |
+
|
80 |
+
is_usable = validate_and_save_cohort_info(
|
81 |
+
is_final=False,
|
82 |
+
cohort=cohort,
|
83 |
+
info_path=json_path,
|
84 |
+
is_gene_available=is_gene_available,
|
85 |
+
is_trait_available=is_trait_available
|
86 |
+
)
|
87 |
+
|
88 |
+
# Step 4: If trait data is available, extract clinical features
|
89 |
+
if trait_row is not None:
|
90 |
+
# 'clinical_data' is the DataFrame with sample characteristics obtained in a previous step
|
91 |
+
selected_clinical_df = geo_select_clinical_features(
|
92 |
+
clinical_df=clinical_data,
|
93 |
+
trait=trait,
|
94 |
+
trait_row=trait_row,
|
95 |
+
convert_trait=convert_trait,
|
96 |
+
age_row=age_row,
|
97 |
+
convert_age=convert_age,
|
98 |
+
gender_row=gender_row,
|
99 |
+
convert_gender=convert_gender
|
100 |
+
)
|
101 |
+
# Preview the resulting clinical data
|
102 |
+
print(preview_df(selected_clinical_df))
|
103 |
+
# Save the clinical data
|
104 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
105 |
+
# STEP3
|
106 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
107 |
+
gene_data = get_genetic_data(matrix_file)
|
108 |
+
|
109 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
110 |
+
print(gene_data.index[:20])
|
111 |
+
# These identifiers appear to be Illumina probe IDs and not direct human gene symbols.
|
112 |
+
# Therefore, mapping to gene symbols is required.
|
113 |
+
|
114 |
+
print("requires_gene_mapping = True")
|
115 |
+
# STEP5
|
116 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
117 |
+
gene_annotation = get_gene_annotation(soft_file)
|
118 |
+
|
119 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
120 |
+
print("Gene annotation preview:")
|
121 |
+
print(preview_df(gene_annotation))
|
122 |
+
# STEP: Gene Identifier Mapping
|
123 |
+
|
124 |
+
# 1. Identify the corresponding columns in the annotation DataFrame
|
125 |
+
# The column "ID" in the annotation matches the probe IDs in the gene expression dataset,
|
126 |
+
# and "Symbol" is the column storing the gene symbols.
|
127 |
+
prob_col = "ID"
|
128 |
+
gene_col = "Symbol"
|
129 |
+
|
130 |
+
# 2. Build the mapping dataframe from 'gene_annotation'
|
131 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col, gene_col)
|
132 |
+
|
133 |
+
# 3. Convert the probe-level measurements in 'gene_data' to gene-level expression data
|
134 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
135 |
+
# STEP7
|
136 |
+
|
137 |
+
# 1. Normalize the obtained gene data and save
|
138 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
139 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
140 |
+
|
141 |
+
# Replace the undefined variable with the correct name from previous steps
|
142 |
+
clinical_selected_df = selected_clinical_df
|
143 |
+
|
144 |
+
# 2. Link clinical and gene expression data on sample IDs
|
145 |
+
linked_data = geo_link_clinical_genetic_data(clinical_selected_df, normalized_gene_data)
|
146 |
+
|
147 |
+
# 3. Handle missing values systematically using the trait column name in the 'trait' variable
|
148 |
+
linked_data = handle_missing_values(linked_data, trait)
|
149 |
+
|
150 |
+
# 4. Check for biased features (trait, age, gender) using the same trait column name
|
151 |
+
is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
152 |
+
|
153 |
+
# 5. Final quality validation and record metadata
|
154 |
+
is_usable = 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=True,
|
160 |
+
is_biased=is_trait_biased,
|
161 |
+
df=linked_data,
|
162 |
+
note=f"Preprocessed with trait column named '{trait}'."
|
163 |
+
)
|
164 |
+
|
165 |
+
# 6. If usable, save linked data
|
166 |
+
if is_usable:
|
167 |
+
linked_data.to_csv(out_data_file, index=True)
|
p1/preprocess/Sjögrens_Syndrome/code/GSE66795.py
ADDED
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE66795"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE66795"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE66795.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE66795.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE66795.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP1
|
19 |
+
from tools.preprocess import *
|
20 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
21 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
22 |
+
|
23 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
24 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
25 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
27 |
+
|
28 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
29 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
32 |
+
print("Background Information:")
|
33 |
+
print(background_info)
|
34 |
+
print("Sample Characteristics Dictionary:")
|
35 |
+
print(sample_characteristics_dict)
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
is_gene_available = True # This dataset uses whole genome microarray, so it's likely to have gene expression data.
|
38 |
+
|
39 |
+
# 2. Variable Availability and Data Type Conversion
|
40 |
+
# Based on the sample characteristics:
|
41 |
+
# - trait_row=2, because "patient group: Control/Patient" maps to presence/absence of Sjögrens_Syndrome.
|
42 |
+
# - age_row=None, as age data is not identified.
|
43 |
+
# - gender_row=None, because the dataset appears to have only females (constant feature).
|
44 |
+
trait_row = 2
|
45 |
+
age_row = None
|
46 |
+
gender_row = None
|
47 |
+
|
48 |
+
def convert_trait(x: str):
|
49 |
+
"""
|
50 |
+
Convert the variable in row 2 to binary for Sjögrens_Syndrome.
|
51 |
+
The raw string format is typically "patient group: Control" or "patient group: Patient".
|
52 |
+
"""
|
53 |
+
parts = x.split(":", 1)
|
54 |
+
if len(parts) < 2:
|
55 |
+
return None
|
56 |
+
val = parts[1].strip().lower()
|
57 |
+
if val == "control":
|
58 |
+
return 0
|
59 |
+
elif val == "patient":
|
60 |
+
return 1
|
61 |
+
return None
|
62 |
+
|
63 |
+
# No age or gender data available, so we won't define conversions for them.
|
64 |
+
convert_age = None
|
65 |
+
convert_gender = None
|
66 |
+
|
67 |
+
# 3. Perform initial filtering and save metadata
|
68 |
+
is_trait_available = (trait_row is not None)
|
69 |
+
is_usable = validate_and_save_cohort_info(
|
70 |
+
is_final=False,
|
71 |
+
cohort=cohort,
|
72 |
+
info_path=json_path,
|
73 |
+
is_gene_available=is_gene_available,
|
74 |
+
is_trait_available=is_trait_available
|
75 |
+
)
|
76 |
+
|
77 |
+
# 4. Clinical Feature Extraction (only if trait data is available)
|
78 |
+
if trait_row is not None:
|
79 |
+
selected_clinical_df = geo_select_clinical_features(
|
80 |
+
clinical_data,
|
81 |
+
trait=trait,
|
82 |
+
trait_row=trait_row,
|
83 |
+
convert_trait=convert_trait,
|
84 |
+
age_row=age_row,
|
85 |
+
convert_age=convert_age,
|
86 |
+
gender_row=gender_row,
|
87 |
+
convert_gender=convert_gender
|
88 |
+
)
|
89 |
+
# Preview
|
90 |
+
preview_result = preview_df(selected_clinical_df)
|
91 |
+
# Save the clinical data
|
92 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
93 |
+
# STEP3
|
94 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
95 |
+
gene_data = get_genetic_data(matrix_file)
|
96 |
+
|
97 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
98 |
+
print(gene_data.index[:20])
|
99 |
+
# These 'ILMN_' identifiers are Illumina probe IDs, not standard gene symbols.
|
100 |
+
# Therefore, they need to be mapped to proper gene symbols.
|
101 |
+
|
102 |
+
print("requires_gene_mapping = True")
|
103 |
+
# STEP5
|
104 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
105 |
+
gene_annotation = get_gene_annotation(soft_file)
|
106 |
+
|
107 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
108 |
+
print("Gene annotation preview:")
|
109 |
+
print(preview_df(gene_annotation))
|
110 |
+
# STEP: Gene Identifier Mapping
|
111 |
+
|
112 |
+
# 1 & 2. Decide which columns in the gene_annotation dataframe correspond to
|
113 |
+
# the probe identifiers and the gene symbols. Then create a mapping dataframe.
|
114 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Symbol')
|
115 |
+
|
116 |
+
# 3. Convert probe-level measurements to gene-level expression data.
|
117 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
118 |
+
# STEP7
|
119 |
+
|
120 |
+
# 1. Normalize the obtained gene data and save
|
121 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
122 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
123 |
+
|
124 |
+
# Replace the undefined variable with the correct name from previous steps
|
125 |
+
clinical_selected_df = selected_clinical_df
|
126 |
+
|
127 |
+
# 2. Link clinical and gene expression data on sample IDs
|
128 |
+
linked_data = geo_link_clinical_genetic_data(clinical_selected_df, normalized_gene_data)
|
129 |
+
|
130 |
+
# 3. Handle missing values systematically using the trait column name in the 'trait' variable
|
131 |
+
linked_data = handle_missing_values(linked_data, trait)
|
132 |
+
|
133 |
+
# 4. Check for biased features (trait, age, gender) using the same trait column name
|
134 |
+
is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
135 |
+
|
136 |
+
# 5. Final quality validation and record metadata
|
137 |
+
is_usable = validate_and_save_cohort_info(
|
138 |
+
is_final=True,
|
139 |
+
cohort=cohort,
|
140 |
+
info_path=json_path,
|
141 |
+
is_gene_available=True,
|
142 |
+
is_trait_available=True,
|
143 |
+
is_biased=is_trait_biased,
|
144 |
+
df=linked_data,
|
145 |
+
note=f"Preprocessed with trait column named '{trait}'."
|
146 |
+
)
|
147 |
+
|
148 |
+
# 6. If usable, save linked data
|
149 |
+
if is_usable:
|
150 |
+
linked_data.to_csv(out_data_file, index=True)
|
p1/preprocess/Sjögrens_Syndrome/code/GSE84844.py
ADDED
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE84844"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE84844"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE84844.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE84844.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE84844.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/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 info (whole-blood transcriptome), we set:
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# 2) Variable Availability and Data Type Conversion
|
41 |
+
|
42 |
+
# 2.1 Data Availability
|
43 |
+
# From the sample characteristics dictionary, we see:
|
44 |
+
# - Row 0 has "disease: Healthy control" and "disease: primary Sjogren's syndrome" => trait
|
45 |
+
# - Row 2 has "age: <value>" => age
|
46 |
+
# - Row 3 has "gender: Female" and "gender: Male" => gender
|
47 |
+
trait_row = 0
|
48 |
+
age_row = 2
|
49 |
+
gender_row = 3
|
50 |
+
|
51 |
+
# 2.2 Data Type Conversion
|
52 |
+
def convert_trait(value: str):
|
53 |
+
"""
|
54 |
+
Convert trait to binary:
|
55 |
+
- healthy -> 0
|
56 |
+
- primary Sjogren's syndrome -> 1
|
57 |
+
"""
|
58 |
+
parts = value.split(":")
|
59 |
+
if len(parts) < 2:
|
60 |
+
return None
|
61 |
+
v = parts[-1].strip().lower()
|
62 |
+
if "sjogren" in v or "sjögren" in v:
|
63 |
+
return 1
|
64 |
+
elif "healthy" in v:
|
65 |
+
return 0
|
66 |
+
return None
|
67 |
+
|
68 |
+
def convert_age(value: str):
|
69 |
+
"""
|
70 |
+
Convert age to continuous (int).
|
71 |
+
If parsing fails, return None.
|
72 |
+
"""
|
73 |
+
parts = value.split(":")
|
74 |
+
if len(parts) < 2:
|
75 |
+
return None
|
76 |
+
v = parts[-1].strip()
|
77 |
+
try:
|
78 |
+
return float(v)
|
79 |
+
except ValueError:
|
80 |
+
return None
|
81 |
+
|
82 |
+
def convert_gender(value: str):
|
83 |
+
"""
|
84 |
+
Convert gender to binary:
|
85 |
+
- female -> 0
|
86 |
+
- male -> 1
|
87 |
+
"""
|
88 |
+
parts = value.split(":")
|
89 |
+
if len(parts) < 2:
|
90 |
+
return None
|
91 |
+
v = parts[-1].strip().lower()
|
92 |
+
if v == "female":
|
93 |
+
return 0
|
94 |
+
elif v == "male":
|
95 |
+
return 1
|
96 |
+
return None
|
97 |
+
|
98 |
+
# 3) Save Metadata (initial filtering)
|
99 |
+
is_trait_available = (trait_row is not None)
|
100 |
+
validate_and_save_cohort_info(
|
101 |
+
is_final=False,
|
102 |
+
cohort=cohort,
|
103 |
+
info_path=json_path,
|
104 |
+
is_gene_available=is_gene_available,
|
105 |
+
is_trait_available=is_trait_available
|
106 |
+
)
|
107 |
+
|
108 |
+
# 4) Clinical Feature Extraction and Preview (only if trait data is available)
|
109 |
+
if trait_row is not None:
|
110 |
+
selected_clinical_df = geo_select_clinical_features(
|
111 |
+
clinical_data,
|
112 |
+
trait=trait,
|
113 |
+
trait_row=trait_row,
|
114 |
+
convert_trait=convert_trait,
|
115 |
+
age_row=age_row,
|
116 |
+
convert_age=convert_age,
|
117 |
+
gender_row=gender_row,
|
118 |
+
convert_gender=convert_gender
|
119 |
+
)
|
120 |
+
preview_output = preview_df(selected_clinical_df)
|
121 |
+
print("Preview of Selected Clinical Features:", preview_output)
|
122 |
+
selected_clinical_df.to_csv(out_clinical_data_file, index=False)
|
123 |
+
# STEP3
|
124 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
125 |
+
gene_data = get_genetic_data(matrix_file)
|
126 |
+
|
127 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
128 |
+
print(gene_data.index[:20])
|
129 |
+
# Observing the identifiers (e.g., '1007_s_at'), they appear to be Affymetrix probe IDs, not human gene symbols.
|
130 |
+
# Therefore, gene symbol mapping is required.
|
131 |
+
requires_gene_mapping = True
|
132 |
+
print("requires_gene_mapping = True")
|
133 |
+
# STEP5
|
134 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
135 |
+
gene_annotation = get_gene_annotation(soft_file)
|
136 |
+
|
137 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
138 |
+
print("Gene annotation preview:")
|
139 |
+
print(preview_df(gene_annotation))
|
140 |
+
# Gene Identifier Mapping
|
141 |
+
|
142 |
+
# 1) Identify the column in the gene_annotation dataframe that matches the probe IDs in gene_data: "ID"
|
143 |
+
# Also identify the column that stores the gene symbols: "Gene Symbol"
|
144 |
+
|
145 |
+
# 2) Extract the two columns to build the gene mapping dataframe
|
146 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
|
147 |
+
|
148 |
+
# 3) Apply the gene mapping to convert probe-level data to gene-level data
|
149 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
150 |
+
|
151 |
+
# (Optional) Print a small preview to confirm the transformation
|
152 |
+
print("Mapped gene expression data (head):")
|
153 |
+
print(gene_data.head())
|
154 |
+
# STEP7
|
155 |
+
|
156 |
+
# 1. Normalize the obtained gene data 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 |
+
# Replace the undefined variable with the correct name from previous steps
|
161 |
+
clinical_selected_df = selected_clinical_df
|
162 |
+
|
163 |
+
# 2. Link clinical and gene expression data on sample IDs
|
164 |
+
linked_data = geo_link_clinical_genetic_data(clinical_selected_df, normalized_gene_data)
|
165 |
+
|
166 |
+
# 3. Handle missing values systematically using the trait column name in the 'trait' variable
|
167 |
+
linked_data = handle_missing_values(linked_data, trait)
|
168 |
+
|
169 |
+
# 4. Check for biased features (trait, age, gender) using the same trait column name
|
170 |
+
is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
171 |
+
|
172 |
+
# 5. Final quality validation and record metadata
|
173 |
+
is_usable = validate_and_save_cohort_info(
|
174 |
+
is_final=True,
|
175 |
+
cohort=cohort,
|
176 |
+
info_path=json_path,
|
177 |
+
is_gene_available=True,
|
178 |
+
is_trait_available=True,
|
179 |
+
is_biased=is_trait_biased,
|
180 |
+
df=linked_data,
|
181 |
+
note=f"Preprocessed with trait column named '{trait}'."
|
182 |
+
)
|
183 |
+
|
184 |
+
# 6. If usable, save linked data
|
185 |
+
if is_usable:
|
186 |
+
linked_data.to_csv(out_data_file, index=True)
|
p1/preprocess/Sjögrens_Syndrome/code/GSE93683.py
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE93683"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE93683"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE93683.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE93683.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE93683.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/cohort_info.json"
|
17 |
+
|
18 |
+
# STEP1
|
19 |
+
from tools.preprocess import *
|
20 |
+
# 1. Identify the paths to the SOFT file and the matrix file
|
21 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
22 |
+
|
23 |
+
# 2. Read the matrix file to obtain background information and sample characteristics data
|
24 |
+
background_prefixes = ['!Series_title', '!Series_summary', '!Series_overall_design']
|
25 |
+
clinical_prefixes = ['!Sample_geo_accession', '!Sample_characteristics_ch1']
|
26 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file, background_prefixes, clinical_prefixes)
|
27 |
+
|
28 |
+
# 3. Obtain the sample characteristics dictionary from the clinical dataframe
|
29 |
+
sample_characteristics_dict = get_unique_values_by_row(clinical_data)
|
30 |
+
|
31 |
+
# 4. Explicitly print out all the background information and the sample characteristics dictionary
|
32 |
+
print("Background Information:")
|
33 |
+
print(background_info)
|
34 |
+
print("Sample Characteristics Dictionary:")
|
35 |
+
print(sample_characteristics_dict)
|
36 |
+
# 1. Determine if gene expression data is available
|
37 |
+
is_gene_available = True # Genome-wide transcriptome arrays indicate gene expression data.
|
38 |
+
|
39 |
+
# 2. Identify rows for trait, age, and gender based on sample characteristics
|
40 |
+
# and define conversion functions.
|
41 |
+
trait_row = 0 # 'disease state' row has 'HC' and 'pSS'
|
42 |
+
age_row = None # No age data found
|
43 |
+
gender_row = None # Only one unique value (Female), not useful for association
|
44 |
+
|
45 |
+
def convert_trait(value: str):
|
46 |
+
parts = value.split(":")
|
47 |
+
if len(parts) < 2:
|
48 |
+
return None
|
49 |
+
v = parts[1].strip().lower()
|
50 |
+
if v == "pss":
|
51 |
+
return 1
|
52 |
+
elif v == "hc":
|
53 |
+
return 0
|
54 |
+
return None
|
55 |
+
|
56 |
+
def convert_age(value: str):
|
57 |
+
return None # Not used, since age_row is None
|
58 |
+
|
59 |
+
def convert_gender(value: str):
|
60 |
+
return None # Not used, since gender_row is None
|
61 |
+
|
62 |
+
# 3. Initial filtering and metadata recording
|
63 |
+
is_usable = validate_and_save_cohort_info(
|
64 |
+
is_final=False,
|
65 |
+
cohort=cohort,
|
66 |
+
info_path=json_path,
|
67 |
+
is_gene_available=is_gene_available,
|
68 |
+
is_trait_available=(trait_row is not None)
|
69 |
+
)
|
70 |
+
|
71 |
+
# 4. If trait data exists, extract clinical features and preview/save them
|
72 |
+
if trait_row is not None:
|
73 |
+
extracted_clinical_data = geo_select_clinical_features(
|
74 |
+
clinical_df=clinical_data,
|
75 |
+
trait=trait,
|
76 |
+
trait_row=trait_row,
|
77 |
+
convert_trait=convert_trait,
|
78 |
+
age_row=age_row,
|
79 |
+
convert_age=convert_age,
|
80 |
+
gender_row=gender_row,
|
81 |
+
convert_gender=convert_gender
|
82 |
+
)
|
83 |
+
preview_result = preview_df(extracted_clinical_data)
|
84 |
+
print(preview_result)
|
85 |
+
extracted_clinical_data.to_csv(out_clinical_data_file, index=False)
|
86 |
+
# STEP3
|
87 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
88 |
+
gene_data = get_genetic_data(matrix_file)
|
89 |
+
|
90 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
91 |
+
print(gene_data.index[:20])
|
92 |
+
# The identifiers (e.g., '1007_s_at') are typical Affymetrix probe IDs rather than human gene symbols,
|
93 |
+
# hence they require mapping to official gene symbols.
|
94 |
+
print("requires_gene_mapping = True")
|
95 |
+
# STEP5
|
96 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
97 |
+
gene_annotation = get_gene_annotation(soft_file)
|
98 |
+
|
99 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
100 |
+
print("Gene annotation preview:")
|
101 |
+
print(preview_df(gene_annotation))
|
102 |
+
# STEP6: Gene Identifier Mapping
|
103 |
+
|
104 |
+
# 1. Identify columns for gene identifier and gene symbol in the gene_annotation DataFrame.
|
105 |
+
# The 'ID' column in gene_annotation matches our expression data index, and 'Gene Symbol' contains the gene symbols.
|
106 |
+
probe_col = "ID"
|
107 |
+
gene_symbol_col = "Gene Symbol"
|
108 |
+
|
109 |
+
# 2. Get a gene mapping dataframe using the library function get_gene_mapping.
|
110 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_col, gene_col=gene_symbol_col)
|
111 |
+
|
112 |
+
# 3. Convert probe-level measurements to gene expression data.
|
113 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
114 |
+
# STEP7
|
115 |
+
|
116 |
+
# 1. Normalize the obtained gene data and save
|
117 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
118 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
119 |
+
|
120 |
+
# Define a local reference to the clinical dataframe we extracted in step 2
|
121 |
+
# (assuming "extracted_clinical_data" still exists in the environment).
|
122 |
+
clinical_selected_df = extracted_clinical_data
|
123 |
+
|
124 |
+
# 2. Link clinical and gene expression data on sample IDs
|
125 |
+
linked_data = geo_link_clinical_genetic_data(clinical_selected_df, normalized_gene_data)
|
126 |
+
|
127 |
+
# 3. Handle missing values systematically using the trait column name in the 'trait' variable
|
128 |
+
linked_data = handle_missing_values(linked_data, trait)
|
129 |
+
|
130 |
+
# 4. Check for biased features (trait, age, gender) using the same trait column name
|
131 |
+
is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
132 |
+
|
133 |
+
# 5. Final quality validation and record metadata
|
134 |
+
is_usable = validate_and_save_cohort_info(
|
135 |
+
is_final=True,
|
136 |
+
cohort=cohort,
|
137 |
+
info_path=json_path,
|
138 |
+
is_gene_available=True,
|
139 |
+
is_trait_available=True,
|
140 |
+
is_biased=is_trait_biased,
|
141 |
+
df=linked_data,
|
142 |
+
note=f"Preprocessed with trait column named '{trait}'."
|
143 |
+
)
|
144 |
+
|
145 |
+
# 6. If usable, save linked data
|
146 |
+
if is_usable:
|
147 |
+
linked_data.to_csv(out_data_file, index=True)
|
p1/preprocess/Sjögrens_Syndrome/code/GSE94510.py
ADDED
@@ -0,0 +1,165 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
cohort = "GSE94510"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Sjögrens_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Sjögrens_Syndrome/GSE94510"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/GSE94510.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/GSE94510.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/GSE94510.csv"
|
16 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/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 Omni/transcriptome details, this dataset likely has gene expression data.
|
38 |
+
|
39 |
+
# 2) Variable Availability
|
40 |
+
# After examining the sample characteristics dictionary, we found:
|
41 |
+
# trait data is under key=0 with 2 unique values ("disease: pSS" or "disease: HC"), so trait_row=0.
|
42 |
+
# age data is not available, so age_row=None.
|
43 |
+
# gender data is constant ("Female"), so it is not usable for association studies, hence gender_row=None.
|
44 |
+
trait_row = 0
|
45 |
+
age_row = None
|
46 |
+
gender_row = None
|
47 |
+
|
48 |
+
# 2.2) Data Type Conversion Functions
|
49 |
+
def convert_trait(value: str):
|
50 |
+
"""
|
51 |
+
Convert 'disease: pSS' to 1 and 'disease: HC' to 0.
|
52 |
+
Return None if unknown.
|
53 |
+
"""
|
54 |
+
parts = value.split(":", 1)
|
55 |
+
if len(parts) < 2:
|
56 |
+
return None
|
57 |
+
val = parts[1].strip().lower()
|
58 |
+
if val == "pss":
|
59 |
+
return 1
|
60 |
+
elif val == "hc":
|
61 |
+
return 0
|
62 |
+
return None
|
63 |
+
|
64 |
+
def convert_age(value: str):
|
65 |
+
"""
|
66 |
+
No age data available, so always return None.
|
67 |
+
"""
|
68 |
+
return None
|
69 |
+
|
70 |
+
def convert_gender(value: str):
|
71 |
+
"""
|
72 |
+
No usable gender variation in this dataset, so always return None.
|
73 |
+
"""
|
74 |
+
return None
|
75 |
+
|
76 |
+
# 3) Save Metadata (Initial Filtering)
|
77 |
+
# Trait data is available if trait_row is not None
|
78 |
+
is_trait_available = (trait_row is not None)
|
79 |
+
validate_and_save_cohort_info(
|
80 |
+
is_final=False,
|
81 |
+
cohort=cohort,
|
82 |
+
info_path=json_path,
|
83 |
+
is_gene_available=is_gene_available,
|
84 |
+
is_trait_available=is_trait_available
|
85 |
+
)
|
86 |
+
|
87 |
+
# 4) Clinical Feature Extraction
|
88 |
+
# Perform this step only if trait_row is not None.
|
89 |
+
if trait_row is not None:
|
90 |
+
clinical_selected_df = geo_select_clinical_features(
|
91 |
+
clinical_df=clinical_data, # 'clinical_data' is assumed to be in the environment
|
92 |
+
trait='Disease',
|
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 features
|
102 |
+
preview_result = preview_df(clinical_selected_df, n=5, max_items=200)
|
103 |
+
print("Preview of extracted clinical features:", preview_result)
|
104 |
+
|
105 |
+
# Save the clinical features to CSV
|
106 |
+
clinical_selected_df.to_csv(out_clinical_data_file, index=False)
|
107 |
+
# STEP3
|
108 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
109 |
+
gene_data = get_genetic_data(matrix_file)
|
110 |
+
|
111 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
112 |
+
print(gene_data.index[:20])
|
113 |
+
print("They appear to be Affymetrix probe set identifiers, not standard human gene symbols.")
|
114 |
+
print("requires_gene_mapping = True")
|
115 |
+
# STEP5
|
116 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
117 |
+
gene_annotation = get_gene_annotation(soft_file)
|
118 |
+
|
119 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
120 |
+
print("Gene annotation preview:")
|
121 |
+
print(preview_df(gene_annotation))
|
122 |
+
# STEP: Gene Identifier Mapping
|
123 |
+
|
124 |
+
# 1. Identify the column in 'gene_annotation' that matches the gene expression dataset's "ID" column
|
125 |
+
# and the column storing the gene symbols. From the preview, these appear to be 'ID' and 'Gene Symbol'.
|
126 |
+
probe_column = "ID"
|
127 |
+
symbol_column = "Gene Symbol"
|
128 |
+
|
129 |
+
# 2. Obtain the mapping dataframe using the get_gene_mapping function
|
130 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=probe_column, gene_col=symbol_column)
|
131 |
+
|
132 |
+
# 3. Convert probe-level data to gene-level data by applying the mapping
|
133 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
134 |
+
print("Gene-level expression data shape:", gene_data.shape)
|
135 |
+
# STEP7
|
136 |
+
|
137 |
+
# 1. Normalize the obtained gene data and save
|
138 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
139 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
140 |
+
|
141 |
+
# 2. Link clinical and gene expression data (use the correct clinical variable name: clinical_selected_df)
|
142 |
+
linked_data = geo_link_clinical_genetic_data(clinical_selected_df, normalized_gene_data)
|
143 |
+
|
144 |
+
# 3. Handle missing values systematically.
|
145 |
+
# The trait column in clinical_selected_df is named "Disease", not the environment variable "trait".
|
146 |
+
linked_data = handle_missing_values(linked_data, "Disease")
|
147 |
+
|
148 |
+
# 4. Check for biased features (trait, age, gender) using "Disease" as the trait column name
|
149 |
+
is_trait_biased, linked_data = judge_and_remove_biased_features(linked_data, "Disease")
|
150 |
+
|
151 |
+
# 5. Final quality validation and record metadata
|
152 |
+
is_usable = validate_and_save_cohort_info(
|
153 |
+
is_final=True,
|
154 |
+
cohort=cohort,
|
155 |
+
info_path=json_path,
|
156 |
+
is_gene_available=True,
|
157 |
+
is_trait_available=True,
|
158 |
+
is_biased=is_trait_biased,
|
159 |
+
df=linked_data,
|
160 |
+
note="Preprocessed with trait column named 'Disease'."
|
161 |
+
)
|
162 |
+
|
163 |
+
# 6. If usable, save linked data
|
164 |
+
if is_usable:
|
165 |
+
linked_data.to_csv(out_data_file, index=True)
|
p1/preprocess/Sjögrens_Syndrome/code/TCGA.py
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Sjögrens_Syndrome"
|
6 |
+
|
7 |
+
# Input paths
|
8 |
+
tcga_root_dir = "../DATA/TCGA"
|
9 |
+
|
10 |
+
# Output paths
|
11 |
+
out_data_file = "./output/preprocess/1/Sjögrens_Syndrome/TCGA.csv"
|
12 |
+
out_gene_data_file = "./output/preprocess/1/Sjögrens_Syndrome/gene_data/TCGA.csv"
|
13 |
+
out_clinical_data_file = "./output/preprocess/1/Sjögrens_Syndrome/clinical_data/TCGA.csv"
|
14 |
+
json_path = "./output/preprocess/1/Sjögrens_Syndrome/cohort_info.json"
|
15 |
+
|
16 |
+
import os
|
17 |
+
|
18 |
+
# List of subdirectories from the TCGA root directory
|
19 |
+
subdirectories = [
|
20 |
+
'TCGA-LGG', 'CrawlData.ipynb', '.DS_Store',
|
21 |
+
'TCGA_lower_grade_glioma_and_glioblastoma_(GBMLGG)',
|
22 |
+
'TCGA_Uterine_Carcinosarcoma_(UCS)', 'TCGA_Thyroid_Cancer_(THCA)',
|
23 |
+
'TCGA_Thymoma_(THYM)', 'TCGA_Testicular_Cancer_(TGCT)',
|
24 |
+
'TCGA_Stomach_Cancer_(STAD)', 'TCGA_Sarcoma_(SARC)',
|
25 |
+
'TCGA_Rectal_Cancer_(READ)', 'TCGA_Prostate_Cancer_(PRAD)',
|
26 |
+
'TCGA_Pheochromocytoma_Paraganglioma_(PCPG)', 'TCGA_Pancreatic_Cancer_(PAAD)',
|
27 |
+
'TCGA_Ovarian_Cancer_(OV)', 'TCGA_Ocular_melanomas_(UVM)',
|
28 |
+
'TCGA_Mesothelioma_(MESO)', 'TCGA_Melanoma_(SKCM)',
|
29 |
+
'TCGA_Lung_Squamous_Cell_Carcinoma_(LUSC)', 'TCGA_Lung_Cancer_(LUNG)',
|
30 |
+
'TCGA_Lung_Adenocarcinoma_(LUAD)', 'TCGA_Lower_Grade_Glioma_(LGG)',
|
31 |
+
'TCGA_Liver_Cancer_(LIHC)', 'TCGA_Large_Bcell_Lymphoma_(DLBC)',
|
32 |
+
'TCGA_Kidney_Papillary_Cell_Carcinoma_(KIRP)', 'TCGA_Kidney_Clear_Cell_Carcinoma_(KIRC)',
|
33 |
+
'TCGA_Kidney_Chromophobe_(KICH)', 'TCGA_Head_and_Neck_Cancer_(HNSC)',
|
34 |
+
'TCGA_Glioblastoma_(GBM)', 'TCGA_Esophageal_Cancer_(ESCA)',
|
35 |
+
'TCGA_Endometrioid_Cancer_(UCEC)', 'TCGA_Colon_and_Rectal_Cancer_(COADREAD)',
|
36 |
+
'TCGA_Colon_Cancer_(COAD)', 'TCGA_Cervical_Cancer_(CESC)',
|
37 |
+
'TCGA_Breast_Cancer_(BRCA)', 'TCGA_Bladder_Cancer_(BLCA)',
|
38 |
+
'TCGA_Bile_Duct_Cancer_(CHOL)', 'TCGA_Adrenocortical_Cancer_(ACC)',
|
39 |
+
'TCGA_Acute_Myeloid_Leukemia_(LAML)'
|
40 |
+
]
|
41 |
+
|
42 |
+
relevant_folder = None
|
43 |
+
for folder in subdirectories:
|
44 |
+
folder_lower = folder.lower()
|
45 |
+
# Searching for terms like 'sjogren' or 'sicca' to match "Sjögrens_Syndrome"
|
46 |
+
if "sjogren" in folder_lower or "sicca" in folder_lower:
|
47 |
+
relevant_folder = folder
|
48 |
+
break
|
49 |
+
|
50 |
+
if not relevant_folder:
|
51 |
+
# No suitable directory found, we skip this trait
|
52 |
+
_ = validate_and_save_cohort_info(
|
53 |
+
is_final=False,
|
54 |
+
cohort="TCGA",
|
55 |
+
info_path=json_path,
|
56 |
+
is_gene_available=False,
|
57 |
+
is_trait_available=False
|
58 |
+
)
|
59 |
+
print("No suitable directory found for trait Sjögrens_Syndrome. Skipping this trait.")
|
60 |
+
else:
|
61 |
+
clinical_file, genetic_file = tcga_get_relevant_filepaths(os.path.join(tcga_root_dir, relevant_folder))
|
62 |
+
|
63 |
+
clinical_data = pd.read_csv(clinical_file, index_col=0, sep='\t')
|
64 |
+
genetic_data = pd.read_csv(genetic_file, index_col=0, sep='\t')
|
65 |
+
|
66 |
+
print("Clinical data columns:", clinical_data.columns.tolist())
|
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE135809.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f872956c5183040775dc2644bbb1adc5397e7bc257b5cde1d1dbd02ed0ad116e
|
3 |
+
size 12770430
|
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE143153.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE40611.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:65e211fa77a05c8e3393f7b4102ab36c7010ee4ce32ea0c64db7a26e09ac168e
|
3 |
+
size 10808851
|
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE51092.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b7ce24129f9056795e980dd6ff815dbc1187b9aca2135243f666fd5a61d8fdc2
|
3 |
+
size 27673057
|
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE84844.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ced8660c3b6e6942c58aaa28a2c6552ecf30e27516e0077911a72f2f616d504e
|
3 |
+
size 15946036
|
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE93683.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8e140dbb88b71e67151974ee622220e2b4c11bec24df485f537a62d43c954d89
|
3 |
+
size 12769411
|
p1/preprocess/Sjögrens_Syndrome/gene_data/GSE94510.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Stomach_Cancer/GSE208099.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p1/preprocess/Stomach_Cancer/clinical_data/GSE208099.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
GSM6337084,GSM6337085,GSM6337086,GSM6337087,GSM6337088,GSM6337089,GSM6337090,GSM6337091,GSM6337092,GSM6337093,GSM6337094,GSM6337095,GSM6337096,GSM6337097,GSM6337098,GSM6337099,GSM6337100,GSM6337101,GSM6337102,GSM6337103,GSM6337104,GSM6337105,GSM6337106,GSM6337107,GSM6337108,GSM6337109,GSM6337110,GSM6337111,GSM6337112,GSM6337113,GSM6337114,GSM6337115
|
2 |
+
1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0
|
3 |
+
1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p1/preprocess/Stomach_Cancer/code/GSE118916.py
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Stomach_Cancer"
|
6 |
+
cohort = "GSE118916"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Stomach_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Stomach_Cancer/GSE118916"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Stomach_Cancer/GSE118916.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Stomach_Cancer/gene_data/GSE118916.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Stomach_Cancer/clinical_data/GSE118916.csv"
|
16 |
+
json_path = "./output/preprocess/1/Stomach_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. Check if the dataset likely contains gene expression data
|
37 |
+
is_gene_available = True # Based on the background info, it's microarray gene expression
|
38 |
+
|
39 |
+
# 2.1 Identify the data availability for each variable
|
40 |
+
trait_row = None # No row found for trait (Stomach_Cancer)
|
41 |
+
age_row = None # No row found for age
|
42 |
+
gender_row = 0 # Row 0 has 2 distinct values ["gender: female", "gender: male"]
|
43 |
+
|
44 |
+
# 2.2 Define conversion functions for each variable
|
45 |
+
def convert_trait(value: str):
|
46 |
+
# No trait data found, so always return None
|
47 |
+
return None
|
48 |
+
|
49 |
+
def convert_age(value: str):
|
50 |
+
# No age data found, so always return None
|
51 |
+
return None
|
52 |
+
|
53 |
+
def convert_gender(value: str):
|
54 |
+
# Extract the part after the colon
|
55 |
+
val = value.split(':')[-1].strip().lower()
|
56 |
+
if val == 'female':
|
57 |
+
return 0
|
58 |
+
elif val == 'male':
|
59 |
+
return 1
|
60 |
+
else:
|
61 |
+
return None
|
62 |
+
|
63 |
+
# 3. Save metadata with initial filtering
|
64 |
+
is_trait_available = (trait_row is not None)
|
65 |
+
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. Since trait_row is None, skip clinical feature extraction
|
74 |
+
# STEP3
|
75 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
76 |
+
gene_data = get_genetic_data(matrix_file)
|
77 |
+
|
78 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
79 |
+
print(gene_data.index[:20])
|
80 |
+
# These probe set IDs (e.g., "11715100_at") are typically Affymetrix array probe identifiers,
|
81 |
+
# not standard human gene symbols. Therefore, they require mapping to gene symbols.
|
82 |
+
print("requires_gene_mapping = True")
|
83 |
+
# STEP5
|
84 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
85 |
+
gene_annotation = get_gene_annotation(soft_file)
|
86 |
+
|
87 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
88 |
+
print("Gene annotation preview:")
|
89 |
+
print(preview_df(gene_annotation))
|
90 |
+
# STEP: Gene Identifier Mapping
|
91 |
+
|
92 |
+
# 1) Determine which columns in the gene_annotation dataframe contain
|
93 |
+
# the same identifiers as the gene_data's index and which contain the gene symbols.
|
94 |
+
# From the preview, "ID" matches the probe identifiers and "Gene Symbol" contains gene symbols.
|
95 |
+
|
96 |
+
# 2) Build a gene mapping dataframe by extracting these two columns from gene_annotation.
|
97 |
+
mapping_df = get_gene_mapping(gene_annotation, "ID", "Gene Symbol")
|
98 |
+
|
99 |
+
# 3) Convert probe-level measurements to gene-level measurements.
|
100 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
101 |
+
# STEP7
|
102 |
+
|
103 |
+
# Per the instructions and reviewer's feedback, this dataset does not actually have a trait column.
|
104 |
+
# Therefore, we cannot proceed with final validation or linking clinical data based on a non-existent trait.
|
105 |
+
|
106 |
+
# 1. Normalize the obtained gene data and save.
|
107 |
+
# (We can still provide normalized gene expression data even though no trait is available.)
|
108 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
109 |
+
normalized_gene_data.to_csv(out_gene_data_file)
|
110 |
+
|
111 |
+
# Since the trait is not available, we skip final linking, missing-value handling, and final validation steps.
|
112 |
+
# We set is_trait_available=False to reflect the actual dataset status.
|
113 |
+
# No final validation or saving of linked data will be performed here.
|
114 |
+
|
115 |
+
is_trait_available = False
|
116 |
+
print("Trait is not available => skipping linking, quality checks, and final validation.")
|
p1/preprocess/Stomach_Cancer/code/GSE128459.py
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Stomach_Cancer"
|
6 |
+
cohort = "GSE128459"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Stomach_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Stomach_Cancer/GSE128459"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/1/Stomach_Cancer/GSE128459.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/1/Stomach_Cancer/gene_data/GSE128459.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/1/Stomach_Cancer/clinical_data/GSE128459.csv"
|
16 |
+
json_path = "./output/preprocess/1/Stomach_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 info ("Expression profiling..." in the GEO record), we consider gene expression data present.
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# 2. Variable Availability and Data Type Conversion
|
41 |
+
# Inspecting the sample characteristics shows only the following rows:
|
42 |
+
# 0 -> ['tissue: Gastric Cancer']
|
43 |
+
# 1 -> ['sample type: Cells', 'sample type: Organoids', 'sample type: PR', 'sample type: PRX']
|
44 |
+
# All samples appear to be cancer samples, so there's no variation for the trait.
|
45 |
+
# No age or gender data is found either.
|
46 |
+
trait_row = None # No variation for trait => treat as not available
|
47 |
+
age_row = None # No age info available
|
48 |
+
gender_row = None # No gender info available
|
49 |
+
|
50 |
+
# Define data conversion functions as placeholders.
|
51 |
+
def convert_trait(value: str):
|
52 |
+
"""
|
53 |
+
Convert trait data to a binary format.
|
54 |
+
Since the data is not actually available, we simply parse but ultimately return None here.
|
55 |
+
"""
|
56 |
+
return None
|
57 |
+
|
58 |
+
def convert_age(value: str):
|
59 |
+
"""
|
60 |
+
Convert age data to a continuous format.
|
61 |
+
Since no age data is available, return None.
|
62 |
+
"""
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_gender(value: str):
|
66 |
+
"""
|
67 |
+
Convert gender data to a binary format: female -> 0, male -> 1.
|
68 |
+
Since no gender data is available, return None.
|
69 |
+
"""
|
70 |
+
return None
|
71 |
+
|
72 |
+
# 3. Save Metadata (initial filtering)
|
73 |
+
# Trait is not available (trait_row is None), so is_trait_available = False.
|
74 |
+
is_trait_available = (trait_row is not None)
|
75 |
+
|
76 |
+
validate_and_save_cohort_info(
|
77 |
+
is_final=False,
|
78 |
+
cohort=cohort,
|
79 |
+
info_path=json_path,
|
80 |
+
is_gene_available=is_gene_available,
|
81 |
+
is_trait_available=is_trait_available
|
82 |
+
)
|
83 |
+
|
84 |
+
# 4. Clinical Feature Extraction
|
85 |
+
# Since trait_row is None, we skip clinical data extraction.
|
86 |
+
# STEP3
|
87 |
+
# 1. Use the get_genetic_data function from the library to get the gene_data from the matrix_file previously defined.
|
88 |
+
gene_data = get_genetic_data(matrix_file)
|
89 |
+
|
90 |
+
# 2. Print the first 20 row IDs (gene or probe identifiers) for future observation.
|
91 |
+
print(gene_data.index[:20])
|
92 |
+
# These are Illumina probe IDs, not standard human gene symbols, so mapping is required.
|
93 |
+
print("requires_gene_mapping = True")
|
94 |
+
# STEP5
|
95 |
+
# 1. Use the 'get_gene_annotation' function from the library to get gene annotation data from the SOFT file.
|
96 |
+
gene_annotation = get_gene_annotation(soft_file)
|
97 |
+
|
98 |
+
# 2. Use the 'preview_df' function from the library to preview the data and print out the results.
|
99 |
+
print("Gene annotation preview:")
|
100 |
+
print(preview_df(gene_annotation))
|
101 |
+
# Gene Identifier Mapping
|
102 |
+
|
103 |
+
# 1) Identify the columns in the gene annotation that match the probe IDs in the expression data
|
104 |
+
# and the gene symbols, respectively.
|
105 |
+
id_column = "ID"
|
106 |
+
symbol_column = "Symbol"
|
107 |
+
|
108 |
+
# 2) Get a gene mapping dataframe from the annotation dataframe
|
109 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col=id_column, gene_col=symbol_column)
|
110 |
+
|
111 |
+
# 3) Convert probe-level measurements to gene expression data
|
112 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
113 |
+
# STEP7
|
114 |
+
|
115 |
+
# Since the dataset has no trait data (trait_row was None), we cannot link clinical data
|
116 |
+
# or perform trait-based analysis. However, we should still normalize the gene data
|
117 |
+
# and record metadata indicating that the dataset is not usable for trait association.
|
118 |
+
|
119 |
+
# 1) Normalize the obtained gene data
|
120 |
+
normalized_gene_data = normalize_gene_symbols_in_index(gene_data)
|
121 |
+
|
122 |
+
# 2) Save the normalized data as a CSV file
|
123 |
+
normalized_gene_data.to_csv(out_gene_data_file, index=True)
|
124 |
+
|
125 |
+
# 3) Perform final validation to record the dataset's unusability for trait analysis
|
126 |
+
# We set is_trait_available=False, so it will be deemed not usable.
|
127 |
+
# We must still pass is_biased (boolean) and a dataframe. Here we set is_biased=False
|
128 |
+
# for consistency, because the absence of the trait is what makes it unusable, not bias.
|
129 |
+
validate_and_save_cohort_info(
|
130 |
+
is_final=True,
|
131 |
+
cohort=cohort,
|
132 |
+
info_path=json_path,
|
133 |
+
is_gene_available=True,
|
134 |
+
is_trait_available=False,
|
135 |
+
is_biased=False,
|
136 |
+
df=normalized_gene_data,
|
137 |
+
note="No trait data available. Only normalized gene data."
|
138 |
+
)
|
139 |
+
|
140 |
+
print("No trait data available; only normalized gene data is saved. Final metadata recorded.")
|