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 +15 -0
- p3/preprocess/Bladder_Cancer/TCGA.csv +3 -0
- p3/preprocess/Bladder_Cancer/gene_data/GSE245953.csv +3 -0
- p3/preprocess/Cardiovascular_Disease/GSE235307.csv +3 -0
- p3/preprocess/Cardiovascular_Disease/gene_data/GSE182600.csv +3 -0
- p3/preprocess/Cardiovascular_Disease/gene_data/GSE228783.csv +3 -0
- p3/preprocess/Cardiovascular_Disease/gene_data/GSE235307.csv +3 -0
- p3/preprocess/Cardiovascular_Disease/gene_data/GSE256539.csv +3 -0
- p3/preprocess/Celiac_Disease/gene_data/GSE138297.csv +3 -0
- p3/preprocess/Celiac_Disease/gene_data/GSE164883.csv +0 -0
- p3/preprocess/Celiac_Disease/gene_data/GSE20332.csv +3 -0
- p3/preprocess/Celiac_Disease/gene_data/GSE72625.csv +3 -0
- p3/preprocess/Celiac_Disease/gene_data/GSE87629.csv +0 -0
- p3/preprocess/Cervical_Cancer/GSE138079.csv +3 -0
- p3/preprocess/Cervical_Cancer/GSE138080.csv +0 -0
- p3/preprocess/Cervical_Cancer/GSE146114.csv +3 -0
- p3/preprocess/Cervical_Cancer/GSE63678.csv +0 -0
- p3/preprocess/Cervical_Cancer/clinical_data/GSE131027.csv +2 -0
- p3/preprocess/Cervical_Cancer/clinical_data/GSE138079.csv +2 -0
- p3/preprocess/Cervical_Cancer/clinical_data/GSE138080.csv +2 -0
- p3/preprocess/Cervical_Cancer/clinical_data/GSE146114.csv +2 -0
- p3/preprocess/Cervical_Cancer/clinical_data/GSE163114.csv +2 -0
- p3/preprocess/Cervical_Cancer/clinical_data/GSE63678.csv +2 -0
- p3/preprocess/Cervical_Cancer/clinical_data/GSE75132.csv +2 -0
- p3/preprocess/Cervical_Cancer/code/GSE107754.py +139 -0
- p3/preprocess/Cervical_Cancer/code/GSE114243.py +255 -0
- p3/preprocess/Cervical_Cancer/code/GSE131027.py +92 -0
- p3/preprocess/Cervical_Cancer/code/GSE137034.py +57 -0
- p3/preprocess/Cervical_Cancer/code/GSE138079.py +176 -0
- p3/preprocess/Cervical_Cancer/code/GSE138080.py +229 -0
- p3/preprocess/Cervical_Cancer/code/GSE146114.py +161 -0
- p3/preprocess/Cervical_Cancer/code/GSE163114.py +114 -0
- p3/preprocess/Cervical_Cancer/code/GSE63678.py +128 -0
- p3/preprocess/Cervical_Cancer/code/GSE75132.py +145 -0
- p3/preprocess/Cervical_Cancer/code/TCGA.py +104 -0
- p3/preprocess/Cervical_Cancer/gene_data/GSE107754.csv +3 -0
- p3/preprocess/Cervical_Cancer/gene_data/GSE114243.csv +0 -0
- p3/preprocess/Cervical_Cancer/gene_data/GSE138079.csv +3 -0
- p3/preprocess/Cervical_Cancer/gene_data/GSE138080.csv +0 -0
- p3/preprocess/Cervical_Cancer/gene_data/GSE146114.csv +3 -0
- p3/preprocess/Cervical_Cancer/gene_data/GSE63678.csv +0 -0
- p3/preprocess/Cervical_Cancer/gene_data/GSE75132.csv +0 -0
- p3/preprocess/Chronic_Fatigue_Syndrome/GSE251792.csv +0 -0
- p3/preprocess/Chronic_Fatigue_Syndrome/clinical_data/GSE251792.csv +4 -0
- p3/preprocess/Chronic_Fatigue_Syndrome/clinical_data/GSE39684.csv +2 -0
- p3/preprocess/Chronic_Fatigue_Syndrome/clinical_data/GSE67311.csv +2 -0
- p3/preprocess/Chronic_Fatigue_Syndrome/code/GSE251792.py +154 -0
- p3/preprocess/Chronic_Fatigue_Syndrome/code/GSE39684.py +129 -0
- p3/preprocess/Chronic_Fatigue_Syndrome/code/GSE67311.py +157 -0
- p3/preprocess/Chronic_Fatigue_Syndrome/code/TCGA.py +30 -0
.gitattributes
CHANGED
@@ -1559,3 +1559,18 @@ p3/preprocess/Cardiovascular_Disease/GSE182600.csv filter=lfs diff=lfs merge=lfs
|
|
1559 |
p3/preprocess/Cardiovascular_Disease/gene_data/GSE285666.csv filter=lfs diff=lfs merge=lfs -text
|
1560 |
p3/preprocess/Cardiovascular_Disease/gene_data/GSE190042.csv filter=lfs diff=lfs merge=lfs -text
|
1561 |
p3/preprocess/Celiac_Disease/GSE138297.csv filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1559 |
p3/preprocess/Cardiovascular_Disease/gene_data/GSE285666.csv filter=lfs diff=lfs merge=lfs -text
|
1560 |
p3/preprocess/Cardiovascular_Disease/gene_data/GSE190042.csv filter=lfs diff=lfs merge=lfs -text
|
1561 |
p3/preprocess/Celiac_Disease/GSE138297.csv filter=lfs diff=lfs merge=lfs -text
|
1562 |
+
p3/preprocess/Cardiovascular_Disease/GSE235307.csv filter=lfs diff=lfs merge=lfs -text
|
1563 |
+
p3/preprocess/Cardiovascular_Disease/gene_data/GSE182600.csv filter=lfs diff=lfs merge=lfs -text
|
1564 |
+
p3/preprocess/Cardiovascular_Disease/gene_data/GSE256539.csv filter=lfs diff=lfs merge=lfs -text
|
1565 |
+
p3/preprocess/Cardiovascular_Disease/gene_data/GSE228783.csv filter=lfs diff=lfs merge=lfs -text
|
1566 |
+
p3/preprocess/Cardiovascular_Disease/gene_data/GSE235307.csv filter=lfs diff=lfs merge=lfs -text
|
1567 |
+
p3/preprocess/Celiac_Disease/gene_data/GSE138297.csv filter=lfs diff=lfs merge=lfs -text
|
1568 |
+
p3/preprocess/Celiac_Disease/gene_data/GSE72625.csv filter=lfs diff=lfs merge=lfs -text
|
1569 |
+
p3/preprocess/Bladder_Cancer/gene_data/GSE245953.csv filter=lfs diff=lfs merge=lfs -text
|
1570 |
+
p3/preprocess/Cervical_Cancer/GSE138079.csv filter=lfs diff=lfs merge=lfs -text
|
1571 |
+
p3/preprocess/Cervical_Cancer/GSE146114.csv filter=lfs diff=lfs merge=lfs -text
|
1572 |
+
p3/preprocess/Cervical_Cancer/gene_data/GSE138079.csv filter=lfs diff=lfs merge=lfs -text
|
1573 |
+
p3/preprocess/Cervical_Cancer/gene_data/GSE107754.csv filter=lfs diff=lfs merge=lfs -text
|
1574 |
+
p3/preprocess/Cervical_Cancer/gene_data/GSE146114.csv filter=lfs diff=lfs merge=lfs -text
|
1575 |
+
p3/preprocess/Celiac_Disease/gene_data/GSE20332.csv filter=lfs diff=lfs merge=lfs -text
|
1576 |
+
p3/preprocess/Bladder_Cancer/TCGA.csv filter=lfs diff=lfs merge=lfs -text
|
p3/preprocess/Bladder_Cancer/TCGA.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3f1924c36b9a7e7f962d041565fdbee3ff06a6b8d08e7cd6a5a72105a2b149df
|
3 |
+
size 128067090
|
p3/preprocess/Bladder_Cancer/gene_data/GSE245953.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:77ff7c68c5202c9d866bd896ce6c4188bfd489a54f1c35c66410d2a1d7835a3a
|
3 |
+
size 101269272
|
p3/preprocess/Cardiovascular_Disease/GSE235307.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:861910b641bf01141e8ebdf4ad74ba38bfaee2180aec58f8960f79e5f57a30e8
|
3 |
+
size 30127849
|
p3/preprocess/Cardiovascular_Disease/gene_data/GSE182600.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8ab10642973a2c6ae075b4608278a038bc9bf2ff5fa8d444a21b081ea4467056
|
3 |
+
size 26035031
|
p3/preprocess/Cardiovascular_Disease/gene_data/GSE228783.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f2bf23a43d7dc835898cc3d3f388f1f187b5b187eb1df2048cd42229d690e1bd
|
3 |
+
size 31577651
|
p3/preprocess/Cardiovascular_Disease/gene_data/GSE235307.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9d40bfec5aee125dd279e5a4a5b658d3b8c0ce73e2f05846a13e621756e1927e
|
3 |
+
size 30126272
|
p3/preprocess/Cardiovascular_Disease/gene_data/GSE256539.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b5d9bb647998b040f0223d33002ee74f0c056ba2da0e63216486b09fb81c0e23
|
3 |
+
size 22918341
|
p3/preprocess/Celiac_Disease/gene_data/GSE138297.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:de9565415a246beb680e5ba05e15de50eccfec4d24f558d0cba022302313ca04
|
3 |
+
size 15408302
|
p3/preprocess/Celiac_Disease/gene_data/GSE164883.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Celiac_Disease/gene_data/GSE20332.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b14885da723a22361e67b291932000bcca46d782922d18d9e505dd11fc7ffbf1
|
3 |
+
size 39152792
|
p3/preprocess/Celiac_Disease/gene_data/GSE72625.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:325807d024ec96bfc7502345547a71e32706a9fa41282e819126c5f7d4b3f51b
|
3 |
+
size 12146945
|
p3/preprocess/Celiac_Disease/gene_data/GSE87629.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Cervical_Cancer/GSE138079.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:98bc373c59133dea1c560857bd5c7d0ddb7722fcdc5760df9d5a9226a609a394
|
3 |
+
size 14805474
|
p3/preprocess/Cervical_Cancer/GSE138080.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Cervical_Cancer/GSE146114.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:05dedb772201477e04aacb74538b53e9174c04afb11f5c8a20772783d5be5b84
|
3 |
+
size 17649533
|
p3/preprocess/Cervical_Cancer/GSE63678.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Cervical_Cancer/clinical_data/GSE131027.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM3759992,GSM3759993,GSM3759994,GSM3759995,GSM3759996,GSM3759997,GSM3759998,GSM3759999,GSM3760000,GSM3760001,GSM3760002,GSM3760003,GSM3760004,GSM3760005,GSM3760006,GSM3760007,GSM3760008,GSM3760009,GSM3760010,GSM3760011,GSM3760012,GSM3760013,GSM3760014,GSM3760015,GSM3760016,GSM3760017,GSM3760018,GSM3760019,GSM3760020,GSM3760021,GSM3760022,GSM3760023,GSM3760024,GSM3760025,GSM3760026,GSM3760027,GSM3760028,GSM3760029,GSM3760030,GSM3760031,GSM3760032,GSM3760033,GSM3760034,GSM3760035,GSM3760036,GSM3760037,GSM3760038,GSM3760039,GSM3760040,GSM3760041,GSM3760042,GSM3760043,GSM3760044,GSM3760045,GSM3760046,GSM3760047,GSM3760048,GSM3760049,GSM3760050,GSM3760051,GSM3760052,GSM3760053,GSM3760054,GSM3760055,GSM3760056,GSM3760057,GSM3760058,GSM3760059,GSM3760060,GSM3760061,GSM3760062,GSM3760063,GSM3760064,GSM3760065,GSM3760066,GSM3760067,GSM3760068,GSM3760069,GSM3760070,GSM3760071,GSM3760072,GSM3760073,GSM3760074,GSM3760075,GSM3760076,GSM3760077,GSM3760078,GSM3760079,GSM3760080,GSM3760081,GSM3760082,GSM3760083
|
2 |
+
Cervical_Cancer,0.0,0.0,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,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,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
|
p3/preprocess/Cervical_Cancer/clinical_data/GSE138079.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM4098797,GSM4098798,GSM4098799,GSM4098800,GSM4098801,GSM4098802,GSM4098803,GSM4098804,GSM4098805,GSM4098806,GSM4098807,GSM4098808,GSM4098809,GSM4098810,GSM4098811,GSM4098812,GSM4098813,GSM4098814,GSM4098815,GSM4098816,GSM4098817,GSM4098818,GSM4098819,GSM4098820,GSM4098821,GSM4098822,GSM4098823,GSM4098824,GSM4098825,GSM4098826,GSM4098827,GSM4098828,GSM4098829,GSM4098830,GSM4098831,GSM4098832,GSM4098833,GSM4098834,GSM4098835,GSM4098836,GSM4098837,GSM4098838,GSM4098839,GSM4098840,GSM4098841,GSM4098842,GSM4098843,GSM4098844,GSM4098845,GSM4098846,GSM4098847,GSM4098848,GSM4098849,GSM4098850,GSM4098851,GSM4098852,GSM4098853,GSM4098854,GSM4098855,GSM4098856,GSM4098857,GSM4098858,GSM4098859,GSM4098860
|
2 |
+
Cervical_Cancer,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,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,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,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0
|
p3/preprocess/Cervical_Cancer/clinical_data/GSE138080.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM4098861,GSM4098862,GSM4098863,GSM4098864,GSM4098865,GSM4098866,GSM4098867,GSM4098868,GSM4098869,GSM4098870,GSM4098871,GSM4098872,GSM4098873,GSM4098874,GSM4098875,GSM4098876,GSM4098877,GSM4098878,GSM4098879,GSM4098880,GSM4098881,GSM4098882,GSM4098883,GSM4098884,GSM4098885,GSM4098886,GSM4098887,GSM4098888,GSM4098889,GSM4098890,GSM4098891,GSM4098892,GSM4098893,GSM4098894,GSM4098895
|
2 |
+
Cervical_Cancer,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
|
p3/preprocess/Cervical_Cancer/clinical_data/GSE146114.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM678702,GSM678704,GSM678706,GSM678710,GSM678711,GSM678713,GSM678715,GSM678718,GSM678719,GSM678720,GSM678721,GSM678722,GSM678723,GSM678724,GSM678726,GSM678727,GSM678728,GSM678729,GSM678730,GSM678731,GSM678732,GSM678733,GSM678736,GSM678737,GSM678739,GSM678740,GSM678741,GSM678742,GSM678743,GSM678744,GSM678745,GSM678748,GSM678752,GSM678753,GSM678754,GSM678755,GSM678756,GSM678757,GSM678759,GSM678760,GSM678761,GSM678762,GSM678765,GSM678767,GSM678768,GSM678769,GSM678770,GSM678771,GSM678772,GSM678773,GSM678774,GSM678775,GSM678776,GSM678777,GSM678778,GSM678779,GSM678780,GSM738916,GSM738917,GSM738918,GSM738919,GSM738920,GSM738924,GSM738930,GSM738931,GSM738932,GSM738933,GSM738934,GSM738936,GSM738937,GSM738938,GSM738940,GSM738941,GSM738942,GSM738948,GSM738950,GSM738952,GSM738953,GSM738954,GSM738958,GSM738959,GSM738960,GSM738961,GSM4365563
|
2 |
+
Cervical_Cancer,1.0,1.0,1.0,1.0,,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,,,1.0,1.0,1.0,1.0,1.0,,1.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,
|
p3/preprocess/Cervical_Cancer/clinical_data/GSE163114.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM4950455,GSM4950456,GSM4950457,GSM4950458,GSM4950459,GSM4950460,GSM4950461,GSM4950462,GSM4950463,GSM4950464,GSM4950465,GSM4950466
|
2 |
+
Cervical_Cancer,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,1.0,1.0
|
p3/preprocess/Cervical_Cancer/clinical_data/GSE63678.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM1555075,GSM1555076,GSM1555077,GSM1555078,GSM1555079,GSM1555080,GSM1555081,GSM1555082,GSM1555083,GSM1555084,GSM1555085,GSM1555086,GSM1555087,GSM1555088,GSM1555089,GSM1555090,GSM1555091,GSM1555092,GSM1555093,GSM1555094,GSM1555095,GSM1555096,GSM1555097,GSM1555098,GSM1555099,GSM1555100,GSM1555101,GSM1555102,GSM1555103,GSM1555104,GSM1555105,GSM1555106,GSM1555107,GSM1555108,GSM1555109
|
2 |
+
disease_state,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,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
p3/preprocess/Cervical_Cancer/clinical_data/GSE75132.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM1943705,GSM1943706,GSM1943707,GSM1943708,GSM1943709,GSM1943710,GSM1943711,GSM1943712,GSM1943713,GSM1943714,GSM1943715,GSM1943716,GSM1943717,GSM1943718,GSM1943719,GSM1943720,GSM1943721,GSM1943722,GSM1943723,GSM1943724,GSM1943725,GSM1943726,GSM1943727,GSM1943728,GSM1943729,GSM1943730,GSM1943731,GSM1943732,GSM1943733,GSM1943734,GSM1943735,GSM1943736,GSM1943737,GSM1943738,GSM1943739,GSM1943740,GSM1943741,GSM1943742,GSM1943743,GSM1943744,GSM1943745
|
2 |
+
Cervical_Cancer,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,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
|
p3/preprocess/Cervical_Cancer/code/GSE107754.py
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE107754"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE107754"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE107754.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE107754.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE107754.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
# Yes, the background info mentions "whole human genome gene expression microarrays"
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# 2. Variable Availability and Data Type Conversion
|
41 |
+
# 2.1 Data Availability
|
42 |
+
# Trait (cervical cancer status) is not available as all samples are cancer cases
|
43 |
+
trait_row = None
|
44 |
+
|
45 |
+
# Gender is available in Feature 0
|
46 |
+
gender_row = 0
|
47 |
+
|
48 |
+
# Age is not available
|
49 |
+
age_row = None
|
50 |
+
|
51 |
+
# 2.2 Data Type Conversion Functions
|
52 |
+
def convert_trait(x):
|
53 |
+
return None
|
54 |
+
|
55 |
+
def convert_gender(x):
|
56 |
+
if not isinstance(x, str):
|
57 |
+
return None
|
58 |
+
value = x.split(': ')[1].strip().lower()
|
59 |
+
if value == 'female':
|
60 |
+
return 0
|
61 |
+
elif value == 'male':
|
62 |
+
return 1
|
63 |
+
return None
|
64 |
+
|
65 |
+
def convert_age(x):
|
66 |
+
return None
|
67 |
+
|
68 |
+
# 3. Save Metadata
|
69 |
+
is_trait_available = trait_row is not None
|
70 |
+
validate_and_save_cohort_info(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 |
+
# 4. Clinical Feature Extraction
|
77 |
+
# Skip as trait_row is None
|
78 |
+
# Extract gene expression data from matrix file
|
79 |
+
gene_data = get_genetic_data(matrix_file)
|
80 |
+
|
81 |
+
# Print first 20 row IDs and shape of data to help debug
|
82 |
+
print("Shape of gene expression data:", gene_data.shape)
|
83 |
+
print("\nFirst few rows of data:")
|
84 |
+
print(gene_data.head())
|
85 |
+
print("\nFirst 20 gene/probe identifiers:")
|
86 |
+
print(gene_data.index[:20])
|
87 |
+
|
88 |
+
# Inspect a snippet of raw file to verify identifier format
|
89 |
+
import gzip
|
90 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
91 |
+
lines = []
|
92 |
+
for i, line in enumerate(f):
|
93 |
+
if "!series_matrix_table_begin" in line:
|
94 |
+
# Get the next 5 lines after the marker
|
95 |
+
for _ in range(5):
|
96 |
+
lines.append(next(f).strip())
|
97 |
+
break
|
98 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
99 |
+
for line in lines:
|
100 |
+
print(line)
|
101 |
+
# Looking at the identifiers (e.g. A_23_P100001), these are Agilent array probe IDs, not gene symbols
|
102 |
+
# Therefore mapping to gene symbols will be required
|
103 |
+
requires_gene_mapping = True
|
104 |
+
# Get file paths using library function
|
105 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
106 |
+
|
107 |
+
# Extract gene annotation from SOFT file
|
108 |
+
gene_annotation = get_gene_annotation(soft_file)
|
109 |
+
|
110 |
+
# Preview gene annotation data
|
111 |
+
print("Gene annotation columns and example values:")
|
112 |
+
print(preview_df(gene_annotation))
|
113 |
+
# Get the mapping between probe IDs and gene symbols
|
114 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
|
115 |
+
|
116 |
+
# Apply the gene mapping to convert probe-level data to gene-level data
|
117 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
118 |
+
# 1. Normalize gene symbols and save normalized gene data
|
119 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
120 |
+
gene_data.to_csv(out_gene_data_file)
|
121 |
+
|
122 |
+
# When trait data is unavailable, use gene data as the linked data
|
123 |
+
linked_data = gene_data.T # Transpose to match expected format
|
124 |
+
|
125 |
+
# As this dataset only contains cancer samples without controls,
|
126 |
+
# it's inherently biased for case-control analysis
|
127 |
+
is_biased = True
|
128 |
+
|
129 |
+
# Validate and save metadata
|
130 |
+
is_usable = validate_and_save_cohort_info(
|
131 |
+
is_final=True,
|
132 |
+
cohort=cohort,
|
133 |
+
info_path=json_path,
|
134 |
+
is_gene_available=True,
|
135 |
+
is_trait_available=False,
|
136 |
+
is_biased=is_biased,
|
137 |
+
df=linked_data,
|
138 |
+
note="Dataset contains only cancer samples, no control group for comparison"
|
139 |
+
)
|
p3/preprocess/Cervical_Cancer/code/GSE114243.py
ADDED
@@ -0,0 +1,255 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE114243"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE114243"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE114243.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE114243.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE114243.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get all matrix files in directory
|
19 |
+
matrix_files = [f for f in os.listdir(in_cohort_dir) if 'matrix' in f.lower()]
|
20 |
+
print("Found matrix files:", matrix_files)
|
21 |
+
|
22 |
+
# Find a matrix file that's not from the SuperSeries summary
|
23 |
+
matrix_file = None
|
24 |
+
soft_file = None
|
25 |
+
for f in matrix_files:
|
26 |
+
with gzip.open(os.path.join(in_cohort_dir, f), 'rt') as file:
|
27 |
+
first_lines = "".join([next(file) for _ in range(10)])
|
28 |
+
if "SuperSeries" not in first_lines:
|
29 |
+
matrix_file = os.path.join(in_cohort_dir, f)
|
30 |
+
soft_files = [sf for sf in os.listdir(in_cohort_dir) if 'soft' in sf.lower()
|
31 |
+
and f.split('_')[0] in sf]
|
32 |
+
if soft_files:
|
33 |
+
soft_file = os.path.join(in_cohort_dir, soft_files[0])
|
34 |
+
break
|
35 |
+
|
36 |
+
if matrix_file is None or soft_file is None:
|
37 |
+
raise ValueError("Could not find suitable matrix and SOFT files")
|
38 |
+
|
39 |
+
print(f"Using SOFT file: {os.path.basename(soft_file)}")
|
40 |
+
print(f"Using matrix file: {os.path.basename(matrix_file)}\n")
|
41 |
+
|
42 |
+
# Extract background info and clinical data
|
43 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
44 |
+
|
45 |
+
# Get unique values per clinical feature
|
46 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
47 |
+
|
48 |
+
# Print background info
|
49 |
+
print("Dataset Background Information:")
|
50 |
+
print(f"{background_info}\n")
|
51 |
+
|
52 |
+
# Print sample characteristics
|
53 |
+
print("Sample Characteristics:")
|
54 |
+
for feature, values in sample_characteristics.items():
|
55 |
+
print(f"Feature: {feature}")
|
56 |
+
print(f"Values: {values}\n")
|
57 |
+
# Get all matrix files in directory to check options
|
58 |
+
matrix_files = [f for f in os.listdir(in_cohort_dir) if 'matrix' in f.lower()]
|
59 |
+
print("Available matrix files:", matrix_files)
|
60 |
+
|
61 |
+
# Try each matrix file until we find one that's not SuperSeries
|
62 |
+
matrix_file = None
|
63 |
+
soft_file = None
|
64 |
+
|
65 |
+
for f in matrix_files:
|
66 |
+
test_file = os.path.join(in_cohort_dir, f)
|
67 |
+
test_soft = os.path.join(in_cohort_dir, f.replace('matrix.txt.gz', 'soft.gz'))
|
68 |
+
|
69 |
+
if os.path.exists(test_soft):
|
70 |
+
with gzip.open(test_file, 'rt') as file:
|
71 |
+
first_lines = "".join([next(file) for _ in range(10)])
|
72 |
+
if "SuperSeries" not in first_lines:
|
73 |
+
matrix_file = test_file
|
74 |
+
soft_file = test_soft
|
75 |
+
break
|
76 |
+
|
77 |
+
if matrix_file is None or soft_file is None:
|
78 |
+
raise ValueError("Could not find suitable matrix and SOFT files")
|
79 |
+
|
80 |
+
print(f"\nUsing SOFT file: {os.path.basename(soft_file)}")
|
81 |
+
print(f"Using matrix file: {os.path.basename(matrix_file)}\n")
|
82 |
+
|
83 |
+
# Extract background info and clinical data
|
84 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
85 |
+
|
86 |
+
# Get unique values per clinical feature
|
87 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
88 |
+
|
89 |
+
# Print background info
|
90 |
+
print("Dataset Background Information:")
|
91 |
+
print(f"{background_info}\n")
|
92 |
+
|
93 |
+
# Print sample characteristics
|
94 |
+
print("Sample Characteristics:")
|
95 |
+
for feature, values in sample_characteristics.items():
|
96 |
+
print(f"Feature: {feature}")
|
97 |
+
print(f"Values: {values}\n")
|
98 |
+
# Get file paths
|
99 |
+
files = os.listdir(in_cohort_dir)
|
100 |
+
matrix_files = [f for f in files if 'matrix' in f.lower()]
|
101 |
+
matrix_file = None
|
102 |
+
soft_file = None
|
103 |
+
|
104 |
+
for mf in matrix_files:
|
105 |
+
matrix_file = os.path.join(in_cohort_dir, mf)
|
106 |
+
with gzip.open(matrix_file, 'rt') as f:
|
107 |
+
header = ''.join([next(f) for _ in range(10)])
|
108 |
+
if 'SuperSeries' not in header:
|
109 |
+
soft_file = os.path.join(in_cohort_dir, mf.replace('matrix.txt.gz', 'soft.gz'))
|
110 |
+
if os.path.exists(soft_file):
|
111 |
+
break
|
112 |
+
|
113 |
+
if not matrix_file or not soft_file:
|
114 |
+
raise ValueError("Could not find suitable matrix and soft files")
|
115 |
+
|
116 |
+
print(f"Using matrix file: {os.path.basename(matrix_file)}")
|
117 |
+
print(f"Using soft file: {os.path.basename(soft_file)}\n")
|
118 |
+
|
119 |
+
# Extract background info and clinical data
|
120 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
121 |
+
|
122 |
+
# Get unique values per clinical feature
|
123 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
124 |
+
|
125 |
+
# Print background info
|
126 |
+
print("Dataset Background Information:")
|
127 |
+
print(f"{background_info}\n")
|
128 |
+
|
129 |
+
# Print sample characteristics
|
130 |
+
print("Sample Characteristics:")
|
131 |
+
for feature, values in sample_characteristics.items():
|
132 |
+
print(f"Feature: {feature}")
|
133 |
+
print(f"Values: {values}\n")
|
134 |
+
# Get file paths for each platform GPL
|
135 |
+
matrix_files = sorted([f for f in os.listdir(in_cohort_dir) if 'matrix' in f.lower() and 'GPL6480' in f])
|
136 |
+
matrix_file = os.path.join(in_cohort_dir, matrix_files[0])
|
137 |
+
soft_file = os.path.join(in_cohort_dir, matrix_files[0].replace('matrix.txt.gz', 'soft.gz'))
|
138 |
+
|
139 |
+
print(f"Using matrix file: {os.path.basename(matrix_file)}")
|
140 |
+
print(f"Using SOFT file: {os.path.basename(soft_file)}\n")
|
141 |
+
|
142 |
+
# Extract background info and clinical data
|
143 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
144 |
+
|
145 |
+
# Get unique values per clinical feature
|
146 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
147 |
+
|
148 |
+
# Print background info
|
149 |
+
print("Dataset Background Information:")
|
150 |
+
print(f"{background_info}\n")
|
151 |
+
|
152 |
+
# Print sample characteristics
|
153 |
+
print("Sample Characteristics:")
|
154 |
+
for feature, values in sample_characteristics.items():
|
155 |
+
print(f"Feature: {feature}")
|
156 |
+
print(f"Values: {values}\n")
|
157 |
+
# 1. Gene Expression Data Availability
|
158 |
+
is_gene_available = True # Based on GPL6480 platform and HEK293T cells, likely to contain gene expression data
|
159 |
+
|
160 |
+
# 2.1 Data Availability
|
161 |
+
trait_row = None # All samples are from HEK293T cells, no cancer/control status
|
162 |
+
age_row = None # Age info not provided
|
163 |
+
gender_row = None # Gender info not provided
|
164 |
+
|
165 |
+
# 2.2 Data Type Conversion Functions
|
166 |
+
def convert_trait(x):
|
167 |
+
return None
|
168 |
+
|
169 |
+
def convert_age(x):
|
170 |
+
return None
|
171 |
+
|
172 |
+
def convert_gender(x):
|
173 |
+
return None
|
174 |
+
|
175 |
+
# 3. Save Metadata
|
176 |
+
validate_and_save_cohort_info(
|
177 |
+
is_final=False,
|
178 |
+
cohort=cohort,
|
179 |
+
info_path=json_path,
|
180 |
+
is_gene_available=is_gene_available,
|
181 |
+
is_trait_available=False # trait_row is None
|
182 |
+
)
|
183 |
+
|
184 |
+
# 4. Skip clinical feature extraction since trait_row is None
|
185 |
+
# Get file paths using library function
|
186 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
187 |
+
|
188 |
+
# Extract gene annotation from SOFT file
|
189 |
+
gene_annotation = get_gene_annotation(soft_file)
|
190 |
+
|
191 |
+
# Preview gene annotation data
|
192 |
+
print("Gene annotation columns and example values:")
|
193 |
+
print(preview_df(gene_annotation))
|
194 |
+
# Get gene expression data from matrix file
|
195 |
+
gene_expression = get_genetic_data(matrix_file)
|
196 |
+
|
197 |
+
# Get gene mapping using probe ID ('ID') and gene symbol ('GENE_SYMBOL') columns
|
198 |
+
gene_mapping = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
|
199 |
+
|
200 |
+
# Map probe IDs to gene symbols and aggregate expression data
|
201 |
+
gene_data = apply_gene_mapping(gene_expression, gene_mapping)
|
202 |
+
|
203 |
+
# Preview the gene expression data
|
204 |
+
print("\nGene expression data preview:")
|
205 |
+
print(preview_df(gene_data))
|
206 |
+
# Recreate gene expression data from Step 7
|
207 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
208 |
+
gene_annotation = get_gene_annotation(soft_file)
|
209 |
+
gene_expression = get_genetic_data(matrix_file)
|
210 |
+
gene_mapping = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
|
211 |
+
gene_data = apply_gene_mapping(gene_expression, gene_mapping)
|
212 |
+
|
213 |
+
# 1. Normalize gene symbols and save normalized gene data
|
214 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
215 |
+
gene_data.to_csv(out_gene_data_file)
|
216 |
+
|
217 |
+
# 2-4. Skip clinical data linking and bias checking since trait data is unavailable
|
218 |
+
|
219 |
+
# 5. Validate data quality and save metadata
|
220 |
+
is_usable = validate_and_save_cohort_info(
|
221 |
+
is_final=True,
|
222 |
+
cohort=cohort,
|
223 |
+
info_path=json_path,
|
224 |
+
is_gene_available=True,
|
225 |
+
is_trait_available=False, # No trait data available
|
226 |
+
is_biased=None, # Cannot determine bias without trait data
|
227 |
+
df=gene_data,
|
228 |
+
note="Cell line gene expression data without trait information"
|
229 |
+
)
|
230 |
+
|
231 |
+
# 6. Skip saving linked data since trait data is unavailable
|
232 |
+
# Setup gene expression data first
|
233 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
234 |
+
gene_annotation = get_gene_annotation(soft_file)
|
235 |
+
gene_expression = get_genetic_data(matrix_file)
|
236 |
+
gene_mapping = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
|
237 |
+
gene_data = apply_gene_mapping(gene_expression, gene_mapping)
|
238 |
+
|
239 |
+
# 1. Normalize gene symbols and save normalized gene data
|
240 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
241 |
+
gene_data.to_csv(out_gene_data_file)
|
242 |
+
|
243 |
+
# 2-4. Skip clinical/trait processing as no trait data available
|
244 |
+
|
245 |
+
# 5. Save metadata indicating dataset is unusable for trait studies
|
246 |
+
is_usable = validate_and_save_cohort_info(
|
247 |
+
is_final=True,
|
248 |
+
cohort=cohort,
|
249 |
+
info_path=json_path,
|
250 |
+
is_gene_available=True,
|
251 |
+
is_trait_available=False,
|
252 |
+
is_biased=True, # No trait comparison possible with single cell line
|
253 |
+
df=gene_data,
|
254 |
+
note="Cell line gene expression data without trait comparison information"
|
255 |
+
)
|
p3/preprocess/Cervical_Cancer/code/GSE131027.py
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE131027"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE131027"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE131027.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE131027.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE131027.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
# Based on series summary, this dataset focuses on germline variants/mutations, not gene expression
|
38 |
+
is_gene_available = False
|
39 |
+
|
40 |
+
# 2.1 Data Availability
|
41 |
+
# For trait: cancer status can be inferred from feature 1 (cancer type)
|
42 |
+
trait_row = 1
|
43 |
+
# Age and gender are not available in characteristics data
|
44 |
+
age_row = None
|
45 |
+
gender_row = None
|
46 |
+
|
47 |
+
# 2.2 Data Type Conversion Functions
|
48 |
+
def convert_trait(value):
|
49 |
+
if not isinstance(value, str):
|
50 |
+
return None
|
51 |
+
value = value.lower()
|
52 |
+
if "cancer:" in value:
|
53 |
+
value = value.split("cancer:")[1].strip()
|
54 |
+
# Convert to binary - 1 for cervical cancer, 0 for other cancers
|
55 |
+
return 1 if "cervical" in value else 0
|
56 |
+
return None
|
57 |
+
|
58 |
+
def convert_age(value):
|
59 |
+
return None # Age data not available
|
60 |
+
|
61 |
+
def convert_gender(value):
|
62 |
+
return None # Gender data not available
|
63 |
+
|
64 |
+
# 3. Save Metadata
|
65 |
+
is_trait_available = trait_row is not None
|
66 |
+
_ = validate_and_save_cohort_info(
|
67 |
+
is_final=False,
|
68 |
+
cohort=cohort,
|
69 |
+
info_path=json_path,
|
70 |
+
is_gene_available=is_gene_available,
|
71 |
+
is_trait_available=is_trait_available
|
72 |
+
)
|
73 |
+
|
74 |
+
# 4. Clinical Feature Extraction
|
75 |
+
if trait_row is not None:
|
76 |
+
clinical_df = geo_select_clinical_features(
|
77 |
+
clinical_df=clinical_data,
|
78 |
+
trait=trait,
|
79 |
+
trait_row=trait_row,
|
80 |
+
convert_trait=convert_trait,
|
81 |
+
age_row=age_row,
|
82 |
+
convert_age=convert_age,
|
83 |
+
gender_row=gender_row,
|
84 |
+
convert_gender=convert_gender
|
85 |
+
)
|
86 |
+
|
87 |
+
# Preview the processed clinical data
|
88 |
+
preview = preview_df(clinical_df)
|
89 |
+
print("Preview of processed clinical data:", preview)
|
90 |
+
|
91 |
+
# Save clinical data
|
92 |
+
clinical_df.to_csv(out_clinical_data_file)
|
p3/preprocess/Cervical_Cancer/code/GSE137034.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE137034"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE137034"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE137034.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE137034.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE137034.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
is_gene_available = False # This dataset appears to study chromatin accessibility rather than gene expression
|
38 |
+
|
39 |
+
# 2. Variable Availability and Data Type Conversion
|
40 |
+
# 2.1. Identify feature rows
|
41 |
+
trait_row = None # Cannot reliably classify samples as cervical cancer vs control
|
42 |
+
age_row = None # No age information
|
43 |
+
gender_row = None # No gender information
|
44 |
+
|
45 |
+
# 2.2. Define conversion functions
|
46 |
+
# Not needed since no clinical data is available
|
47 |
+
|
48 |
+
# 3. Save metadata
|
49 |
+
validate_and_save_cohort_info(
|
50 |
+
is_final=False,
|
51 |
+
cohort=cohort,
|
52 |
+
info_path=json_path,
|
53 |
+
is_gene_available=is_gene_available,
|
54 |
+
is_trait_available=trait_row is not None
|
55 |
+
)
|
56 |
+
|
57 |
+
# 4. Skip clinical feature extraction since trait_row is None
|
p3/preprocess/Cervical_Cancer/code/GSE138079.py
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE138079"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE138079"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE138079.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE138079.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE138079.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
# Yes, this is a mRNA microarray dataset (Agilent 4x44K) according to background info
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# 2.1 Data Availability
|
41 |
+
# None of trait, age, or gender data is directly available in sample characteristics
|
42 |
+
# But trait (transformation stage) can be extracted from Feature 1
|
43 |
+
trait_row = 1
|
44 |
+
age_row = None
|
45 |
+
gender_row = None
|
46 |
+
|
47 |
+
# 2.2 Data Type Conversion
|
48 |
+
def convert_trait(value):
|
49 |
+
if not value or ':' not in value:
|
50 |
+
return None
|
51 |
+
stage = value.split(':')[1].strip()
|
52 |
+
# Convert transformation stages to binary (0=early/benign, 1=late/malignant)
|
53 |
+
if stage == 'extended lifespan':
|
54 |
+
return 0 # Early stage
|
55 |
+
elif stage == 'immortal':
|
56 |
+
return 0 # Early stage
|
57 |
+
elif stage == 'anchorage independent':
|
58 |
+
return 1 # Late stage, more transformed/malignant
|
59 |
+
return None
|
60 |
+
|
61 |
+
def convert_age(value):
|
62 |
+
return None # Not used
|
63 |
+
|
64 |
+
def convert_gender(value):
|
65 |
+
return None # Not used
|
66 |
+
|
67 |
+
# 3. Save Metadata
|
68 |
+
is_trait_available = trait_row is not None
|
69 |
+
validate_and_save_cohort_info(is_final=False,
|
70 |
+
cohort=cohort,
|
71 |
+
info_path=json_path,
|
72 |
+
is_gene_available=is_gene_available,
|
73 |
+
is_trait_available=is_trait_available)
|
74 |
+
|
75 |
+
# 4. Clinical Feature Extraction
|
76 |
+
if trait_row is not None:
|
77 |
+
selected_clinical_df = geo_select_clinical_features(
|
78 |
+
clinical_df=clinical_data,
|
79 |
+
trait=trait,
|
80 |
+
trait_row=trait_row,
|
81 |
+
convert_trait=convert_trait
|
82 |
+
)
|
83 |
+
|
84 |
+
# Preview the processed clinical data
|
85 |
+
preview_result = preview_df(selected_clinical_df)
|
86 |
+
print("Clinical data preview:", preview_result)
|
87 |
+
|
88 |
+
# Save to CSV
|
89 |
+
selected_clinical_df.to_csv(out_clinical_data_file)
|
90 |
+
# Extract gene expression data from matrix file
|
91 |
+
gene_data = get_genetic_data(matrix_file)
|
92 |
+
|
93 |
+
# Print first 20 row IDs and shape of data to help debug
|
94 |
+
print("Shape of gene expression data:", gene_data.shape)
|
95 |
+
print("\nFirst few rows of data:")
|
96 |
+
print(gene_data.head())
|
97 |
+
print("\nFirst 20 gene/probe identifiers:")
|
98 |
+
print(gene_data.index[:20])
|
99 |
+
|
100 |
+
# Inspect a snippet of raw file to verify identifier format
|
101 |
+
import gzip
|
102 |
+
with gzip.open(matrix_file, 'rt', encoding='utf-8') as f:
|
103 |
+
lines = []
|
104 |
+
for i, line in enumerate(f):
|
105 |
+
if "!series_matrix_table_begin" in line:
|
106 |
+
# Get the next 5 lines after the marker
|
107 |
+
for _ in range(5):
|
108 |
+
lines.append(next(f).strip())
|
109 |
+
break
|
110 |
+
print("\nFirst few lines after matrix marker in raw file:")
|
111 |
+
for line in lines:
|
112 |
+
print(line)
|
113 |
+
# Looking at the gene identifiers (which are just numbers like '12', '13', etc.)
|
114 |
+
# and comparing with the raw file which shows "ID_REF" as column header,
|
115 |
+
# these appear to be probe IDs from a microarray rather than gene symbols
|
116 |
+
requires_gene_mapping = True
|
117 |
+
# Extract gene annotation from SOFT file
|
118 |
+
gene_annotation = get_gene_annotation(soft_file)
|
119 |
+
|
120 |
+
# Preview gene annotation data
|
121 |
+
print("Gene annotation columns and example values:")
|
122 |
+
print(preview_df(gene_annotation))
|
123 |
+
# 1. From previous output we can see:
|
124 |
+
# - Gene expression data uses 'ID' as identifiers
|
125 |
+
# - Gene annotation data has 'ID' and 'GENE_SYMBOL' columns
|
126 |
+
|
127 |
+
# 2. Get gene mapping dataframe
|
128 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='GENE_SYMBOL')
|
129 |
+
|
130 |
+
# 3. Apply gene mapping to convert probe-level data to gene-level data
|
131 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
132 |
+
|
133 |
+
# Print shape and preview to verify the mapping
|
134 |
+
print("\nShape of mapped gene expression data:", gene_data.shape)
|
135 |
+
print("\nFirst few rows of mapped data:")
|
136 |
+
print(gene_data.head())
|
137 |
+
# 1. Normalize gene symbols and save normalized gene data
|
138 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
139 |
+
gene_data.to_csv(out_gene_data_file)
|
140 |
+
|
141 |
+
# 2. Link clinical and genetic data and trait
|
142 |
+
# First get selected clinical features using the extraction function from previous step
|
143 |
+
selected_clinical = geo_select_clinical_features(
|
144 |
+
clinical_df=clinical_data,
|
145 |
+
trait=trait,
|
146 |
+
trait_row=trait_row,
|
147 |
+
convert_trait=convert_trait,
|
148 |
+
age_row=age_row,
|
149 |
+
convert_age=convert_age,
|
150 |
+
gender_row=gender_row,
|
151 |
+
convert_gender=convert_gender
|
152 |
+
)
|
153 |
+
|
154 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
|
155 |
+
|
156 |
+
# 3. Handle missing values systematically
|
157 |
+
linked_data = handle_missing_values(linked_data, trait)
|
158 |
+
|
159 |
+
# 4. Check for biased features and remove them if needed
|
160 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
161 |
+
|
162 |
+
# 5. Validate data quality and save metadata
|
163 |
+
is_usable = validate_and_save_cohort_info(
|
164 |
+
is_final=True,
|
165 |
+
cohort=cohort,
|
166 |
+
info_path=json_path,
|
167 |
+
is_gene_available=True,
|
168 |
+
is_trait_available=True,
|
169 |
+
is_biased=is_biased,
|
170 |
+
df=linked_data,
|
171 |
+
note="Gene expression data comparing cervical carcinoma vs normal tissue samples"
|
172 |
+
)
|
173 |
+
|
174 |
+
# 6. Save linked data if usable
|
175 |
+
if is_usable:
|
176 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Cervical_Cancer/code/GSE138080.py
ADDED
@@ -0,0 +1,229 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE138080"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE138080"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE138080.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE138080.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE138080.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
# Based on background info mentioning "mRNA tissues" and "whole human genome oligo microarrays"
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# 2. Variable Availability and Data Type Conversion
|
41 |
+
|
42 |
+
# 2.1 For trait:
|
43 |
+
# Feature 0 contains info about cancer stage (normal vs CIN2/3 vs SCC)
|
44 |
+
trait_row = 0
|
45 |
+
|
46 |
+
def convert_trait(value: str) -> float:
|
47 |
+
# Binary: 0 for normal, 1 for cancer/pre-cancer
|
48 |
+
if not value or ':' not in value:
|
49 |
+
return None
|
50 |
+
value = value.split(': ')[1].lower()
|
51 |
+
if 'normal' in value:
|
52 |
+
return 0.0
|
53 |
+
elif 'carcinoma' in value or 'neoplasia' in value:
|
54 |
+
return 1.0
|
55 |
+
return None
|
56 |
+
|
57 |
+
# 2.2 Age and gender not explicitly available
|
58 |
+
age_row = None
|
59 |
+
gender_row = None
|
60 |
+
|
61 |
+
def convert_age(value: str) -> float:
|
62 |
+
return None
|
63 |
+
|
64 |
+
def convert_gender(value: str) -> float:
|
65 |
+
return None
|
66 |
+
|
67 |
+
# 3. Save metadata
|
68 |
+
is_trait_available = trait_row is not None
|
69 |
+
_ = 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
|
78 |
+
if trait_row is not None:
|
79 |
+
selected_clinical = geo_select_clinical_features(
|
80 |
+
clinical_df=clinical_data,
|
81 |
+
trait=trait,
|
82 |
+
trait_row=trait_row,
|
83 |
+
convert_trait=convert_trait,
|
84 |
+
age_row=age_row,
|
85 |
+
convert_age=convert_age,
|
86 |
+
gender_row=gender_row,
|
87 |
+
convert_gender=convert_gender
|
88 |
+
)
|
89 |
+
|
90 |
+
# Preview data
|
91 |
+
preview = preview_df(selected_clinical)
|
92 |
+
print("Preview of selected clinical features:")
|
93 |
+
print(preview)
|
94 |
+
|
95 |
+
# Save to CSV
|
96 |
+
selected_clinical.to_csv(out_clinical_data_file)
|
97 |
+
# Extract gene expression data from matrix file
|
98 |
+
gene_data = get_genetic_data(matrix_file)
|
99 |
+
|
100 |
+
# Print first 20 row IDs
|
101 |
+
print("First 20 gene/probe identifiers:")
|
102 |
+
print(gene_data.index[:20])
|
103 |
+
# These appear to be probe IDs rather than human gene symbols
|
104 |
+
# They are numerical identifiers which is not the format for gene symbols
|
105 |
+
# Gene symbols typically follow patterns like "TP53", "BRCA1", "IL6", etc.
|
106 |
+
# Therefore mapping will be required to convert these to gene symbols
|
107 |
+
requires_gene_mapping = True
|
108 |
+
# Examine first few hundred lines of SOFT file to find where gene annotations are stored
|
109 |
+
with gzip.open(soft_file, 'rt') as f:
|
110 |
+
content = ''.join([next(f) for _ in range(100)])
|
111 |
+
print("First 100 lines of SOFT file:")
|
112 |
+
print(content)
|
113 |
+
# Extract gene annotation data
|
114 |
+
gene_metadata = get_gene_annotation(soft_file)
|
115 |
+
|
116 |
+
print("Preview of gene annotation data columns:")
|
117 |
+
print(gene_metadata.columns.tolist())
|
118 |
+
print("\nFirst few rows:")
|
119 |
+
print(gene_metadata.head())
|
120 |
+
|
121 |
+
# Create mapping between probe IDs and gene symbols
|
122 |
+
mapping_data = get_gene_mapping(gene_metadata, 'ID', 'GENE_SYMBOL')
|
123 |
+
print("\nFirst few rows of mapping data:")
|
124 |
+
print(mapping_data.head())
|
125 |
+
|
126 |
+
# Apply mapping to convert probe-level data to gene-level data
|
127 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
128 |
+
print("\nFirst few gene symbols after mapping:")
|
129 |
+
print(gene_data.index[:10])
|
130 |
+
|
131 |
+
# Save gene expression data
|
132 |
+
gene_data.to_csv(out_gene_data_file)
|
133 |
+
# 1. Normalize gene symbols and save normalized gene data
|
134 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
135 |
+
gene_data.to_csv(out_gene_data_file)
|
136 |
+
|
137 |
+
# 2. Link clinical and genetic data
|
138 |
+
linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
|
139 |
+
|
140 |
+
# 3. Handle missing values systematically
|
141 |
+
linked_data = handle_missing_values(linked_data, "Cervical_Cancer")
|
142 |
+
|
143 |
+
# 4. Check for biased features and remove them if needed
|
144 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, "Cervical_Cancer")
|
145 |
+
|
146 |
+
# 5. Validate data quality and save metadata
|
147 |
+
is_usable = validate_and_save_cohort_info(
|
148 |
+
is_final=True,
|
149 |
+
cohort=cohort,
|
150 |
+
info_path=json_path,
|
151 |
+
is_gene_available=True,
|
152 |
+
is_trait_available=True,
|
153 |
+
is_biased=is_biased,
|
154 |
+
df=linked_data,
|
155 |
+
note="Gene expression data comparing cervical carcinoma vs normal tissue samples"
|
156 |
+
)
|
157 |
+
|
158 |
+
# 6. Save linked data if usable
|
159 |
+
if is_usable:
|
160 |
+
linked_data.to_csv(out_data_file)
|
161 |
+
# 1. Normalize gene symbols and save normalized gene data
|
162 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
163 |
+
gene_data.to_csv(out_gene_data_file)
|
164 |
+
|
165 |
+
# 2. Link clinical and genetic data
|
166 |
+
selected_clinical = pd.DataFrame(clinical_data.loc[trait])
|
167 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
|
168 |
+
|
169 |
+
# 3. Handle missing values systematically
|
170 |
+
linked_data = handle_missing_values(linked_data, trait)
|
171 |
+
|
172 |
+
# 4. Check for biased features and remove them if needed
|
173 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
174 |
+
|
175 |
+
# 5. Validate data quality and save metadata
|
176 |
+
is_usable = validate_and_save_cohort_info(
|
177 |
+
is_final=True,
|
178 |
+
cohort=cohort,
|
179 |
+
info_path=json_path,
|
180 |
+
is_gene_available=True,
|
181 |
+
is_trait_available=True,
|
182 |
+
is_biased=is_biased,
|
183 |
+
df=linked_data,
|
184 |
+
note="Gene expression data comparing cervical carcinoma vs normal tissue samples"
|
185 |
+
)
|
186 |
+
|
187 |
+
# 6. Save linked data if usable
|
188 |
+
if is_usable:
|
189 |
+
linked_data.to_csv(out_data_file)
|
190 |
+
# 1. Normalize gene symbols and save normalized gene data
|
191 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
192 |
+
gene_data.to_csv(out_gene_data_file)
|
193 |
+
|
194 |
+
# 2. Link clinical and genetic data and trait
|
195 |
+
# First get selected clinical features using the extraction function from previous step
|
196 |
+
selected_clinical = geo_select_clinical_features(
|
197 |
+
clinical_df=clinical_data,
|
198 |
+
trait=trait,
|
199 |
+
trait_row=trait_row,
|
200 |
+
convert_trait=convert_trait,
|
201 |
+
age_row=age_row,
|
202 |
+
convert_age=convert_age,
|
203 |
+
gender_row=gender_row,
|
204 |
+
convert_gender=convert_gender
|
205 |
+
)
|
206 |
+
|
207 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
|
208 |
+
|
209 |
+
# 3. Handle missing values systematically
|
210 |
+
linked_data = handle_missing_values(linked_data, trait)
|
211 |
+
|
212 |
+
# 4. Check for biased features and remove them if needed
|
213 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
214 |
+
|
215 |
+
# 5. Validate data quality and save metadata
|
216 |
+
is_usable = validate_and_save_cohort_info(
|
217 |
+
is_final=True,
|
218 |
+
cohort=cohort,
|
219 |
+
info_path=json_path,
|
220 |
+
is_gene_available=True,
|
221 |
+
is_trait_available=True,
|
222 |
+
is_biased=is_biased,
|
223 |
+
df=linked_data,
|
224 |
+
note="Gene expression data comparing cervical carcinoma vs normal tissue samples"
|
225 |
+
)
|
226 |
+
|
227 |
+
# 6. Save linked data if usable
|
228 |
+
if is_usable:
|
229 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Cervical_Cancer/code/GSE146114.py
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE146114"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE146114"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE146114.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE146114.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE146114.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
# Based on Series_summary, this study used RNA-seq with Illumina platforms,
|
38 |
+
# so gene expression data should be available
|
39 |
+
is_gene_available = True
|
40 |
+
|
41 |
+
# 2. Variable Availability and Data Type Conversion
|
42 |
+
# 2.1 Data Availability
|
43 |
+
# Trait (cancer stage) is available in feature 7 with FIGO stages
|
44 |
+
trait_row = 7
|
45 |
+
|
46 |
+
# Age is not available in any feature
|
47 |
+
age_row = None
|
48 |
+
|
49 |
+
# Gender is not available/mentioned in any feature
|
50 |
+
gender_row = None
|
51 |
+
|
52 |
+
# 2.2 Data Type Conversion Functions
|
53 |
+
def convert_trait(x):
|
54 |
+
if pd.isna(x):
|
55 |
+
return None
|
56 |
+
# Extract value after colon
|
57 |
+
val = x.split(': ')[1].strip() if ': ' in x else x
|
58 |
+
|
59 |
+
# Convert FIGO stages to binary
|
60 |
+
# Stage 2B and above are considered advanced
|
61 |
+
early_stages = ['1B1', '1B2', '2A']
|
62 |
+
advanced_stages = ['2B', '3A', '3B', '4A']
|
63 |
+
|
64 |
+
if val in early_stages:
|
65 |
+
return 0 # Early stage
|
66 |
+
elif val in advanced_stages:
|
67 |
+
return 1 # Advanced stage
|
68 |
+
return None
|
69 |
+
|
70 |
+
def convert_age(x):
|
71 |
+
# Not needed since age data is not available
|
72 |
+
return None
|
73 |
+
|
74 |
+
def convert_gender(x):
|
75 |
+
# Not needed since gender data is not available
|
76 |
+
return None
|
77 |
+
|
78 |
+
# 3. Save Metadata
|
79 |
+
# Conduct initial filtering
|
80 |
+
_ = 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=(trait_row is not None)
|
86 |
+
)
|
87 |
+
|
88 |
+
# 4. Clinical Feature Extraction
|
89 |
+
# Since trait_row is not None, we need to extract clinical features
|
90 |
+
selected_clinical = geo_select_clinical_features(
|
91 |
+
clinical_df=clinical_data,
|
92 |
+
trait=trait,
|
93 |
+
trait_row=trait_row,
|
94 |
+
convert_trait=convert_trait,
|
95 |
+
age_row=age_row,
|
96 |
+
convert_age=convert_age,
|
97 |
+
gender_row=gender_row,
|
98 |
+
convert_gender=convert_gender
|
99 |
+
)
|
100 |
+
|
101 |
+
# Preview the extracted features
|
102 |
+
preview = preview_df(selected_clinical)
|
103 |
+
print("Preview of clinical features:")
|
104 |
+
print(preview)
|
105 |
+
|
106 |
+
# Save clinical data
|
107 |
+
selected_clinical.to_csv(out_clinical_data_file)
|
108 |
+
# Extract gene expression data from matrix file
|
109 |
+
gene_data = get_genetic_data(matrix_file)
|
110 |
+
|
111 |
+
# Print first 20 row IDs
|
112 |
+
print("First 20 gene/probe identifiers:")
|
113 |
+
print(gene_data.index[:20])
|
114 |
+
# These are Illumina probe IDs (starting with ILMN_) which need to be mapped to official gene symbols
|
115 |
+
# They are not standard human gene symbols like BRCA1, TP53 etc.
|
116 |
+
requires_gene_mapping = True
|
117 |
+
# Extract gene annotation from SOFT file
|
118 |
+
gene_annotation = get_gene_annotation(soft_file)
|
119 |
+
|
120 |
+
# Preview gene annotation data
|
121 |
+
print("Gene annotation columns and example values:")
|
122 |
+
print(preview_df(gene_annotation))
|
123 |
+
# 1. Identify mapping columns
|
124 |
+
# ID column contains Illumina probe IDs (e.g., ILMN_1825594)
|
125 |
+
# Symbol column contains gene symbols (e.g., JMJD1A)
|
126 |
+
prob_col = 'ID'
|
127 |
+
gene_col = 'Symbol'
|
128 |
+
|
129 |
+
# 2. Get gene mapping dataframe
|
130 |
+
gene_mapping = get_gene_mapping(gene_annotation, prob_col, gene_col)
|
131 |
+
|
132 |
+
# 3. Apply gene mapping to convert probe expression to gene expression
|
133 |
+
gene_data = apply_gene_mapping(gene_data, gene_mapping)
|
134 |
+
# 1. Normalize gene symbols and save normalized gene data
|
135 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
136 |
+
gene_data.to_csv(out_gene_data_file)
|
137 |
+
|
138 |
+
# 2. Link clinical and genetic data
|
139 |
+
linked_data = geo_link_clinical_genetic_data(selected_clinical, gene_data)
|
140 |
+
|
141 |
+
# 3. Handle missing values systematically
|
142 |
+
linked_data = handle_missing_values(linked_data, trait)
|
143 |
+
|
144 |
+
# 4. Check for biased features and remove them if needed
|
145 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
146 |
+
|
147 |
+
# 5. Validate data quality and save metadata
|
148 |
+
is_usable = validate_and_save_cohort_info(
|
149 |
+
is_final=True,
|
150 |
+
cohort=cohort,
|
151 |
+
info_path=json_path,
|
152 |
+
is_gene_available=True,
|
153 |
+
is_trait_available=True,
|
154 |
+
is_biased=is_biased,
|
155 |
+
df=linked_data,
|
156 |
+
note="Gene expression data comparing cervical cancer stages (early vs advanced) based on FIGO staging"
|
157 |
+
)
|
158 |
+
|
159 |
+
# 6. Save linked data if usable
|
160 |
+
if is_usable:
|
161 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Cervical_Cancer/code/GSE163114.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE163114"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE163114"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE163114.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE163114.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE163114.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
# Based on "HeLa" cell line experiments, this is likely a gene expression dataset
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# 2. Variable Availability and Data Type Conversion
|
41 |
+
# 2.1 Data Availability
|
42 |
+
# Feature 1 indicates treatment groups - can be used as trait
|
43 |
+
trait_row = 1
|
44 |
+
# Age and gender not available since this is cell line data
|
45 |
+
age_row = None
|
46 |
+
gender_row = None
|
47 |
+
|
48 |
+
# 2.2 Data Type Conversion Functions
|
49 |
+
def convert_trait(x):
|
50 |
+
if not isinstance(x, str):
|
51 |
+
return None
|
52 |
+
value = x.split(": ")[-1].strip().lower()
|
53 |
+
# Convert control vs Ki-67 knockdown to binary
|
54 |
+
if "control" in value:
|
55 |
+
return 0 # control
|
56 |
+
elif "ki-67" in value:
|
57 |
+
return 1 # Ki-67 knockdown
|
58 |
+
return None
|
59 |
+
|
60 |
+
convert_age = None
|
61 |
+
convert_gender = None
|
62 |
+
|
63 |
+
# 3. Save Metadata
|
64 |
+
# Conduct initial filtering
|
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=trait_row is not None
|
71 |
+
)
|
72 |
+
|
73 |
+
# 4. Clinical Feature Extraction
|
74 |
+
# Since trait_row is available, extract clinical features
|
75 |
+
clinical_df = geo_select_clinical_features(
|
76 |
+
clinical_df=clinical_data,
|
77 |
+
trait=trait,
|
78 |
+
trait_row=trait_row,
|
79 |
+
convert_trait=convert_trait,
|
80 |
+
age_row=age_row,
|
81 |
+
convert_age=convert_age,
|
82 |
+
gender_row=gender_row,
|
83 |
+
convert_gender=convert_gender
|
84 |
+
)
|
85 |
+
|
86 |
+
# Preview the extracted features
|
87 |
+
print("Preview of clinical features:")
|
88 |
+
print(preview_df(clinical_df))
|
89 |
+
|
90 |
+
# Save clinical data
|
91 |
+
os.makedirs(os.path.dirname(out_clinical_data_file), exist_ok=True)
|
92 |
+
clinical_df.to_csv(out_clinical_data_file)
|
93 |
+
# First let's identify the SubSeries information
|
94 |
+
with gzip.open(soft_file, 'rt') as file:
|
95 |
+
for line in file:
|
96 |
+
if 'Series = GSE' in line:
|
97 |
+
print(line.strip())
|
98 |
+
elif '!Series_type' in line:
|
99 |
+
print(line.strip())
|
100 |
+
# Stop after finding subseries info
|
101 |
+
elif '!series_matrix_table_begin' in line:
|
102 |
+
break
|
103 |
+
|
104 |
+
print("\nAnalyzing first subseries:")
|
105 |
+
# Construct path to first subseries
|
106 |
+
subseries_dir = os.path.join(os.path.dirname(in_cohort_dir), "GSE163112")
|
107 |
+
subseries_soft, subseries_matrix = geo_get_relevant_filepaths(subseries_dir)
|
108 |
+
|
109 |
+
# Extract gene expression data from subseries matrix file
|
110 |
+
gene_data = get_genetic_data(subseries_matrix)
|
111 |
+
|
112 |
+
# Print first 20 row IDs
|
113 |
+
print("\nFirst 20 gene/probe identifiers:")
|
114 |
+
print(gene_data.index[:20])
|
p3/preprocess/Cervical_Cancer/code/GSE63678.py
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE63678"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE63678"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE63678.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE63678.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE63678.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# Extract gene expression data from matrix file
|
37 |
+
gene_data = get_genetic_data(matrix_file)
|
38 |
+
|
39 |
+
# Process clinical data to get trait information - disease state from row 1
|
40 |
+
clinical_df = geo_select_clinical_features(
|
41 |
+
clinical_data,
|
42 |
+
trait="disease_state",
|
43 |
+
trait_row=1,
|
44 |
+
convert_trait=lambda x: 1 if "carcinoma" in str(x).lower() else (0 if "normal" in str(x).lower() else None)
|
45 |
+
)
|
46 |
+
|
47 |
+
# Save clinical data
|
48 |
+
clinical_df.to_csv(out_clinical_data_file)
|
49 |
+
|
50 |
+
# Normalize gene symbols and save normalized gene data
|
51 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
52 |
+
gene_data.to_csv(out_gene_data_file)
|
53 |
+
|
54 |
+
# Link clinical and genetic data
|
55 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, gene_data)
|
56 |
+
|
57 |
+
# Handle missing values systematically
|
58 |
+
linked_data = handle_missing_values(linked_data, "disease_state")
|
59 |
+
|
60 |
+
# Check for biased features and remove them if needed
|
61 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, "disease_state")
|
62 |
+
|
63 |
+
# Validate data quality and save metadata
|
64 |
+
is_usable = validate_and_save_cohort_info(
|
65 |
+
is_final=True,
|
66 |
+
cohort=cohort,
|
67 |
+
info_path=json_path,
|
68 |
+
is_gene_available=True,
|
69 |
+
is_trait_available=True,
|
70 |
+
is_biased=is_biased,
|
71 |
+
df=linked_data,
|
72 |
+
note="Gene expression data comparing cervical carcinoma vs normal tissue samples"
|
73 |
+
)
|
74 |
+
|
75 |
+
# Save linked data if usable
|
76 |
+
if is_usable:
|
77 |
+
linked_data.to_csv(out_data_file)
|
78 |
+
# Extract gene expression data from matrix file
|
79 |
+
gene_data = get_genetic_data(matrix_file)
|
80 |
+
|
81 |
+
# Print first 20 row IDs
|
82 |
+
print("First 20 gene/probe identifiers:")
|
83 |
+
print(gene_data.index[:20])
|
84 |
+
# Review identifiers - using knowledge of gene naming conventions
|
85 |
+
# These are from Affymetrix HG-U133A platform which requires mapping to gene symbols
|
86 |
+
|
87 |
+
requires_gene_mapping = True
|
88 |
+
# Extract gene annotation from SOFT file
|
89 |
+
gene_annotation = get_gene_annotation(soft_file)
|
90 |
+
|
91 |
+
# Preview gene annotation data
|
92 |
+
print("Gene annotation columns and example values:")
|
93 |
+
print(preview_df(gene_annotation))
|
94 |
+
# Extract probe-to-gene mapping from annotation data
|
95 |
+
# ID column contains probe IDs matching gene expression data
|
96 |
+
# Gene Symbol column contains target gene symbols
|
97 |
+
mapping_df = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
|
98 |
+
|
99 |
+
# Apply gene mapping to convert probe-level data to gene-level data
|
100 |
+
gene_data = apply_gene_mapping(gene_data, mapping_df)
|
101 |
+
# 1. Normalize gene symbols and save normalized gene data
|
102 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
103 |
+
gene_data.to_csv(out_gene_data_file)
|
104 |
+
|
105 |
+
# 2. Link clinical and genetic data
|
106 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, gene_data)
|
107 |
+
|
108 |
+
# 3. Handle missing values systematically
|
109 |
+
linked_data = handle_missing_values(linked_data, "disease_state")
|
110 |
+
|
111 |
+
# 4. Check for biased features and remove them if needed
|
112 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, "disease_state")
|
113 |
+
|
114 |
+
# 5. Validate data quality and save metadata
|
115 |
+
is_usable = validate_and_save_cohort_info(
|
116 |
+
is_final=True,
|
117 |
+
cohort=cohort,
|
118 |
+
info_path=json_path,
|
119 |
+
is_gene_available=True,
|
120 |
+
is_trait_available=True,
|
121 |
+
is_biased=is_biased,
|
122 |
+
df=linked_data,
|
123 |
+
note="Gene expression data comparing cervical carcinoma vs normal tissue samples"
|
124 |
+
)
|
125 |
+
|
126 |
+
# 6. Save linked data if usable
|
127 |
+
if is_usable:
|
128 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Cervical_Cancer/code/GSE75132.py
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
cohort = "GSE75132"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Cervical_Cancer"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Cervical_Cancer/GSE75132"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/GSE75132.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/GSE75132.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/GSE75132.csv"
|
16 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
17 |
+
|
18 |
+
# Get file paths
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Extract background info and clinical data
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values per clinical feature
|
25 |
+
sample_characteristics = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("Dataset Background Information:")
|
29 |
+
print(f"{background_info}\n")
|
30 |
+
|
31 |
+
# Print sample characteristics
|
32 |
+
print("Sample Characteristics:")
|
33 |
+
for feature, values in sample_characteristics.items():
|
34 |
+
print(f"Feature: {feature}")
|
35 |
+
print(f"Values: {values}\n")
|
36 |
+
# 1. Gene Expression Data Availability
|
37 |
+
# Based on background info, this is gene expression data (TMEM45A, SERPINB5, p16INK4A)
|
38 |
+
is_gene_available = True
|
39 |
+
|
40 |
+
# 2. Variable Availability and Data Type Conversion
|
41 |
+
# 2.1 Data Availability
|
42 |
+
trait_row = 1 # Category/progression info in row 1
|
43 |
+
age_row = None # Age not available
|
44 |
+
gender_row = None # Gender not available
|
45 |
+
|
46 |
+
# 2.2 Data Type Conversion Functions
|
47 |
+
def convert_trait(x):
|
48 |
+
"""Convert progression category to binary:
|
49 |
+
0 = normal/no progression
|
50 |
+
1 = progression (categories 1 & 2 both indicate HPV infection)
|
51 |
+
"""
|
52 |
+
if not isinstance(x, str):
|
53 |
+
return None
|
54 |
+
value = x.split(': ')[-1]
|
55 |
+
try:
|
56 |
+
category = int(value)
|
57 |
+
if category == 0:
|
58 |
+
return 0
|
59 |
+
elif category in [1, 2]:
|
60 |
+
return 1
|
61 |
+
return None
|
62 |
+
except:
|
63 |
+
return None
|
64 |
+
|
65 |
+
convert_age = None
|
66 |
+
convert_gender = None
|
67 |
+
|
68 |
+
# 3. Save metadata
|
69 |
+
is_trait_available = trait_row is not None
|
70 |
+
validate_and_save_cohort_info(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 |
+
# 4. Clinical Feature Extraction
|
77 |
+
if trait_row is not None:
|
78 |
+
selected_clinical = geo_select_clinical_features(
|
79 |
+
clinical_df=clinical_data,
|
80 |
+
trait=trait,
|
81 |
+
trait_row=trait_row,
|
82 |
+
convert_trait=convert_trait
|
83 |
+
)
|
84 |
+
|
85 |
+
# Preview the processed clinical data
|
86 |
+
print("Preview of processed clinical data:")
|
87 |
+
print(preview_df(selected_clinical))
|
88 |
+
|
89 |
+
# Save clinical data
|
90 |
+
selected_clinical.to_csv(out_clinical_data_file)
|
91 |
+
# Extract gene expression data from matrix file
|
92 |
+
gene_data = get_genetic_data(matrix_file)
|
93 |
+
|
94 |
+
# Print first 20 row IDs
|
95 |
+
print("First 20 gene/probe identifiers:")
|
96 |
+
print(gene_data.index[:20])
|
97 |
+
requires_gene_mapping = True
|
98 |
+
# Extract gene annotation from SOFT file
|
99 |
+
gene_annotation = get_gene_annotation(soft_file)
|
100 |
+
|
101 |
+
# Preview gene annotation data
|
102 |
+
print("Gene annotation columns and example values:")
|
103 |
+
print(preview_df(gene_annotation))
|
104 |
+
# 1 & 2. Get gene mapping from annotation data
|
105 |
+
# The 'ID' column in gene_annotation matches the probe IDs in gene_data
|
106 |
+
# The 'Gene Symbol' column contains the corresponding gene symbols
|
107 |
+
mapping_data = get_gene_mapping(gene_annotation, prob_col='ID', gene_col='Gene Symbol')
|
108 |
+
|
109 |
+
# 3. Map probes to genes and convert to gene expression data
|
110 |
+
gene_data = apply_gene_mapping(gene_data, mapping_data)
|
111 |
+
|
112 |
+
# Print preview of mapped gene data
|
113 |
+
print("\nPreview of gene expression data after mapping:")
|
114 |
+
print(gene_data.index[:5])
|
115 |
+
# 1. Normalize gene symbols and save normalized gene data
|
116 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
117 |
+
gene_data.to_csv(out_gene_data_file)
|
118 |
+
|
119 |
+
# 2. Link clinical and genetic data
|
120 |
+
linked_data = geo_link_clinical_genetic_data(clinical_data, gene_data)
|
121 |
+
|
122 |
+
# Convert index to column with trait name before handling missing values
|
123 |
+
linked_data = linked_data.reset_index().rename(columns={linked_data.index.name: trait})
|
124 |
+
|
125 |
+
# 3. Handle missing values systematically
|
126 |
+
linked_data = handle_missing_values(linked_data, trait)
|
127 |
+
|
128 |
+
# 4. Check for biased features and remove them if needed
|
129 |
+
is_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
130 |
+
|
131 |
+
# 5. Validate data quality and save metadata
|
132 |
+
is_usable = validate_and_save_cohort_info(
|
133 |
+
is_final=True,
|
134 |
+
cohort=cohort,
|
135 |
+
info_path=json_path,
|
136 |
+
is_gene_available=True,
|
137 |
+
is_trait_available=True,
|
138 |
+
is_biased=is_biased,
|
139 |
+
df=linked_data,
|
140 |
+
note="Gene expression data from cervical tissue samples. Trait defined based on HPV infection and progression."
|
141 |
+
)
|
142 |
+
|
143 |
+
# 6. Save linked data if usable
|
144 |
+
if is_usable:
|
145 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Cervical_Cancer/code/TCGA.py
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Cervical_Cancer"
|
6 |
+
|
7 |
+
# Input paths
|
8 |
+
tcga_root_dir = "../DATA/TCGA"
|
9 |
+
|
10 |
+
# Output paths
|
11 |
+
out_data_file = "./output/preprocess/3/Cervical_Cancer/TCGA.csv"
|
12 |
+
out_gene_data_file = "./output/preprocess/3/Cervical_Cancer/gene_data/TCGA.csv"
|
13 |
+
out_clinical_data_file = "./output/preprocess/3/Cervical_Cancer/clinical_data/TCGA.csv"
|
14 |
+
json_path = "./output/preprocess/3/Cervical_Cancer/cohort_info.json"
|
15 |
+
|
16 |
+
# 1. Select the relevant subdirectory for cervical cancer
|
17 |
+
subdirectory = 'TCGA_Cervical_Cancer_(CESC)'
|
18 |
+
cohort_dir = os.path.join(tcga_root_dir, subdirectory)
|
19 |
+
|
20 |
+
# 2. Get the file paths
|
21 |
+
clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)
|
22 |
+
|
23 |
+
# 3. Load the data files
|
24 |
+
clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\t')
|
25 |
+
genetic_df = pd.read_csv(genetic_file_path, index_col=0, sep='\t')
|
26 |
+
|
27 |
+
# 4. Print clinical data columns
|
28 |
+
print("Clinical data columns:")
|
29 |
+
print(clinical_df.columns.tolist())
|
30 |
+
# Step 1: Identify candidate columns
|
31 |
+
candidate_age_cols = ["age_at_initial_pathologic_diagnosis", "age_began_smoking_in_years", "days_to_birth"]
|
32 |
+
candidate_gender_cols = ["gender"]
|
33 |
+
|
34 |
+
# Step 2: Use correct TCGA cohort name
|
35 |
+
clinical_path, _ = tcga_get_relevant_filepaths(os.path.join(tcga_root_dir, "CESC"))
|
36 |
+
clinical_df = pd.read_csv(clinical_path, sep='\t', index_col=0)
|
37 |
+
|
38 |
+
# Preview selected columns
|
39 |
+
preview_cols = candidate_age_cols + candidate_gender_cols
|
40 |
+
preview_data = preview_df(clinical_df[preview_cols])
|
41 |
+
print("Preview of demographic columns:", preview_data)
|
42 |
+
# 1. Select the relevant subdirectory for cervical cancer
|
43 |
+
subdirectory = 'TCGA_Cervical_Cancer_(CESC)'
|
44 |
+
cohort_dir = os.path.join(tcga_root_dir, subdirectory)
|
45 |
+
|
46 |
+
# 2. Get the file paths
|
47 |
+
clinical_file_path, genetic_file_path = tcga_get_relevant_filepaths(cohort_dir)
|
48 |
+
|
49 |
+
# 3. Load the data files
|
50 |
+
clinical_df = pd.read_csv(clinical_file_path, index_col=0, sep='\t')
|
51 |
+
genetic_df = pd.read_csv(genetic_file_path, index_col=0, sep='\t')
|
52 |
+
|
53 |
+
# 4. Print clinical data columns
|
54 |
+
print("Clinical data columns:")
|
55 |
+
print(clinical_df.columns.tolist())
|
56 |
+
# Age column candidates contain words like 'age' or 'birth'
|
57 |
+
age_col = 'age_at_initial_pathologic_diagnosis' # Contains clear numerical age values
|
58 |
+
|
59 |
+
# Gender column candidates contain word 'gender'
|
60 |
+
gender_col = 'gender' # Contains clear gender values
|
61 |
+
|
62 |
+
# Print selected columns
|
63 |
+
print(f"Selected age column: {age_col}")
|
64 |
+
print(f"Selected gender column: {gender_col}")
|
65 |
+
# 1. Extract and standardize clinical features
|
66 |
+
# First create trait labels using sample IDs, then add demographics if available
|
67 |
+
clinical_features = tcga_select_clinical_features(
|
68 |
+
clinical_df,
|
69 |
+
trait=trait,
|
70 |
+
age_col='age_at_initial_pathologic_diagnosis',
|
71 |
+
gender_col='gender'
|
72 |
+
)
|
73 |
+
|
74 |
+
# 2. Normalize gene symbols and save
|
75 |
+
normalized_gene_df = normalize_gene_symbols_in_index(genetic_df)
|
76 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
77 |
+
normalized_gene_df.to_csv(out_gene_data_file)
|
78 |
+
|
79 |
+
# 3. Link clinical and genetic data
|
80 |
+
linked_data = pd.concat([clinical_features, normalized_gene_df.T], axis=1)
|
81 |
+
|
82 |
+
# 4. Handle missing values systematically
|
83 |
+
linked_data = handle_missing_values(linked_data, trait)
|
84 |
+
|
85 |
+
# 5. Check for bias in trait and demographic features
|
86 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
87 |
+
|
88 |
+
# 6. Validate data quality and save cohort info
|
89 |
+
note = "Contains molecular data from tumor and normal samples with patient demographics."
|
90 |
+
is_usable = validate_and_save_cohort_info(
|
91 |
+
is_final=True,
|
92 |
+
cohort="TCGA",
|
93 |
+
info_path=json_path,
|
94 |
+
is_gene_available=True,
|
95 |
+
is_trait_available=True,
|
96 |
+
is_biased=trait_biased,
|
97 |
+
df=linked_data,
|
98 |
+
note=note
|
99 |
+
)
|
100 |
+
|
101 |
+
# 7. Save linked data if usable
|
102 |
+
if is_usable:
|
103 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
104 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Cervical_Cancer/gene_data/GSE107754.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a82da64a5edcbde2a3ccf1c07d005767e02ceeaad822b4ed6217419063405079
|
3 |
+
size 19822703
|
p3/preprocess/Cervical_Cancer/gene_data/GSE114243.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Cervical_Cancer/gene_data/GSE138079.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ce5db634b575bdbdafa08fb5f64269273ee335c54eee01add0988aeff973e030
|
3 |
+
size 14805206
|
p3/preprocess/Cervical_Cancer/gene_data/GSE138080.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Cervical_Cancer/gene_data/GSE146114.csv
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f1451952dd968a27803c16c51aa325f075ec49a344592f530380fee4e49a2c3f
|
3 |
+
size 18757988
|
p3/preprocess/Cervical_Cancer/gene_data/GSE63678.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Cervical_Cancer/gene_data/GSE75132.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Chronic_Fatigue_Syndrome/GSE251792.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|
p3/preprocess/Chronic_Fatigue_Syndrome/clinical_data/GSE251792.csv
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
,GSM7988184,GSM7988185,GSM7988186,GSM7988187,GSM7988188,GSM7988189,GSM7988190,GSM7988191,GSM7988192,GSM7988193,GSM7988194,GSM7988195,GSM7988196,GSM7988197,GSM7988198,GSM7988199,GSM7988200,GSM7988201,GSM7988202,GSM7988203,GSM7988204,GSM7988205,GSM7988206,GSM7988207,GSM7988208,GSM7988209,GSM7988210,GSM7988211,GSM7988212,GSM7988213,GSM7988214,GSM7988215,GSM7988216,GSM7988217,GSM7988218,GSM7988219,GSM7988220,GSM7988221,GSM7988222,GSM7988223,GSM7988224,GSM7988225,GSM8032049,GSM8032050,GSM8032051,GSM8032052,GSM8032053,GSM8032054,GSM8032055,GSM8032056,GSM8032057,GSM8032058,GSM8032059,GSM8032060,GSM8032061,GSM8032062,GSM8032063,GSM8032064,GSM8032065,GSM8032066,GSM8032067,GSM8032068,GSM8032069,GSM8032070,GSM8032071,GSM8032072,GSM8032073,GSM8032074,GSM8032075,GSM8032076,GSM8032077,GSM8032078,GSM8032079,GSM8032080,GSM8032081,GSM8032082,GSM8032083,GSM8032084,GSM8032085,GSM8032086,GSM8032087,GSM8032088,GSM8032089,GSM8032090
|
2 |
+
Chronic_Fatigue_Syndrome,1.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,0.0,1.0,0.0,1.0,1.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,0.0,1.0
|
3 |
+
Age,61.0,37.0,56.0,56.0,24.0,58.0,43.0,26.0,40.0,47.0,22.0,54.0,58.0,44.0,20.0,26.0,23.0,33.0,54.0,25.0,58.0,37.0,23.0,22.0,51.0,48.0,36.0,56.0,38.0,60.0,37.0,25.0,44.0,61.0,50.0,60.0,47.0,49.0,50.0,55.0,60.0,57.0,44.0,60.0,37.0,58.0,60.0,56.0,24.0,50.0,51.0,55.0,48.0,26.0,22.0,38.0,50.0,56.0,33.0,47.0,22.0,23.0,23.0,58.0,54.0,37.0,36.0,61.0,49.0,57.0,60.0,25.0,47.0,44.0,56.0,54.0,58.0,20.0,37.0,26.0,25.0,43.0,40.0,61.0
|
4 |
+
Gender,0.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,0.0,1.0,1.0,0.0,1.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,0.0,1.0,1.0,0.0
|
p3/preprocess/Chronic_Fatigue_Syndrome/clinical_data/GSE39684.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM977688,GSM977689,GSM977690,GSM977691,GSM977692,GSM977693,GSM977694,GSM977695,GSM977696,GSM977697,GSM977698,GSM977699,GSM977700,GSM977701,GSM977702,GSM977703,GSM977704,GSM977705,GSM977706,GSM977707,GSM977708,GSM977709,GSM977710,GSM977711,GSM977712,GSM977713,GSM977714,GSM977715,GSM977716,GSM977717,GSM977718,GSM977719,GSM977720,GSM977721,GSM977722,GSM977723,GSM977724,GSM977725,GSM977726,GSM977727,GSM977728,GSM977729,GSM977730,GSM977731,GSM977732,GSM977733,GSM977734,GSM977735,GSM977736,GSM977737,GSM977738,GSM977739,GSM977740,GSM977741,GSM977742,GSM977743,GSM977744,GSM977745,GSM977746,GSM977747,GSM977748,GSM977749,GSM977750
|
2 |
+
Chronic_Fatigue_Syndrome,,,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
|
p3/preprocess/Chronic_Fatigue_Syndrome/clinical_data/GSE67311.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
,GSM1644447,GSM1644448,GSM1644449,GSM1644450,GSM1644451,GSM1644452,GSM1644453,GSM1644454,GSM1644455,GSM1644456,GSM1644457,GSM1644458,GSM1644459,GSM1644460,GSM1644461,GSM1644462,GSM1644463,GSM1644464,GSM1644465,GSM1644466,GSM1644467,GSM1644468,GSM1644469,GSM1644470,GSM1644471,GSM1644472,GSM1644473,GSM1644474,GSM1644475,GSM1644476,GSM1644477,GSM1644478,GSM1644479,GSM1644480,GSM1644481,GSM1644482,GSM1644483,GSM1644484,GSM1644485,GSM1644486,GSM1644487,GSM1644488,GSM1644489,GSM1644490,GSM1644491,GSM1644492,GSM1644493,GSM1644494,GSM1644495,GSM1644496,GSM1644497,GSM1644498,GSM1644499,GSM1644500,GSM1644501,GSM1644502,GSM1644503,GSM1644504,GSM1644505,GSM1644506,GSM1644507,GSM1644508,GSM1644509,GSM1644510,GSM1644511,GSM1644512,GSM1644513,GSM1644514,GSM1644515,GSM1644516,GSM1644517,GSM1644518,GSM1644519,GSM1644520,GSM1644521,GSM1644522,GSM1644523,GSM1644524,GSM1644525,GSM1644526,GSM1644527,GSM1644528,GSM1644529,GSM1644530,GSM1644531,GSM1644532,GSM1644533,GSM1644534,GSM1644535,GSM1644536,GSM1644537,GSM1644538,GSM1644539,GSM1644540,GSM1644541,GSM1644542,GSM1644543,GSM1644544,GSM1644545,GSM1644546,GSM1644547,GSM1644548,GSM1644549,GSM1644550,GSM1644551,GSM1644552,GSM1644553,GSM1644554,GSM1644555,GSM1644556,GSM1644557,GSM1644558,GSM1644559,GSM1644560,GSM1644561,GSM1644562,GSM1644563,GSM1644564,GSM1644565,GSM1644566,GSM1644567,GSM1644568,GSM1644569,GSM1644570,GSM1644571,GSM1644572,GSM1644573,GSM1644574,GSM1644575,GSM1644576,GSM1644577,GSM1644578,GSM1644579,GSM1644580,GSM1644581,GSM1644582,GSM1644583,GSM1644584,GSM1644585,GSM1644586,GSM1644587,GSM1644588
|
2 |
+
Chronic_Fatigue_Syndrome,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,0.0,,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,,0.0,1.0,0.0,0.0,0.0,0.0,,0.0,,0.0,0.0,1.0,0.0,,0.0,0.0,0.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,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,0.0,,0.0,0.0,0.0
|
p3/preprocess/Chronic_Fatigue_Syndrome/code/GSE251792.py
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Chronic_Fatigue_Syndrome"
|
6 |
+
cohort = "GSE251792"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Chronic_Fatigue_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Chronic_Fatigue_Syndrome/GSE251792"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/GSE251792.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/gene_data/GSE251792.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/clinical_data/GSE251792.csv"
|
16 |
+
json_path = "./output/preprocess/3/Chronic_Fatigue_Syndrome/cohort_info.json"
|
17 |
+
|
18 |
+
# Get paths to the SOFT and matrix files
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Get background info and clinical data from matrix file
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values for each feature (row) in clinical data
|
25 |
+
unique_values_dict = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("=== Dataset Background Information ===")
|
29 |
+
print(background_info)
|
30 |
+
print("\n=== Sample Characteristics ===")
|
31 |
+
print(json.dumps(unique_values_dict, indent=2))
|
32 |
+
# Gene expression data appears available given this is a deep phenotyping study
|
33 |
+
is_gene_available = True
|
34 |
+
|
35 |
+
# Feature row identification
|
36 |
+
trait_row = 2 # 'group' field contains trait data
|
37 |
+
age_row = 1 # 'age' field contains age data
|
38 |
+
gender_row = 0 # 'Sex' field contains gender data
|
39 |
+
|
40 |
+
# Convert trait (Patient=1, Control=0)
|
41 |
+
def convert_trait(x):
|
42 |
+
if not isinstance(x, str):
|
43 |
+
return None
|
44 |
+
x = x.lower().split(': ')[-1].strip()
|
45 |
+
if 'patient' in x:
|
46 |
+
return 1
|
47 |
+
elif 'control' in x:
|
48 |
+
return 0
|
49 |
+
return None
|
50 |
+
|
51 |
+
# Convert age to float
|
52 |
+
def convert_age(x):
|
53 |
+
if not isinstance(x, str):
|
54 |
+
return None
|
55 |
+
try:
|
56 |
+
return float(x.split(': ')[-1])
|
57 |
+
except:
|
58 |
+
return None
|
59 |
+
|
60 |
+
# Convert gender (Female=0, Male=1)
|
61 |
+
def convert_gender(x):
|
62 |
+
if not isinstance(x, str):
|
63 |
+
return None
|
64 |
+
x = x.lower().split(': ')[-1].strip()
|
65 |
+
if 'female' in x:
|
66 |
+
return 0
|
67 |
+
elif 'male' in x:
|
68 |
+
return 1
|
69 |
+
return None
|
70 |
+
|
71 |
+
# Save initial metadata
|
72 |
+
validate_and_save_cohort_info(is_final=False,
|
73 |
+
cohort=cohort,
|
74 |
+
info_path=json_path,
|
75 |
+
is_gene_available=is_gene_available,
|
76 |
+
is_trait_available=trait_row is not None)
|
77 |
+
|
78 |
+
# Extract clinical features since trait data is available
|
79 |
+
clinical_df = geo_select_clinical_features(clinical_data,
|
80 |
+
trait=trait,
|
81 |
+
trait_row=trait_row,
|
82 |
+
convert_trait=convert_trait,
|
83 |
+
age_row=age_row,
|
84 |
+
convert_age=convert_age,
|
85 |
+
gender_row=gender_row,
|
86 |
+
convert_gender=convert_gender)
|
87 |
+
|
88 |
+
# Preview the clinical data
|
89 |
+
print("Preview of clinical data:")
|
90 |
+
print(preview_df(clinical_df))
|
91 |
+
|
92 |
+
# Save clinical data
|
93 |
+
clinical_df.to_csv(out_clinical_data_file)
|
94 |
+
# Extract gene expression data from matrix file
|
95 |
+
genetic_df = get_genetic_data(matrix_file)
|
96 |
+
|
97 |
+
# Print DataFrame shape and first 20 row IDs
|
98 |
+
print("DataFrame shape:", genetic_df.shape)
|
99 |
+
print("\nFirst 20 row IDs:")
|
100 |
+
print(genetic_df.index[:20])
|
101 |
+
|
102 |
+
print("\nPreview of first few rows and columns:")
|
103 |
+
print(genetic_df.head().iloc[:, :5])
|
104 |
+
# Row IDs like 'HCE000104' are Helicos BioSciences Corporation Probe IDs, not standard gene symbols
|
105 |
+
# These need to be mapped to proper gene symbols for analysis
|
106 |
+
requires_gene_mapping = True
|
107 |
+
# Extract gene annotation data, excluding control probe lines
|
108 |
+
gene_metadata = get_gene_annotation(soft_file)
|
109 |
+
|
110 |
+
# Preview filtered annotation data
|
111 |
+
print("Column names:")
|
112 |
+
print(gene_metadata.columns)
|
113 |
+
print("\nPreview of gene annotation data:")
|
114 |
+
print(preview_df(gene_metadata))
|
115 |
+
# Get gene mapping using ID and EntrezGeneSymbol columns
|
116 |
+
mapping_df = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='EntrezGeneSymbol')
|
117 |
+
|
118 |
+
# Apply gene mapping to convert probe values to gene expression values
|
119 |
+
gene_data = apply_gene_mapping(genetic_df, mapping_df)
|
120 |
+
|
121 |
+
# Preview the resulting gene expression data
|
122 |
+
print("Gene expression data shape:", gene_data.shape)
|
123 |
+
print("\nFirst few rows and columns:")
|
124 |
+
print(gene_data.head().iloc[:, :5])
|
125 |
+
# 1. Normalize gene symbols and save
|
126 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
127 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
128 |
+
gene_data.to_csv(out_gene_data_file)
|
129 |
+
|
130 |
+
# 2. Link clinical and genetic data
|
131 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, gene_data)
|
132 |
+
|
133 |
+
# 3. Handle missing values
|
134 |
+
linked_data = handle_missing_values(linked_data, trait)
|
135 |
+
|
136 |
+
# 4. Check for biased features
|
137 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
138 |
+
|
139 |
+
# 5. Final validation and metadata saving
|
140 |
+
is_usable = validate_and_save_cohort_info(
|
141 |
+
is_final=True,
|
142 |
+
cohort=cohort,
|
143 |
+
info_path=json_path,
|
144 |
+
is_gene_available=is_gene_available,
|
145 |
+
is_trait_available=True,
|
146 |
+
is_biased=trait_biased,
|
147 |
+
df=linked_data,
|
148 |
+
note="Dataset contains gene expression data from blood samples used to study chronic fatigue syndrome"
|
149 |
+
)
|
150 |
+
|
151 |
+
# 6. Save linked data if usable
|
152 |
+
if is_usable:
|
153 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
154 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Chronic_Fatigue_Syndrome/code/GSE39684.py
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Chronic_Fatigue_Syndrome"
|
6 |
+
cohort = "GSE39684"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Chronic_Fatigue_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Chronic_Fatigue_Syndrome/GSE39684"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/GSE39684.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/gene_data/GSE39684.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/clinical_data/GSE39684.csv"
|
16 |
+
json_path = "./output/preprocess/3/Chronic_Fatigue_Syndrome/cohort_info.json"
|
17 |
+
|
18 |
+
# Get paths to the SOFT and matrix files
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Get background info and clinical data from matrix file
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values for each feature (row) in clinical data
|
25 |
+
unique_values_dict = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("=== Dataset Background Information ===")
|
29 |
+
print(background_info)
|
30 |
+
print("\n=== Sample Characteristics ===")
|
31 |
+
print(json.dumps(unique_values_dict, indent=2))
|
32 |
+
# 1. Gene Expression Data Availability
|
33 |
+
# Yes, this is microarray data from prostate tissue samples analyzing genes
|
34 |
+
is_gene_available = True
|
35 |
+
|
36 |
+
# 2. Clinical Feature Analysis
|
37 |
+
# 2.1 Data Availability
|
38 |
+
# From cohort in sample char row 1, we can infer cohort year represents CFS cases vs controls
|
39 |
+
trait_row = 1
|
40 |
+
# No age information available
|
41 |
+
age_row = None
|
42 |
+
# No gender information available
|
43 |
+
gender_row = None
|
44 |
+
|
45 |
+
# 2.2 Data Type Conversion Functions
|
46 |
+
def convert_trait(val):
|
47 |
+
if not isinstance(val, str):
|
48 |
+
return None
|
49 |
+
# Cohort 2006 = CFS cases, 2012 = controls
|
50 |
+
if "cohort:" in val:
|
51 |
+
year = val.split(":")[1].strip()
|
52 |
+
if year == "2006":
|
53 |
+
return 1 # Cases
|
54 |
+
elif year == "2012":
|
55 |
+
return 0 # Controls
|
56 |
+
return None
|
57 |
+
|
58 |
+
def convert_age(val):
|
59 |
+
# No age data
|
60 |
+
return None
|
61 |
+
|
62 |
+
def convert_gender(val):
|
63 |
+
# No gender data
|
64 |
+
return None
|
65 |
+
|
66 |
+
# 3. Save Metadata
|
67 |
+
validate_and_save_cohort_info(
|
68 |
+
is_final=False,
|
69 |
+
cohort=cohort,
|
70 |
+
info_path=json_path,
|
71 |
+
is_gene_available=is_gene_available,
|
72 |
+
is_trait_available=trait_row is not None
|
73 |
+
)
|
74 |
+
|
75 |
+
# 4. Clinical Feature Extraction
|
76 |
+
if trait_row is not None:
|
77 |
+
clinical_features = geo_select_clinical_features(
|
78 |
+
clinical_df=clinical_data,
|
79 |
+
trait=trait,
|
80 |
+
trait_row=trait_row,
|
81 |
+
convert_trait=convert_trait,
|
82 |
+
age_row=age_row,
|
83 |
+
convert_age=convert_age,
|
84 |
+
gender_row=gender_row,
|
85 |
+
convert_gender=convert_gender
|
86 |
+
)
|
87 |
+
|
88 |
+
print("Preview of extracted clinical features:")
|
89 |
+
print(preview_df(clinical_features))
|
90 |
+
|
91 |
+
# Save clinical features
|
92 |
+
clinical_features.to_csv(out_clinical_data_file)
|
93 |
+
# Extract gene expression data from matrix file
|
94 |
+
genetic_df = get_genetic_data(matrix_file)
|
95 |
+
|
96 |
+
# Print DataFrame shape and first 20 row IDs
|
97 |
+
print("DataFrame shape:", genetic_df.shape)
|
98 |
+
print("\nFirst 20 row IDs:")
|
99 |
+
print(genetic_df.index[:20])
|
100 |
+
|
101 |
+
print("\nPreview of first few rows and columns:")
|
102 |
+
print(genetic_df.head().iloc[:, :5])
|
103 |
+
# These identifiers appear to be custom probe IDs from a microarray platform (XXX-V3-70mer format)
|
104 |
+
# and will need to be mapped to official gene symbols
|
105 |
+
requires_gene_mapping = True
|
106 |
+
# Extract gene annotation data, excluding control probe lines
|
107 |
+
gene_metadata = get_gene_annotation(soft_file)
|
108 |
+
|
109 |
+
# Preview filtered annotation data
|
110 |
+
print("Column names:")
|
111 |
+
print(gene_metadata.columns)
|
112 |
+
print("\nPreview of gene annotation data:")
|
113 |
+
print(preview_df(gene_metadata))
|
114 |
+
|
115 |
+
print("\nIMPORTANT NOTE: After reviewing the gene annotation data,")
|
116 |
+
print("it is clear this dataset contains viral gene expression data (Parvovirus, Retrovirus etc.)")
|
117 |
+
print("rather than human gene expression data. Therefore this dataset is not suitable for human trait analysis.")
|
118 |
+
|
119 |
+
# Invalidate our previous assessment
|
120 |
+
is_gene_available = False
|
121 |
+
|
122 |
+
# Re-run validation with updated gene availability
|
123 |
+
validate_and_save_cohort_info(
|
124 |
+
is_final=False,
|
125 |
+
cohort=cohort,
|
126 |
+
info_path=json_path,
|
127 |
+
is_gene_available=is_gene_available,
|
128 |
+
is_trait_available=trait_row is not None
|
129 |
+
)
|
p3/preprocess/Chronic_Fatigue_Syndrome/code/GSE67311.py
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Chronic_Fatigue_Syndrome"
|
6 |
+
cohort = "GSE67311"
|
7 |
+
|
8 |
+
# Input paths
|
9 |
+
in_trait_dir = "../DATA/GEO/Chronic_Fatigue_Syndrome"
|
10 |
+
in_cohort_dir = "../DATA/GEO/Chronic_Fatigue_Syndrome/GSE67311"
|
11 |
+
|
12 |
+
# Output paths
|
13 |
+
out_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/GSE67311.csv"
|
14 |
+
out_gene_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/gene_data/GSE67311.csv"
|
15 |
+
out_clinical_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/clinical_data/GSE67311.csv"
|
16 |
+
json_path = "./output/preprocess/3/Chronic_Fatigue_Syndrome/cohort_info.json"
|
17 |
+
|
18 |
+
# Get paths to the SOFT and matrix files
|
19 |
+
soft_file, matrix_file = geo_get_relevant_filepaths(in_cohort_dir)
|
20 |
+
|
21 |
+
# Get background info and clinical data from matrix file
|
22 |
+
background_info, clinical_data = get_background_and_clinical_data(matrix_file)
|
23 |
+
|
24 |
+
# Get unique values for each feature (row) in clinical data
|
25 |
+
unique_values_dict = get_unique_values_by_row(clinical_data)
|
26 |
+
|
27 |
+
# Print background info
|
28 |
+
print("=== Dataset Background Information ===")
|
29 |
+
print(background_info)
|
30 |
+
print("\n=== Sample Characteristics ===")
|
31 |
+
print(json.dumps(unique_values_dict, indent=2))
|
32 |
+
# 1. Gene Expression Data Availability
|
33 |
+
# Dataset uses Affymetrix Human Gene arrays, indicating gene expression data is available
|
34 |
+
is_gene_available = True
|
35 |
+
|
36 |
+
# 2. Variable Availability and Data Type
|
37 |
+
# 2.1 Row identification
|
38 |
+
trait_row = 8 # Chronic fatigue syndrome status in row 8
|
39 |
+
age_row = None # Age not available
|
40 |
+
gender_row = None # Gender not available
|
41 |
+
|
42 |
+
# 2.2 Data type conversion functions
|
43 |
+
def convert_trait(value: str) -> int:
|
44 |
+
"""Convert CFS status to binary (0: No CFS, 1: Has CFS)"""
|
45 |
+
if pd.isna(value):
|
46 |
+
return None
|
47 |
+
value = value.lower().split(': ')[-1]
|
48 |
+
if value == 'yes':
|
49 |
+
return 1
|
50 |
+
elif value == 'no':
|
51 |
+
return 0
|
52 |
+
return None
|
53 |
+
|
54 |
+
def convert_age(value: str) -> float:
|
55 |
+
"""Convert age to float - not used as age unavailable"""
|
56 |
+
return None
|
57 |
+
|
58 |
+
def convert_gender(value: str) -> int:
|
59 |
+
"""Convert gender to binary - not used as gender unavailable"""
|
60 |
+
return None
|
61 |
+
|
62 |
+
# 3. Save initial metadata
|
63 |
+
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. Clinical Feature Extraction
|
72 |
+
# Since trait_row is not None, extract clinical features
|
73 |
+
clinical_df = 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 |
+
|
84 |
+
# Preview the extracted features
|
85 |
+
print("Preview of clinical features:")
|
86 |
+
print(preview_df(clinical_df))
|
87 |
+
|
88 |
+
# Save clinical features
|
89 |
+
clinical_df.to_csv(out_clinical_data_file)
|
90 |
+
# Extract gene expression data from matrix file
|
91 |
+
genetic_df = get_genetic_data(matrix_file)
|
92 |
+
|
93 |
+
# Print DataFrame shape and first 20 row IDs
|
94 |
+
print("DataFrame shape:", genetic_df.shape)
|
95 |
+
print("\nFirst 20 row IDs:")
|
96 |
+
print(genetic_df.index[:20])
|
97 |
+
|
98 |
+
print("\nPreview of first few rows and columns:")
|
99 |
+
print(genetic_df.head().iloc[:, :5])
|
100 |
+
# Gene probe identifier pattern suggests they are not gene symbols
|
101 |
+
# The identifiers are numeric values in the format 7XXXXXX, which appear to be Illumina probe IDs
|
102 |
+
# We will need to perform identifier mapping
|
103 |
+
requires_gene_mapping = True
|
104 |
+
# Extract gene annotation data, excluding control probe lines
|
105 |
+
gene_metadata = get_gene_annotation(soft_file)
|
106 |
+
|
107 |
+
# Preview filtered annotation data
|
108 |
+
print("Column names:")
|
109 |
+
print(gene_metadata.columns)
|
110 |
+
print("\nPreview of gene annotation data:")
|
111 |
+
print(preview_df(gene_metadata))
|
112 |
+
# 1. Identify columns for mapping
|
113 |
+
# 'ID' column in gene_metadata contains probe IDs matching genetic_df index
|
114 |
+
# 'gene_assignment' column contains gene symbols in the format "NM_XXX // GENESYMBOL // description"
|
115 |
+
|
116 |
+
# 2. Get mapping dataframe by extracting probe IDs and gene symbols
|
117 |
+
# Use text extraction to get gene symbols from gene_assignment strings
|
118 |
+
mapping_df = get_gene_mapping(gene_metadata, prob_col='ID', gene_col='gene_assignment')
|
119 |
+
|
120 |
+
# 3. Apply mapping to convert probe data to gene expression data
|
121 |
+
gene_data = apply_gene_mapping(genetic_df, mapping_df)
|
122 |
+
|
123 |
+
# Print info about the mapping result
|
124 |
+
print(f"Original probe data shape: {genetic_df.shape}")
|
125 |
+
print(f"Gene expression data shape: {gene_data.shape}")
|
126 |
+
print("\nPreview of gene expression data:")
|
127 |
+
print(gene_data.head().iloc[:, :5])
|
128 |
+
# 1. Normalize gene symbols and save
|
129 |
+
gene_data = normalize_gene_symbols_in_index(gene_data)
|
130 |
+
os.makedirs(os.path.dirname(out_gene_data_file), exist_ok=True)
|
131 |
+
gene_data.to_csv(out_gene_data_file)
|
132 |
+
|
133 |
+
# 2. Link clinical and genetic data
|
134 |
+
linked_data = geo_link_clinical_genetic_data(clinical_df, gene_data)
|
135 |
+
|
136 |
+
# 3. Handle missing values
|
137 |
+
linked_data = handle_missing_values(linked_data, trait)
|
138 |
+
|
139 |
+
# 4. Check for biased features
|
140 |
+
trait_biased, linked_data = judge_and_remove_biased_features(linked_data, trait)
|
141 |
+
|
142 |
+
# 5. Final validation and metadata saving
|
143 |
+
is_usable = validate_and_save_cohort_info(
|
144 |
+
is_final=True,
|
145 |
+
cohort=cohort,
|
146 |
+
info_path=json_path,
|
147 |
+
is_gene_available=is_gene_available,
|
148 |
+
is_trait_available=True,
|
149 |
+
is_biased=trait_biased,
|
150 |
+
df=linked_data,
|
151 |
+
note="Dataset contains gene expression data from blood samples used to study chronic fatigue syndrome"
|
152 |
+
)
|
153 |
+
|
154 |
+
# 6. Save linked data if usable
|
155 |
+
if is_usable:
|
156 |
+
os.makedirs(os.path.dirname(out_data_file), exist_ok=True)
|
157 |
+
linked_data.to_csv(out_data_file)
|
p3/preprocess/Chronic_Fatigue_Syndrome/code/TCGA.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Path Configuration
|
2 |
+
from tools.preprocess import *
|
3 |
+
|
4 |
+
# Processing context
|
5 |
+
trait = "Chronic_Fatigue_Syndrome"
|
6 |
+
|
7 |
+
# Input paths
|
8 |
+
tcga_root_dir = "../DATA/TCGA"
|
9 |
+
|
10 |
+
# Output paths
|
11 |
+
out_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/TCGA.csv"
|
12 |
+
out_gene_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/gene_data/TCGA.csv"
|
13 |
+
out_clinical_data_file = "./output/preprocess/3/Chronic_Fatigue_Syndrome/clinical_data/TCGA.csv"
|
14 |
+
json_path = "./output/preprocess/3/Chronic_Fatigue_Syndrome/cohort_info.json"
|
15 |
+
|
16 |
+
# Check available directories
|
17 |
+
available_dirs = os.listdir(tcga_root_dir)
|
18 |
+
available_dirs = [d for d in available_dirs if not d.startswith('.') and not d.endswith('.ipynb')]
|
19 |
+
|
20 |
+
# For cardiovascular disease, there is no directly matching cohort in TCGA
|
21 |
+
# Mark the trait as not available and exit
|
22 |
+
is_usable = validate_and_save_cohort_info(
|
23 |
+
is_final=False,
|
24 |
+
cohort="TCGA",
|
25 |
+
info_path=json_path,
|
26 |
+
is_gene_available=False,
|
27 |
+
is_trait_available=False
|
28 |
+
)
|
29 |
+
|
30 |
+
raise ValueError(f"No suitable TCGA cohort found for {trait}")
|