Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +2 -0
- .gitignore +4 -0
- .ms_upload_cache +1 -0
- LICENSE +52 -0
- README.md +292 -0
- conf/analysis/G4.ipynb +451 -0
- conf/analysis/align/mut_inits.npy +3 -0
- conf/analysis/align/seq_init.npy +3 -0
- conf/analysis/align/seq_mutated.npy +3 -0
- conf/analysis/align/seq_opt.npy +3 -0
- conf/analysis/files/gen_4mer_new.npy +3 -0
- conf/analysis/files/gen_ham_new.npy +3 -0
- conf/analysis/files/opt_4mer_new.npy +3 -0
- conf/analysis/files/opt_ham_new.npy +3 -0
- conf/analysis/files/rand_4mer_new.npy +3 -0
- conf/analysis/files/rand_ham_new.npy +3 -0
- conf/analysis/files/real_4mer_new.npy +3 -0
- conf/analysis/files/real_ham_new.npy +3 -0
- conf/analysis/files/te_gens.npy +3 -0
- conf/analysis/files/te_optimized.npy +3 -0
- conf/analysis/files/te_optimus.npy +3 -0
- conf/analysis/files/te_rands.npy +3 -0
- conf/analysis/files/te_reals.npy +3 -0
- conf/analysis/mrl_te_opt.py +186 -0
- conf/analysis/opt_check.py +262 -0
- conf/analysis/per_gene_features.py +196 -0
- conf/analysis/plot_4x4.py +290 -0
- conf/analysis/uorfs.ipynb +0 -0
- conf/analysis/utils/__init__.py +0 -0
- conf/analysis/utils/__pycache__/__init__.cpython-310.pyc +0 -0
- conf/analysis/utils/__pycache__/framepool.cpython-310.pyc +0 -0
- conf/analysis/utils/__pycache__/util.cpython-310.pyc +0 -0
- conf/analysis/utils/framepool.py +172 -0
- conf/analysis/utils/util.py +362 -0
- conf/analysis/violin.py +567 -0
- conf/analysis/violin_dists.py +463 -0
- conf/config.json +23 -0
- conf/data/motifs.csv +257 -0
- conf/data/utrdb2.csv +3 -0
- conf/environment.yml +297 -0
- conf/img/pipeline.png +3 -0
- conf/notebooks/exp_optimization_multiple.ipynb +1053 -0
- conf/notebooks/exp_optimization_single.ipynb +906 -0
- conf/notebooks/optimize_te_mrl.ipynb +483 -0
- configuration.json +17 -0
- model/__init__.py +5 -0
- model/src/__init__.py +0 -0
- model/src/__pycache__/__init__.cpython-311.pyc +0 -0
- model/src/exp_optimization/__init__.py +0 -0
- model/src/exp_optimization/exp_joint.py +571 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
conf/data/utrdb2.csv filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
conf/img/pipeline.png filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
**/__pycache__/
|
| 2 |
+
.vscode/
|
| 3 |
+
**/.cache/
|
| 4 |
+
**/outputs/
|
.ms_upload_cache
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"version": 3, "repo_id": "OneScience/UTRGAN", "files": {"LICENSE|1788147042.0|2066": {"hash": "cea15b2ae31f975eddf4f4e497e4a4f1163a136895d6f5bdb250bc07c2e98c03", "size": 2066, "status": "c"}, "conf/analysis/G4.ipynb|1785812342.0|18619": {"hash": "8ae4d9175042f74547dc53347ff5303289df4fba33568f6425f20d450dfac5ad", "size": 18619, "status": "c"}, ".gitignore|1785812342.0|47": {"hash": "9aa388e10ea5fb2e1d4330f5793eef8ca6758eef9012f0f7313569f580863ac0", "size": 47, "status": "c"}, "README.md|1788147563.0|8310": {"hash": "af743559047fa32e20c102bfe9baed0908767449ee167c9a5767d3b594a5337f", "size": 8310, "status": "c"}, "conf/analysis/align/mut_inits.npy|1785812342.0|8320": {"hash": "b4defe5aaf89c16f10cea7e90f3037e896bbbb4b572afdaebac1438a412aa726", "size": 8320, "status": "c"}, "conf/analysis/align/seq_init.npy|1785812342.0|640": {"hash": "efaa32e7cbf675db8218633a8fab7fc73c4f050ac6ee2fe36edace02353c1326", "size": 640, "status": "c"}, "conf/analysis/align/seq_mutated.npy|1785812342.0|8320": {"hash": "7e4d39a4eb211f507b4c13a765408cb5e988a69c65dd79ce492cb7a64237a04b", "size": 8320, "status": "c"}, "conf/analysis/align/seq_opt.npy|1785812342.0|640": {"hash": "fd28b83a5c3d4a43e4bfc0173ea6322a7760e1bb5947803a6f0f8ac9aa1ea03d", "size": 640, "status": "c"}, "conf/analysis/files/gen_4mer_new.npy|1785812342.0|4224": {"hash": "3019b9b6e6494f58f219d36e32057046b6562ce91163e90b90543798af958edb", "size": 4224, "status": "c"}, "conf/analysis/files/opt_4mer_new.npy|1785812342.0|8320": {"hash": "cad973fbfcec1714669b0eb77ca9e88eb172bf49ac13a174c7ffda9835fe7139", "size": 8320, "status": "c"}, "conf/analysis/files/opt_ham_new.npy|1785812342.0|8320": {"hash": "a4bb77a899716eaf15d8a849558195574d86b0ef672ec544a9f67b5da4c0849f", "size": 8320, "status": "c"}, "conf/analysis/files/gen_ham_new.npy|1785812342.0|16512": {"hash": "863ff673d30298635c6c9811045748dbdc0c41c784365bf93823cbb5205a1d52", "size": 16512, "status": "c"}, "conf/analysis/files/rand_4mer_new.npy|1785812342.0|4224": {"hash": "567b6ec5148cff4676f246450656cf821e8614181a197897b7503b8b13f30153", "size": 4224, "status": "c"}, "conf/analysis/files/rand_ham_new.npy|1785812342.0|16512": {"hash": "b682a172394378c81d433766374f0cac005591113476b50340faff18606f9079", "size": 16512, "status": "c"}, "conf/analysis/files/real_4mer_new.npy|1785812342.0|4224": {"hash": "ba1484b28c87d4145476af7e31e6b0d4bd17d29c38fc0bddf598e25f28ebc2b9", "size": 4224, "status": "c"}, "conf/analysis/files/real_ham_new.npy|1785812342.0|16512": {"hash": "e4a0c44f28a53700e74655d71303158df9c3491fa2fb91cdb2bc8f8ec067bc1e", "size": 16512, "status": "c"}, "conf/analysis/files/te_gens.npy|1785812342.0|8320": {"hash": "5123558dca0ee55109001effc674d49a24a4e9ac6ad4414312b4c963cb7c75c5", "size": 8320, "status": "c"}, "conf/analysis/files/te_optimized.npy|1785812342.0|4224": {"hash": "965402fd8be6ae2b52f6247524dc5987fe34f098482a73be0b02ff9e37764cfa", "size": 4224, "status": "c"}, "conf/analysis/files/te_optimus.npy|1785812342.0|4224": {"hash": "f6af8f80b7dd9b17ada1e83234e19a105321b5b3f3fb1e79ef99ac1e14a0469a", "size": 4224, "status": "c"}, "conf/analysis/files/te_rands.npy|1785812342.0|8320": {"hash": "9afb713954378a127aa7d223bbd2d7c2547d5a4f4faaf5cd0fd68f4f6de7808e", "size": 8320, "status": "c"}, "conf/analysis/files/te_reals.npy|1785812342.0|133128": {"hash": "185aadd3b234d3735d198ea1a0adc1b741396c6b09b62cab9054000d5b88f1ed", "size": 133128, "status": "c"}, "conf/analysis/mrl_te_opt.py|1785812342.0|5474": {"hash": "97d98e3213b0755c76c93370adb8a6a6f0f5cf06006d273b6d453a81c6906b73", "size": 5474, "status": "c"}, "conf/analysis/opt_check.py|1785812342.0|6105": {"hash": "d8db84a3e88936d863ab3dd780cded8cf4eab94e73e7b8a8f1e7fae99e35e59d", "size": 6105, "status": "c"}, "conf/analysis/per_gene_features.py|1785812342.0|7049": {"hash": "53e915339107dd53762359b56062411548c8ec1e0dc86b425c8c2dd7f90236e7", "size": 7049, "status": "c"}, "conf/analysis/plot_4x4.py|1785812342.0|9478": {"hash": "75cf5a8c61627f4672951a30b69bf90d922925f1c6cd00c904e29760a1ff5daa", "size": 9478, "status": "c"}, "conf/analysis/utils/__init__.py|1785812342.0|0": {"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "size": 0, "status": "c"}, "conf/analysis/utils/__pycache__/__init__.cpython-310.pyc|1785812342.0|145": {"hash": "a46fd1df886d31f79c188336ec4ed8a7484a2fc4d1410171b359e6149ede0c0b", "size": 145, "status": "c"}, "conf/analysis/utils/__pycache__/framepool.cpython-310.pyc|1785812342.0|7084": {"hash": "ed32c250436b1b3db2bff16070ac26de9059353614a57c7f1e488ac93b0f576e", "size": 7084, "status": "c"}, "conf/analysis/utils/__pycache__/util.cpython-310.pyc|1785812342.0|9768": {"hash": "9ee08d5991f8a7c72f17734469456102346b92c8281638dfa95ec1ca60670dea", "size": 9768, "status": "c"}, "conf/analysis/utils/framepool.py|1785812342.0|8331": {"hash": "aad684f464a89f7635508128d4668d904b13a13649216a5fc84795e06426a1da", "size": 8331, "status": "c"}, "conf/analysis/uorfs.ipynb|1785812342.0|3687955": {"hash": "7b040ed01035197775cb95670809ddff21509a0ba7ef19746fe89135f8691715", "size": 3687955, "status": "c"}, "conf/analysis/violin.py|1785812342.0|17788": {"hash": "57d2f09f6001a9c2c9e6b55bfad2cc3a37219d8c8c1bc3a8bf6b96ab3f19fcfa", "size": 17788, "status": "c"}, "conf/analysis/utils/util.py|1785812342.0|9205": {"hash": "c05cda0aec8dea02e896e0a1fcd98d12a99f563e8d03ba7d477e107054019417", "size": 9205, "status": "c"}, "conf/analysis/violin_dists.py|1785812342.0|13926": {"hash": "c75a950fe8bf675c6572dd64cf0b8df4178bf6ebd903b84f3eadde39f3f6d70d", "size": 13926, "status": "c"}, "conf/config.json|1788143599.0|632": {"hash": "ee1b6a125b323661e42fff8e353f80dd2cd22dcfcf28a488777d1b076dcf9b4b", "size": 632, "status": "c"}, "conf/data/motifs.csv|1785812342.0|5168": {"hash": "36d4dc48bd23ae7b09ef64800520a41eb19d7da46d67cb79a40cc16877c37daa", "size": 5168, "status": "c"}, "conf/environment.yml|1785812343.0|6179": {"hash": "db4d949b1705473bb932c6018e2a673fdf4626b5a3d045ba44839447888d861f", "size": 6179, "status": "c"}, "conf/img/pipeline.png|1785812343.0|924991": {"hash": "a847cfb671458a0617b45e2ddc8f5dda98d36591b073e6be23565a59403f82d9", "size": 924991, "status": "c"}, "conf/notebooks/exp_optimization_multiple.ipynb|1785812343.0|51207": {"hash": "cd6b69cb7765947568ece0f472d856d6fb9c688add7375d92a48a986f4684765", "size": 51207, "status": "c"}, "conf/notebooks/exp_optimization_single.ipynb|1785812343.0|39483": {"hash": "dc2622c95bc51788dfc2e76868579d1ef70937238ca281b42bc883ad8c6add1a", "size": 39483, "status": "c"}, "conf/notebooks/optimize_te_mrl.ipynb|1785812343.0|17150": {"hash": "20b5cc301e4c1ebd167c4d7381439d2318e179e949cfa3b1e334b9e8972ed067", "size": 17150, "status": "c"}, "configuration.json|1788143598.0|482": {"hash": "1c5438191a7b51dfe185771a7423e21d09df28a67a1f26aa1b5995127296b6a7", "size": 482, "status": "c"}, "model/__init__.py|1788143379.0|179": {"hash": "0cf355f618d214afd39d9f2d1c275107ff2e25dd0b075b8da0d0a1c20d3bbf24", "size": 179, "status": "c"}, "model/src/__init__.py|1785812343.0|0": {"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "size": 0, "status": "c"}, "model/src/__pycache__/__init__.cpython-311.pyc|1785814526.0|160": {"hash": "4609a86785ab27f3f8d417df94410310d89a425866cf1847b707bfe7629eac6e", "size": 160, "status": "c"}, "model/src/exp_optimization/__init__.py|1785812343.0|0": {"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "size": 0, "status": "c"}, "model/src/exp_optimization/exp_joint.py|1785812343.0|17626": {"hash": "aa6995bad98d83b571a5bb413d975aea9447e27b400b90d4685ff42a19932429", "size": 17626, "status": "c"}, "model/src/exp_optimization/framepool.py|1785812343.0|9241": {"hash": "d4d8984f673f73b6d2a9a2ed3433317964c92f2b3cdc41155fc78bdb641e9abc", "size": 9241, "status": "c"}, "model/src/exp_optimization/genes/IFNG.txt|1785812343.0|10629": {"hash": "25fb3c1c368930af52a01be77359ea42a372aaacca10ef4d082e04e3f6b9b9f9", "size": 10629, "status": "c"}, "model/src/exp_optimization/genes/TLR6.txt|1785812343.0|10629": {"hash": "08ba1ba4365a692f56c8126b26ec156aa6edcc4fc81b37277744f2c74fb8efea", "size": 10629, "status": "c"}, "model/src/exp_optimization/genes/TNF.txt|1785812343.0|10629": {"hash": "c3008c428732c12e979a62d6b617ec381859ecb62abdd50c3005759fb9778e42", "size": 10629, "status": "c"}, "model/src/exp_optimization/genes/TP53.txt|1785812343.0|10629": {"hash": "5fa0f2352cd8ee14e33ac1c69a1b81c00d5863a5e6b11ba142645d5e79d0fe1f", "size": 10629, "status": "c"}, "model/src/exp_optimization/joint_opt.py|1785812343.0|32386": {"hash": "525d1f9b4b50e28f354ae390309b3f94df06d89a738c13a178669a71a109e674", "size": 32386, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_intercept/3M/no_covar.ini|1785812343.0|889": {"hash": "f27c2fb7f0f97d3812a92f02a28a3d95ffa50b0e1338daefff81ec0ce5f3f0ab", "size": 889, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_intercept/H2K/H.ini|1785812343.0|1105": {"hash": "fb210f1f75f0e963c84599eb016005e3cc48383bc7c498f35083d54743dd01d0", "size": 1105, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_intercept/2M2K/HnV.ini|1785812343.0|1130": {"hash": "d686924aff9ad4a586c1ed16fccd1ff6cd34544e1f685c0eeeeb27fb50d2b781", "size": 1130, "status": "c"}, "conf/data/utrdb2.csv|1785812343.0|20420229": {"hash": "f2ac8227b6084f0164d75a3f1dde738daa93199a156dc60601a53e7204360120", "size": 20420229, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_intercept/karollus_RPs/pad0_16covar.ini|1785812343.0|1162": {"hash": "63512245792f95c58da8f7bd633f28f5acebfba49fce12c95f48ff062684e774", "size": 1162, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/2M2K/HnV.ini|1785812343.0|943": {"hash": "fd6ed0256afd110ca32824c46b488a515de25bddf2f60a709d49f112b61d323b", "size": 943, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/3M/debug_covar.ini|1785812343.0|902": {"hash": "8e1f791063eac6780a993dbe86fda402b3a555e36a8a5c03dab58c90c855b897", "size": 902, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/3M/regress_scaled_MFE.ini|1785812343.0|911": {"hash": "c66f84b981410f30127f740af4b8cf43bfdded301f949820af2e9dc5f768b9d1", "size": 911, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/3M2K/debug_multiask.ini|1785812343.0|967": {"hash": "d8ff73042a0346371fbb4d07f900f35fa06a7ee7188b4e2b48feb4b519e1c058", "size": 967, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/3M/no_covar.ini|1785812343.0|889": {"hash": "778bd8575217cbb6a9a3325ee0811965c15b63a273f98b974750f88714e563f7", "size": 889, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/karollus_RPs/len106_t32_16covar.ini|1785812343.0|1102": {"hash": "30f70af9d7dabf926075b44b73be52919662a754a6114af8ba8ec157b192426c", "size": 1102, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/karollus_RPs/len105_t80_16covar.ini|1785812343.0|1105": {"hash": "7c71e55d66ee65e0faa5034712d720927676b59683b79efa880daabf363aefca", "size": 1105, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/karollus_RPs/len106_t32_18covar.ini|1785812343.0|1095": {"hash": "f5ff0818933d58f580513b96e570f883f398d7f938f8adf0867c442bf90060c0", "size": 1095, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/karollus_RPs/rp_cycle.ini|1785812343.0|1086": {"hash": "c2a518ee99523c0737ab576ba00c66fb74baddaa988e8e33a74817543d0fad43", "size": 1086, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/karollus_RPs/len106_t80_16covar.ini|1785812343.0|1102": {"hash": "9cc46bfa007b8d9ec9ae27e851b02a6e3f3e6f09487ce6770a2114796df83e6f", "size": 1102, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/karollus_RPs/rp_cycle_smaller_tower.ini|1785812343.0|1133": {"hash": "53e00f8be8c7c6af15a59e375b1039526b9662fda33720aa8acfa2a6f6f0eab9", "size": 1133, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_covar_reg/karollus_RPs/rp_cycle_static.ini|1785812343.0|1083": {"hash": "416c5993b4c970643c0bc26a7dc7ab0a1712144b8dd187065ff84b48977d82b9", "size": 1083, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru/RL_gru_GSE104252/MDL_transfer_kfold/fixed_transfer.ini|1785812343.0|932": {"hash": "1591ab7846af4b43158d91083971913658bd3f70fd94b958e2df1082914990a4", "size": 932, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru/ds4rl_human_reset/schdule_cv.ini|1785812343.0|733": {"hash": "6ee0ddb7ce3769dc57688179990386c632dfb069a7d67e9e76933093612ae50b", "size": 733, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru/ds4rl_unmod1_new/schdule_cv.ini|1785812343.0|732": {"hash": "c05d0d338318ac32ed345d3c476e19279a8b0f076425f98842e13e62ae715bd1", "size": 732, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru/ds4rl_vleng_new/schdule_cv.ini|1785812343.0|740": {"hash": "4ef54d783a68ce3efc298ee86e1a973e7e900d5f153a1828cb9ffb19ca97bf0d", "size": 740, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru/mixing_task_kfold/mix_strid1113.ini|1785812343.0|749": {"hash": "c0d32c00cbef978eb715f6ec2d8d1e0c31db8c406b80af4f6cab3229ad6870e5", "size": 749, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru/mixing_task_kfold/schedual_lr.ini|1785812343.0|748": {"hash": "ef76899180433164da88cfd46b23d29f6b249a61863a078cd96af079bc9e9181", "size": 748, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru_yeast/pretrained.ini|1785812343.0|950": {"hash": "71dfdcda207e7acf943c2fe576d4036a3a2835f5079de34fd1b13d44129d12ec", "size": 950, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru_yeast/inherit_pretrained.ini|1785812343.0|931": {"hash": "28b5d268efd5e4c873ae2b3f80af952f96fe6854329adb3ec4ccefd36344800d", "size": 931, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_gru_yeast/scratch.ini|1785812343.0|872": {"hash": "1d4a68729c73e675213162783d8505543d45755df96d63456189df63c89faede", "size": 872, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/2M2R/w5.ini|1785812343.0|924": {"hash": "d240fae3fd680b67bd656b1248890abf5dee0a8637450338d7caf63bed34f389", "size": 924, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/2M2R/A_P_H_V.ini|1785812343.0|949": {"hash": "478a548bbe47f37c83171d00f9c0927252a7abafed96c6b5ad0f003a2cbe750d", "size": 949, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/2M3R/HV_3R_w1.ini|1785812343.0|964": {"hash": "c5cbbc970df7f2e0ea575834ee634ea497d5802221174a6ba8480e54c47768f1", "size": 964, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/2sM2R/2Sub2cell_weightpc3.ini|1785812343.0|982": {"hash": "f910208d6720d13f26a4e6e9b221dbcd289cd6e973a44a0a03b67a5bb183208b", "size": 982, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3M/schedule_lr.ini|1785812343.0|890": {"hash": "771ebb60fc63ae4219e7399052985a9b940837a2d0a564372c3d1387d458013f", "size": 890, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3M/small_repective_filed.ini|1785812343.0|909": {"hash": "e82a9128f79d1bf9a4d661e60a2588a6b48b77ea303989d743e57e7cedc35a75", "size": 909, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3M/small_repective_filed_strides1111.ini|1785812343.0|913": {"hash": "1ce3c9985cc7d6e5df8fd0e600d4926e6ecb4e70b570eb5b7192d93bf2ebdd1f", "size": 913, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3M/small_repective_filed_strides1113.ini|1785812343.0|914": {"hash": "5ae6e0b38edc418a88d558ba5fae54e443d1a8704f8d1087335dcae3a83399d3", "size": 914, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3M1R/Andrev_3M_w0.ini|1785812343.0|974": {"hash": "5f6da81e509a32e03817f7db1a62a06d0bab4a9174db03df5fbcc62a667f729f", "size": 974, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3M3R/PoolingAll.ini|1785812344.0|994": {"hash": "01a26833c5deb5b12b72496fd1e20729ab0d6eb8fe7dae171b560635dfdcdcd8", "size": 994, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3M2R/AP_3M_w0.ini|1785812343.0|980": {"hash": "d85813b32bc820ddae9bd5e9a323ed9381dfde27e63ddcdab32c82c385b0f078", "size": 980, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3R/schedule_MTL.ini|1785812344.0|905": {"hash": "1c9ae556beb90ab81f16a6d8379a14937fb30b829162bab8f77c263a27826204", "size": 905, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/M1SM3R/sV_H_3R_w0.ini|1785812344.0|978": {"hash": "f8359ba393c1280f65d3507209d7d377d36be22d8813a52c8ac38d41a097b7df", "size": 978, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3R/testing.ini|1785812344.0|871": {"hash": "16f14364de93a3a5537173f88d8d40b30589107c5a6c531ba74666dfb1bf1cc8", "size": 871, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/3R/transfer_from_3M.ini|1785812344.0|938": {"hash": "3eb4dc084526679c756005f786cee613c9c98fd2f7fb5a7710e9ed5198ce9769", "size": 938, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/M3R/Human_3R_w0.ini|1785812344.0|948": {"hash": "6c3d40e42e394f6a027607b8b867eb6b17bedda10290ad6fc1532cdb4e5d7d21", "size": 948, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/single_task/RP_single_task/ST_293T.ini|1785812344.0|860": {"hash": "6ddd5c586c679fe4a0053b9680448317df619eac7dcf9eb4cb366601a615b9c5", "size": 860, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/sM3R/SubHuman_3C_1.ini|1785812344.0|956": {"hash": "cc632dd297118b61168cdf563d1dde33a36fa81e711495fd3e564da445b923bb", "size": 956, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/single_task/RP_single_task/ST_PC3.ini|1785812344.0|855": {"hash": "c8b88a24d0107b2c26ad8f2fb9fe6a0ef92a5c417f04417e40743d6bac4b1b85", "size": 855, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/single_task/RP_single_task/ST_muscle.ini|1785812344.0|861": {"hash": "ab271e07233ea5f8d829f425b13b4e85fbdb1cc86f3f48a9bfb8c5484b4d699e", "size": 861, "status": "c"}, "model/src/exp_optimization/log/Backbone/RL_hard_share/single_task/counterpart_for_transfer/Singletask_unmod1_pretrain.ini|1785812344.0|776": {"hash": "5a7262d2d69629c7834bffad22152a3cded70866ebddd0b4afc700c7dbc22ae2", "size": 776, "status": "c"}, "model/src/exp_optimization/log/GP_net/Frame_GP/3mFP_debug.ini|1785812344.0|906": {"hash": "337c5ec095eda121ff592e72edab1d69bcff765d8ab85bc741b37aa88ab4bff0", "size": 906, "status": "c"}, "model/src/exp_optimization/log/GP_net/Frame_GP/3mFP_3lyer_k7_s1113.ini|1785812344.0|905": {"hash": "91e7f497f7bc5748c75c57c9d1a672f1cef87705ce3c075f288f4416f1c68bac", "size": 905, "status": "c"}, "model/src/exp_optimization/log/GP_net/Frame_GP/3mFP_strides_1111.ini|1785812344.0|924": {"hash": "9bac4b405222c10032664d58a932b7032a8ef7a54e6d4e8766f6609bf089efae", "size": 924, "status": "c"}, "model/src/exp_optimization/log/GP_net/Frame_GP/3mFP_strides_1113.ini|1785812344.0|917": {"hash": "ee901b89a808b74ac8448638432f88e35854e1585a2c4cec6a207aeffebbc13a", "size": 917, "status": "c"}, "model/src/exp_optimization/log/GP_net/GP_net/3M/3mGP_avgpool.ini|1785812344.0|905": {"hash": "67af4d2eecbf9174e94123e24ee94b1ea0e47024aa41135374a50fbf9ce5c1c1", "size": 905, "status": "c"}, "model/src/exp_optimization/log/GP_net/GP_net/3M/3mGP_debug.ini|1785812344.0|893": {"hash": "9813d840154045b0bcf10a3bed1fb416ae91cd756ed74db8139525c6f6537e32", "size": 893, "status": "c"}, "model/src/exp_optimization/log/GP_net/GP_net/MPA_U_GP_avgpool.ini|1785812344.0|894": {"hash": "63c42ccd5bacf789715ac24c566cbd92b8da5af31c3b4203d15de362b27da751", "size": 894, "status": "c"}, "model/src/exp_optimization/log/GP_net/GP_net/new_GP_by_amax.ini|1785812344.0|896": {"hash": "0cb222df6d95dd36f7e3327c76b03a4a27e5ccf3524f285093daa8fd76e3bf73", "size": 896, "status": "c"}, "model/src/exp_optimization/log/GP_net/RL_Atten/3M/debug_RL_atten.ini|1785812344.0|804": {"hash": "2139d7fb58b91d6526698b853bc331ee79189e883f5d255355a50eb16d69839f", "size": 804, "status": "c"}, "model/src/exp_optimization/log/GP_net/RL_Atten/debug_RL_atten.ini|1785812344.0|861": {"hash": "0676ace9d77434b7ac051aa83009b9de75e6dbf97cfeeda2f88e006065ab62b8", "size": 861, "status": "c"}, "model/src/exp_optimization/log/Koo_net/Conf_CNN/k8_5_P20_5_100bp/MPA_H.ini|1785812344.0|729": {"hash": "ec5a27a98ecf873c1c619d67beef61804b5ee0883b25df0dd2cc69df8c847214", "size": 729, "status": "c"}, "model/src/exp_optimization/log/Koo_net/Conf_CNN/k8_5_P20_5_100bp/MPA_U.ini|1785812344.0|736": {"hash": "7ed91ffbd3f952145a2c83fac80ac5ad99e107f00760123ac3f9532c5c8489a4", "size": 736, "status": "c"}, "model/src/exp_optimization/log/Koo_net/Conf_CNN/k8_5_P20_5_100bp/MPA_V.ini|1785812344.0|730": {"hash": "fcff38188b4b3aca2b669afb63d2d9616242e9243a232928373f6c6cba97f3d8", "size": 730, "status": "c"}, "model/src/exp_optimization/machine_configure.json|1785812344.0|299": {"hash": "99dbd34183448c875cc405f0f7ef08847277d26bc2830b21b44c445c9193ecbb", "size": 299, "status": "c"}, "model/src/exp_optimization/models/Backbone.py|1785812344.0|24256": {"hash": "26361269a592e79385e1b983d9cda8c86df40498287ac247fa2aa583980e27ce", "size": 24256, "status": "c"}, "model/src/exp_optimization/models/Modules/Backbone.py|1785812344.0|24215": {"hash": "34ca5d63674925275b0be437769c6752b3f10eb4104db58b49dbd21302bafb0b", "size": 24215, "status": "c"}, "model/src/exp_optimization/models/Baseline_models.py|1785812344.0|5894": {"hash": "04d9e1ca30c611ecd2f3fac28b632e311da52407e89dad5ff287a77b3ff8478c", "size": 5894, "status": "c"}, "model/src/exp_optimization/models/Modules/GP_net.py|1785812344.0|5938": {"hash": "1656bb4751ac801b9e53cd79d7bb25b3739a0bedae024416a80055802089dee8", "size": 5938, "status": "c"}, "model/src/exp_optimization/models/Modules/Koo_net.py|1785812344.0|3645": {"hash": "3da19054769f18b5fe8e6d0113bd839dc1d8d880c8b7b5bb8c68fe27026d8b92", "size": 3645, "status": "c"}, "model/src/exp_optimization/models/Modules/__init__.py|1785812344.0|127": {"hash": "da5d63fc32d960ecaf6ccd69fcbecb22502b9cee327eddd43c5e35120dd74024", "size": 127, "status": "c"}, "model/src/exp_optimization/models/Modules/_operator.py|1785812344.0|8656": {"hash": "c6aeff3b6ff52d6bbfc2c971ae52aff12f741b997189dcafb75c04b751cd9287", "size": 8656, "status": "c"}, "model/src/exp_optimization/models/ScheduleOptimizer.py|1785812344.0|3395": {"hash": "7f5c6fa27cd0e8613d0effb52e54b07b6090ec430c13d117bf76f232016e899b", "size": 3395, "status": "c"}, "model/src/exp_optimization/models/Modules/nonDeep.py|1785812344.0|1847": {"hash": "46c3915a71b3cc47ee6a70e663fb0b695a113c847a541f0a2849c406a3326126", "size": 1847, "status": "c"}, "model/src/exp_optimization/models/Self_attention.py|1785812344.0|3521": {"hash": "087eda250e992c721272d40504e294ccd12387b94f762581f1df96ffa141d3cc", "size": 3521, "status": "c"}, "model/src/exp_optimization/models/__init__.py|1785812344.0|0": {"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "size": 0, "status": "c"}, "model/src/exp_optimization/models/bucket_sampler.py|1785812344.0|3847": {"hash": "72b4eda6c5f0c0099a59462ba38aff2faa0e7a60039944682f1e70ed8f537aae", "size": 3847, "status": "c"}, "model/src/exp_optimization/models/log_and_save.py|1785812344.0|11187": {"hash": "a1afb14f476ae0d6415114700320aa5fb370712fcaaf2dafcff0ce0200ca8193", "size": 11187, "status": "c"}, "model/src/exp_optimization/models/loss.py|1785812344.0|3106": {"hash": "76a1243aa85c3c11aaaf7b5173fd31608bc97ffa0875143831c967f344540c32", "size": 3106, "status": "c"}, "model/src/exp_optimization/models/max_activation_patch.py|1785812344.0|29460": {"hash": "39bce5ecbef128ce2227b1d6735f95c7f1b422cba5cc9945c1d479f3f9dce171", "size": 29460, "status": "c"}, "model/src/exp_optimization/models/popen.py|1785812344.0|6159": {"hash": "175a3ab21264424a7db553c75bc0e564f778b76359b75989f8c1c029bff5371b", "size": 6159, "status": "c"}, "model/src/exp_optimization/models/reader.py|1785812344.0|18222": {"hash": "594d03b8643a7e8b2b0ffea4578097c249be8b2d550557c34f54239539429c7b", "size": 18222, "status": "c"}, "model/src/exp_optimization/multiple-genes-nb.ipynb|1785812344.0|66554": {"hash": "a6590f5e61812157196341cc99cc3662935796333d84eae7dbcaaa41d81723f0", "size": 66554, "status": "c"}, "model/src/exp_optimization/models/train_val.py|1785812344.0|12343": {"hash": "1ba2becae3e316242405244234f0a6ed0ac13f542fedb9ff832cbf6dff979f31", "size": 12343, "status": "c"}, "model/src/exp_optimization/multiple-genes-nb.py|1785812344.0|47186": {"hash": "2b7753e9ea755c50477d42731fa356990d4da43ac4a71921cc6bb3bddba49ab4", "size": 47186, "status": "c"}, "model/src/exp_optimization/outputs/mul_best_exps.txt|1785812344.0|161": {"hash": "3128d5d25d9fef75f2b04b6fc2399754c8ad25eb2b991b6f066c1f0c42930c6c", "size": 161, "status": "c"}, "model/src/exp_optimization/outputs/mul_best_seqs.txt|1785812344.0|80628": {"hash": "9109c40a351bb3de6ee573617a4c6961606292eaf841cce109ede503eb6a6d20", "size": 80628, "status": "c"}, "model/src/exp_optimization/outputs/mul_init_exps.txt|1785812344.0|2045": {"hash": "b729df5c6da1abb27e7344c4b1a58f64b2c72d44fc9baa3125e2a84318b830ad", "size": 2045, "status": "c"}, "model/src/exp_optimization/outputs/mul_init_seqs.txt|1785812344.0|9455": {"hash": "2314aedd9d1dcbaa14a2d03ab6e5db22a8a82757ac272355064d72124d3d84b8", "size": 9455, "status": "c"}, "model/src/exp_optimization/outputs/mul_opt_exps.txt|1785812344.0|2038": {"hash": "9036ad3581183577437459b46e07b7ce1c6578d9ec24cddcf8ecf02234f3c4f3", "size": 2038, "status": "c"}, "model/src/exp_optimization/popen.py|1785812344.0|13070": {"hash": "efd8993615ec19c380aee1e16df96642ab50110f103853f2d8f048dc664d482c", "size": 13070, "status": "c"}, "model/src/exp_optimization/script/PATH.py|1785812344.0|93": {"hash": "9d6a1a07d2e9562b9d864c0dd2eb74dfbef79b7e3c6c3c0e880122ae74b742f2", "size": 93, "status": "c"}, "model/src/exp_optimization/script/Nupack_MFE_prediction.py|1785812344.0|1435": {"hash": "b654974e0cb9a759d888ad1e61af6d9d6e6f9d8a5f4da39fde0498147cb550c4", "size": 1435, "status": "c"}, "model/src/exp_optimization/script/covar_test.py|1785812345.0|8631": {"hash": "0f5bcf753930dfe3c7abee7c6e007b2b0f37fd3482625c518a5bc84ab8a33ac2", "size": 8631, "status": "c"}, "model/src/exp_optimization/script/data_prepocessing.sh|1785812345.0|58": {"hash": "f388c9bcd350f9d7c527da48bae8f17a74257165c9d821d7d66dd9cfdda26b3a", "size": 58, "status": "c"}, "model/src/exp_optimization/script/detect_changepoint_featmap.py|1785812345.0|5655": {"hash": "0a951a6137d797a86eebd86281d1f299ca2a1c010523fc6ce7b26fefd60efd0f", "size": 5655, "status": "c"}, "model/src/exp_optimization/script/covar_train.py|1785812345.0|10359": {"hash": "f3fddf6ecc1e4e2da73eace36c2c0cf03bd713dac0bc3ee269398090fe2f3b54", "size": 10359, "status": "c"}, "model/src/exp_optimization/script/download_training_data.sh|1785812345.0|1623": {"hash": "4eb1acbaf25448f1c3408cf083fd918a765ea104886eb1213d7b6fc50991c711", "size": 1623, "status": "c"}, "model/src/exp_optimization/script/evaluate_channel_effect.py|1785812345.0|4396": {"hash": "5aad174d6ba918b666ddbcf764d5648f52d469803009f7cf26632f6c3531ed0f", "size": 4396, "status": "c"}, "model/src/exp_optimization/script/fix_test_for_RP.py|1785812345.0|1041": {"hash": "1ab2ec5b2a0d2ad80bbd5de158fe7b5dd23b4cad1180a6a590300d72e97b7de1", "size": 1041, "status": "c"}, "model/src/exp_optimization/script/generate_config_js.sh|1785812345.0|458": {"hash": "e894798538e96498138e1d7075c3737dcce04fcc7b769956e4027391ecc73c9e", "size": 458, "status": "c"}, "model/src/exp_optimization/script/iter_test.py|1785812345.0|9406": {"hash": "d1d2020b8e97ff5afe71e442d277a1a3c217dd36b1f51321f52424f15899e65d", "size": 9406, "status": "c"}, "model/src/exp_optimization/script/iter_train.py|1785812345.0|10890": {"hash": "6edf665180733df3506769c3324bf546e40ba6899403e9b0cdbc4441cfa12832", "size": 10890, "status": "c"}, "model/src/exp_optimization/script/main_train.py|1785812345.0|8478": {"hash": "494b6ce452bd442473fafe011e747617d73dc79a66ef184e18152e33a7e23797", "size": 8478, "status": "c"}, "model/src/exp_optimization/script/preprocessing_MPA.py|1785812345.0|3741": {"hash": "59cc75121fb019b8320db9f81674e6409a4a45f62628a9f922fb30f698c67283", "size": 3741, "status": "c"}, "model/src/exp_optimization/script/preprocessing_RP.py|1785812345.0|2286": {"hash": "e42bd567619611b570284c17f4e37ebf79eefeee9f52e2a3bd965f4c3f6248a2", "size": 2286, "status": "c"}, "model/src/exp_optimization/script/train_kmer_classifer.py|1785812345.0|8449": {"hash": "bda2913a029bfb3d90a331d635897292c64f0db07a7ce4a602825876e6a0bd07", "size": 8449, "status": "c"}, "model/src/exp_optimization/script/run-TF-modisco.py|1785812345.0|3498": {"hash": "d49a84e7e51d431ebad3d0bc23459f15e9621ce0e0e13b0b0faa3b493b27747f", "size": 3498, "status": "c"}, "model/src/exp_optimization/script/train_kmer_models.py|1785812345.0|5595": {"hash": "3fd3998d2beaa4572830ad337324a7483806f32553891b36757f4b8c27ac60b3", "size": 5595, "status": "c"}, "model/src/exp_optimization/script/train_oneLayer_CNN.py|1785812345.0|3771": {"hash": "3bcbfb6a9ded0280ba916fab6d7c376c1acb02481720c992e4cb621afbae913c", "size": 3771, "status": "c"}, "model/src/exp_optimization/single-gene-nb.ipynb|1785812345.0|37851": {"hash": "bcdc117cea2afdbad8f486568acffc6935a4d9df5b8423b27a057cd0398d3df4", "size": 37851, "status": "c"}, "model/src/exp_optimization/single-gene-nb.py|1785812345.0|28824": {"hash": "0041c9efeea53a90c0ec7f54c5b6d5a28761ba2290aac5baf60f42d0fc6d473f", "size": 28824, "status": "c"}, "model/src/gan/__init__.py|1785812345.0|0": {"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "size": 0, "status": "c"}, "model/src/exp_optimization/util.py|1785812345.0|9246": {"hash": "9fd25d8a66e0c47dcccb77abd8ac8f0714f564fd6cc5c702ea70e69059c730d8", "size": 9246, "status": "c"}, "model/src/exp_optimization/utils.py|1785812345.0|6848": {"hash": "cba0cb4c05860cd8b20e3f87dde740508d7da3e16c08270067c3756b3a51e00d", "size": 6848, "status": "c"}, "model/src/gan/lib/__init__.py|1785812345.0|0": {"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "size": 0, "status": "c"}, "model/src/gan/__pycache__/__init__.cpython-311.pyc|1785832408.0|164": {"hash": "0bd42161be264e5f8f7c8ab8bb3eafe1625c18cfe6e1ec7e407e7aa4149c6ae6", "size": 164, "status": "c"}, "model/src/gan/lib/__pycache__/dna.cpython-311.pyc|1785832850.0|6993": {"hash": "b3078f98afb5084c35c3aae9573d4aaf0472f5e7948d2e2dc2a199f9e726dd3a", "size": 6993, "status": "c"}, "model/src/gan/lib/__pycache__/__init__.cpython-311.pyc|1785832408.0|168": {"hash": "46b5b43c2624b58b468656462a3ac5040149647da2d754f71cc0574ed901bcca", "size": 168, "status": "c"}, "model/src/gan/lib/__pycache__/models.cpython-311.pyc|1785832408.0|5231": {"hash": "6deb3c096d8b593f03b23f85b4a8e23cd7f3853e8565bb5c589ac31baa15370d", "size": 5231, "status": "c"}, "model/src/gan/lib/__pycache__/utils.cpython-311.pyc|1785832849.0|11425": {"hash": "50dfd1873118c7a595e9cd11b7876d8dfa324532baaa7e91da60f47f7963e9ad", "size": 11425, "status": "c"}, "model/src/gan/lib/dna.py|1785812345.0|3189": {"hash": "eea39b2c6e63ec577ea214bfdbd16ce914384886f4585d4e131595b7387357c3", "size": 3189, "status": "c"}, "model/src/gan/lib/models.py|1785812345.0|3007": {"hash": "d4fb1d91ea2e777e58c4138b0364f571e63205441a496ced890223c2062375e4", "size": 3007, "status": "c"}, "model/src/gan/lib/read.py|1785812345.0|1980": {"hash": "397e4eeee22aca36090aeed80559b937ce6f0b6950433f3a8a79d9421aa87f1a", "size": 1980, "status": "c"}, "model/src/mrl_te_optimization/__init__.py|1785812345.0|0": {"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "size": 0, "status": "c"}, "model/src/gan/lib/utils.py|1785812345.0|5138": {"hash": "6b54f502d7e0d66a89193a8c3836d8be90d685911b5f1e1a69f14c8e183af4e0", "size": 5138, "status": "c"}, "model/src/gan/wgan.py|1785812345.0|12378": {"hash": "523db5e670c474c58654f723086a6d604ddd8535388607ac3622488fa3aeb974", "size": 12378, "status": "c"}, "model/src/mrl_te_optimization/__pycache__/__init__.cpython-311.pyc|1785814526.0|180": {"hash": "db1a9a3ed5ab889c2b9954582bfaff6a57d4fdd75e8d4b354797d6c47e121db4", "size": 180, "status": "c"}, "model/src/mrl_te_optimization/__pycache__/framepool.cpython-311.pyc|1785814526.0|12547": {"hash": "ea6a3a7a54c32712bd4e62b767a8d5ac3a5b1d9f0166c11d2e44d34a6f335e74", "size": 12547, "status": "c"}, "model/src/mrl_te_optimization/__pycache__/util.cpython-311.pyc|1785833426.0|19506": {"hash": "5a1528761d4b73f3d3497b4e3dfd3a83f3ccd4a333ffad491c1f7cfaaeabbf8a", "size": 19506, "status": "c"}, "model/src/mrl_te_optimization/framepool.py|1785812345.0|9200": {"hash": "971d7588bb95752cb1df816892d9e25de6633db1b83e133b31afce4e8aab03c0", "size": 9200, "status": "c"}, "model/src/mrl_te_optimization/lib/__init__.py|1785812345.0|0": {"hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", "size": 0, "status": "c"}, "model/src/mrl_te_optimization/lib/dna.py|1785812345.0|3189": {"hash": "eea39b2c6e63ec577ea214bfdbd16ce914384886f4585d4e131595b7387357c3", "size": 3189, "status": "c"}, "model/src/mrl_te_optimization/lib/utils.py|1785812345.0|5140": {"hash": "b62ca9d6133dc72fb5c8c3c5427342d92ad5f8ec07b185f430762d718dde088c", "size": 5140, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_intercept/2M2K/HnV.ini|1785812345.0|1130": {"hash": "d686924aff9ad4a586c1ed16fccd1ff6cd34544e1f685c0eeeeb27fb50d2b781", "size": 1130, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_intercept/3M/no_covar.ini|1785812345.0|889": {"hash": "f27c2fb7f0f97d3812a92f02a28a3d95ffa50b0e1338daefff81ec0ce5f3f0ab", "size": 889, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_intercept/H2K/H.ini|1785812345.0|1105": {"hash": "fb210f1f75f0e963c84599eb016005e3cc48383bc7c498f35083d54743dd01d0", "size": 1105, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_intercept/karollus_RPs/pad0_16covar.ini|1785812345.0|1162": {"hash": "63512245792f95c58da8f7bd633f28f5acebfba49fce12c95f48ff062684e774", "size": 1162, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/2M2K/HnV.ini|1785812345.0|943": {"hash": "fd6ed0256afd110ca32824c46b488a515de25bddf2f60a709d49f112b61d323b", "size": 943, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/3M/debug_covar.ini|1785812345.0|902": {"hash": "8e1f791063eac6780a993dbe86fda402b3a555e36a8a5c03dab58c90c855b897", "size": 902, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/3M/no_covar.ini|1785812345.0|889": {"hash": "778bd8575217cbb6a9a3325ee0811965c15b63a273f98b974750f88714e563f7", "size": 889, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/3M/regress_scaled_MFE.ini|1785812345.0|911": {"hash": "c66f84b981410f30127f740af4b8cf43bfdded301f949820af2e9dc5f768b9d1", "size": 911, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/3M2K/debug_multiask.ini|1785812345.0|967": {"hash": "d8ff73042a0346371fbb4d07f900f35fa06a7ee7188b4e2b48feb4b519e1c058", "size": 967, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/karollus_RPs/len105_t80_16covar.ini|1785812345.0|1105": {"hash": "7c71e55d66ee65e0faa5034712d720927676b59683b79efa880daabf363aefca", "size": 1105, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/karollus_RPs/len106_t32_16covar.ini|1785812345.0|1102": {"hash": "30f70af9d7dabf926075b44b73be52919662a754a6114af8ba8ec157b192426c", "size": 1102, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/karollus_RPs/len106_t32_18covar.ini|1785812345.0|1095": {"hash": "f5ff0818933d58f580513b96e570f883f398d7f938f8adf0867c442bf90060c0", "size": 1095, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/karollus_RPs/len106_t80_16covar.ini|1785812345.0|1102": {"hash": "9cc46bfa007b8d9ec9ae27e851b02a6e3f3e6f09487ce6770a2114796df83e6f", "size": 1102, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/karollus_RPs/rp_cycle.ini|1785812345.0|1086": {"hash": "c2a518ee99523c0737ab576ba00c66fb74baddaa988e8e33a74817543d0fad43", "size": 1086, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/karollus_RPs/rp_cycle_static.ini|1785812345.0|1083": {"hash": "416c5993b4c970643c0bc26a7dc7ab0a1712144b8dd187065ff84b48977d82b9", "size": 1083, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_covar_reg/karollus_RPs/rp_cycle_smaller_tower.ini|1785812345.0|1133": {"hash": "53e00f8be8c7c6af15a59e375b1039526b9662fda33720aa8acfa2a6f6f0eab9", "size": 1133, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru/RL_gru_GSE104252/MDL_transfer_kfold/fixed_transfer.ini|1785812345.0|932": {"hash": "1591ab7846af4b43158d91083971913658bd3f70fd94b958e2df1082914990a4", "size": 932, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru/ds4rl_human_reset/schdule_cv.ini|1785812345.0|733": {"hash": "6ee0ddb7ce3769dc57688179990386c632dfb069a7d67e9e76933093612ae50b", "size": 733, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru/ds4rl_unmod1_new/schdule_cv.ini|1785812345.0|732": {"hash": "c05d0d338318ac32ed345d3c476e19279a8b0f076425f98842e13e62ae715bd1", "size": 732, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru/ds4rl_vleng_new/schdule_cv.ini|1785812345.0|740": {"hash": "4ef54d783a68ce3efc298ee86e1a973e7e900d5f153a1828cb9ffb19ca97bf0d", "size": 740, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru_yeast/inherit_pretrained.ini|1785812345.0|931": {"hash": "28b5d268efd5e4c873ae2b3f80af952f96fe6854329adb3ec4ccefd36344800d", "size": 931, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru/mixing_task_kfold/schedual_lr.ini|1785812345.0|748": {"hash": "ef76899180433164da88cfd46b23d29f6b249a61863a078cd96af079bc9e9181", "size": 748, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru/mixing_task_kfold/mix_strid1113.ini|1785812345.0|749": {"hash": "c0d32c00cbef978eb715f6ec2d8d1e0c31db8c406b80af4f6cab3229ad6870e5", "size": 749, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/2M2R/A_P_H_V.ini|1785812345.0|949": {"hash": "478a548bbe47f37c83171d00f9c0927252a7abafed96c6b5ad0f003a2cbe750d", "size": 949, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru_yeast/scratch.ini|1785812345.0|872": {"hash": "1d4a68729c73e675213162783d8505543d45755df96d63456189df63c89faede", "size": 872, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_gru_yeast/pretrained.ini|1785812345.0|950": {"hash": "71dfdcda207e7acf943c2fe576d4036a3a2835f5079de34fd1b13d44129d12ec", "size": 950, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/2M2R/w5.ini|1785812345.0|924": {"hash": "d240fae3fd680b67bd656b1248890abf5dee0a8637450338d7caf63bed34f389", "size": 924, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/2M3R/HV_3R_w1.ini|1785812346.0|964": {"hash": "c5cbbc970df7f2e0ea575834ee634ea497d5802221174a6ba8480e54c47768f1", "size": 964, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/2sM2R/2Sub2cell_weightpc3.ini|1785812346.0|982": {"hash": "f910208d6720d13f26a4e6e9b221dbcd289cd6e973a44a0a03b67a5bb183208b", "size": 982, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3M/schedule_lr.ini|1785812346.0|890": {"hash": "771ebb60fc63ae4219e7399052985a9b940837a2d0a564372c3d1387d458013f", "size": 890, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3M/small_repective_filed.ini|1785812346.0|909": {"hash": "e82a9128f79d1bf9a4d661e60a2588a6b48b77ea303989d743e57e7cedc35a75", "size": 909, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3M/small_repective_filed_strides1111.ini|1785812346.0|913": {"hash": "1ce3c9985cc7d6e5df8fd0e600d4926e6ecb4e70b570eb5b7192d93bf2ebdd1f", "size": 913, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3M/small_repective_filed_strides1113.ini|1785812346.0|914": {"hash": "5ae6e0b38edc418a88d558ba5fae54e443d1a8704f8d1087335dcae3a83399d3", "size": 914, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3M2R/AP_3M_w0.ini|1785812346.0|980": {"hash": "d85813b32bc820ddae9bd5e9a323ed9381dfde27e63ddcdab32c82c385b0f078", "size": 980, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3M1R/Andrev_3M_w0.ini|1785812346.0|974": {"hash": "5f6da81e509a32e03817f7db1a62a06d0bab4a9174db03df5fbcc62a667f729f", "size": 974, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3M3R/PoolingAll.ini|1785812346.0|1014": {"hash": "102b9f2c44c0fa7f9551b6bcecff400ffa63713b38e860be196cd7521d0f0f4e", "size": 1014, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3R/schedule_MTL.ini|1785812346.0|905": {"hash": "1c9ae556beb90ab81f16a6d8379a14937fb30b829162bab8f77c263a27826204", "size": 905, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3R/testing.ini|1785812346.0|871": {"hash": "16f14364de93a3a5537173f88d8d40b30589107c5a6c531ba74666dfb1bf1cc8", "size": 871, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/3R/transfer_from_3M.ini|1785812346.0|938": {"hash": "3eb4dc084526679c756005f786cee613c9c98fd2f7fb5a7710e9ed5198ce9769", "size": 938, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/M1SM3R/sV_H_3R_w0.ini|1785812346.0|978": {"hash": "f8359ba393c1280f65d3507209d7d377d36be22d8813a52c8ac38d41a097b7df", "size": 978, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/M3R/Human_3R_w0.ini|1785812346.0|948": {"hash": "6c3d40e42e394f6a027607b8b867eb6b17bedda10290ad6fc1532cdb4e5d7d21", "size": 948, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/single_task/RP_single_task/ST_293T.ini|1785812346.0|860": {"hash": "6ddd5c586c679fe4a0053b9680448317df619eac7dcf9eb4cb366601a615b9c5", "size": 860, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/sM3R/SubHuman_3C_1.ini|1785812346.0|956": {"hash": "cc632dd297118b61168cdf563d1dde33a36fa81e711495fd3e564da445b923bb", "size": 956, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/single_task/RP_single_task/ST_PC3.ini|1785812346.0|855": {"hash": "c8b88a24d0107b2c26ad8f2fb9fe6a0ef92a5c417f04417e40743d6bac4b1b85", "size": 855, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/single_task/RP_single_task/ST_muscle.ini|1785812346.0|861": {"hash": "ab271e07233ea5f8d829f425b13b4e85fbdb1cc86f3f48a9bfb8c5484b4d699e", "size": 861, "status": "c"}, "model/src/mrl_te_optimization/log/Backbone/RL_hard_share/single_task/counterpart_for_transfer/Singletask_unmod1_pretrain.ini|1785812346.0|776": {"hash": "5a7262d2d69629c7834bffad22152a3cded70866ebddd0b4afc700c7dbc22ae2", "size": 776, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/Frame_GP/3mFP_3lyer_k7_s1113.ini|1785812346.0|905": {"hash": "91e7f497f7bc5748c75c57c9d1a672f1cef87705ce3c075f288f4416f1c68bac", "size": 905, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/Frame_GP/3mFP_strides_1113.ini|1785812346.0|917": {"hash": "ee901b89a808b74ac8448638432f88e35854e1585a2c4cec6a207aeffebbc13a", "size": 917, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/Frame_GP/3mFP_debug.ini|1785812346.0|906": {"hash": "337c5ec095eda121ff592e72edab1d69bcff765d8ab85bc741b37aa88ab4bff0", "size": 906, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/Frame_GP/3mFP_strides_1111.ini|1785812346.0|924": {"hash": "9bac4b405222c10032664d58a932b7032a8ef7a54e6d4e8766f6609bf089efae", "size": 924, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/GP_net/3M/3mGP_debug.ini|1785812346.0|893": {"hash": "9813d840154045b0bcf10a3bed1fb416ae91cd756ed74db8139525c6f6537e32", "size": 893, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/GP_net/3M/3mGP_avgpool.ini|1785812346.0|905": {"hash": "67af4d2eecbf9174e94123e24ee94b1ea0e47024aa41135374a50fbf9ce5c1c1", "size": 905, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/GP_net/MPA_U_GP_avgpool.ini|1785812346.0|894": {"hash": "63c42ccd5bacf789715ac24c566cbd92b8da5af31c3b4203d15de362b27da751", "size": 894, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/RL_Atten/debug_RL_atten.ini|1785812346.0|861": {"hash": "0676ace9d77434b7ac051aa83009b9de75e6dbf97cfeeda2f88e006065ab62b8", "size": 861, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/RL_Atten/3M/debug_RL_atten.ini|1785812346.0|804": {"hash": "2139d7fb58b91d6526698b853bc331ee79189e883f5d255355a50eb16d69839f", "size": 804, "status": "c"}, "model/src/mrl_te_optimization/log/GP_net/GP_net/new_GP_by_amax.ini|1785812346.0|896": {"hash": "0cb222df6d95dd36f7e3327c76b03a4a27e5ccf3524f285093daa8fd76e3bf73", "size": 896, "status": "c"}, "model/src/mrl_te_optimization/log/Koo_net/Conf_CNN/k8_5_P20_5_100bp/MPA_H.ini|1785812346.0|729": {"hash": "ec5a27a98ecf873c1c619d67beef61804b5ee0883b25df0dd2cc69df8c847214", "size": 729, "status": "c"}, "model/src/mrl_te_optimization/log/Koo_net/Conf_CNN/k8_5_P20_5_100bp/MPA_V.ini|1785812346.0|730": {"hash": "fcff38188b4b3aca2b669afb63d2d9616242e9243a232928373f6c6cba97f3d8", "size": 730, "status": "c"}, "model/src/mrl_te_optimization/log/Koo_net/Conf_CNN/k8_5_P20_5_100bp/MPA_U.ini|1785812346.0|736": {"hash": "7ed91ffbd3f952145a2c83fac80ac5ad99e107f00760123ac3f9532c5c8489a4", "size": 736, "status": "c"}, "model/src/mrl_te_optimization/machine_configure.json|1785812346.0|211": {"hash": "315d93c54ba22b21cfd3d49dca9105f23f6b9021a07928a144cca353102a5ee4", "size": 211, "status": "c"}, "model/src/mrl_te_optimization/models/Baseline_models.py|1785812346.0|5894": {"hash": "04d9e1ca30c611ecd2f3fac28b632e311da52407e89dad5ff287a77b3ff8478c", "size": 5894, "status": "c"}, "model/src/mrl_te_optimization/models/Backbone.py|1785812346.0|24403": {"hash": "d6eb78dba161e0707e376487112dc393062bfbdf7c67afee0e2be62813d955f8", "size": 24403, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/GP_net.py|1785812346.0|5938": {"hash": "1656bb4751ac801b9e53cd79d7bb25b3739a0bedae024416a80055802089dee8", "size": 5938, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/Backbone.py|1785812346.0|24242": {"hash": "1b6792fa6d3997448b08f80934026ab66e12a6284e7be11e6222704dd955c643", "size": 24242, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/Koo_net.py|1785812346.0|3645": {"hash": "3da19054769f18b5fe8e6d0113bd839dc1d8d880c8b7b5bb8c68fe27026d8b92", "size": 3645, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__init__.py|1785812346.0|127": {"hash": "da5d63fc32d960ecaf6ccd69fcbecb22502b9cee327eddd43c5e35120dd74024", "size": 127, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/Backbone.cpython-311.pyc|1785832288.0|43780": {"hash": "996384a4a534467eddb9fdc284a2db0d8aafe214fad527850f61b1b8b845d8e6", "size": 43780, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/Backbone.cpython-310.pyc|1785812346.0|23567": {"hash": "9e60521bd9209224fcbe4dc64dbb91a3f67fccdd7210ccd1efea15577908086d", "size": 23567, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/GP_net.cpython-310.pyc|1785812346.0|5885": {"hash": "a72a2b1dafe107c6723b6653925ee7d6a273c33de60b807258effd192834be89", "size": 5885, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/GP_net.cpython-311.pyc|1785832288.0|10490": {"hash": "26d55b57bbf1825412bf298308c774ba9a89ea0f412ae231ff106a0da4da88a3", "size": 10490, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/Koo_net.cpython-310.pyc|1785812346.0|3762": {"hash": "5486ffad68edf66d7ce86444b8f946f8b28f01355ba2a36652a1f481bbdf90e1", "size": 3762, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/Koo_net.cpython-311.pyc|1785832288.0|6741": {"hash": "bcc8982a357b834587104c32bf73f3042be80a1bde9d725de53efcb66c943759", "size": 6741, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/__init__.cpython-311.pyc|1785831950.0|292": {"hash": "a16eec7640b61ecc5bbe88d352d0588ed8550d39e9646cf8f21ca9572ba105c4", "size": 292, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/__init__.cpython-310.pyc|1785812346.0|287": {"hash": "eab674a6ae2bec16571919089ae94760bab33d3421fefaf7ac752237956dc9cd", "size": 287, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/_operator.cpython-310.pyc|1785812346.0|9878": {"hash": "7ef4eb6d3e01b4e4e4cedcd27802df4540924435181daf63e895f14b64231973", "size": 9878, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/__pycache__/_operator.cpython-311.pyc|1785832288.0|16921": {"hash": "1fb584717beec17657522e8f8e81a5519e60e90ace412076fffa9575e38a698f", "size": 16921, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/_operator.py|1785812346.0|8656": {"hash": "c6aeff3b6ff52d6bbfc2c971ae52aff12f741b997189dcafb75c04b751cd9287", "size": 8656, "status": "c"}, "model/src/mrl_te_optimization/models/Modules/nonDeep.py|1785812346.0|1847": {"hash": "46c3915a71b3cc47ee6a70e663fb0b695a113c847a541f0a2849c406a3326126", "size": 1847, "status": "c"}, "model/src/mrl_te_optimization/models/ScheduleOptimizer.py|1785812346.0|3395": {"hash": "7f5c6fa27cd0e8613d0effb52e54b07b6090ec430c13d117bf76f232016e899b", "size": 3395, "status": "c"}, "model/src/mrl_te_optimization/models/Self_attention.py|1785812346.0|3521": {"hash": "087eda250e992c721272d40504e294ccd12387b94f762581f1df96ffa141d3cc", "size": 3521, "status": "c"}, "model/src/mrl_te_optimization/models/__pycache__/Backbone.cpython-311.pyc|1785831950.0|44066": {"hash": "d610087511af987296750961a49d5e9e37d38d5172f8c10d86b4e40a43daf766", "size": 44066, "status": "c"}, "model/src/mrl_te_optimization/models/bucket_sampler.py|1785812346.0|3847": {"hash": "72b4eda6c5f0c0099a59462ba38aff2faa0e7a60039944682f1e70ed8f537aae", "size": 3847, "status": "c"}, "model/src/mrl_te_optimization/models/__pycache__/Backbone.cpython-310.pyc|1785812346.0|23689": {"hash": "6854a869a0a6f016fef1cd10ccabe9c69bb55612c89a6778081f7ade8f08c706", "size": 23689, "status": "c"}, "model/src/mrl_te_optimization/models/log_and_save.py|1785812346.0|11187": {"hash": "a1afb14f476ae0d6415114700320aa5fb370712fcaaf2dafcff0ce0200ca8193", "size": 11187, "status": "c"}, "model/src/mrl_te_optimization/models/max_activation_patch.py|1785812346.0|29460": {"hash": "39bce5ecbef128ce2227b1d6735f95c7f1b422cba5cc9945c1d479f3f9dce171", "size": 29460, "status": "c"}, "model/src/mrl_te_optimization/models/loss.py|1785812346.0|3106": {"hash": "76a1243aa85c3c11aaaf7b5173fd31608bc97ffa0875143831c967f344540c32", "size": 3106, "status": "c"}, "model/src/mrl_te_optimization/models/popen.py|1785812346.0|6182": {"hash": "71e03cdc5d845070be7da8e9932cb379cd33e1162946ac83ef67c7d965675d57", "size": 6182, "status": "c"}, "model/src/mrl_te_optimization/models/train_val.py|1785812346.0|12343": {"hash": "1ba2becae3e316242405244234f0a6ed0ac13f542fedb9ff832cbf6dff979f31", "size": 12343, "status": "c"}, "model/src/mrl_te_optimization/models/reader.py|1785812346.0|18222": {"hash": "594d03b8643a7e8b2b0ffea4578097c249be8b2d550557c34f54239539429c7b", "size": 18222, "status": "c"}, "model/src/mrl_te_optimization/popen.py|1785812346.0|6180": {"hash": "8ebcc95b7cb9f0f5078c5da81e95676931b1eeb58bdf8a25c11e7c2a6b3a5b58", "size": 6180, "status": "c"}, "model/src/mrl_te_optimization/script/Nupack_MFE_prediction.py|1785812346.0|1435": {"hash": "b654974e0cb9a759d888ad1e61af6d9d6e6f9d8a5f4da39fde0498147cb550c4", "size": 1435, "status": "c"}, "model/src/mrl_te_optimization/script/PATH.py|1785812346.0|93": {"hash": "9d6a1a07d2e9562b9d864c0dd2eb74dfbef79b7e3c6c3c0e880122ae74b742f2", "size": 93, "status": "c"}, "model/src/mrl_te_optimization/script/data_prepocessing.sh|1785812346.0|58": {"hash": "f388c9bcd350f9d7c527da48bae8f17a74257165c9d821d7d66dd9cfdda26b3a", "size": 58, "status": "c"}, "model/src/mrl_te_optimization/script/covar_test.py|1785812346.0|8631": {"hash": "0f5bcf753930dfe3c7abee7c6e007b2b0f37fd3482625c518a5bc84ab8a33ac2", "size": 8631, "status": "c"}, "model/src/mrl_te_optimization/script/covar_train.py|1785812346.0|10359": {"hash": "f3fddf6ecc1e4e2da73eace36c2c0cf03bd713dac0bc3ee269398090fe2f3b54", "size": 10359, "status": "c"}, "model/src/mrl_te_optimization/script/download_training_data.sh|1785812346.0|1623": {"hash": "4eb1acbaf25448f1c3408cf083fd918a765ea104886eb1213d7b6fc50991c711", "size": 1623, "status": "c"}, "model/src/mrl_te_optimization/script/detect_changepoint_featmap.py|1785812346.0|5655": {"hash": "0a951a6137d797a86eebd86281d1f299ca2a1c010523fc6ce7b26fefd60efd0f", "size": 5655, "status": "c"}, "model/src/mrl_te_optimization/script/evaluate_channel_effect.py|1785812346.0|4396": {"hash": "5aad174d6ba918b666ddbcf764d5648f52d469803009f7cf26632f6c3531ed0f", "size": 4396, "status": "c"}, "model/src/mrl_te_optimization/script/generate_config_js.sh|1785812346.0|458": {"hash": "e894798538e96498138e1d7075c3737dcce04fcc7b769956e4027391ecc73c9e", "size": 458, "status": "c"}, "model/src/mrl_te_optimization/script/fix_test_for_RP.py|1785812346.0|1041": {"hash": "1ab2ec5b2a0d2ad80bbd5de158fe7b5dd23b4cad1180a6a590300d72e97b7de1", "size": 1041, "status": "c"}, "model/src/mrl_te_optimization/script/iter_test.py|1785812346.0|9406": {"hash": "d1d2020b8e97ff5afe71e442d277a1a3c217dd36b1f51321f52424f15899e65d", "size": 9406, "status": "c"}, "model/src/mrl_te_optimization/script/iter_train.py|1785812346.0|10890": {"hash": "6edf665180733df3506769c3324bf546e40ba6899403e9b0cdbc4441cfa12832", "size": 10890, "status": "c"}, "model/src/mrl_te_optimization/script/main_train.py|1785812346.0|8478": {"hash": "494b6ce452bd442473fafe011e747617d73dc79a66ef184e18152e33a7e23797", "size": 8478, "status": "c"}, "model/src/mrl_te_optimization/script/preprocessing_MPA.py|1785812346.0|3741": {"hash": "59cc75121fb019b8320db9f81674e6409a4a45f62628a9f922fb30f698c67283", "size": 3741, "status": "c"}, "model/src/mrl_te_optimization/script/run-TF-modisco.py|1785812346.0|3498": {"hash": "d49a84e7e51d431ebad3d0bc23459f15e9621ce0e0e13b0b0faa3b493b27747f", "size": 3498, "status": "c"}, "model/src/mrl_te_optimization/script/preprocessing_RP.py|1785812346.0|2286": {"hash": "e42bd567619611b570284c17f4e37ebf79eefeee9f52e2a3bd965f4c3f6248a2", "size": 2286, "status": "c"}, "model/src/mrl_te_optimization/script/train_kmer_classifer.py|1785812346.0|8449": {"hash": "bda2913a029bfb3d90a331d635897292c64f0db07a7ce4a602825876e6a0bd07", "size": 8449, "status": "c"}, "model/src/mrl_te_optimization/script/train_kmer_models.py|1785812346.0|5595": {"hash": "3fd3998d2beaa4572830ad337324a7483806f32553891b36757f4b8c27ac60b3", "size": 5595, "status": "c"}, "model/src/mrl_te_optimization/script/train_oneLayer_CNN.py|1785812346.0|3771": {"hash": "3bcbfb6a9ded0280ba916fab6d7c376c1acb02481720c992e4cb621afbae913c", "size": 3771, "status": "c"}, "model/src/mrl_te_optimization/util.py|1785812346.0|9810": {"hash": "5007a216a52330751ef832e7552987ef04ad36b957ada355cb11874abf789c3e", "size": 9810, "status": "c"}, "model/src/mrl_te_optimization/utils.py|1785812347.0|6850": {"hash": "4a59de58c85353dd57d150d48c367a8bb0bb2b7dead63301e63cb909b1b9004f", "size": 6850, "status": "c"}, "requirements.txt|1788144367.0|2471": {"hash": "c47cfce222b3cae462cef0b233665c3390c42e2ec11ed21ce27c4c5c167d4e92", "size": 2471, "status": "c"}, "model/src/mrl_te_optimization/xpresso_input.json|1785812347.0|504375": {"hash": "a8fdda439e7a16d06bded0530a995a0d078a73dc5da536898e80ee817a247050", "size": 504375, "status": "c"}, "scripts/optimize_te_mrl.py|1788143455.0|12242": {"hash": "dc3501e8c110df6b80ae96131b6b70da77447b76eb68373d42d597452e94a7e5", "size": 12242, "status": "c"}, "scripts/predict.py|1788143548.0|7967": {"hash": "eedbb6c01427952f63815692f72ff6018accca6f89969f00ca6d0b7f8f2f2dd3", "size": 7967, "status": "c"}, "scripts/train.py|1788143378.0|13433": {"hash": "ce2ae464ebfef487b3cc0f1a6c097ea0ad4f5c72f25a35e48277533f73cfd720", "size": 13433, "status": "c"}, "weight/G4Boost_classifier.json|1785812343.0|1031488": {"hash": "a3c1b4e0cbfb7778e83e6ab4aed335cf8bef0017fc6a1bac292d2e343b213bc6", "size": 1031488, "status": "c"}, "weight/K562_trainepoch.11-0.4917.h5|1785812343.0|1392384": {"hash": "95cb2279568a039bff7ae5dcfc1c9e467a8065ba97a7b250e91265b5cd946b80", "size": 1392384, "status": "c"}, "weight/GM12878_trainepoch.06-0.5062.h5|1785812343.0|1392384": {"hash": "3e44d222897ca54d6dff9a5cff440ac351804d529be036f19c7c61c4bcc865f7", "size": 1392384, "status": "c"}, "weight/checkpoint_3000.h5|1785812343.0|1240488": {"hash": "ab43c9bbe34eda0febec49f225e19788c2f21270f3714853a8db370b849944ce", "size": 1240488, "status": "c"}, "weight/G4Boost_regressor.json|1785812343.0|4402517": {"hash": "2e78954788ea2d75ef4d3100a57e2e4fc4edb32de9fa05322b1d37a2b9ba13f9", "size": 4402517, "status": "c"}, "weight/humanMedian_trainepoch.11-0.426.h5|1785812343.0|1392384": {"hash": "15a383648008df5f843ec8651e78be5faf82609c88fb068da890aa7a89387bb0", "size": 1392384, "status": "c"}, "weight/mttrans/RL_hard_share_MTL/3M/schedule_lr-model_best_cv1.pth|1785812346.0|13782356": {"hash": "fe3ac2b7389fa605d2b9edd247e7095689ef4ca9e2583ff00247de16d5f6c1b6", "size": 13782356, "status": "c"}, "weight/mttrans/RL_hard_share_MTL/3R/schedule_MTL-model_best_cv1.pth|1785812346.0|13782579": {"hash": "58d3ba543136ea5067524554332a1050b539aabf6d01288bcf5f238088df384e", "size": 13782579, "status": "c"}, "weight/utr_model_combined_residual_new.h5|1785812343.0|3464672": {"hash": "8ae837bb73b3bf2e2be2babbd0fb55a4194efa4de0a1abafd390d3793cfbc4f0", "size": 3464672, "status": "c"}}}
|
LICENSE
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
UTRGAN DCU Adaptation License Notice
|
| 2 |
+
|
| 3 |
+
Upstream project: UTRGAN — Deep Learning for 5' UTR Generation and
|
| 4 |
+
Translation Optimization
|
| 5 |
+
Upstream source: https://github.com/ciceklab/UTRGAN
|
| 6 |
+
Upstream copyright notice: Copyright 2025 © UTRGAN
|
| 7 |
+
|
| 8 |
+
The UTRGAN-originated material in this repository, together with adaptations
|
| 9 |
+
made for DCU execution, is distributed under the Creative Commons
|
| 10 |
+
Attribution-NonCommercial-ShareAlike 2.0 Generic license
|
| 11 |
+
(CC BY-NC-SA 2.0), subject to the rights held by the original authors.
|
| 12 |
+
|
| 13 |
+
License deed:
|
| 14 |
+
https://creativecommons.org/licenses/by-nc-sa/2.0/
|
| 15 |
+
|
| 16 |
+
Legal code:
|
| 17 |
+
https://creativecommons.org/licenses/by-nc-sa/2.0/legalcode
|
| 18 |
+
|
| 19 |
+
You may share and adapt the covered material only if you:
|
| 20 |
+
|
| 21 |
+
1. give appropriate credit to the UTRGAN authors, link to the upstream
|
| 22 |
+
project and this license, and identify that changes were made;
|
| 23 |
+
2. use the material only for non-commercial purposes;
|
| 24 |
+
3. distribute adaptations under CC BY-NC-SA 2.0; and
|
| 25 |
+
4. do not imply endorsement by the original authors or impose additional
|
| 26 |
+
legal or technological restrictions.
|
| 27 |
+
|
| 28 |
+
DCU adaptation notice
|
| 29 |
+
---------------------
|
| 30 |
+
|
| 31 |
+
This distribution modifies the upstream package layout and adds SCNet/DCU
|
| 32 |
+
runtime configuration, DTK-compatible dependency documentation, inference,
|
| 33 |
+
comparison, candidate-ranking, and training entry scripts. These adaptation
|
| 34 |
+
changes do not claim authorship of the original UTRGAN architecture, source
|
| 35 |
+
code, datasets, or pretrained parameters.
|
| 36 |
+
|
| 37 |
+
Third-party material
|
| 38 |
+
--------------------
|
| 39 |
+
|
| 40 |
+
Components, pretrained parameters, datasets, and other material originating
|
| 41 |
+
outside UTRGAN remain subject to their own licenses and terms. They are not
|
| 42 |
+
relicensed by this notice. Required notices and provenance information are in
|
| 43 |
+
THIRD_PARTY_NOTICES.md.
|
| 44 |
+
|
| 45 |
+
No warranty
|
| 46 |
+
-----------
|
| 47 |
+
|
| 48 |
+
The material is provided without warranties. The license may not grant every
|
| 49 |
+
permission needed for a particular use. Commercial use requires separate
|
| 50 |
+
permission from the relevant rights holders. The upstream UTRGAN authors list
|
| 51 |
+
cicek@cs.bilkent.edu.tr for commercial licensing inquiries.
|
| 52 |
+
|
README.md
ADDED
|
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
frameworks:
|
| 3 |
+
- TensorFlow
|
| 4 |
+
- PyTorch
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
license: cc-by-nc-sa-2.0
|
| 8 |
+
tags:
|
| 9 |
+
- OneScience
|
| 10 |
+
- bioscience
|
| 11 |
+
- 5UTR
|
| 12 |
+
- RNA-generation
|
| 13 |
+
- translation-efficiency-prediction
|
| 14 |
+
- UTRGAN
|
| 15 |
+
tasks: []
|
| 16 |
+
datasets: []
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
<p align="center">
|
| 20 |
+
<strong>
|
| 21 |
+
<span style="font-size: 30px;">UTRGAN</span>
|
| 22 |
+
</strong>
|
| 23 |
+
</p>
|
| 24 |
+
|
| 25 |
+
# Model Introduction
|
| 26 |
+
|
| 27 |
+
UTRGAN is a generative and optimization framework for 5′ UTR design. It can generate candidate 5′ UTR sequences and predict and rank them according to gene expression, Mean Ribosome Load (MRL), and Translation Efficiency (TE).
|
| 28 |
+
|
| 29 |
+
The Hugging Face model package already contains the data and pretrained weights required for the basic workflow, so no additional model files need to be downloaded during inference.
|
| 30 |
+
|
| 31 |
+
# Model Description
|
| 32 |
+
|
| 33 |
+
UTRGAN consists of multiple cooperating models:
|
| 34 |
+
|
| 35 |
+
- **WGAN-GP Generator:** Generates candidate 5′ UTR sequences of up to 128 nt from a 40-dimensional random latent vector;
|
| 36 |
+
- **WGAN-GP Critic:** Used during generative-model training;
|
| 37 |
+
- **Xpresso:** Predicts gene-expression-related scores;
|
| 38 |
+
- **FramePool:** Predicts Mean Ribosome Load (MRL);
|
| 39 |
+
- **MTtrans:** Predicts Translation Efficiency (TE);
|
| 40 |
+
- **G4Boost:** Performs G4-related classification and regression analyses.
|
| 41 |
+
|
| 42 |
+
WGAN, Xpresso, and FramePool use TensorFlow/Keras, while MTtrans uses PyTorch.
|
| 43 |
+
|
| 44 |
+
To maintain compatibility with the legacy H5 model files released by the original projects, Legacy Keras is used when loading the corresponding models.
|
| 45 |
+
|
| 46 |
+
# Use Cases
|
| 47 |
+
|
| 48 |
+
| Use Case | Description |
|
| 49 |
+
| :---: | :--- |
|
| 50 |
+
| 5′ UTR candidate generation | Generate 5′ UTR candidate sequences in batches using the official pretrained WGAN. |
|
| 51 |
+
| MRL prediction and ranking | Use FramePool to calculate MRL scores and rank candidate sequences. |
|
| 52 |
+
| TE prediction and ranking | Use MTtrans to calculate TE scores and rank candidate sequences. |
|
| 53 |
+
| MRL/TE-directed optimization | Freeze the pretrained models and optimize the latent noise to improve the target score. |
|
| 54 |
+
| Gene-expression optimization | Combine UTRGAN with Xpresso to evaluate gene-expression-related properties of candidate sequences. |
|
| 55 |
+
| WGAN-GP training | Validate or retrain the generative model using the included UTRdb2 dataset. |
|
| 56 |
+
|
| 57 |
+
# Usage
|
| 58 |
+
|
| 59 |
+
## 1. OneCode
|
| 60 |
+
|
| 61 |
+
You can use the OneCode online environment for an intelligent one-click AI4S programming experience:
|
| 62 |
+
|
| 63 |
+
[Try OneCode for AI4S Programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
|
| 64 |
+
|
| 65 |
+
## 2. Manual Installation
|
| 66 |
+
|
| 67 |
+
**Hardware Requirements**
|
| 68 |
+
|
| 69 |
+
- CPU inference is supported;
|
| 70 |
+
- A OneScience-supported DCU environment is recommended for batch generation, ranking, and training;
|
| 71 |
+
- TensorFlow and PyTorch access the same DCU through their compatible accelerator interfaces;
|
| 72 |
+
- Full training time depends on the number of candidate sequences, batch size, and device performance.
|
| 73 |
+
|
| 74 |
+
### Download the Model Package
|
| 75 |
+
|
| 76 |
+
Install the Hugging Face command-line tool and download the model repository:
|
| 77 |
+
|
| 78 |
+
```bash
|
| 79 |
+
python -m pip install -U huggingface_hub
|
| 80 |
+
|
| 81 |
+
hf download OneScience-Group/UTRGAN --local-dir ./UTRGAN
|
| 82 |
+
cd UTRGAN
|
| 83 |
+
```
|
| 84 |
+
|
| 85 |
+
### Install the Runtime Environment
|
| 86 |
+
|
| 87 |
+
Create and activate a Python 3.11 environment, and then install the OneScience bioscience base environment:
|
| 88 |
+
|
| 89 |
+
```bash
|
| 90 |
+
conda create -n utrgan python=3.11 -y
|
| 91 |
+
conda activate utrgan
|
| 92 |
+
|
| 93 |
+
pip install onescience[bio-dcu]
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
Then install the additional or replacement dependencies specified in `requirements.txt`:
|
| 97 |
+
|
| 98 |
+
```bash
|
| 99 |
+
python -m pip install --no-deps -r requirements.txt
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
> **Note:** This model adaptation uses **DTK 26.04**. The corresponding TensorFlow runtime has also been upgraded to **TensorFlow 2.18**.
|
| 103 |
+
|
| 104 |
+
Check the frameworks and available devices:
|
| 105 |
+
|
| 106 |
+
```bash
|
| 107 |
+
python - <<'PY'
|
| 108 |
+
import tensorflow as tf
|
| 109 |
+
import torch
|
| 110 |
+
|
| 111 |
+
print("TensorFlow:", tf.__version__)
|
| 112 |
+
print("TensorFlow devices:", tf.config.list_physical_devices("GPU"))
|
| 113 |
+
print("PyTorch:", torch.__version__)
|
| 114 |
+
print("HIP:", torch.version.hip)
|
| 115 |
+
print("DCU available:", torch.cuda.is_available())
|
| 116 |
+
PY
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### Weights and Data Preparation
|
| 120 |
+
|
| 121 |
+
The Hugging Face model package already contains the resources required for basic generation, prediction, ranking, and training validation:
|
| 122 |
+
|
| 123 |
+
| Resource | Location | Purpose |
|
| 124 |
+
| --- | --- | --- |
|
| 125 |
+
| UTRdb2 | `conf/data/utrdb2.csv` | WGAN-GP training data |
|
| 126 |
+
| Motif data | `conf/data/motifs.csv` | Motif statistics and optimization analysis |
|
| 127 |
+
| WGAN Generator | `weight/checkpoint_3000.h5` | Generate candidate 5′ UTR sequences |
|
| 128 |
+
| FramePool | `weight/utr_model_combined_residual_new.h5` | MRL prediction |
|
| 129 |
+
| Xpresso | `weight/humanMedian_trainepoch.11-0.426.h5` | Gene-expression-related prediction |
|
| 130 |
+
| Xpresso | `weight/GM12878_trainepoch.06-0.5062.h5` | GM12878 expression-related prediction |
|
| 131 |
+
| Xpresso | `weight/K562_trainepoch.11-0.4917.h5` | K562 expression-related prediction |
|
| 132 |
+
| MTtrans | `weight/mttrans/RL_hard_share_MTL/3R/schedule_MTL-model_best_cv1.pth` | TE prediction |
|
| 133 |
+
| G4Boost | `weight/G4Boost_classifier.json` | G4 classification |
|
| 134 |
+
| G4Boost | `weight/G4Boost_regressor.json` | G4 regression |
|
| 135 |
+
|
| 136 |
+
After applying the filtering and deduplication logic used by the official training scripts, UTRdb2 contains approximately 33,250 sequences with lengths between 65 and 128 nt.
|
| 137 |
+
|
| 138 |
+
The basic workflow does not require additional dataset downloads or precomputed features.
|
| 139 |
+
|
| 140 |
+
### Optional Dependencies
|
| 141 |
+
|
| 142 |
+
`requirements.txt` includes XGBoost, ViennaRNA, logomaker, ruptures, and cliffs-delta for G4-related and downstream analysis scripts.
|
| 143 |
+
|
| 144 |
+
NUPACK is used only by optional MFE preprocessing scripts.
|
| 145 |
+
|
| 146 |
+
Because NUPACK 4 must be obtained and installed separately according to the licensing and installation requirements of its publisher, it is not automatically installed through standard PyPI dependencies in this model package.
|
| 147 |
+
|
| 148 |
+
NUPACK is not required for:
|
| 149 |
+
|
| 150 |
+
- Basic inference;
|
| 151 |
+
- MRL ranking;
|
| 152 |
+
- TE ranking;
|
| 153 |
+
- WGAN-GP training.
|
| 154 |
+
|
| 155 |
+
### Quick Inference
|
| 156 |
+
|
| 157 |
+
Use the official pretrained WGAN to generate candidate sequences and rank them independently by MRL and TE.
|
| 158 |
+
|
| 159 |
+
**Purpose:** Generate 5′ UTR candidates in batches on DCU and output separate MRL and TE ranking results.
|
| 160 |
+
|
| 161 |
+
```bash
|
| 162 |
+
python scripts/predict.py \
|
| 163 |
+
--device dcu \
|
| 164 |
+
--device-id 0 \
|
| 165 |
+
--num-candidates 1024 \
|
| 166 |
+
--batch-size 128 \
|
| 167 |
+
--seed 33 \
|
| 168 |
+
--output-dir outputs/pretrained_batch_ranking
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
The results are saved to:
|
| 172 |
+
|
| 173 |
+
```text
|
| 174 |
+
outputs/pretrained_batch_ranking/
|
| 175 |
+
├── all_candidates_scores.csv
|
| 176 |
+
├── ranked_by_mrl.csv
|
| 177 |
+
├── ranked_by_te.csv
|
| 178 |
+
├── generator_probabilities.npy
|
| 179 |
+
└── summary.json
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
The output files contain:
|
| 183 |
+
|
| 184 |
+
- `all_candidates_scores.csv`: all candidate sequences together with their MRL and TE prediction scores;
|
| 185 |
+
- `ranked_by_mrl.csv`: candidates ranked from highest to lowest MRL score;
|
| 186 |
+
- `ranked_by_te.csv`: candidates ranked from highest to lowest TE score;
|
| 187 |
+
- `is_duplicate`: indicates whether a generated sequence is duplicated;
|
| 188 |
+
- MRL and TE are measured on different scales and their raw scores should not be directly added together.
|
| 189 |
+
|
| 190 |
+
### MRL-Directed Optimization
|
| 191 |
+
|
| 192 |
+
**Purpose:** Freeze the WGAN and FramePool models and optimize the latent noise to increase the predicted MRL score of generated candidates.
|
| 193 |
+
|
| 194 |
+
```bash
|
| 195 |
+
python scripts/optimize_te_mrl.py \
|
| 196 |
+
-gpu 0 \
|
| 197 |
+
-task mrl \
|
| 198 |
+
-bs 64 \
|
| 199 |
+
-s 10 \
|
| 200 |
+
--output-dir outputs/optimization_mrl
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
During this process, the WGAN and FramePool model weights remain frozen. Only the latent noise is updated.
|
| 204 |
+
|
| 205 |
+
### TE-Directed Optimization
|
| 206 |
+
|
| 207 |
+
**Purpose:** Freeze the WGAN and MTtrans models and optimize the latent noise to increase the predicted TE score of generated candidates.
|
| 208 |
+
|
| 209 |
+
```bash
|
| 210 |
+
python scripts/optimize_te_mrl.py \
|
| 211 |
+
-gpu 0 \
|
| 212 |
+
-task te \
|
| 213 |
+
-bs 64 \
|
| 214 |
+
-s 10 \
|
| 215 |
+
--output-dir outputs/optimization_te
|
| 216 |
+
```
|
| 217 |
+
|
| 218 |
+
During this process, the WGAN and MTtrans model weights remain frozen.
|
| 219 |
+
|
| 220 |
+
Therefore, this workflow is latent-space optimization rather than fine-tuning of the pretrained models.
|
| 221 |
+
|
| 222 |
+
### Training
|
| 223 |
+
|
| 224 |
+
UTRGAN supports WGAN-GP training.
|
| 225 |
+
|
| 226 |
+
The trainable components in this workflow are:
|
| 227 |
+
|
| 228 |
+
- Generator;
|
| 229 |
+
- Critic.
|
| 230 |
+
|
| 231 |
+
Xpresso, FramePool, and MTtrans do not participate in this training entry point.
|
| 232 |
+
|
| 233 |
+
To run one epoch using the complete data-processing pipeline and the UTRdb2 dataset included in the repository:
|
| 234 |
+
|
| 235 |
+
```bash
|
| 236 |
+
python scripts/train.py \
|
| 237 |
+
-gpu 0 \
|
| 238 |
+
-bs 64 \
|
| 239 |
+
-lr 5 \
|
| 240 |
+
-mxl 128 \
|
| 241 |
+
-dim 40 \
|
| 242 |
+
--epochs 1 \
|
| 243 |
+
--output-dir outputs/train_1epoch
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
According to the upstream README, `-lr 5` corresponds to a learning rate of:
|
| 247 |
+
|
| 248 |
+
```text
|
| 249 |
+
1e-5
|
| 250 |
+
```
|
| 251 |
+
|
| 252 |
+
The adapted training entry point adds the `--epochs` argument and corrects the learning-rate expression in the upstream script so that it is consistent with the documented definition.
|
| 253 |
+
|
| 254 |
+
To run the full upstream training configuration, use the complete UTRdb2 training dataset for 4000 epochs:
|
| 255 |
+
|
| 256 |
+
```bash
|
| 257 |
+
python scripts/train.py \
|
| 258 |
+
-gpu 0 \
|
| 259 |
+
-bs 64 \
|
| 260 |
+
-lr 5 \
|
| 261 |
+
-mxl 128 \
|
| 262 |
+
-dim 40 \
|
| 263 |
+
--epochs 4000 \
|
| 264 |
+
--output-dir outputs/train_full
|
| 265 |
+
```
|
| 266 |
+
|
| 267 |
+
This retrains the WGAN-GP Generator and Critic.
|
| 268 |
+
|
| 269 |
+
Full training can require substantial runtime. Training progress should be evaluated according to available accelerator resources and training logs.
|
| 270 |
+
|
| 271 |
+
Generated checkpoints are saved in the specified output directory and do not overwrite the official pretrained weights under:
|
| 272 |
+
|
| 273 |
+
```text
|
| 274 |
+
weight/
|
| 275 |
+
```
|
| 276 |
+
|
| 277 |
+
# OneScience Official Resources
|
| 278 |
+
|
| 279 |
+
| Platform | OneScience Main Repository | Skills Repository |
|
| 280 |
+
| --- | --- | --- |
|
| 281 |
+
| Gitee | [OneScience](https://gitee.com/onescience-ai/onescience) | [OneSkills](https://gitee.com/onescience-ai/oneskills) |
|
| 282 |
+
| GitHub | [OneScience](https://github.com/onescience-ai/OneScience) | [OneSkills](https://github.com/onescience-ai/oneskills) |
|
| 283 |
+
|
| 284 |
+
# Citation and License
|
| 285 |
+
|
| 286 |
+
- Upstream implementation: https://github.com/ciceklab/UTRGAN
|
| 287 |
+
- Xpresso: https://github.com/vagarwal87/Xpresso
|
| 288 |
+
- FramePool: https://github.com/Karollus/5UTR
|
| 289 |
+
- MTtrans: https://github.com/holab-hku/MTtrans
|
| 290 |
+
- The upstream UTRGAN project is distributed under the [CC BY-NC-SA 2.0](https://creativecommons.org/licenses/by-nc-sa/2.0/) license and is intended for academic and non-commercial use. Commercial use requires permission from the upstream authors.
|
| 291 |
+
- Third-party models, datasets, pretrained weights, and software components remain subject to their respective original licenses and terms of use.
|
| 292 |
+
- The DCU adaptation in this repository continues to use the same CC BY-NC-SA 2.0 license.
|
conf/analysis/G4.ipynb
ADDED
|
@@ -0,0 +1,451 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 3,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [],
|
| 8 |
+
"source": [
|
| 9 |
+
"#!/usr/bin/env python\n",
|
| 10 |
+
"\n",
|
| 11 |
+
"import re\n",
|
| 12 |
+
"import sys\n",
|
| 13 |
+
"import string\n",
|
| 14 |
+
"import argparse\n",
|
| 15 |
+
"import operator\n",
|
| 16 |
+
"import pandas as pd\n",
|
| 17 |
+
"import xgboost as xgb\n",
|
| 18 |
+
"import numpy as np\n",
|
| 19 |
+
"\n",
|
| 20 |
+
"VERSION='0.1.0'\n",
|
| 21 |
+
"\n",
|
| 22 |
+
"parser = argparse.ArgumentParser(description=\"\"\"\n",
|
| 23 |
+
"\n",
|
| 24 |
+
"DESCRIPTION\n",
|
| 25 |
+
"\n",
|
| 26 |
+
"EXAMPLE:\n",
|
| 27 |
+
"\n",
|
| 28 |
+
" \"\"\", formatter_class= argparse.RawTextHelpFormatter)\n",
|
| 29 |
+
"\n",
|
| 30 |
+
"parser.add_argument('--fasta', '-f',\n",
|
| 31 |
+
" type= str,\n",
|
| 32 |
+
" help='''Input fasta file to search. Use '-' to read the file from stdin.\n",
|
| 33 |
+
" \n",
|
| 34 |
+
" ''',default='./seq.fasta',\n",
|
| 35 |
+
" required= True)\n",
|
| 36 |
+
"\n",
|
| 37 |
+
"parser.add_argument('--classifier',\n",
|
| 38 |
+
" required= False,\n",
|
| 39 |
+
" default= 'G4Boost_classifier.json',\n",
|
| 40 |
+
" help='''Use specified classifier (G4Boost_classifier.sav)\n",
|
| 41 |
+
" ''')\n",
|
| 42 |
+
"parser.add_argument('--regressor',\n",
|
| 43 |
+
" required= False,\n",
|
| 44 |
+
" default= 'G4Boost_regressor.json',\n",
|
| 45 |
+
" help='''Use specified classifier (G4Boost_regressor.sav)\n",
|
| 46 |
+
" ''')\n",
|
| 47 |
+
"parser.add_argument('--maxloop', '-N',\n",
|
| 48 |
+
" type= int,\n",
|
| 49 |
+
" required= False,\n",
|
| 50 |
+
" default= 12,\n",
|
| 51 |
+
" help='''Maximum length of the loop. Default is to report up to 12nt.\n",
|
| 52 |
+
" ''')\n",
|
| 53 |
+
"parser.add_argument('--minloop', '-n',\n",
|
| 54 |
+
" type= int,\n",
|
| 55 |
+
" required= False,\n",
|
| 56 |
+
" default= 1,\n",
|
| 57 |
+
" help='''Minimum length of the loop. Default is to report up to 1nt.\n",
|
| 58 |
+
" ''')\n",
|
| 59 |
+
"parser.add_argument('--maxG', '-G',\n",
|
| 60 |
+
" type= int,\n",
|
| 61 |
+
" required= False,\n",
|
| 62 |
+
" default= 7,\n",
|
| 63 |
+
" help='''Maximum number of consecutive G bases within a G-stem. Default is to report up to 7 Gs.\n",
|
| 64 |
+
" ''')\n",
|
| 65 |
+
"parser.add_argument('--minG', '-g',\n",
|
| 66 |
+
" type= int,\n",
|
| 67 |
+
" required= False,\n",
|
| 68 |
+
" default= 2,\n",
|
| 69 |
+
" help='''Maximum number of consecutive G bases within a G-stem. Default is to report up to 1 Gs.\n",
|
| 70 |
+
" ''')\n",
|
| 71 |
+
"parser.add_argument('--loops', '-l',\n",
|
| 72 |
+
" type= int,\n",
|
| 73 |
+
" required= False,\n",
|
| 74 |
+
" default= 11,\n",
|
| 75 |
+
" help='''Maximum number of flexible loops separating the G-stems. Default is to report up to 11 Gs.\n",
|
| 76 |
+
" ''')\n",
|
| 77 |
+
"\n",
|
| 78 |
+
"parser.add_argument('--noreverse',\n",
|
| 79 |
+
" action= 'store_true',\n",
|
| 80 |
+
" help='''Do not search the reverse complement of the input fasta.\n",
|
| 81 |
+
" ''')\n",
|
| 82 |
+
"\n",
|
| 83 |
+
"parser.add_argument('--quiet', '-q',\n",
|
| 84 |
+
" action= 'store_true',\n",
|
| 85 |
+
" help='''Do not print progress report (i.e. sequence names as they are scanned). \n",
|
| 86 |
+
" ''')\n",
|
| 87 |
+
"\n",
|
| 88 |
+
"parser.add_argument('--version', '-v', action='version', version='%(prog)s ' + VERSION)\n",
|
| 89 |
+
"args = parser.parse_args()\n",
|
| 90 |
+
"\n",
|
| 91 |
+
"\n",
|
| 92 |
+
"\" ------------------------------[ Functions ]--------------------------------- \"\n",
|
| 93 |
+
"\n",
|
| 94 |
+
"def sort_table(table, cols):\n",
|
| 95 |
+
" for col in reversed(cols):\n",
|
| 96 |
+
" table = sorted(table, key=operator.itemgetter(col))\n",
|
| 97 |
+
" return(table)\n",
|
| 98 |
+
"\n",
|
| 99 |
+
"\n",
|
| 100 |
+
"def chrom_name(header):\n",
|
| 101 |
+
" if not header.startswith('>'):\n",
|
| 102 |
+
"# raise Exception('FASTA header does not start with \">\":\\n%s' % header)\n",
|
| 103 |
+
" return 'noID'\n",
|
| 104 |
+
" chr= re.sub('^>\\s*', '', header)\n",
|
| 105 |
+
" chr= re.sub('\\s.*', '', chr)\n",
|
| 106 |
+
" return chr\n",
|
| 107 |
+
"\n",
|
| 108 |
+
"def revcomp(seq):\n",
|
| 109 |
+
" complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A', 'U': 'A', 'N': 'N'}\n",
|
| 110 |
+
" return \"\".join(complement.get(base, base) for base in reversed(seq))\n",
|
| 111 |
+
"\n",
|
| 112 |
+
"\n",
|
| 113 |
+
"def findall(seq, search):\n",
|
| 114 |
+
" count=-1\n",
|
| 115 |
+
" loc= 0\n",
|
| 116 |
+
" newloc=0\n",
|
| 117 |
+
" while newloc > -1:\n",
|
| 118 |
+
" newloc=seq[loc:].find(search)\n",
|
| 119 |
+
" loc=loc+newloc+1\n",
|
| 120 |
+
" count+=1\n",
|
| 121 |
+
" return count\n",
|
| 122 |
+
"\n",
|
| 123 |
+
"def initialize_dataFrame():\n",
|
| 124 |
+
" header=[\"seq\", \"seq_length\", \"g4motif\", 'maxgbase', 'maxgstem', \"length\", \"maxlbase\", \"minlbase\", \"G\", \"C\", \"GG\", \"CC\"]\n",
|
| 125 |
+
" data_dict={}\n",
|
| 126 |
+
" for h in header:\n",
|
| 127 |
+
" data_dict[h]=[]\n",
|
| 128 |
+
" return data_dict\n",
|
| 129 |
+
"\n",
|
| 130 |
+
"def topology(reg, seq):\n",
|
| 131 |
+
" split_seq=re.split(reg, seq)\n",
|
| 132 |
+
" if len(split_seq[-1])==0: gstem_base=split_seq[-2]\n",
|
| 133 |
+
" else: gstem_base=split_seq[-1]\n",
|
| 134 |
+
" g=len(gstem_base)\n",
|
| 135 |
+
" loops=[len(sp_seq)-g for sp_seq in split_seq]\n",
|
| 136 |
+
" loops=[lbase for lbase in loops if lbase>0]\n",
|
| 137 |
+
" maxlbase=max(loops)\n",
|
| 138 |
+
" minlbase=min(loops)\n",
|
| 139 |
+
" test=gstem_base\n",
|
| 140 |
+
" for sp_seq in split_seq:\n",
|
| 141 |
+
" if len(sp_seq)>g:\n",
|
| 142 |
+
" test+=sp_seq[g:].lower()\n",
|
| 143 |
+
" test+=gstem_base\n",
|
| 144 |
+
" return [test, len(test), len(loops)+1, g, maxlbase, minlbase]\n",
|
| 145 |
+
"\n",
|
| 146 |
+
"def update_dataFrame(features, reg, seq, ref):\n",
|
| 147 |
+
" [test, length, maxgstem, maxgbase, maxlbase, minlbase] = topology(reg, seq)\n",
|
| 148 |
+
" features['g4motif'].append(test)\n",
|
| 149 |
+
" features['length'].append(length)\n",
|
| 150 |
+
" features['seq_length'].append(len(ref))\n",
|
| 151 |
+
" features['maxgstem'].append(maxgstem)\n",
|
| 152 |
+
" features['maxgbase'].append(maxgbase)\n",
|
| 153 |
+
" features['maxlbase'].append(maxlbase)\n",
|
| 154 |
+
" features['minlbase'].append(minlbase)\n",
|
| 155 |
+
" features['G'].append(int(findall(ref,'G')*100/len(ref)))\n",
|
| 156 |
+
" features['GG'].append(int(findall(ref,'GG')*100/len(ref)))\n",
|
| 157 |
+
" features['C'].append(int(findall(ref,'C')*100/len(ref)))\n",
|
| 158 |
+
" features['CC'].append(int(findall(ref,'CC')*100/len(ref)))\n",
|
| 159 |
+
" return features\n",
|
| 160 |
+
"\n",
|
| 161 |
+
"\n",
|
| 162 |
+
"def findmotifs(reg, seq, start):\n",
|
| 163 |
+
" gquad_list=[]\n",
|
| 164 |
+
" for m in re.finditer(reg, seq):\n",
|
| 165 |
+
" seq= m.group(0)\n",
|
| 166 |
+
" quad_id= chrom + '_' + str(m.start()+start) + '_' + str(m.end()+start)\n",
|
| 167 |
+
" gquad_list.append([chrom, m.start()+start, m.end()+start, quad_id, len(m.group(0)), '+', seq])\n",
|
| 168 |
+
" return gquad_list\n",
|
| 169 |
+
"# -----------------------------------------------------------------------------\n",
|
| 170 |
+
"\n",
|
| 171 |
+
"\n",
|
| 172 |
+
"if args.fasta != '-':\n",
|
| 173 |
+
" ref_seq_fh= open(args.fasta)\n",
|
| 174 |
+
" output= args.fasta+'.gff'\n",
|
| 175 |
+
"else:\n",
|
| 176 |
+
" ref_seq_fh= sys.stdin\n",
|
| 177 |
+
" output='G4Boost_quadruplexes.gff'\n",
|
| 178 |
+
"\n",
|
| 179 |
+
"# ref_seq=[]\n",
|
| 180 |
+
"# line= ref_seq_fh.readline()\n",
|
| 181 |
+
"# if chrom != 'noID': line= ref_seq_fh.readline()\n",
|
| 182 |
+
"# else: chrom = line.strip()\n",
|
| 183 |
+
"\n",
|
| 184 |
+
"\n"
|
| 185 |
+
]
|
| 186 |
+
},
|
| 187 |
+
{
|
| 188 |
+
"cell_type": "code",
|
| 189 |
+
"execution_count": 4,
|
| 190 |
+
"metadata": {},
|
| 191 |
+
"outputs": [],
|
| 192 |
+
"source": [
|
| 193 |
+
"\n",
|
| 194 |
+
"import re\n",
|
| 195 |
+
"import sys\n",
|
| 196 |
+
"import string\n",
|
| 197 |
+
"import argparse\n",
|
| 198 |
+
"import operator\n",
|
| 199 |
+
"import pandas as pd\n",
|
| 200 |
+
"import xgboost as xgb\n",
|
| 201 |
+
"import numpy as np\n",
|
| 202 |
+
"\n",
|
| 203 |
+
"def predict(seqs,):\n",
|
| 204 |
+
" gquad_list= []\n",
|
| 205 |
+
"# eof= False\n",
|
| 206 |
+
"\n",
|
| 207 |
+
"\n",
|
| 208 |
+
"\n",
|
| 209 |
+
"#if args.fasta != '-': output= args.fasta+'.gff'\n",
|
| 210 |
+
"#else: output = 'G4Boost_quadruplexes.gff'\n",
|
| 211 |
+
"#out=open(output, 'w')\n",
|
| 212 |
+
"\n",
|
| 213 |
+
"\n",
|
| 214 |
+
" sys.stderr.write('Starting stability prediction!\\n\\n')\n",
|
| 215 |
+
" regressor = xgb.XGBRegressor()\n",
|
| 216 |
+
" classifier = xgb.XGBClassifier()\n",
|
| 217 |
+
" regressor.load_model(args.regressor)\n",
|
| 218 |
+
" classifier.load_model(args.classifier)\n",
|
| 219 |
+
" preds = []\n",
|
| 220 |
+
" all_features = []\n",
|
| 221 |
+
" for i in range(len(seqs)):\n",
|
| 222 |
+
" chrom = str(i)\n",
|
| 223 |
+
" gb=range(args.minG, args.maxG+1)[::-1]\n",
|
| 224 |
+
" gs=range(3, args.loops+1)[::-1]\n",
|
| 225 |
+
" longest = (args.maxG + args.maxloop) * args.loops + args.maxG\n",
|
| 226 |
+
" features=initialize_dataFrame()\n",
|
| 227 |
+
" ref_seq = seqs[i]\n",
|
| 228 |
+
" # ref_seq= ''.join(ref_seq)\n",
|
| 229 |
+
" ref_seq=ref_seq.upper().replace('U', 'T')\n",
|
| 230 |
+
" rev_ref_seq=revcomp(ref_seq)\n",
|
| 231 |
+
" seqlen= len(ref_seq)\n",
|
| 232 |
+
" for g in gb:\n",
|
| 233 |
+
" for s in gs:\n",
|
| 234 |
+
" gstem_base=''\n",
|
| 235 |
+
" for i in range(g): gstem_base+=\"G\"\n",
|
| 236 |
+
" reg=\"\"\n",
|
| 237 |
+
" for i in range(s): reg+='([gG]{%d}\\w{%d,%d})' % (g , args.minloop, args.maxloop)\n",
|
| 238 |
+
" reg+='([gG]{%d})' % (g)\n",
|
| 239 |
+
" for m in re.finditer(reg, ref_seq):\n",
|
| 240 |
+
" seq= m.group(0)\n",
|
| 241 |
+
" start=m.start()\n",
|
| 242 |
+
" end=m.end()\n",
|
| 243 |
+
" if len(ref_seq) > longest: ref = seq\n",
|
| 244 |
+
" else: ref = ref_seq\n",
|
| 245 |
+
" quad_id= chrom + '_' + str(m.start()) + '_' + str(m.end())\n",
|
| 246 |
+
" gquad_list.append([chrom, start, end, quad_id, len(seq), '+', seq])\n",
|
| 247 |
+
" if seq not in features['g4motif']:\n",
|
| 248 |
+
" features = update_dataFrame(features, reg, seq, ref)\n",
|
| 249 |
+
" features['seq'].append(chrom)\n",
|
| 250 |
+
" temp=''\n",
|
| 251 |
+
" for i in range(start,end): temp+='N'\n",
|
| 252 |
+
" ref_seq=ref_seq[:start]+temp+ref_seq[end:]\n",
|
| 253 |
+
" if args.noreverse is False:\n",
|
| 254 |
+
" for m in re.finditer(reg, rev_ref_seq):\n",
|
| 255 |
+
" seq= m.group(0)\n",
|
| 256 |
+
" start=m.start()\n",
|
| 257 |
+
" end=m.end()\n",
|
| 258 |
+
" if len(rev_ref_seq) > longest: ref = seq\n",
|
| 259 |
+
" else: ref = rev_ref_seq\n",
|
| 260 |
+
" quad_id= chrom + '_' + str(m.start()) + '_' + str(m.end())\n",
|
| 261 |
+
" gquad_list.append([chrom, seqlen-end, seqlen-start, quad_id, len(seq), '-', seq])\n",
|
| 262 |
+
" if seq not in features['g4motif']:\n",
|
| 263 |
+
" features = update_dataFrame(features, reg, seq, ref)\n",
|
| 264 |
+
" features['seq'].append(chrom)\n",
|
| 265 |
+
" temp=''\n",
|
| 266 |
+
" for i in range(start,end): temp+='N'\n",
|
| 267 |
+
" rev_ref_seq=rev_ref_seq[:start]+temp+rev_ref_seq[end:]\n",
|
| 268 |
+
" gquad_sorted= sort_table(gquad_list, (1,2,3))\n",
|
| 269 |
+
" gquad_list= []\n",
|
| 270 |
+
" for xline in gquad_sorted:\n",
|
| 271 |
+
" xline= '\\t'.join([str(x) for x in xline])\n",
|
| 272 |
+
" with open(output, 'a') as out: out.write(xline+'\\n')\n",
|
| 273 |
+
"\n",
|
| 274 |
+
"\n",
|
| 275 |
+
" #---------------\n",
|
| 276 |
+
"\n",
|
| 277 |
+
"\n",
|
| 278 |
+
"\n",
|
| 279 |
+
"\n",
|
| 280 |
+
" selected=[\"seq_length\", \"length\", \"maxgstem\" ,\"maxgbase\", \"maxlbase\", \"minlbase\", \"G\", \"C\", \"GG\", \"CC\"]\n",
|
| 281 |
+
" # print(features)\n",
|
| 282 |
+
" # del features['G-quartet']\n",
|
| 283 |
+
" # del features['loops']\n",
|
| 284 |
+
" features=pd.DataFrame.from_dict(features)\n",
|
| 285 |
+
" X_test = features[selected]\n",
|
| 286 |
+
"\n",
|
| 287 |
+
" X_test.columns = [\"length\", \"len\", \"maxgstem\", \"maxgbase\", \"maxlbase\", \"minlbase\", \"G\", \"C\", \"GG\", \"CC\"]\n",
|
| 288 |
+
"\n",
|
| 289 |
+
" # print(X_test)\n",
|
| 290 |
+
"\n",
|
| 291 |
+
"\n",
|
| 292 |
+
" # X_test=xgb.DMatrix(X_test)\n",
|
| 293 |
+
" g4_pred=classifier.predict(X_test)\n",
|
| 294 |
+
" if len(g4_pred) < 1:\n",
|
| 295 |
+
" preds.append(0)\n",
|
| 296 |
+
" else:\n",
|
| 297 |
+
" g4_pred_proba=classifier.predict_proba(X_test)[:, 1]\n",
|
| 298 |
+
" mfe_pred = regressor.predict(X_test)\n",
|
| 299 |
+
" if np.max(g4_pred_proba) < 0.5:\n",
|
| 300 |
+
" preds.append(0)\n",
|
| 301 |
+
" else:\n",
|
| 302 |
+
" preds.append(1)\n",
|
| 303 |
+
" # features['g4_pred']=g4_pred\n",
|
| 304 |
+
" # features['g4_prob']=g4_pred_proba\n",
|
| 305 |
+
" # features['mfe_pred']=mfe_pred\n",
|
| 306 |
+
" # features['maxgstem']=[l-1 for l in features['maxgstem']]\n",
|
| 307 |
+
"\n",
|
| 308 |
+
" # if args.fasta != '-': output= args.fasta+'.g4scores.csv'\n",
|
| 309 |
+
" # else: output = 'G4Boost_quadruplexes.g4.csv'\n",
|
| 310 |
+
" # features.to_csv(output,sep='\\t',index=False)\n",
|
| 311 |
+
"\n",
|
| 312 |
+
"\n",
|
| 313 |
+
" # print(float(np.sum(preds))/len(preds))\n",
|
| 314 |
+
" return preds"
|
| 315 |
+
]
|
| 316 |
+
},
|
| 317 |
+
{
|
| 318 |
+
"cell_type": "code",
|
| 319 |
+
"execution_count": 5,
|
| 320 |
+
"metadata": {},
|
| 321 |
+
"outputs": [],
|
| 322 |
+
"source": [
|
| 323 |
+
"from Bio import SeqIO\n",
|
| 324 |
+
"import pandas as pd\n",
|
| 325 |
+
"import sys\n",
|
| 326 |
+
"\n",
|
| 327 |
+
"# read generated\n",
|
| 328 |
+
"lines = []\n",
|
| 329 |
+
"for record in SeqIO.parse('/data4/sina/UTR/MEME/1024_10000_init.fasta','fasta'):\n",
|
| 330 |
+
" lines.append(str(record.seq))\n",
|
| 331 |
+
"\n",
|
| 332 |
+
"mut_inits = []\n",
|
| 333 |
+
"for i in range(len(lines)):\n",
|
| 334 |
+
" mut_inits.append(lines[i].replace('\\n','')[:50])\n",
|
| 335 |
+
"\n",
|
| 336 |
+
"\n",
|
| 337 |
+
"# read optimus\n",
|
| 338 |
+
"optimus = []\n",
|
| 339 |
+
"for record in SeqIO.parse('/data4/sina/UTR/MEME/optimus_fasta.fasta','fasta'):\n",
|
| 340 |
+
" optimus.append(str(record.seq))\n",
|
| 341 |
+
"\n",
|
| 342 |
+
"\n",
|
| 343 |
+
"# read generated\n",
|
| 344 |
+
"inits = []\n",
|
| 345 |
+
"for record in SeqIO.parse('/data4/sina/UTR/MEME/1024_10000_init.fasta','fasta'):\n",
|
| 346 |
+
" inits.append(str(record.seq))\n",
|
| 347 |
+
"\n",
|
| 348 |
+
"opts = []\n",
|
| 349 |
+
"for record in SeqIO.parse('/data4/sina/UTR/MEME/1024_10000_opt.fasta','fasta'):\n",
|
| 350 |
+
" opts.append(str(record.seq))\n",
|
| 351 |
+
"\n",
|
| 352 |
+
"\n",
|
| 353 |
+
"# read natural:\n",
|
| 354 |
+
"df = pd.read_csv('./../UTRGAN/data/utrdb2.csv')\n",
|
| 355 |
+
"df = df['seq'].to_numpy()\n",
|
| 356 |
+
"nats = []\n",
|
| 357 |
+
"for i in range(len(df)):\n",
|
| 358 |
+
" if len(df[i])< 129 and len(df[i]) > 64:\n",
|
| 359 |
+
" nats.append(df[i].replace('T','U'))"
|
| 360 |
+
]
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
"cell_type": "code",
|
| 364 |
+
"execution_count": 6,
|
| 365 |
+
"metadata": {},
|
| 366 |
+
"outputs": [
|
| 367 |
+
{
|
| 368 |
+
"name": "stderr",
|
| 369 |
+
"output_type": "stream",
|
| 370 |
+
"text": [
|
| 371 |
+
"Starting stability prediction!\n",
|
| 372 |
+
"\n",
|
| 373 |
+
"/var/anaconda3/envs/tf25/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: [12:44:31] WARNING: /croot/xgboost-split_1713972711803/work/cpp_src/src/learner.cc:873: Found JSON model saved before XGBoost 1.6, please save the model using current version again. The support for old JSON model will be discontinued in XGBoost 2.3.\n",
|
| 374 |
+
" warnings.warn(smsg, UserWarning)\n",
|
| 375 |
+
"/var/anaconda3/envs/tf25/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: [12:44:32] WARNING: /croot/xgboost-split_1713972711803/work/cpp_src/src/learner.cc:873: Found JSON model saved before XGBoost 1.6, please save the model using current version again. The support for old JSON model will be discontinued in XGBoost 2.3.\n",
|
| 376 |
+
" warnings.warn(smsg, UserWarning)\n",
|
| 377 |
+
"Starting stability prediction!\n",
|
| 378 |
+
"\n",
|
| 379 |
+
"/var/anaconda3/envs/tf25/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: [12:54:47] WARNING: /croot/xgboost-split_1713972711803/work/cpp_src/src/learner.cc:873: Found JSON model saved before XGBoost 1.6, please save the model using current version again. The support for old JSON model will be discontinued in XGBoost 2.3.\n",
|
| 380 |
+
" warnings.warn(smsg, UserWarning)\n",
|
| 381 |
+
"Starting stability prediction!\n",
|
| 382 |
+
"\n",
|
| 383 |
+
"/var/anaconda3/envs/tf25/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: [12:55:05] WARNING: /croot/xgboost-split_1713972711803/work/cpp_src/src/learner.cc:873: Found JSON model saved before XGBoost 1.6, please save the model using current version again. The support for old JSON model will be discontinued in XGBoost 2.3.\n",
|
| 384 |
+
" warnings.warn(smsg, UserWarning)\n",
|
| 385 |
+
"Starting stability prediction!\n",
|
| 386 |
+
"\n",
|
| 387 |
+
"/var/anaconda3/envs/tf25/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: [12:55:24] WARNING: /croot/xgboost-split_1713972711803/work/cpp_src/src/learner.cc:873: Found JSON model saved before XGBoost 1.6, please save the model using current version again. The support for old JSON model will be discontinued in XGBoost 2.3.\n",
|
| 388 |
+
" warnings.warn(smsg, UserWarning)\n",
|
| 389 |
+
"Starting stability prediction!\n",
|
| 390 |
+
"\n",
|
| 391 |
+
"/var/anaconda3/envs/tf25/lib/python3.10/site-packages/xgboost/core.py:160: UserWarning: [12:55:33] WARNING: /croot/xgboost-split_1713972711803/work/cpp_src/src/learner.cc:873: Found JSON model saved before XGBoost 1.6, please save the model using current version again. The support for old JSON model will be discontinued in XGBoost 2.3.\n",
|
| 392 |
+
" warnings.warn(smsg, UserWarning)\n"
|
| 393 |
+
]
|
| 394 |
+
}
|
| 395 |
+
],
|
| 396 |
+
"source": [
|
| 397 |
+
"nat_pred = predict(nats)\n",
|
| 398 |
+
"init_pred = predict(inits)\n",
|
| 399 |
+
"opt_pred = predict(opts)\n",
|
| 400 |
+
"optimus_pred = predict(optimus)\n",
|
| 401 |
+
"mut_init_pred = predict(mut_inits)"
|
| 402 |
+
]
|
| 403 |
+
},
|
| 404 |
+
{
|
| 405 |
+
"cell_type": "code",
|
| 406 |
+
"execution_count": 7,
|
| 407 |
+
"metadata": {},
|
| 408 |
+
"outputs": [
|
| 409 |
+
{
|
| 410 |
+
"name": "stdout",
|
| 411 |
+
"output_type": "stream",
|
| 412 |
+
"text": [
|
| 413 |
+
"236.76727819548873\n",
|
| 414 |
+
"209\n",
|
| 415 |
+
"199\n",
|
| 416 |
+
"16\n",
|
| 417 |
+
"162\n"
|
| 418 |
+
]
|
| 419 |
+
}
|
| 420 |
+
],
|
| 421 |
+
"source": [
|
| 422 |
+
"print(np.sum(nat_pred)/len(nat_pred)*1024.)\n",
|
| 423 |
+
"print(np.sum(init_pred))\n",
|
| 424 |
+
"print(np.sum(opt_pred))\n",
|
| 425 |
+
"print(np.sum(optimus_pred))\n",
|
| 426 |
+
"print(np.sum(mut_init_pred))"
|
| 427 |
+
]
|
| 428 |
+
}
|
| 429 |
+
],
|
| 430 |
+
"metadata": {
|
| 431 |
+
"kernelspec": {
|
| 432 |
+
"display_name": "tf25",
|
| 433 |
+
"language": "python",
|
| 434 |
+
"name": "python3"
|
| 435 |
+
},
|
| 436 |
+
"language_info": {
|
| 437 |
+
"codemirror_mode": {
|
| 438 |
+
"name": "ipython",
|
| 439 |
+
"version": 3
|
| 440 |
+
},
|
| 441 |
+
"file_extension": ".py",
|
| 442 |
+
"mimetype": "text/x-python",
|
| 443 |
+
"name": "python",
|
| 444 |
+
"nbconvert_exporter": "python",
|
| 445 |
+
"pygments_lexer": "ipython3",
|
| 446 |
+
"version": "3.10.11"
|
| 447 |
+
}
|
| 448 |
+
},
|
| 449 |
+
"nbformat": 4,
|
| 450 |
+
"nbformat_minor": 2
|
| 451 |
+
}
|
conf/analysis/align/mut_inits.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b4defe5aaf89c16f10cea7e90f3037e896bbbb4b572afdaebac1438a412aa726
|
| 3 |
+
size 8320
|
conf/analysis/align/seq_init.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:efaa32e7cbf675db8218633a8fab7fc73c4f050ac6ee2fe36edace02353c1326
|
| 3 |
+
size 640
|
conf/analysis/align/seq_mutated.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7e4d39a4eb211f507b4c13a765408cb5e988a69c65dd79ce492cb7a64237a04b
|
| 3 |
+
size 8320
|
conf/analysis/align/seq_opt.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fd28b83a5c3d4a43e4bfc0173ea6322a7760e1bb5947803a6f0f8ac9aa1ea03d
|
| 3 |
+
size 640
|
conf/analysis/files/gen_4mer_new.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3019b9b6e6494f58f219d36e32057046b6562ce91163e90b90543798af958edb
|
| 3 |
+
size 4224
|
conf/analysis/files/gen_ham_new.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:863ff673d30298635c6c9811045748dbdc0c41c784365bf93823cbb5205a1d52
|
| 3 |
+
size 16512
|
conf/analysis/files/opt_4mer_new.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:cad973fbfcec1714669b0eb77ca9e88eb172bf49ac13a174c7ffda9835fe7139
|
| 3 |
+
size 8320
|
conf/analysis/files/opt_ham_new.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a4bb77a899716eaf15d8a849558195574d86b0ef672ec544a9f67b5da4c0849f
|
| 3 |
+
size 8320
|
conf/analysis/files/rand_4mer_new.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:567b6ec5148cff4676f246450656cf821e8614181a197897b7503b8b13f30153
|
| 3 |
+
size 4224
|
conf/analysis/files/rand_ham_new.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b682a172394378c81d433766374f0cac005591113476b50340faff18606f9079
|
| 3 |
+
size 16512
|
conf/analysis/files/real_4mer_new.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ba1484b28c87d4145476af7e31e6b0d4bd17d29c38fc0bddf598e25f28ebc2b9
|
| 3 |
+
size 4224
|
conf/analysis/files/real_ham_new.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e4a0c44f28a53700e74655d71303158df9c3491fa2fb91cdb2bc8f8ec067bc1e
|
| 3 |
+
size 16512
|
conf/analysis/files/te_gens.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5123558dca0ee55109001effc674d49a24a4e9ac6ad4414312b4c963cb7c75c5
|
| 3 |
+
size 8320
|
conf/analysis/files/te_optimized.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:965402fd8be6ae2b52f6247524dc5987fe34f098482a73be0b02ff9e37764cfa
|
| 3 |
+
size 4224
|
conf/analysis/files/te_optimus.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f6af8f80b7dd9b17ada1e83234e19a105321b5b3f3fb1e79ef99ac1e14a0469a
|
| 3 |
+
size 4224
|
conf/analysis/files/te_rands.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9afb713954378a127aa7d223bbd2d7c2547d5a4f4faaf5cd0fd68f4f6de7808e
|
| 3 |
+
size 8320
|
conf/analysis/files/te_reals.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:185aadd3b234d3735d198ea1a0adc1b741396c6b09b62cab9054000d5b88f1ed
|
| 3 |
+
size 133128
|
conf/analysis/mrl_te_opt.py
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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c5068", "#acbab6", "#dcd3cd", "#d4a6a6"]
|
| 11 |
+
|
| 12 |
+
params = {'legend.fontsize': 32,
|
| 13 |
+
'figure.figsize': (32, 10),
|
| 14 |
+
'axes.labelsize': 34,
|
| 15 |
+
'axes.titlesize':34,
|
| 16 |
+
'xtick.labelsize':34,
|
| 17 |
+
'ytick.labelsize':24}
|
| 18 |
+
|
| 19 |
+
#POSTER
|
| 20 |
+
params = {'legend.fontsize': 50,
|
| 21 |
+
'figure.figsize': (54, 18),
|
| 22 |
+
'axes.labelsize': 60,
|
| 23 |
+
'axes.titlesize':60,
|
| 24 |
+
'xtick.labelsize':60,
|
| 25 |
+
'ytick.labelsize':36}
|
| 26 |
+
|
| 27 |
+
plt.rcParams.update(params)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
np.random.seed(25)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
DISPLAY_DIFF = True
|
| 34 |
+
|
| 35 |
+
K = 100
|
| 36 |
+
|
| 37 |
+
PREFIX = ''
|
| 38 |
+
|
| 39 |
+
# MRL, TE
|
| 40 |
+
|
| 41 |
+
TYPE = 'MRL'
|
| 42 |
+
|
| 43 |
+
DISPLAY_DIFF = True
|
| 44 |
+
|
| 45 |
+
if TYPE == 'REGULAR':
|
| 46 |
+
PREFIX = 'outputs/'
|
| 47 |
+
elif TYPE == 'MIXED':
|
| 48 |
+
PREFIX = 'outputs_mixed/'
|
| 49 |
+
elif TYPE == 'GC_CONTROLED':
|
| 50 |
+
PREFIX = 'outputs/gc_'
|
| 51 |
+
|
| 52 |
+
if DISPLAY_DIFF:
|
| 53 |
+
TYPE = 'MMRL'
|
| 54 |
+
TITLE = "A"
|
| 55 |
+
|
| 56 |
+
init = []
|
| 57 |
+
with open(f'./../src/mrl_te_optimization/outputs/init_mrl_FMRL.txt') as f:
|
| 58 |
+
scores = f.readlines()
|
| 59 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 60 |
+
|
| 61 |
+
opt = []
|
| 62 |
+
with open(f'./../src/mrl_te_optimization/outputs/opt_mrl_FMRL.txt') as f:
|
| 63 |
+
scores = f.readlines()
|
| 64 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
init = np.array(init)
|
| 68 |
+
opt = np.array(opt)
|
| 69 |
+
|
| 70 |
+
diffs = (opt - init)/init
|
| 71 |
+
|
| 72 |
+
print("FramePool MRL optimization:")
|
| 73 |
+
print(f"Average Opt: {np.average(opt)}")
|
| 74 |
+
print(f"Average Init: {np.average(init)}")
|
| 75 |
+
print(f"Max Opt: {np.max(opt)}")
|
| 76 |
+
print(f"Max Init: {np.max(init)}")
|
| 77 |
+
print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
|
| 78 |
+
print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
|
| 79 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")
|
| 80 |
+
|
| 81 |
+
indices = np.argsort(opt)[::-1]
|
| 82 |
+
|
| 83 |
+
init_large = []
|
| 84 |
+
init_small = []
|
| 85 |
+
opt_large = []
|
| 86 |
+
opt_small = []
|
| 87 |
+
|
| 88 |
+
for i in range(len(indices)):
|
| 89 |
+
if diffs[indices[i]] >= 0:
|
| 90 |
+
init_small.append(init[indices[i]])
|
| 91 |
+
init_large.append(0)
|
| 92 |
+
opt_small.append(0)
|
| 93 |
+
opt_large.append(opt[indices[i]])
|
| 94 |
+
else:
|
| 95 |
+
init_large.append(init[indices[i]])
|
| 96 |
+
init_small.append(0)
|
| 97 |
+
opt_large.append(0)
|
| 98 |
+
opt_small.append(opt[indices[i]])
|
| 99 |
+
|
| 100 |
+
width = 1.0/(len(indices))
|
| 101 |
+
bins = [(i+1) * width for i in range(len(indices))]
|
| 102 |
+
|
| 103 |
+
ns = [i * width for i in range(len(indices))]
|
| 104 |
+
fig, axs = plt.subplots(1,2)
|
| 105 |
+
|
| 106 |
+
axs[0].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
|
| 107 |
+
axs[0].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
|
| 108 |
+
axs[0].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
|
| 109 |
+
axs[0].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
|
| 110 |
+
|
| 111 |
+
axs[0].set_title(TITLE,loc='left',weight='bold',fontsize=64)
|
| 112 |
+
axs[0].set_xticks([])
|
| 113 |
+
|
| 114 |
+
TYPE = "FMRL"
|
| 115 |
+
TITLE = "B"
|
| 116 |
+
|
| 117 |
+
init = []
|
| 118 |
+
|
| 119 |
+
with open(f'./../src/mrl_te_optimization/outputs/init_mrl_TE.txt') as f:
|
| 120 |
+
scores = f.readlines()
|
| 121 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 122 |
+
|
| 123 |
+
opt = []
|
| 124 |
+
with open(f'./../src/mrl_te_optimization/outputs/opt_mrl_TE.txt') as f:
|
| 125 |
+
scores = f.readlines()
|
| 126 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
init = np.power(10,init)
|
| 130 |
+
init = np.array(init)
|
| 131 |
+
opt = np.power(10,opt)
|
| 132 |
+
opt = np.array(opt)
|
| 133 |
+
|
| 134 |
+
diffs = (opt - init)/init
|
| 135 |
+
|
| 136 |
+
print("MTtrans 3R TE optimization:")
|
| 137 |
+
print(f"Average Opt: {np.average(opt)}")
|
| 138 |
+
print(f"Average Init: {np.average(init)}")
|
| 139 |
+
print(f"Max Opt: {np.max(opt)}")
|
| 140 |
+
print(f"Max Init: {np.max(init)}")
|
| 141 |
+
print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
|
| 142 |
+
print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
|
| 143 |
+
print(f"Max Increase (wrt Natural) : {np.max(opt/np.power(10,-0.63))}")
|
| 144 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")
|
| 145 |
+
|
| 146 |
+
indices = np.argsort(opt)[::-1]
|
| 147 |
+
|
| 148 |
+
init_large = []
|
| 149 |
+
init_small = []
|
| 150 |
+
opt_large = []
|
| 151 |
+
opt_small = []
|
| 152 |
+
|
| 153 |
+
for i in range(len(indices)):
|
| 154 |
+
if diffs[indices[i]] >= 0:
|
| 155 |
+
init_small.append(init[indices[i]])
|
| 156 |
+
init_large.append(0)
|
| 157 |
+
opt_small.append(0)
|
| 158 |
+
opt_large.append(opt[indices[i]])
|
| 159 |
+
else:
|
| 160 |
+
init_large.append(init[indices[i]])
|
| 161 |
+
init_small.append(0)
|
| 162 |
+
opt_large.append(0)
|
| 163 |
+
opt_small.append(opt[indices[i]])
|
| 164 |
+
|
| 165 |
+
axs[1].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
|
| 166 |
+
axs[1].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
|
| 167 |
+
axs[1].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
|
| 168 |
+
axs[1].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
|
| 169 |
+
axs[1].set_title(TITLE,loc='left',weight='bold',fontsize=64)
|
| 170 |
+
axs[1].set_xticks([])
|
| 171 |
+
|
| 172 |
+
orange_patch = mpatches.Patch(color=colors[3], label='Initial')
|
| 173 |
+
blue_patch = mpatches.Patch(color=colors[0], label='Optimized')
|
| 174 |
+
fig.legend(handles=[orange_patch,blue_patch],loc='upper right')
|
| 175 |
+
|
| 176 |
+
axs[0].set_ylabel('Predicted MRL')
|
| 177 |
+
axs[1].set_ylabel('Predicted TE')
|
| 178 |
+
|
| 179 |
+
axs[0].set_xlabel('UTR Samples')
|
| 180 |
+
axs[1].set_xlabel('UTR Samples')
|
| 181 |
+
|
| 182 |
+
fig.tight_layout()
|
| 183 |
+
|
| 184 |
+
plt.savefig(f'./plots/mrl_te_all.png')
|
| 185 |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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import matplotlib.pyplot as plt
|
| 3 |
+
import matplotlib.patches as mpatches
|
| 4 |
+
import seaborn as sns
|
| 5 |
+
import os
|
| 6 |
+
import argparse
|
| 7 |
+
sns.set()
|
| 8 |
+
sns.set_style('ticks')
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
params = {'legend.fontsize': 50,
|
| 12 |
+
'figure.figsize': (54, 27),
|
| 13 |
+
'axes.labelsize': 60,
|
| 14 |
+
'axes.titlesize':60,
|
| 15 |
+
'xtick.labelsize':60,
|
| 16 |
+
'ytick.labelsize':36}
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
plt.rcParams.update(params)
|
| 20 |
+
|
| 21 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = '2'
|
| 22 |
+
|
| 23 |
+
fig, axs = plt.subplots(2,3)
|
| 24 |
+
|
| 25 |
+
colors = ["#3c5068", "#acbab6", "#dcd3cd", "#d4a6a6"]
|
| 26 |
+
|
| 27 |
+
init = []
|
| 28 |
+
with open(f'./../src/mrl_te_optimization/outputs/init_mrl_TE.txt') as f:
|
| 29 |
+
scores = f.readlines()
|
| 30 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 31 |
+
|
| 32 |
+
opt = []
|
| 33 |
+
with open(f'./../src/mrl_te_optimization/outputs/opt_mrl_TE.txt') as f:
|
| 34 |
+
scores = f.readlines()
|
| 35 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 36 |
+
|
| 37 |
+
init = np.array(init)
|
| 38 |
+
opt = np.array(opt)
|
| 39 |
+
|
| 40 |
+
init = np.power(10,init)
|
| 41 |
+
opt = np.power(10,opt)
|
| 42 |
+
|
| 43 |
+
SORT_INIT = False
|
| 44 |
+
|
| 45 |
+
if SORT_INIT:
|
| 46 |
+
|
| 47 |
+
min_init_indices = np.argsort(init)
|
| 48 |
+
init = init[min_init_indices[:min(int(len(init)),100)]]
|
| 49 |
+
opt = opt[min_init_indices[:min(int(len(opt)),100)]]
|
| 50 |
+
else:
|
| 51 |
+
init = init[:min(int(len(init)),100)]
|
| 52 |
+
opt = opt[:min(int(len(opt)),100)]
|
| 53 |
+
|
| 54 |
+
diffs = [(opt[i]-init[i]) for i in range(len(init))]
|
| 55 |
+
|
| 56 |
+
count = 0
|
| 57 |
+
for i in range(len(diffs)):
|
| 58 |
+
if diffs[i] < 0:
|
| 59 |
+
count += 1
|
| 60 |
+
|
| 61 |
+
print(count)
|
| 62 |
+
|
| 63 |
+
print(np.average(init))
|
| 64 |
+
print(np.average(opt))
|
| 65 |
+
print(np.max(diffs/init))
|
| 66 |
+
print(np.average(diffs/init))
|
| 67 |
+
|
| 68 |
+
indices_sorted = np.argsort(diffs)[::-1]
|
| 69 |
+
|
| 70 |
+
diffs = np.sort(diffs)[::-1]
|
| 71 |
+
|
| 72 |
+
new_inits = []
|
| 73 |
+
|
| 74 |
+
for i in range(len(diffs)):
|
| 75 |
+
new_inits.append(init[indices_sorted[i]])
|
| 76 |
+
|
| 77 |
+
N = min(100, len(diffs))
|
| 78 |
+
|
| 79 |
+
step = 1.0/N
|
| 80 |
+
|
| 81 |
+
new_n = [i * step for i in range(N)]
|
| 82 |
+
|
| 83 |
+
width = step
|
| 84 |
+
|
| 85 |
+
plt.rcParams.update({'font.size': 12})
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
print(len(diffs))
|
| 89 |
+
|
| 90 |
+
axs[0,1].bar(x=new_n, bottom=0, width=width, height=diffs,color=colors[0])
|
| 91 |
+
axs[0,1].set_xticks([])
|
| 92 |
+
axs[0,1].set_ylabel('TE Change')
|
| 93 |
+
axs[0,1].set_title('B',weight='bold',fontsize=60,loc='left')
|
| 94 |
+
|
| 95 |
+
axs[1,1].bar(x=new_n, bottom=0, width=width, height=new_inits,color=colors[3])
|
| 96 |
+
axs[1,1].set_xticks([])
|
| 97 |
+
axs[1,1].set_xlabel('UTR Samples')
|
| 98 |
+
axs[1,1].set_ylabel('Initial TE')
|
| 99 |
+
axs[1,1].set_title('E',weight='bold',fontsize=60,loc='left')
|
| 100 |
+
|
| 101 |
+
init = []
|
| 102 |
+
with open('./../src/exp_optimization/outputs/mul_init_exps.txt') as f:
|
| 103 |
+
scores = f.readlines()
|
| 104 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 105 |
+
|
| 106 |
+
opt = []
|
| 107 |
+
with open('./../src/exp_optimization/outputs/mul_opt_exps.txt') as f:
|
| 108 |
+
scores = f.readlines()
|
| 109 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 110 |
+
|
| 111 |
+
init = np.array(init)
|
| 112 |
+
opt = np.array(opt)
|
| 113 |
+
|
| 114 |
+
init = np.power(10,init)
|
| 115 |
+
opt = np.power(10,opt)
|
| 116 |
+
|
| 117 |
+
print(np.average(init))
|
| 118 |
+
print(np.average(opt))
|
| 119 |
+
|
| 120 |
+
SORT_INIT = True
|
| 121 |
+
|
| 122 |
+
if SORT_INIT:
|
| 123 |
+
|
| 124 |
+
min_init_indices = np.argsort(init)
|
| 125 |
+
init = init[min_init_indices[:min(int(len(init)),100)]]
|
| 126 |
+
opt = opt[min_init_indices[:min(int(len(opt)),100)]]
|
| 127 |
+
else:
|
| 128 |
+
init = init[:min(int(len(init)),100)]
|
| 129 |
+
opt = opt[:min(int(len(opt)),100)]
|
| 130 |
+
|
| 131 |
+
diffs = [(opt[i]-init[i]) for i in range(len(init))]
|
| 132 |
+
|
| 133 |
+
count = 0
|
| 134 |
+
for i in range(len(diffs)):
|
| 135 |
+
if diffs[i] < 0:
|
| 136 |
+
count += 1
|
| 137 |
+
|
| 138 |
+
print(count)
|
| 139 |
+
|
| 140 |
+
print(np.mean(diffs/init))
|
| 141 |
+
# print(diffs)
|
| 142 |
+
|
| 143 |
+
indices_sorted = np.argsort(diffs)[::-1]
|
| 144 |
+
|
| 145 |
+
print(f"Average Opt: {np.average(opt)}")
|
| 146 |
+
print(f"Average Init: {np.average(init)}")
|
| 147 |
+
print(f"Max Opt: {np.max(opt)}")
|
| 148 |
+
print(f"Max Init: {np.max(init)}")
|
| 149 |
+
print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
|
| 150 |
+
print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
|
| 151 |
+
print(f"Max Increase (wrt Natural) : {np.max(opt/np.power(10,-0.63))}")
|
| 152 |
+
|
| 153 |
+
diffs = (opt - init)/init
|
| 154 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")
|
| 155 |
+
|
| 156 |
+
print(np.max(diffs/init))
|
| 157 |
+
|
| 158 |
+
new_inits = []
|
| 159 |
+
|
| 160 |
+
for i in range(len(diffs)):
|
| 161 |
+
new_inits.append(init[indices_sorted[i]])
|
| 162 |
+
|
| 163 |
+
N = min(100, len(diffs))
|
| 164 |
+
|
| 165 |
+
step = 1.0/N
|
| 166 |
+
|
| 167 |
+
new_n = [i * step for i in range(N)]
|
| 168 |
+
|
| 169 |
+
width = step
|
| 170 |
+
|
| 171 |
+
axs[0,0].bar(x=new_n, bottom=0, width=width, height=diffs,color=colors[0])
|
| 172 |
+
axs[0,0].set_xticks([])
|
| 173 |
+
# axs[0,0].set_xlabel('UTR Samples')
|
| 174 |
+
axs[0,0].set_ylabel('Log TPM Expression Change')
|
| 175 |
+
axs[0,0].set_title('A',weight='bold',fontsize=60,loc='left')
|
| 176 |
+
|
| 177 |
+
axs[1,0].bar(x=new_n, bottom=0, width=width, height=init,color=colors[3])
|
| 178 |
+
axs[1,0].set_xticks([])
|
| 179 |
+
axs[1,0].set_xlabel('UTR Samples')
|
| 180 |
+
axs[1,0].set_ylabel('Initial TPM Expression')
|
| 181 |
+
axs[1,0].set_title('D',weight='bold',fontsize=60,loc='left')
|
| 182 |
+
|
| 183 |
+
######## MRL
|
| 184 |
+
|
| 185 |
+
init = []
|
| 186 |
+
with open(f'/home/sina/UTR/optimization/mrl/init_mrl_FMRL.txt') as f:
|
| 187 |
+
scores = f.readlines()
|
| 188 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 189 |
+
|
| 190 |
+
opt = []
|
| 191 |
+
with open(f'/home/sina/UTR/optimization/mrl/opt_mrl_FMRL.txt') as f:
|
| 192 |
+
scores = f.readlines()
|
| 193 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 194 |
+
|
| 195 |
+
init = np.array(init)
|
| 196 |
+
opt = np.array(opt)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
SORT_INIT = False
|
| 200 |
+
|
| 201 |
+
if SORT_INIT:
|
| 202 |
+
|
| 203 |
+
min_init_indices = np.argsort(init)
|
| 204 |
+
init = init[min_init_indices[:min(int(len(init)),100)]]
|
| 205 |
+
opt = opt[min_init_indices[:min(int(len(opt)),100)]]
|
| 206 |
+
else:
|
| 207 |
+
init = init[:min(int(len(init)),100)]
|
| 208 |
+
opt = opt[:min(int(len(opt)),100)]
|
| 209 |
+
|
| 210 |
+
diffs = [(opt[i]-init[i]) for i in range(len(init))]
|
| 211 |
+
|
| 212 |
+
count = 0
|
| 213 |
+
for i in range(len(diffs)):
|
| 214 |
+
if diffs[i] < 0:
|
| 215 |
+
count += 1
|
| 216 |
+
|
| 217 |
+
print(count)
|
| 218 |
+
|
| 219 |
+
print(np.average(init))
|
| 220 |
+
print(np.average(opt))
|
| 221 |
+
print(np.max(diffs/init))
|
| 222 |
+
print(np.average(diffs/init))
|
| 223 |
+
|
| 224 |
+
indices_sorted = np.argsort(diffs)[::-1]
|
| 225 |
+
|
| 226 |
+
diffs = np.sort(diffs)[::-1]
|
| 227 |
+
|
| 228 |
+
new_inits = []
|
| 229 |
+
|
| 230 |
+
for i in range(len(diffs)):
|
| 231 |
+
new_inits.append(init[indices_sorted[i]])
|
| 232 |
+
|
| 233 |
+
N = min(100, len(diffs))
|
| 234 |
+
|
| 235 |
+
step = 1.0/N
|
| 236 |
+
|
| 237 |
+
new_n = [i * step for i in range(N)]
|
| 238 |
+
|
| 239 |
+
width = step
|
| 240 |
+
|
| 241 |
+
plt.rcParams.update({'font.size': 12})
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
print(len(diffs))
|
| 245 |
+
|
| 246 |
+
axs[0,2].bar(x=new_n, bottom=0, width=width, height=diffs,color=colors[0])
|
| 247 |
+
axs[0,2].set_xticks([])
|
| 248 |
+
axs[0,2].set_ylabel('MRL Change')
|
| 249 |
+
axs[0,2].set_title('C',weight='bold',fontsize=60,loc='left')
|
| 250 |
+
|
| 251 |
+
axs[1,2].bar(x=new_n, bottom=0, width=width, height=new_inits,color=colors[3])
|
| 252 |
+
axs[1,2].set_xticks([])
|
| 253 |
+
axs[1,2].set_xlabel('UTR Samples')
|
| 254 |
+
axs[1,2].set_ylabel('Initial MRL')
|
| 255 |
+
axs[1,2].set_title('F',weight='bold',fontsize=60,loc='left')
|
| 256 |
+
|
| 257 |
+
#############
|
| 258 |
+
|
| 259 |
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import numpy as np
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
import seaborn as sns
|
| 5 |
+
import RNA
|
| 6 |
+
from scipy.stats import ttest_ind, mannwhitneyu
|
| 7 |
+
from scipy.stats import norm
|
| 8 |
+
import os
|
| 9 |
+
from matplotlib.patches import Patch
|
| 10 |
+
from itertools import product
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
np.random.seed(1337)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
colors = ["#3c5068", "#acbab6", "#dcd3cd", "#d4a6a6"]
|
| 17 |
+
customPalette = {'Initial': colors[0], 'Optimized': colors[3]}
|
| 18 |
+
|
| 19 |
+
# Constants
|
| 20 |
+
BATCH_SIZE = 2048
|
| 21 |
+
K = 4
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
params = {
|
| 25 |
+
'legend.fontsize': 40,
|
| 26 |
+
'figure.figsize': (120, 80),
|
| 27 |
+
'axes.labelsize': 120,
|
| 28 |
+
'axes.titlesize': 120,
|
| 29 |
+
'xtick.labelsize': 100,
|
| 30 |
+
'ytick.labelsize': 100
|
| 31 |
+
}
|
| 32 |
+
plt.rcParams.update(params)
|
| 33 |
+
sns.set()
|
| 34 |
+
sns.set_style('ticks')
|
| 35 |
+
|
| 36 |
+
def get_gc_content_many(sequences):
|
| 37 |
+
gc_contents = []
|
| 38 |
+
for seq in sequences:
|
| 39 |
+
gc_count = seq.count('G') + seq.count('C')
|
| 40 |
+
gc_contents.append(gc_count / len(seq) if len(seq) > 0 else 0)
|
| 41 |
+
return np.array(gc_contents)
|
| 42 |
+
|
| 43 |
+
def get_lengths(sequences):
|
| 44 |
+
return np.array([len(seq) for seq in sequences])
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def get_kmer_frequency(sequences, k=4):
|
| 48 |
+
# Generate all possible k-mers
|
| 49 |
+
bases = ['A', 'C', 'G', 'T']
|
| 50 |
+
kmers = [''.join(p) for p in product(bases, repeat=k)]
|
| 51 |
+
|
| 52 |
+
mean_frequencies = []
|
| 53 |
+
for seq in sequences:
|
| 54 |
+
if len(seq) < k:
|
| 55 |
+
mean_frequencies.append(0)
|
| 56 |
+
continue
|
| 57 |
+
# Count occurrences of each k-mer
|
| 58 |
+
kmer_counts = {kmer: 0 for kmer in kmers}
|
| 59 |
+
for i in range(len(seq) - k + 1):
|
| 60 |
+
kmer = seq[i:i+k]
|
| 61 |
+
if kmer in kmer_counts:
|
| 62 |
+
kmer_counts[kmer] += 1
|
| 63 |
+
# Normalize by number of possible k-mer positions
|
| 64 |
+
total_positions = len(seq) - k + 1
|
| 65 |
+
frequencies = [count / total_positions for count in kmer_counts.values() if total_positions > 0]
|
| 66 |
+
# Compute mean frequency
|
| 67 |
+
mean_freq = np.mean(frequencies) if frequencies else 0
|
| 68 |
+
mean_frequencies.append(mean_freq)
|
| 69 |
+
return np.array(mean_frequencies)
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def generate_synthetic_data(num_samples=100):
|
| 75 |
+
bases = ['A', 'C', 'G', 'T']
|
| 76 |
+
|
| 77 |
+
sequences = [''.join(np.random.choice(bases, np.random.randint(50, 151))) for _ in range(num_samples)]
|
| 78 |
+
return sequences
|
| 79 |
+
|
| 80 |
+
# Function to read sequences from .txt file
|
| 81 |
+
def read_sequences(file_path):
|
| 82 |
+
if os.path.exists(file_path):
|
| 83 |
+
with open(file_path, 'r') as f:
|
| 84 |
+
sequences = [line.strip() for line in f if line.strip()]
|
| 85 |
+
return sequences
|
| 86 |
+
else:
|
| 87 |
+
print(f"File {file_path} not found, generating synthetic data.")
|
| 88 |
+
return generate_synthetic_data(100)
|
| 89 |
+
|
| 90 |
+
def analyze_utr_features(file_pairs):
|
| 91 |
+
|
| 92 |
+
all_data = []
|
| 93 |
+
|
| 94 |
+
# Process each gene (set of initial and optimized files)
|
| 95 |
+
for idx, (initial_path, optimized_path, gene_name) in enumerate(file_pairs, 1):
|
| 96 |
+
|
| 97 |
+
initial_seqs = read_sequences(initial_path)
|
| 98 |
+
optimized_seqs = read_sequences(optimized_path)
|
| 99 |
+
|
| 100 |
+
# Compute features
|
| 101 |
+
# Minimum Free Energy (MFE)
|
| 102 |
+
initial_mfe = [RNA.fold(seq)[1] for seq in initial_seqs]
|
| 103 |
+
optimized_mfe = [RNA.fold(seq)[1] for seq in optimized_seqs]
|
| 104 |
+
|
| 105 |
+
# G/C Content
|
| 106 |
+
initial_gc = get_gc_content_many(initial_seqs)
|
| 107 |
+
optimized_gc = get_gc_content_many(optimized_seqs)
|
| 108 |
+
|
| 109 |
+
# Sequence Length
|
| 110 |
+
initial_length = get_lengths(initial_seqs)
|
| 111 |
+
optimized_length = get_lengths(optimized_seqs)
|
| 112 |
+
|
| 113 |
+
# 4-mer Frequency
|
| 114 |
+
initial_kmer = 1000*get_kmer_frequency(initial_seqs, k=K)
|
| 115 |
+
optimized_kmer = 1000*get_kmer_frequency(optimized_seqs, k=K)
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
for seq_type, mfe, gc, length, kmer in [
|
| 120 |
+
('Initial', initial_mfe, initial_gc, initial_length, initial_kmer),
|
| 121 |
+
('Optimized', optimized_mfe, optimized_gc, optimized_length, optimized_kmer)
|
| 122 |
+
]:
|
| 123 |
+
for m, g, l, k in zip(mfe, gc, length, kmer):
|
| 124 |
+
all_data.append({
|
| 125 |
+
'Gene': gene_name,
|
| 126 |
+
'Type': seq_type,
|
| 127 |
+
'MFE': m,
|
| 128 |
+
'GC Content': g,
|
| 129 |
+
'Length': l,
|
| 130 |
+
'4-mer Frequency': k
|
| 131 |
+
})
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
df = pd.DataFrame(all_data)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
fig, axs = plt.subplots(2, 2, figsize=(100, 70))
|
| 139 |
+
|
| 140 |
+
legend_handles = [
|
| 141 |
+
Patch(color=customPalette['Initial'], label='Initial'),
|
| 142 |
+
Patch(color=customPalette['Optimized'], label='Optimized')
|
| 143 |
+
]
|
| 144 |
+
|
| 145 |
+
# MFE
|
| 146 |
+
sns.boxplot(x='Gene', y='MFE', hue='Type', data=df, ax=axs[0, 0], palette=customPalette)
|
| 147 |
+
axs[0, 0].get_legend().remove()
|
| 148 |
+
axs[0, 0].legend(handles=legend_handles, loc='lower right', fontsize=70, title='Type', title_fontsize=70)
|
| 149 |
+
axs[0, 0].set_ylabel("Minimum Free Energy", fontsize=120)
|
| 150 |
+
axs[0, 0].set_xlabel("", fontsize=120)
|
| 151 |
+
axs[0, 0].set_title('A', weight='bold', fontsize=100, loc='left')
|
| 152 |
+
axs[0, 0].tick_params(axis='both', labelsize=100)
|
| 153 |
+
|
| 154 |
+
# G/C Content
|
| 155 |
+
sns.boxplot(x='Gene', y='GC Content', hue='Type', data=df, ax=axs[0, 1], palette=customPalette)
|
| 156 |
+
axs[0, 1].get_legend().remove()
|
| 157 |
+
axs[0, 1].legend(handles=legend_handles, loc='lower right', fontsize=70, title='Type', title_fontsize=70)
|
| 158 |
+
axs[0, 1].set_ylabel("G/C Content", fontsize=120)
|
| 159 |
+
axs[0, 1].set_xlabel("", fontsize=120)
|
| 160 |
+
axs[0, 1].set_title('B', weight='bold', fontsize=100, loc='left')
|
| 161 |
+
axs[0, 1].tick_params(axis='both', labelsize=100)
|
| 162 |
+
|
| 163 |
+
# Length
|
| 164 |
+
sns.boxplot(x='Gene', y='Length', hue='Type', data=df, ax=axs[1, 0], palette=customPalette)
|
| 165 |
+
axs[1, 0].get_legend().remove()
|
| 166 |
+
axs[1, 0].legend(handles=legend_handles, loc='lower right', fontsize=70, title='Type', title_fontsize=70)
|
| 167 |
+
axs[1, 0].set_ylabel("Sequence Length", fontsize=120)
|
| 168 |
+
axs[1, 0].set_xlabel("", fontsize=120)
|
| 169 |
+
axs[1, 0].set_title('C', weight='bold', fontsize=100, loc='left')
|
| 170 |
+
axs[1, 0].tick_params(axis='both', labelsize=100)
|
| 171 |
+
|
| 172 |
+
# 4-mer Frequency
|
| 173 |
+
sns.boxplot(x='Gene', y='4-mer Frequency', hue='Type', data=df, ax=axs[1, 1], palette=customPalette)
|
| 174 |
+
axs[1, 1].get_legend().remove()
|
| 175 |
+
axs[1, 1].legend(handles=legend_handles, loc='lower right', fontsize=70, title='Type', title_fontsize=70)
|
| 176 |
+
axs[1, 1].set_ylabel("Mean 4-mer Frequency", fontsize=120)
|
| 177 |
+
axs[1, 1].set_xlabel("", fontsize=120)
|
| 178 |
+
axs[1, 1].set_title('D', weight='bold', fontsize=100, loc='left')
|
| 179 |
+
axs[1, 1].tick_params(axis='both', labelsize=100)
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
fig.tight_layout(pad=2, rect=[0, 0, 1, 1]) # Adjust for suptitle
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
plt.savefig('./plots/utr_features_boxplots_with_kmer_bottom_right_legends_custom_fonts.png')
|
| 186 |
+
plt.close()
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
file_pairs = [
|
| 190 |
+
('./src/exp_optimization/outputs/gc_best_seqs_IFNG.txt', '/src/exp_optimization/outputs/gc_init_seqs_IFNG.txt', 'IFNG'),
|
| 191 |
+
('/src/exp_optimization/outputs/gc_best_seqs_TLR6.txt', '/src/exp_optimization/outputs/gc_init_seqs_TLR6.txt', 'TLR6'),
|
| 192 |
+
('/src/exp_optimization/outputs/gc_best_seqs_TNF.txt', '/src/exp_optimization/outputs/gc_init_seqs_TNF.txt', 'TNF'),
|
| 193 |
+
('/src/exp_optimization/outputs/gc_best_seqs_TP53.txt', '/src/exp_optimization/outputs/gc_init_seqs_TP53.txt', 'TP53')
|
| 194 |
+
]
|
| 195 |
+
|
| 196 |
+
analyze_utr_features(file_pairs)
|
conf/analysis/plot_4x4.py
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
import seaborn as sns
|
| 7 |
+
import os
|
| 8 |
+
import argparse
|
| 9 |
+
sns.set()
|
| 10 |
+
sns.set_style('ticks')
|
| 11 |
+
|
| 12 |
+
colors = ["#3c5068", "#acbab6", "#dcd3cd", "#d4a6a6"]
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
#POSTER
|
| 16 |
+
params = {'legend.fontsize': 50,
|
| 17 |
+
'figure.figsize': (54, 38),
|
| 18 |
+
'axes.labelsize': 60,
|
| 19 |
+
'axes.titlesize':60,
|
| 20 |
+
'xtick.labelsize':60,
|
| 21 |
+
'ytick.labelsize':60}
|
| 22 |
+
|
| 23 |
+
plt.rcParams.update(params)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
np.random.seed(25)
|
| 27 |
+
|
| 28 |
+
DISPLAY_DIFF = True
|
| 29 |
+
|
| 30 |
+
root_path = './../src/exp_optimization/'
|
| 31 |
+
|
| 32 |
+
PREFIX = 'outputs/'
|
| 33 |
+
|
| 34 |
+
# MIXED, REGULAR, GC_CONTROLED, MULT
|
| 35 |
+
|
| 36 |
+
TYPE = 'GC_CONTROLED'
|
| 37 |
+
|
| 38 |
+
DISPLAY_DIFF = True
|
| 39 |
+
|
| 40 |
+
if TYPE == 'REGULAR':
|
| 41 |
+
PREFIX = 'outputs/'
|
| 42 |
+
elif TYPE == 'MIXED':
|
| 43 |
+
PREFIX = 'outputs_joint/'
|
| 44 |
+
elif TYPE == 'GC_CONTROLED':
|
| 45 |
+
PREFIX = 'outputs/gc_'
|
| 46 |
+
elif TYPE == 'K562':
|
| 47 |
+
PREFIX = 'outputs/K562_'
|
| 48 |
+
elif TYPE == 'GM12878':
|
| 49 |
+
PREFIX = 'outputs/GM12878_'
|
| 50 |
+
|
| 51 |
+
if DISPLAY_DIFF:
|
| 52 |
+
parser = argparse.ArgumentParser(description="Gene Expression Optimization Visualization")
|
| 53 |
+
|
| 54 |
+
# Add arguments
|
| 55 |
+
parser.add_argument("-g", help="a list of gene names separated by comma")
|
| 56 |
+
|
| 57 |
+
# Parse the arguments
|
| 58 |
+
args = parser.parse_args()
|
| 59 |
+
gene_names = args.g.split(',')
|
| 60 |
+
|
| 61 |
+
gene_name = gene_names[0]
|
| 62 |
+
|
| 63 |
+
init = []
|
| 64 |
+
with open(root_path+PREFIX+'init_exps_'+gene_name+'.txt') as f:
|
| 65 |
+
scores = f.readlines()
|
| 66 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 67 |
+
|
| 68 |
+
opt = []
|
| 69 |
+
with open(root_path+PREFIX+'opt_exps_'+gene_name+'.txt') as f:
|
| 70 |
+
scores = f.readlines()
|
| 71 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
init = np.power(10,init)
|
| 75 |
+
opt = np.power(10,opt)
|
| 76 |
+
diffs = (opt - init)/init
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
print("####################################################################")
|
| 81 |
+
print(f"{gene_name} results:")
|
| 82 |
+
print(f"Max Opt: {np.max(opt):.2f}")
|
| 83 |
+
print(f"Max Init: {np.max(init):.2f}")
|
| 84 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)*100:.2f}")
|
| 85 |
+
print(f"Max Percent Increase (wrt Init): {np.max(diffs)*100:.2f}")
|
| 86 |
+
|
| 87 |
+
indices = np.argsort(opt)[::-1]
|
| 88 |
+
|
| 89 |
+
init_large = []
|
| 90 |
+
init_small = []
|
| 91 |
+
opt_large = []
|
| 92 |
+
opt_small = []
|
| 93 |
+
|
| 94 |
+
for i in range(len(indices)):
|
| 95 |
+
if diffs[indices[i]] >= 0:
|
| 96 |
+
init_small.append(init[indices[i]])
|
| 97 |
+
init_large.append(0)
|
| 98 |
+
opt_small.append(0)
|
| 99 |
+
opt_large.append(opt[indices[i]])
|
| 100 |
+
else:
|
| 101 |
+
init_large.append(init[indices[i]])
|
| 102 |
+
init_small.append(0)
|
| 103 |
+
opt_large.append(0)
|
| 104 |
+
opt_small.append(opt[indices[i]])
|
| 105 |
+
|
| 106 |
+
width = 1.0/(len(indices))
|
| 107 |
+
bins = [(i+1) * width for i in range(len(indices))]
|
| 108 |
+
|
| 109 |
+
ns = [i * width for i in range(len(indices))]
|
| 110 |
+
fig, axs = plt.subplots(2,2)
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
axs[0,0].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
|
| 114 |
+
axs[0,0].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
|
| 115 |
+
axs[0,0].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
|
| 116 |
+
axs[0,0].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
|
| 117 |
+
|
| 118 |
+
axs[0,0].set_title(gene_name,loc='left',style='italic',fontsize=64)
|
| 119 |
+
axs[0,0].set_xticks([])
|
| 120 |
+
|
| 121 |
+
gene_name = gene_names[1]
|
| 122 |
+
|
| 123 |
+
init = []
|
| 124 |
+
with open(root_path+PREFIX+'init_exps_'+gene_name+'.txt') as f:
|
| 125 |
+
scores = f.readlines()
|
| 126 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 127 |
+
|
| 128 |
+
opt = []
|
| 129 |
+
with open(root_path+PREFIX+'opt_exps_'+gene_name+'.txt') as f:
|
| 130 |
+
scores = f.readlines()
|
| 131 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 132 |
+
|
| 133 |
+
init = np.power(10,init)
|
| 134 |
+
opt = np.power(10,opt)
|
| 135 |
+
diffs = (opt - init)/init
|
| 136 |
+
|
| 137 |
+
print("####################################################################")
|
| 138 |
+
print(f"{gene_name} results:")
|
| 139 |
+
print(f"Max Opt: {np.max(opt):.2f}")
|
| 140 |
+
print(f"Max Init: {np.max(init):.2f}")
|
| 141 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)*100:.2f}")
|
| 142 |
+
print(f"Max Percent Increase (wrt Init): {np.max(diffs)*100:.2f}")
|
| 143 |
+
|
| 144 |
+
indices = np.argsort(opt)[::-1]
|
| 145 |
+
|
| 146 |
+
init_large = []
|
| 147 |
+
init_small = []
|
| 148 |
+
opt_large = []
|
| 149 |
+
opt_small = []
|
| 150 |
+
|
| 151 |
+
for i in range(len(indices)):
|
| 152 |
+
if diffs[indices[i]] >= 0:
|
| 153 |
+
init_small.append(init[indices[i]])
|
| 154 |
+
init_large.append(0)
|
| 155 |
+
opt_small.append(0)
|
| 156 |
+
opt_large.append(opt[indices[i]])
|
| 157 |
+
else:
|
| 158 |
+
init_large.append(init[indices[i]])
|
| 159 |
+
init_small.append(0)
|
| 160 |
+
opt_large.append(0)
|
| 161 |
+
opt_small.append(opt[indices[i]])
|
| 162 |
+
|
| 163 |
+
axs[0,1].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
|
| 164 |
+
axs[0,1].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
|
| 165 |
+
axs[0,1].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
|
| 166 |
+
axs[0,1].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
|
| 167 |
+
axs[0,1].set_title(gene_name,loc='left',style='italic',fontsize=64)
|
| 168 |
+
axs[0,1].set_xticks([])
|
| 169 |
+
|
| 170 |
+
gene_name = gene_names[2]
|
| 171 |
+
|
| 172 |
+
init = []
|
| 173 |
+
with open(root_path+PREFIX+'init_exps_'+gene_name+'.txt') as f:
|
| 174 |
+
scores = f.readlines()
|
| 175 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 176 |
+
|
| 177 |
+
opt = []
|
| 178 |
+
with open(root_path+PREFIX+'opt_exps_'+gene_name+'.txt') as f:
|
| 179 |
+
scores = f.readlines()
|
| 180 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
init = np.power(10,init)
|
| 184 |
+
opt = np.power(10,opt)
|
| 185 |
+
diffs = (opt - init)/init
|
| 186 |
+
|
| 187 |
+
print("####################################################################")
|
| 188 |
+
print(f"{gene_name} results:")
|
| 189 |
+
print(f"Max Opt: {np.max(opt):.2f}")
|
| 190 |
+
print(f"Max Init: {np.max(init):.2f}")
|
| 191 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)*100:.2f}")
|
| 192 |
+
print(f"Max Percent Increase (wrt Init): {np.max(diffs)*100:.2f}")
|
| 193 |
+
|
| 194 |
+
indices = np.argsort(opt)[::-1]
|
| 195 |
+
|
| 196 |
+
init_large = []
|
| 197 |
+
init_small = []
|
| 198 |
+
opt_large = []
|
| 199 |
+
opt_small = []
|
| 200 |
+
|
| 201 |
+
for i in range(len(indices)):
|
| 202 |
+
if diffs[indices[i]] >= 0:
|
| 203 |
+
init_small.append(init[indices[i]])
|
| 204 |
+
init_large.append(0)
|
| 205 |
+
opt_small.append(0)
|
| 206 |
+
opt_large.append(opt[indices[i]])
|
| 207 |
+
else:
|
| 208 |
+
init_large.append(init[indices[i]])
|
| 209 |
+
init_small.append(0)
|
| 210 |
+
opt_large.append(0)
|
| 211 |
+
opt_small.append(opt[indices[i]])
|
| 212 |
+
|
| 213 |
+
axs[1,0].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
|
| 214 |
+
axs[1,0].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
|
| 215 |
+
axs[1,0].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
|
| 216 |
+
axs[1,0].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
|
| 217 |
+
axs[1,0].set_title(gene_name,loc='left',style='italic',fontsize=64)
|
| 218 |
+
axs[1,0].set_xticks([])
|
| 219 |
+
|
| 220 |
+
gene_name = gene_names[3]
|
| 221 |
+
|
| 222 |
+
init = []
|
| 223 |
+
with open(root_path+PREFIX+'init_exps_'+gene_name+'.txt') as f:
|
| 224 |
+
scores = f.readlines()
|
| 225 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 226 |
+
|
| 227 |
+
opt = []
|
| 228 |
+
with open(root_path+PREFIX+'opt_exps_'+gene_name+'.txt') as f:
|
| 229 |
+
scores = f.readlines()
|
| 230 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 231 |
+
|
| 232 |
+
init = np.power(10,init)
|
| 233 |
+
opt = np.power(10,opt)
|
| 234 |
+
diffs = (opt - init)/init
|
| 235 |
+
|
| 236 |
+
print("####################################################################")
|
| 237 |
+
print(f"{gene_name} results:")
|
| 238 |
+
print(f"Max Opt: {np.max(opt):.2f}")
|
| 239 |
+
print(f"Max Init: {np.max(init):.2f}")
|
| 240 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)*100:.2f}")
|
| 241 |
+
print(f"Max Percent Increase (wrt Init): {np.max(diffs)*100:.2f}")
|
| 242 |
+
print("####################################################################")
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
indices = np.argsort(opt)[::-1]
|
| 246 |
+
init_large = []
|
| 247 |
+
init_small = []
|
| 248 |
+
opt_large = []
|
| 249 |
+
opt_small = []
|
| 250 |
+
|
| 251 |
+
for i in range(len(indices)):
|
| 252 |
+
if diffs[indices[i]] >= 0:
|
| 253 |
+
init_small.append(init[indices[i]])
|
| 254 |
+
init_large.append(0)
|
| 255 |
+
opt_small.append(0)
|
| 256 |
+
opt_large.append(opt[indices[i]])
|
| 257 |
+
else:
|
| 258 |
+
init_large.append(init[indices[i]])
|
| 259 |
+
init_small.append(0)
|
| 260 |
+
opt_large.append(0)
|
| 261 |
+
opt_small.append(opt[indices[i]])
|
| 262 |
+
|
| 263 |
+
axs[1,1].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
|
| 264 |
+
axs[1,1].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
|
| 265 |
+
axs[1,1].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
|
| 266 |
+
axs[1,1].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
|
| 267 |
+
axs[1,1].set_title(gene_name,loc='left',style='italic',fontsize=64)
|
| 268 |
+
axs[1,1].set_xticks([])
|
| 269 |
+
|
| 270 |
+
orange_patch = mpatches.Patch(color=colors[3], label='Initial Expression')
|
| 271 |
+
blue_patch = mpatches.Patch(color=colors[0], label='Optimized Expression')
|
| 272 |
+
fig.legend(handles=[orange_patch,blue_patch],loc='upper right')
|
| 273 |
+
|
| 274 |
+
axs[0,0].set_ylabel('TPM Expression')
|
| 275 |
+
axs[1,0].set_ylabel('TPM Expression')
|
| 276 |
+
|
| 277 |
+
axs[1,0].set_xlabel('UTR Samples')
|
| 278 |
+
axs[1,1].set_xlabel('UTR Samples')
|
| 279 |
+
|
| 280 |
+
|
| 281 |
+
fig.tight_layout()
|
| 282 |
+
plt.gcf().subplots_adjust(left=0.06)
|
| 283 |
+
|
| 284 |
+
os.makedirs('./plots/',exist_ok=True)
|
| 285 |
+
|
| 286 |
+
plt.savefig(f'./plots/exp_opt_all_{TYPE}_{gene_names}.png')
|
| 287 |
+
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
|
conf/analysis/uorfs.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
conf/analysis/utils/__init__.py
ADDED
|
File without changes
|
conf/analysis/utils/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (145 Bytes). View file
|
|
|
conf/analysis/utils/__pycache__/framepool.cpython-310.pyc
ADDED
|
Binary file (7.08 kB). View file
|
|
|
conf/analysis/utils/__pycache__/util.cpython-310.pyc
ADDED
|
Binary file (9.77 kB). View file
|
|
|
conf/analysis/utils/framepool.py
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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as K
|
| 5 |
+
from tensorflow.keras.models import load_model
|
| 6 |
+
from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping
|
| 7 |
+
from tensorflow.keras.layers import Input, Dense, Conv1D, GlobalMaxPooling1D, GlobalAveragePooling1D, Dropout, Concatenate, Lambda, Flatten, ZeroPadding1D, MaxPooling1D, BatchNormalization, ThresholdedReLU, Masking, Add, LSTM, SpatialDropout1D
|
| 8 |
+
from tensorflow.keras.models import Model
|
| 9 |
+
from tensorflow.keras.layers import Layer
|
| 10 |
+
from tensorflow.keras import losses
|
| 11 |
+
from tensorflow.keras.utils import Sequence
|
| 12 |
+
tf.compat.v1.enable_eager_execution()
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def apply_pad_mask(input_tensors):
|
| 16 |
+
tensor = input_tensors[0]
|
| 17 |
+
mask = input_tensors[1]
|
| 18 |
+
mask = K.expand_dims(mask, axis=2)
|
| 19 |
+
return tf.multiply(tensor, mask)
|
| 20 |
+
|
| 21 |
+
class LogNonhomogenousGeometric(Layer):
|
| 22 |
+
|
| 23 |
+
def __init__(self, **kwargs):
|
| 24 |
+
super().__init__(**kwargs)
|
| 25 |
+
|
| 26 |
+
def build(self, input_shape):
|
| 27 |
+
super().build(input_shape)
|
| 28 |
+
|
| 29 |
+
def call(self, x):
|
| 30 |
+
log_P = tf.log_sigmoid(x)
|
| 31 |
+
log_inverse_P = -x + log_P
|
| 32 |
+
cumul_P = tf.cumsum(log_inverse_P, axis=1, exclusive=True) # exclusive ensures correct index
|
| 33 |
+
Q = log_P + cumul_P
|
| 34 |
+
return Q
|
| 35 |
+
|
| 36 |
+
def compute_output_shape(self, input_shape):
|
| 37 |
+
return input_shape
|
| 38 |
+
|
| 39 |
+
# Function to compute an interaction term between a value and a one-hot vector
|
| 40 |
+
def interaction_term(tensors):
|
| 41 |
+
prediction = tensors[0]
|
| 42 |
+
experiment_indicator = tensors[1]
|
| 43 |
+
return tf.multiply(prediction, experiment_indicator)
|
| 44 |
+
|
| 45 |
+
# Layer which slices input tensor into three tensors, one for each frame w.r.t. the canonical start
|
| 46 |
+
class FrameSliceLayer(Layer):
|
| 47 |
+
|
| 48 |
+
def __init__(self, **kwargs):
|
| 49 |
+
super().__init__(**kwargs)
|
| 50 |
+
|
| 51 |
+
def build(self, input_shape):
|
| 52 |
+
super().build(input_shape)
|
| 53 |
+
|
| 54 |
+
def call(self, x):
|
| 55 |
+
shape = K.shape(x)
|
| 56 |
+
x = K.reverse(x, axes=1) # reverse, so that frameness is related to fixed point (start codon)
|
| 57 |
+
frame_1 = tf.gather(x, K.arange(start=0, stop=shape[1], step=3), axis=1)
|
| 58 |
+
frame_2 = tf.gather(x, K.arange(start=1, stop=shape[1], step=3), axis=1)
|
| 59 |
+
frame_3 = tf.gather(x, K.arange(start=2, stop=shape[1], step=3), axis=1)
|
| 60 |
+
return [frame_1, frame_2, frame_3]
|
| 61 |
+
|
| 62 |
+
def compute_output_shape(self, input_shape):
|
| 63 |
+
if len(input_shape) == 2:
|
| 64 |
+
return [(input_shape[0], None),(input_shape[0], None),(input_shape[0], None)]
|
| 65 |
+
return [(input_shape[0], None, input_shape[2]),(input_shape[0], None, input_shape[2]),(input_shape[0], None, input_shape[2])]
|
| 66 |
+
|
| 67 |
+
# Masking to prevent zero padding to influence results
|
| 68 |
+
def compute_pad_mask(x):
|
| 69 |
+
return K.sum(x, axis=2)
|
| 70 |
+
|
| 71 |
+
def apply_pad_mask(input_tensors):
|
| 72 |
+
tensor = input_tensors[0]
|
| 73 |
+
mask = input_tensors[1]
|
| 74 |
+
mask = K.expand_dims(mask, axis=2)
|
| 75 |
+
return tf.multiply(tensor, mask)
|
| 76 |
+
|
| 77 |
+
# Average pooling that accounts for masking
|
| 78 |
+
def global_avg_pool_masked(input_tensors):
|
| 79 |
+
tensor = input_tensors[0]
|
| 80 |
+
mask = input_tensors[1]
|
| 81 |
+
mask = K.expand_dims(mask, axis=2)
|
| 82 |
+
return K.sum(tensor, axis=1)/K.sum(mask, axis=1)
|
| 83 |
+
|
| 84 |
+
def convolve_and_mask(conv_features, pad_mask, n_filters, kernel_size, suffix, prefix="",
|
| 85 |
+
padding="causal", dilation=1, batchnorm=False, conv_dropout=0.0):
|
| 86 |
+
convolution = Conv1D(filters=n_filters, kernel_size=kernel_size, dilation_rate=dilation, activation='relu',
|
| 87 |
+
padding=padding, name=prefix+"convolution_"+suffix)
|
| 88 |
+
conv_features = convolution(conv_features)
|
| 89 |
+
conv_features = Lambda(apply_pad_mask, name=prefix+"apply_pad_mask_"+suffix)([conv_features, pad_mask]) # Mask padding
|
| 90 |
+
if batchnorm:
|
| 91 |
+
conv_features = BatchNormalization(axis=2, name="batchnorm_"+suffix)(conv_features)
|
| 92 |
+
if conv_dropout > 0.0:
|
| 93 |
+
conv_features = SpatialDropout1D(conv_dropout, name=prefix+"1d_dropout_"+suffix)(conv_features)
|
| 94 |
+
return conv_features
|
| 95 |
+
|
| 96 |
+
def inception_block(conv_features, pad_mask, n_filters, suffix, prefix=""):
|
| 97 |
+
conv_features_3 = convolve_and_mask(conv_features, pad_mask, n_filters[0], kernel_size=3, suffix="incept3_"+suffix, prefix=prefix)
|
| 98 |
+
conv_features_5 = convolve_and_mask(conv_features, pad_mask, n_filters[1], kernel_size=5, suffix="incept5_"+suffix, prefix=prefix)
|
| 99 |
+
conv_features_7 = convolve_and_mask(conv_features, pad_mask, n_filters[2], kernel_size=7, suffix="incept7_"+suffix, prefix=prefix)
|
| 100 |
+
conv_features = Concatenate(name="incept_concat"+suffix)([conv_features_3, conv_features_5, conv_features_7])
|
| 101 |
+
return conv_features
|
| 102 |
+
|
| 103 |
+
def create_frame_slice_model(n_conv_layers=3,
|
| 104 |
+
kernel_size=[8,8,8], n_filters=128, dilations=[1, 1, 1],
|
| 105 |
+
padding="causal", use_batchnorm=False,
|
| 106 |
+
conv_dropout=[0.0, 0.0, 0.0],
|
| 107 |
+
use_inception=False, skip_connections="",
|
| 108 |
+
n_dense_layers=1, fc_neurons=[64], fc_drop_rate=0.2,
|
| 109 |
+
only_max_pool=False,
|
| 110 |
+
loss='mean_squared_error',
|
| 111 |
+
use_counter_input=False,
|
| 112 |
+
use_scaling_regression=False, library_size=6):
|
| 113 |
+
# Inputs
|
| 114 |
+
input_seq = Input(shape=(None, 4), name="input_seq")
|
| 115 |
+
inputs = input_seq
|
| 116 |
+
conv_features = input_seq
|
| 117 |
+
# Compute presence of zero padding
|
| 118 |
+
pad_mask = Lambda(compute_pad_mask, name="compute_pad_mask")(conv_features)
|
| 119 |
+
|
| 120 |
+
layer_list = []
|
| 121 |
+
for i in range(n_conv_layers):
|
| 122 |
+
if skip_connections:
|
| 123 |
+
conv_features_shortcut = conv_features #shortcut connections
|
| 124 |
+
if use_inception:
|
| 125 |
+
conv_features = inception_block(conv_features, pad_mask, n_filters, suffix=str(i))
|
| 126 |
+
else:
|
| 127 |
+
conv_features = convolve_and_mask(conv_features, pad_mask, n_filters, kernel_size[i],
|
| 128 |
+
suffix=str(i), padding=padding,
|
| 129 |
+
dilation=dilations[i],
|
| 130 |
+
batchnorm=use_batchnorm,
|
| 131 |
+
conv_dropout=conv_dropout[i])
|
| 132 |
+
if skip_connections == "residual" and i > 0:
|
| 133 |
+
conv_features = Add(name="add_residual_"+str(i))([conv_features, conv_features_shortcut])
|
| 134 |
+
elif skip_connections == "dense":
|
| 135 |
+
conv_features = Concatenate(axis=-1, name="concat_dense_"+str(i))([conv_features,
|
| 136 |
+
conv_features_shortcut])
|
| 137 |
+
# Frame based masking
|
| 138 |
+
frame_masked_features = FrameSliceLayer(name="frame_masking")(conv_features)
|
| 139 |
+
frame_masked_pad_mask = FrameSliceLayer(name="frame_masking_padmask")(pad_mask)
|
| 140 |
+
# Pooling
|
| 141 |
+
pooled_features = []
|
| 142 |
+
max_pooling = GlobalMaxPooling1D(name="pool_max_frame_conv")
|
| 143 |
+
avg_pooling = Lambda(global_avg_pool_masked, name="pool_avg_frame_conv")
|
| 144 |
+
pooled_features = pooled_features + \
|
| 145 |
+
[max_pooling(frame_masked_features[i]) for i in range(len(frame_masked_features))]
|
| 146 |
+
if not only_max_pool:
|
| 147 |
+
pooled_features = pooled_features + [avg_pooling([frame_masked_features[i], frame_masked_pad_mask[i]]) for i in
|
| 148 |
+
range(len(frame_masked_features))]
|
| 149 |
+
pooled_features = Concatenate(axis=-1, name="concatenate_pooled")(pooled_features)
|
| 150 |
+
# Add tis_context if necessary
|
| 151 |
+
concat_features = pooled_features
|
| 152 |
+
# Prediction (Dense layer)
|
| 153 |
+
predict = concat_features
|
| 154 |
+
for i in range(n_dense_layers):
|
| 155 |
+
predict = Dense(fc_neurons[i], activation='relu', name="fully_connected_"+str(i))(predict)
|
| 156 |
+
predict = Dropout(rate=fc_drop_rate, name="fc_dropout_"+str(i))(predict)
|
| 157 |
+
predict = Dense(1, name="mrl_output_unscaled")(predict)
|
| 158 |
+
|
| 159 |
+
model = Model(inputs=inputs, outputs=predict)
|
| 160 |
+
adam = tf.keras.optimizers.Adam(lr=0.001, beta_1=0.9, beta_2=0.999, epsilon=1e-08)
|
| 161 |
+
model.compile(loss=loss, optimizer=adam)
|
| 162 |
+
return model
|
| 163 |
+
|
| 164 |
+
def load_framepool(path):
|
| 165 |
+
model = create_frame_slice_model(kernel_size=[7,7,7],
|
| 166 |
+
only_max_pool=False,
|
| 167 |
+
padding="same",
|
| 168 |
+
skip_connections="residual",
|
| 169 |
+
use_scaling_regression=True, library_size=2)
|
| 170 |
+
|
| 171 |
+
model.load_weights(path)
|
| 172 |
+
return model
|
conf/analysis/utils/util.py
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.pyplot as plt
|
| 7 |
+
import pandas as pd
|
| 8 |
+
import numpy as np
|
| 9 |
+
import math
|
| 10 |
+
import itertools
|
| 11 |
+
import random
|
| 12 |
+
import os
|
| 13 |
+
from polyleven import levenshtein
|
| 14 |
+
import operator
|
| 15 |
+
import pickle
|
| 16 |
+
import time
|
| 17 |
+
import tensorflow as tf
|
| 18 |
+
|
| 19 |
+
tf.random.set_seed(35)
|
| 20 |
+
np.random.seed(35)
|
| 21 |
+
|
| 22 |
+
rna_vocab = {"A":0,
|
| 23 |
+
"C":1,
|
| 24 |
+
"G":2,
|
| 25 |
+
"U":3,
|
| 26 |
+
"*":4}
|
| 27 |
+
|
| 28 |
+
rev_rna_vocab = {v:k for k,v in rna_vocab.items()}
|
| 29 |
+
|
| 30 |
+
def recover_seq(samples, rev_charmap=rev_rna_vocab):
|
| 31 |
+
"""Convert samples to strings and save to log directory."""
|
| 32 |
+
|
| 33 |
+
char_probs = samples
|
| 34 |
+
argmax = np.argmax(char_probs, 2)
|
| 35 |
+
seqs = []
|
| 36 |
+
for line in argmax:
|
| 37 |
+
s = "".join(rev_charmap[d] for d in line)
|
| 38 |
+
s = s.replace('*','')
|
| 39 |
+
s = s.replace('U','T')
|
| 40 |
+
seqs.append(s)
|
| 41 |
+
return seqs
|
| 42 |
+
|
| 43 |
+
def file_to_list(file_name,size):
|
| 44 |
+
data = []
|
| 45 |
+
with open(file_name,'r') as f:
|
| 46 |
+
lines = f.readlines()
|
| 47 |
+
|
| 48 |
+
for seq in lines:
|
| 49 |
+
seq_ = seq.replace('\n','')
|
| 50 |
+
data.append(seq_)
|
| 51 |
+
# if len(seq) == size:
|
| 52 |
+
# data.append(seq)
|
| 53 |
+
|
| 54 |
+
return data
|
| 55 |
+
|
| 56 |
+
def one_hot_encode(seq):
|
| 57 |
+
mapping = dict(zip("ACGT", range(4)))
|
| 58 |
+
seq = seq.replace('U','T')
|
| 59 |
+
seq2 = [mapping[i] for i in seq]
|
| 60 |
+
return np.eye(4)[seq2]
|
| 61 |
+
|
| 62 |
+
def encode(seqs):
|
| 63 |
+
return np.reshape([one_hot_encode(seqs[i]) for i in range(len(seqs))],(np.array(seqs).shape[0],-1))
|
| 64 |
+
|
| 65 |
+
min_len = None
|
| 66 |
+
nuc_dict = {'a':[1.0,0.0,0.0,0.0],'c':[0.0,1.0,0.0,0.0],'g':[0.0,0.0,1.0,0.0],
|
| 67 |
+
'u':[0.0,0.0,0.0,1.0], 't':[0.0,0.0,0.0,1.0],
|
| 68 |
+
'n':[0.0,0.0,0.0,0.0], 'x':[1/4,1/4,1/4,1/4]}
|
| 69 |
+
|
| 70 |
+
def encode_seq_framepool(seq, max_len=128):
|
| 71 |
+
# print(seq)
|
| 72 |
+
length = len(seq)
|
| 73 |
+
if max_len > 0 and min_len is None:
|
| 74 |
+
padding_needed = max_len - length
|
| 75 |
+
seq = "N"*padding_needed + seq
|
| 76 |
+
if min_len is not None:
|
| 77 |
+
if len(seq) < min_len:
|
| 78 |
+
seq = "N"*(min_len - len(seq)) + seq
|
| 79 |
+
|
| 80 |
+
if len(seq) > min_len:
|
| 81 |
+
seq = seq[(len(seq) - min_len):]
|
| 82 |
+
seq = seq.lower()
|
| 83 |
+
one_hot = np.array([nuc_dict[x] for x in seq]) # get stacked on top of each other
|
| 84 |
+
|
| 85 |
+
return one_hot
|
| 86 |
+
|
| 87 |
+
def list_to_file(filename,list):
|
| 88 |
+
with open(filename + ".txt", 'w') as f:
|
| 89 |
+
for element in list[:-1]:
|
| 90 |
+
f.write(element+"\n")
|
| 91 |
+
f.write(list[-1])
|
| 92 |
+
|
| 93 |
+
def tsne_natural(file_name, length, key='seq'):
|
| 94 |
+
df = pd.read_csv(file_name)
|
| 95 |
+
seqs = np.array(df[key]).tolist()
|
| 96 |
+
|
| 97 |
+
selected_seqs = []
|
| 98 |
+
|
| 99 |
+
for i in range(len(seqs)):
|
| 100 |
+
seq = seqs[i]
|
| 101 |
+
seq = seq.upper()
|
| 102 |
+
if seq not in selected_seqs and len(seq) == length:
|
| 103 |
+
selected_seqs.append(seq)
|
| 104 |
+
|
| 105 |
+
return selected_seqs
|
| 106 |
+
|
| 107 |
+
def read_real(file_name, UTR_LEN, key='seq', all= True, samples= 128 ):
|
| 108 |
+
df = pd.read_csv(file_name)
|
| 109 |
+
seqs = np.array(df[key]).tolist()
|
| 110 |
+
|
| 111 |
+
selected_seqs = []
|
| 112 |
+
|
| 113 |
+
for i in range(len(seqs)):
|
| 114 |
+
if len(seqs[i]) < (UTR_LEN + 1) and len(seqs[i]) > int(UTR_LEN/2):
|
| 115 |
+
seqs[i] = seqs[i].upper()
|
| 116 |
+
if seqs[i] not in selected_seqs:
|
| 117 |
+
selected_seqs.append(seqs[i])
|
| 118 |
+
|
| 119 |
+
if all:
|
| 120 |
+
return selected_seqs
|
| 121 |
+
|
| 122 |
+
else:
|
| 123 |
+
indices = []
|
| 124 |
+
|
| 125 |
+
for i in range(len(selected_seqs)):
|
| 126 |
+
|
| 127 |
+
indices.append(i)
|
| 128 |
+
|
| 129 |
+
samples = np.random.choice(len(indices),samples,replace=False)
|
| 130 |
+
|
| 131 |
+
chosen = []
|
| 132 |
+
|
| 133 |
+
for i in range(len(samples)):
|
| 134 |
+
chosen.append(selected_seqs[samples[i]])
|
| 135 |
+
|
| 136 |
+
return chosen
|
| 137 |
+
|
| 138 |
+
def random_sample(length):
|
| 139 |
+
rna_vocab = {"A":0,
|
| 140 |
+
"C":1,
|
| 141 |
+
"G":2,
|
| 142 |
+
"T":3}
|
| 143 |
+
|
| 144 |
+
rev_rna_vocab = {v:k for k,v in rna_vocab.items()}
|
| 145 |
+
|
| 146 |
+
mapping = dict(zip([0,1,2,3],"ACGT"))
|
| 147 |
+
gc_limit = random.randrange(2,9)
|
| 148 |
+
gc_limit = float(gc_limit)/10
|
| 149 |
+
gc_limit = 0.6
|
| 150 |
+
sample = ''
|
| 151 |
+
for i in range(length):
|
| 152 |
+
r = random.random()
|
| 153 |
+
if r < gc_limit:
|
| 154 |
+
sample += random.choice(['C','G'])
|
| 155 |
+
else:
|
| 156 |
+
sample += random.choice(['A','T'])
|
| 157 |
+
|
| 158 |
+
return sample
|
| 159 |
+
|
| 160 |
+
def random_data(length, size):
|
| 161 |
+
samples = []
|
| 162 |
+
for i in range(size):
|
| 163 |
+
samples.append(random_sample(length))
|
| 164 |
+
|
| 165 |
+
return samples
|
| 166 |
+
|
| 167 |
+
def tsne_gen(path,length=128,BATCH_SIZE=64,DIM=40):
|
| 168 |
+
wgan = tf.keras.models.load_model(path)
|
| 169 |
+
|
| 170 |
+
selected = []
|
| 171 |
+
while len(selected) < BATCH_SIZE:
|
| 172 |
+
|
| 173 |
+
noise = tf.Variable(tf.random.normal(shape=[64,DIM]))
|
| 174 |
+
|
| 175 |
+
sequences_init = wgan(noise)
|
| 176 |
+
|
| 177 |
+
gen_seqs_init = sequences_init.numpy().astype('float')
|
| 178 |
+
|
| 179 |
+
seqs_gen_init = recover_seq(gen_seqs_init, rev_rna_vocab)
|
| 180 |
+
|
| 181 |
+
for i in range(len(seqs_gen_init)):
|
| 182 |
+
if len(seqs_gen_init[i]) == length:
|
| 183 |
+
selected.append(seqs_gen_init[i])
|
| 184 |
+
|
| 185 |
+
return selected[:BATCH_SIZE]
|
| 186 |
+
|
| 187 |
+
def generate_data(path,BATCH_SIZE=64,UTR_LEN=128,DIM=40):
|
| 188 |
+
wgan = tf.keras.models.load_model(path)
|
| 189 |
+
|
| 190 |
+
gens = []
|
| 191 |
+
|
| 192 |
+
while len(gens) < BATCH_SIZE:
|
| 193 |
+
|
| 194 |
+
noise = tf.Variable(tf.random.normal(shape=[BATCH_SIZE,DIM]))
|
| 195 |
+
|
| 196 |
+
sequences_init = wgan(noise)
|
| 197 |
+
|
| 198 |
+
gen_seqs_init = sequences_init.numpy().astype('float')
|
| 199 |
+
|
| 200 |
+
seqs_gen_init = recover_seq(gen_seqs_init, rev_rna_vocab)
|
| 201 |
+
|
| 202 |
+
for i in range(len(seqs_gen_init)):
|
| 203 |
+
if len(seqs_gen_init[i]) > int(UTR_LEN/2) and len(seqs_gen_init[i])< UTR_LEN+1:
|
| 204 |
+
gens.append(seqs_gen_init[i])
|
| 205 |
+
if len(gens) == BATCH_SIZE:
|
| 206 |
+
break
|
| 207 |
+
|
| 208 |
+
return gens[:BATCH_SIZE]
|
| 209 |
+
|
| 210 |
+
def gc_percentage(seq):
|
| 211 |
+
count = 0.0
|
| 212 |
+
for char in seq:
|
| 213 |
+
if char == 'C' or char == 'G':
|
| 214 |
+
count +=1
|
| 215 |
+
|
| 216 |
+
return float(count/len(seq))
|
| 217 |
+
|
| 218 |
+
def get_gc_content(data):
|
| 219 |
+
gc_content = []
|
| 220 |
+
for seq in data:
|
| 221 |
+
seq.replace('\n','')
|
| 222 |
+
seq.replace('*','')
|
| 223 |
+
gc = gc_percentage(seq)
|
| 224 |
+
gc_content.append(gc)
|
| 225 |
+
|
| 226 |
+
return gc_content
|
| 227 |
+
|
| 228 |
+
def get_gc_content_many(data):
|
| 229 |
+
|
| 230 |
+
collection = []
|
| 231 |
+
gc_contents = []
|
| 232 |
+
for seq in data:
|
| 233 |
+
seq = seq.upper()
|
| 234 |
+
seq.replace('\n','')
|
| 235 |
+
seq.replace('*','')
|
| 236 |
+
gc = gc_percentage(seq)
|
| 237 |
+
gc_contents.append(gc)
|
| 238 |
+
|
| 239 |
+
return gc_contents
|
| 240 |
+
|
| 241 |
+
def get_4mers():
|
| 242 |
+
neucs = ['A','C','G','T']
|
| 243 |
+
|
| 244 |
+
mers = [p for p in itertools.product(neucs, repeat=4)]
|
| 245 |
+
for i in range(len(mers)):
|
| 246 |
+
mers[i] = mers[i][0] + mers[i][1] + mers[i][2] + mers[i][3]
|
| 247 |
+
|
| 248 |
+
return mers
|
| 249 |
+
|
| 250 |
+
def get_4mer_dic(seqs):
|
| 251 |
+
|
| 252 |
+
_4mers = get_4mers()
|
| 253 |
+
length = 0
|
| 254 |
+
dics = []
|
| 255 |
+
c = 0
|
| 256 |
+
for seq in seqs:
|
| 257 |
+
c += 1
|
| 258 |
+
# dic = {}
|
| 259 |
+
dic = []
|
| 260 |
+
for item in _4mers:
|
| 261 |
+
dic.append(0)
|
| 262 |
+
|
| 263 |
+
# Iterate With the Sliding Window
|
| 264 |
+
length = len(seq)
|
| 265 |
+
limit = length - 4
|
| 266 |
+
for i in range(limit):
|
| 267 |
+
mer = seq[i:i+4]
|
| 268 |
+
indx = _4mers.index(mer)
|
| 269 |
+
dic[indx] += 1
|
| 270 |
+
|
| 271 |
+
dics.append(dic)
|
| 272 |
+
|
| 273 |
+
if c % 2000 == 0:
|
| 274 |
+
print("YUE")
|
| 275 |
+
|
| 276 |
+
return dics
|
| 277 |
+
|
| 278 |
+
def euclidean_kmer(item, ref, mers):
|
| 279 |
+
dist = 0
|
| 280 |
+
# diff = np.linalg.norm(item-re)
|
| 281 |
+
for mer in range(len(mers)):
|
| 282 |
+
|
| 283 |
+
diff = item[mer] - ref[mer]
|
| 284 |
+
dist += diff * diff
|
| 285 |
+
|
| 286 |
+
return math.sqrt(dist)
|
| 287 |
+
|
| 288 |
+
def euclidean_kmer_all(item,refs,mers):
|
| 289 |
+
dists = []
|
| 290 |
+
for ref in refs:
|
| 291 |
+
dist = euclidean_kmer(item,ref,mers)
|
| 292 |
+
if dist > 0:
|
| 293 |
+
dists.append(dist)
|
| 294 |
+
|
| 295 |
+
return min(dists)
|
| 296 |
+
|
| 297 |
+
def kmer_dist_list(source, target, mers):
|
| 298 |
+
dists = []
|
| 299 |
+
for item in source:
|
| 300 |
+
dists.append(euclidean_kmer_all(item, target, mers))
|
| 301 |
+
|
| 302 |
+
return dists
|
| 303 |
+
|
| 304 |
+
def calc_dist_kmer(source,target):
|
| 305 |
+
mers = get_4mers()
|
| 306 |
+
source_dic = get_4mer_dic(source)
|
| 307 |
+
target_dic = get_4mer_dic(target)
|
| 308 |
+
print("Dicts Processed")
|
| 309 |
+
dists = kmer_dist_list(source_dic, target_dic, mers)
|
| 310 |
+
|
| 311 |
+
return dists
|
| 312 |
+
|
| 313 |
+
def hamming_dist(src, target):
|
| 314 |
+
|
| 315 |
+
dists = []
|
| 316 |
+
for i in range(len(src)):
|
| 317 |
+
smallest = np.inf
|
| 318 |
+
for j in range(len(target)):
|
| 319 |
+
dist = levenshtein(src[i],target[j])
|
| 320 |
+
if dist > 0 and dist < smallest:
|
| 321 |
+
smallest = dist
|
| 322 |
+
|
| 323 |
+
dists.append(dist)
|
| 324 |
+
|
| 325 |
+
return np.array(dists)
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
|
| 334 |
+
def one_hot_motif(seq,length=128,complementary=False):
|
| 335 |
+
"""
|
| 336 |
+
one_hot encoding on sequence
|
| 337 |
+
complementary: encode nucleatide into complementary one
|
| 338 |
+
"""
|
| 339 |
+
|
| 340 |
+
if length == -1:
|
| 341 |
+
length = len(seq)
|
| 342 |
+
|
| 343 |
+
# seq = str(seq)
|
| 344 |
+
# setting
|
| 345 |
+
seq = list(seq.replace("U","T"))
|
| 346 |
+
seq_len = len(seq)
|
| 347 |
+
complementary = -1 if complementary else 1
|
| 348 |
+
# compose dict
|
| 349 |
+
keys = ['A', 'C', 'G', 'T'][::complementary]
|
| 350 |
+
oh_dict = {keys[i]:i for i in range(4)}
|
| 351 |
+
# array
|
| 352 |
+
oh_array = np.zeros((length,4))
|
| 353 |
+
for i,C in enumerate(seq):
|
| 354 |
+
try:
|
| 355 |
+
oh_array[i,oh_dict[C]]=1
|
| 356 |
+
except:
|
| 357 |
+
continue # for nucleotide that are not in A C G T
|
| 358 |
+
return oh_array
|
| 359 |
+
|
| 360 |
+
def one_hot_all_motif(seqs):
|
| 361 |
+
length = np.max([len(seq) for seq in seqs])
|
| 362 |
+
return [one_hot_motif(seqs[i], length = 128) for i in range(len(seqs))]
|
conf/analysis/violin.py
ADDED
|
@@ -0,0 +1,567 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from matplotlib import colors
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
import matplotlib.patches as mpatches
|
| 6 |
+
import random
|
| 7 |
+
from scipy.stats import ks_2samp,kstest,ttest_ind, mannwhitneyu, norm
|
| 8 |
+
from cliffs_delta import cliffs_delta
|
| 9 |
+
import seaborn as sns
|
| 10 |
+
from tqdm import tqdm
|
| 11 |
+
import random
|
| 12 |
+
random.seed(1337)
|
| 13 |
+
import os
|
| 14 |
+
import numpy as np
|
| 15 |
+
np.random.seed(1337)
|
| 16 |
+
import pandas as pd
|
| 17 |
+
pd.options.mode.chained_assignment = None
|
| 18 |
+
import RNA
|
| 19 |
+
from polyleven import levenshtein
|
| 20 |
+
import time
|
| 21 |
+
import itertools
|
| 22 |
+
import tensorflow as tf
|
| 23 |
+
from tensorflow.keras import backend as K
|
| 24 |
+
from tensorflow.keras.models import load_model
|
| 25 |
+
from tensorflow.keras.layers import Layer
|
| 26 |
+
|
| 27 |
+
from utils.util import *
|
| 28 |
+
from utils.framepool import *
|
| 29 |
+
|
| 30 |
+
colors = ["#3c5068", "#acbab6", "#dcd3cd", "#d4a6a6"]
|
| 31 |
+
|
| 32 |
+
tf.compat.v1.enable_eager_execution()
|
| 33 |
+
|
| 34 |
+
os.environ["CUDA_VISIBLE_DEVICES"] = '-1'
|
| 35 |
+
|
| 36 |
+
def ES_CI(d1, d2):
|
| 37 |
+
n1 = len(d1)
|
| 38 |
+
n2 = len(d2)
|
| 39 |
+
|
| 40 |
+
u1 = np.mean(d1)
|
| 41 |
+
u2 = np.mean(d2)
|
| 42 |
+
|
| 43 |
+
s1 = np.std(d1)
|
| 44 |
+
s2 = np.std(d2)
|
| 45 |
+
|
| 46 |
+
s = np.sqrt(((n1 - 1) * np.power(s1,2) + (n2 - 1) * np.power(s2,2)) / (n1 + n2 - 2))
|
| 47 |
+
|
| 48 |
+
effect_size = (u1 - u2)/s
|
| 49 |
+
effect_size = cliffs_delta(d1, d2)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
ct1 = n1 #items in dataset 1
|
| 54 |
+
ct2 = n2 #items in dataset 2
|
| 55 |
+
ds1 = d1
|
| 56 |
+
ds2 = d2
|
| 57 |
+
alpha = 0.05 #95% confidence interval
|
| 58 |
+
N = norm.ppf(1 - alpha/2) # percent point function - inverse of cdf
|
| 59 |
+
|
| 60 |
+
# The confidence interval for the difference between the two population
|
| 61 |
+
# medians is derived through these nxm differences.
|
| 62 |
+
diffs = sorted([i-j for i in ds1 for j in ds2])
|
| 63 |
+
|
| 64 |
+
# For an approximate 100(1-a)% confidence interval first calculate K:
|
| 65 |
+
k = int(round(ct1*ct2/2 - (N * (ct1*ct2*(ct1+ct2+1)/12)**0.5)))
|
| 66 |
+
|
| 67 |
+
# The Kth smallest to the Kth largest of the n x m differences
|
| 68 |
+
# ct1 and ct2 should be > ~20
|
| 69 |
+
CI = (diffs[k], diffs[len(diffs)-k])
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
return effect_size, CI
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
customPalette = {'Generated':colors[0],'Optimus\n5-Prime':colors[3],'Natural\n5\' UTR':colors[1], 'Optimized':colors[2]}
|
| 76 |
+
|
| 77 |
+
UTR_LEN = 128
|
| 78 |
+
Z_DIM = 40
|
| 79 |
+
DIM = Z_DIM
|
| 80 |
+
BATCH_SIZE = 2048
|
| 81 |
+
MAX_LEN = UTR_LEN
|
| 82 |
+
gpath = './../models/checkpoint_3000.h5'
|
| 83 |
+
data_path = './../data/utrdb2.csv'
|
| 84 |
+
mrl_path = './../models/utr_model_combined_residual_new.h5'
|
| 85 |
+
|
| 86 |
+
sns.set()
|
| 87 |
+
sns.set_style('ticks')
|
| 88 |
+
|
| 89 |
+
#POSTER
|
| 90 |
+
params = {'legend.fontsize': 48,
|
| 91 |
+
'figure.figsize': (60, 30),
|
| 92 |
+
'axes.labelsize': 50,
|
| 93 |
+
'axes.titlesize':50,
|
| 94 |
+
'xtick.labelsize':50,
|
| 95 |
+
'ytick.labelsize':50}
|
| 96 |
+
|
| 97 |
+
plt.rcParams.update(params)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
model = load_framepool(mrl_path)
|
| 101 |
+
|
| 102 |
+
# gens = generate_data(path=gpath, UTR_LEN=UTR_LEN, BATCH_SIZE=BATCH_SIZE, DIM=DIM)
|
| 103 |
+
# gens2 = generate_data(path=gpath, UTR_LEN=UTR_LEN, BATCH_SIZE=4096, DIM=DIM)
|
| 104 |
+
BATCH_SIZE=1024
|
| 105 |
+
|
| 106 |
+
gens = read_data('/data4/sina/UTR/UTRGAN/src/mrl_te_optimization/outputs/opt_10000_1024_saved/init_seqs_FMRL_10000.txt')
|
| 107 |
+
gens_encoded = np.array([encode_seq_framepool(seq) for seq in gens])
|
| 108 |
+
opts = read_data('/data4/sina/UTR/UTRGAN/src/mrl_te_optimization/outputs/opt_10000_1024_saved/opt_seqs_FMRL_10000.txt')
|
| 109 |
+
opts_encoded = np.array([encode_seq_framepool(seq) for seq in opts])
|
| 110 |
+
randoms = random_data(length=UTR_LEN, size=BATCH_SIZE)
|
| 111 |
+
randoms = read_optimus()
|
| 112 |
+
randoms_encoded = np.array([encode_seq_framepool(seq) for seq in randoms])
|
| 113 |
+
naturals = read_real(data_path, UTR_LEN=UTR_LEN, all=False, samples=BATCH_SIZE)
|
| 114 |
+
naturals2 = read_real(data_path, UTR_LEN=UTR_LEN, all=False, samples=10000)
|
| 115 |
+
naturals_encoded = np.array([encode_seq_framepool(seq) for seq in naturals])
|
| 116 |
+
naturals_all = read_real(data_path, UTR_LEN=UTR_LEN, all=True)
|
| 117 |
+
naturals_encoded_all = np.array([encode_seq_framepool(seq) for seq in naturals_all])
|
| 118 |
+
############################# MRL PREDICTION ####################################
|
| 119 |
+
|
| 120 |
+
######### Gens
|
| 121 |
+
|
| 122 |
+
gens_tensor = tf.convert_to_tensor(gens_encoded,dtype=tf.float32)
|
| 123 |
+
pred_gens = model(gens_tensor)
|
| 124 |
+
pred_gens = tf.reshape(pred_gens,(-1))
|
| 125 |
+
genpreds = pred_gens.numpy().astype('float')
|
| 126 |
+
|
| 127 |
+
######### Opts
|
| 128 |
+
|
| 129 |
+
opts_tensor = tf.convert_to_tensor(opts_encoded,dtype=tf.float32)
|
| 130 |
+
pred_opts = model(opts_tensor)
|
| 131 |
+
pred_opts = tf.reshape(pred_opts,(-1))
|
| 132 |
+
optpreds = pred_opts.numpy().astype('float')
|
| 133 |
+
|
| 134 |
+
######### Randoms
|
| 135 |
+
|
| 136 |
+
randoms_tensor = tf.convert_to_tensor(randoms_encoded,dtype=tf.float32)
|
| 137 |
+
pred_randoms = model(randoms_tensor)
|
| 138 |
+
pred_randoms = tf.reshape(pred_randoms,(-1))
|
| 139 |
+
randpreds = pred_randoms.numpy().astype('float')
|
| 140 |
+
|
| 141 |
+
######## Labeled
|
| 142 |
+
|
| 143 |
+
naturals_tensors = tf.convert_to_tensor(naturals_encoded_all,dtype=tf.float32)
|
| 144 |
+
pred_naturals = model(naturals_tensors)
|
| 145 |
+
pred_naturals = tf.reshape(pred_naturals,(-1))
|
| 146 |
+
realpreds = pred_naturals.numpy().astype('float')
|
| 147 |
+
|
| 148 |
+
############
|
| 149 |
+
|
| 150 |
+
bins = np.linspace(2.5, 9, 30)
|
| 151 |
+
|
| 152 |
+
fig, axs = plt.subplots(2,3)
|
| 153 |
+
|
| 154 |
+
real_x = ['Natural\n5\' UTR' for i in range(len(realpreds))]
|
| 155 |
+
gen_x = ['Generated' for i in range(len(genpreds))]
|
| 156 |
+
opt_x = ['Optimized' for i in range(len(optpreds))]
|
| 157 |
+
rand_x = ['Optimus\n5-Prime' for i in range(len(randpreds))]
|
| 158 |
+
|
| 159 |
+
x = np.concatenate((gen_x,opt_x,real_x,rand_x))
|
| 160 |
+
y = np.concatenate((genpreds,optpreds,realpreds,randpreds))
|
| 161 |
+
|
| 162 |
+
gent_mrl = ttest_ind(genpreds,realpreds)
|
| 163 |
+
optt_mrl = ttest_ind(optpreds,realpreds)
|
| 164 |
+
randt_mrl = ttest_ind(randpreds,realpreds)
|
| 165 |
+
genu_mrl = mannwhitneyu(genpreds, realpreds)
|
| 166 |
+
optu_mrl = mannwhitneyu(optpreds, realpreds)
|
| 167 |
+
randu_mrl = mannwhitneyu(randpreds, realpreds)
|
| 168 |
+
es_gen_mrl = ES_CI(genpreds,realpreds)
|
| 169 |
+
es_opt_mrl = ES_CI(optpreds,realpreds)
|
| 170 |
+
es_rand_mrl = ES_CI(randpreds,realpreds)
|
| 171 |
+
|
| 172 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 173 |
+
|
| 174 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[1,0],palette=customPalette)
|
| 175 |
+
|
| 176 |
+
axs[1,0].set_ylabel("Mean Ribosome Load")
|
| 177 |
+
axs[1,0].set_xlabel("")
|
| 178 |
+
|
| 179 |
+
############################# MFE PREDICTION ####################################
|
| 180 |
+
|
| 181 |
+
genpreds = []
|
| 182 |
+
|
| 183 |
+
for i in range(len(gens)):
|
| 184 |
+
(ss, mfe) = RNA.fold(gens[i])
|
| 185 |
+
genpreds.append(mfe)
|
| 186 |
+
|
| 187 |
+
optpreds = []
|
| 188 |
+
|
| 189 |
+
for i in range(len(opts)):
|
| 190 |
+
(ss, mfe) = RNA.fold(opts[i])
|
| 191 |
+
optpreds.append(mfe)
|
| 192 |
+
|
| 193 |
+
randpreds = []
|
| 194 |
+
|
| 195 |
+
for i in range(len(randoms)):
|
| 196 |
+
(ss, mfe) = RNA.fold(randoms[i])
|
| 197 |
+
randpreds.append(mfe)
|
| 198 |
+
|
| 199 |
+
realpreds = []
|
| 200 |
+
|
| 201 |
+
for i in range(len(naturals_all)):
|
| 202 |
+
(ss, mfe) = RNA.fold(naturals_all[i])
|
| 203 |
+
realpreds.append(mfe)
|
| 204 |
+
|
| 205 |
+
real_x = ['Natural\n5\' UTR' for i in range(len(realpreds))]
|
| 206 |
+
gen_x = ['Generated' for i in range(len(genpreds))]
|
| 207 |
+
opt_x = ['Optimized' for i in range(len(optpreds))]
|
| 208 |
+
rand_x = ['Optimus\n5-Prime' for i in range(len(randpreds))]
|
| 209 |
+
|
| 210 |
+
gent_mfe = ttest_ind(genpreds,realpreds)
|
| 211 |
+
optt_mfe = ttest_ind(optpreds,realpreds)
|
| 212 |
+
randt_mfe = ttest_ind(randpreds,realpreds)
|
| 213 |
+
randu_mfe = mannwhitneyu(randpreds, realpreds)
|
| 214 |
+
genu_mfe = mannwhitneyu(genpreds, realpreds)
|
| 215 |
+
optu_mfe = mannwhitneyu(optpreds, realpreds)
|
| 216 |
+
es_gen_mfe = ES_CI(genpreds,realpreds)
|
| 217 |
+
es_opt_mfe = ES_CI(optpreds,realpreds)
|
| 218 |
+
es_rand_mfe = ES_CI(randpreds,realpreds)
|
| 219 |
+
|
| 220 |
+
x = np.concatenate((gen_x,opt_x,real_x,rand_x))
|
| 221 |
+
y = np.concatenate((genpreds,optpreds,realpreds,randpreds))
|
| 222 |
+
|
| 223 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 224 |
+
|
| 225 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[1,2],palette=customPalette)
|
| 226 |
+
|
| 227 |
+
axs[1,2].set_ylabel("Minimum Free Energy")
|
| 228 |
+
axs[1,2].set_xlabel("")
|
| 229 |
+
|
| 230 |
+
############################# Levenshtein Distance ####################################
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
|
| 234 |
+
DIST = 'S'
|
| 235 |
+
|
| 236 |
+
if DIST == 'KMER':
|
| 237 |
+
dist_rand = calc_dist_kmer(randoms, naturals)
|
| 238 |
+
dist_gen = calc_dist_kmer(gens, naturals)
|
| 239 |
+
dist_real = calc_dist_kmer(naturals, naturals)
|
| 240 |
+
dist_opt = calc_dist_kmer(opts, naturals)
|
| 241 |
+
else:
|
| 242 |
+
if os.path.exists('./files/rand_ham_new.npy'):
|
| 243 |
+
dist_rand = np.load('./files/rand_ham_new.npy', allow_pickle=True)
|
| 244 |
+
else:
|
| 245 |
+
dist_rand = hamming_dist(randoms,naturals_all)
|
| 246 |
+
with open("./files/rand_ham_new.npy", 'wb') as f:
|
| 247 |
+
np.save(f,dist_rand)
|
| 248 |
+
|
| 249 |
+
if os.path.exists('./files/real_ham_new.npy'):
|
| 250 |
+
dist_real = np.load('./files/real_ham_new.npy', allow_pickle=True)
|
| 251 |
+
else:
|
| 252 |
+
dist_real = hamming_dist(naturals, naturals_all)
|
| 253 |
+
with open("./files/real_ham_new.npy", 'wb') as f:
|
| 254 |
+
np.save(f,dist_real)
|
| 255 |
+
|
| 256 |
+
if os.path.exists('./files/gen_ham_new.npy'):
|
| 257 |
+
dist_gen = np.load('./files/gen_ham_new.npy', allow_pickle=True)
|
| 258 |
+
else:
|
| 259 |
+
dist_gen = hamming_dist(gens, naturals_all)
|
| 260 |
+
with open("./files/gen_ham_new.npy", 'wb') as f:
|
| 261 |
+
np.save(f,dist_gen)
|
| 262 |
+
|
| 263 |
+
if os.path.exists('./files/opt_ham_new.npy'):
|
| 264 |
+
dist_opt = np.load('./files/opt_ham_new.npy', allow_pickle=True)
|
| 265 |
+
else:
|
| 266 |
+
dist_opt = hamming_dist(opts, naturals_all)
|
| 267 |
+
with open("./files/opt_ham_new.npy", 'wb') as f:
|
| 268 |
+
np.save(f,dist_opt)
|
| 269 |
+
|
| 270 |
+
# filter:
|
| 271 |
+
dist_real_filtered = []
|
| 272 |
+
for i in range(len(dist_real)):
|
| 273 |
+
if dist_real[i] > 21:
|
| 274 |
+
dist_real_filtered.append(dist_real[i])
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
dist_real = dist_real_filtered
|
| 278 |
+
|
| 279 |
+
real_x = ['Natural\n5\' UTR' for i in range(len(dist_real))]
|
| 280 |
+
gen_x = ['Generated' for i in range(len(dist_gen))]
|
| 281 |
+
opt_x = ['Optimized' for i in range(len(dist_opt))]
|
| 282 |
+
rand_x = ['Optimus\n5-Prime' for i in range(len(dist_rand))]
|
| 283 |
+
|
| 284 |
+
gent_dist = ttest_ind(dist_gen,dist_real)
|
| 285 |
+
optt_dist = ttest_ind(dist_opt,dist_real)
|
| 286 |
+
randt_dist = ttest_ind(dist_rand,dist_real)
|
| 287 |
+
genu_dist = mannwhitneyu(dist_gen, dist_real)
|
| 288 |
+
optu_dist = mannwhitneyu(dist_opt, dist_real)
|
| 289 |
+
randu_dist = mannwhitneyu(dist_rand, dist_real)
|
| 290 |
+
es_gen_lev = ES_CI(dist_gen,dist_real)
|
| 291 |
+
es_opt_lev = ES_CI(dist_opt,dist_real)
|
| 292 |
+
es_rand_lev = ES_CI(dist_rand,dist_real)
|
| 293 |
+
|
| 294 |
+
x = np.concatenate((gen_x,opt_x,real_x,rand_x))
|
| 295 |
+
y = np.concatenate((dist_gen,dist_opt,dist_real,dist_rand))
|
| 296 |
+
|
| 297 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 298 |
+
|
| 299 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[0,0], palette=customPalette)
|
| 300 |
+
|
| 301 |
+
if DIST == 'KMER':
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
axs[0,0].set_ylabel("Min. 4-mer Distance")
|
| 305 |
+
axs[0,0].set_xlabel("")
|
| 306 |
+
|
| 307 |
+
else:
|
| 308 |
+
|
| 309 |
+
axs[0,0].set_ylabel("Min. Levenshtein Distance")
|
| 310 |
+
axs[0,0].set_xlabel("")
|
| 311 |
+
|
| 312 |
+
############################################################################
|
| 313 |
+
|
| 314 |
+
if os.path.exists('./files/rand_4mer_new.npy'):
|
| 315 |
+
dist_rand = np.load('./files/rand_4mer_new.npy', allow_pickle=True)
|
| 316 |
+
else:
|
| 317 |
+
dist_rand = calc_dist_kmer(randoms, naturals_all)
|
| 318 |
+
with open("./files/rand_4mer_new.npy", 'wb') as f:
|
| 319 |
+
np.save(f,dist_rand)
|
| 320 |
+
|
| 321 |
+
if os.path.exists('./files/real_4mer_new.npy'):
|
| 322 |
+
dist_real = np.load('./files/real_4mer_new.npy', allow_pickle=True)
|
| 323 |
+
else:
|
| 324 |
+
dist_real = calc_dist_kmer(naturals, naturals_all)
|
| 325 |
+
with open("./files/real_4mer_new.npy", 'wb') as f:
|
| 326 |
+
np.save(f,dist_real)
|
| 327 |
+
|
| 328 |
+
if os.path.exists('./files/gen_4mer_new.npy'):
|
| 329 |
+
dist_gen = np.load('./files/gen_4mer_new.npy', allow_pickle=True)
|
| 330 |
+
else:
|
| 331 |
+
dist_gen = calc_dist_kmer(gens, naturals_all)
|
| 332 |
+
with open("./files/gen_4mer_new.npy", 'wb') as f:
|
| 333 |
+
np.save(f,dist_gen)
|
| 334 |
+
|
| 335 |
+
if os.path.exists('./files/opt_4mer_new.npy'):
|
| 336 |
+
dist_opt = np.load('./files/opt_4mer_new.npy', allow_pickle=True)
|
| 337 |
+
else:
|
| 338 |
+
dist_opt = calc_dist_kmer(opts, naturals_all)
|
| 339 |
+
with open("./files/opt_4mer_new.npy", 'wb') as f:
|
| 340 |
+
np.save(f,dist_opt)
|
| 341 |
+
|
| 342 |
+
anomalies = 0
|
| 343 |
+
|
| 344 |
+
dist_real_filtered = []
|
| 345 |
+
for i in range(len(dist_real)):
|
| 346 |
+
if dist_real[i] > 7.5:
|
| 347 |
+
dist_real_filtered.append(dist_real[i])
|
| 348 |
+
else:
|
| 349 |
+
anomalies += 1
|
| 350 |
+
|
| 351 |
+
print(anomalies)
|
| 352 |
+
|
| 353 |
+
dist_real = dist_real_filtered
|
| 354 |
+
|
| 355 |
+
real_x = ['Natural\n5\' UTR' for i in range(len(dist_real))]
|
| 356 |
+
gen_x = ['Generated' for i in range(len(dist_gen))]
|
| 357 |
+
opt_x = ['Optimized' for i in range(len(dist_opt))]
|
| 358 |
+
rand_x = ['Optimus\n5-Prime' for i in range(len(dist_rand))]
|
| 359 |
+
|
| 360 |
+
gent_dist2 = ttest_ind(dist_gen,dist_real)
|
| 361 |
+
optt_dist2 = ttest_ind(dist_opt,dist_real)
|
| 362 |
+
randt_dist2 = ttest_ind(dist_rand,dist_real)
|
| 363 |
+
genu_dist2 = mannwhitneyu(dist_gen, dist_real)
|
| 364 |
+
optu_dist2 = mannwhitneyu(dist_opt, dist_real)
|
| 365 |
+
randu_dist2 = mannwhitneyu(dist_rand, dist_real)
|
| 366 |
+
es_gen_4mer = ES_CI(dist_gen,dist_real)
|
| 367 |
+
es_opt_4mer = ES_CI(dist_opt,dist_real)
|
| 368 |
+
es_rand_4mer = ES_CI(dist_rand,dist_real)
|
| 369 |
+
|
| 370 |
+
x = np.concatenate((gen_x,opt_x,real_x,rand_x))
|
| 371 |
+
y = np.concatenate((dist_gen,dist_opt,dist_real,dist_rand))
|
| 372 |
+
|
| 373 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 374 |
+
|
| 375 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[0,1], palette = customPalette)
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
axs[0,1].set_ylabel("Min. 4-mer Distance")
|
| 379 |
+
axs[0,1].set_xlabel("")
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
############################# GC Content ####################################
|
| 383 |
+
|
| 384 |
+
rand_gc = get_gc_content_many(randoms)
|
| 385 |
+
real_gc = get_gc_content_many(naturals_all)
|
| 386 |
+
gens_gc = get_gc_content_many(gens)
|
| 387 |
+
opts_gc = get_gc_content_many(opts)
|
| 388 |
+
|
| 389 |
+
real_x = ['Natural\n5\' UTR' for i in range(len(real_gc))]
|
| 390 |
+
gen_x = ['Generated' for i in range(len(gens_gc))]
|
| 391 |
+
opt_x = ['Optimized' for i in range(len(opts_gc))]
|
| 392 |
+
rand_x = ['Optimus\n5-Prime' for i in range(len(rand_gc))]
|
| 393 |
+
|
| 394 |
+
x = np.concatenate((gen_x,opt_x,real_x,rand_x))
|
| 395 |
+
y = np.concatenate((gens_gc,opts_gc,real_gc,rand_gc))
|
| 396 |
+
|
| 397 |
+
gent_gc = ttest_ind(gens_gc, real_gc)
|
| 398 |
+
optt_gc = ttest_ind(opts_gc, real_gc)
|
| 399 |
+
randt_gc = ttest_ind(rand_gc, real_gc)
|
| 400 |
+
genu_gc = mannwhitneyu(gens_gc, real_gc)
|
| 401 |
+
optu_gc = mannwhitneyu(opts_gc, real_gc)
|
| 402 |
+
randu_gc = mannwhitneyu(rand_gc, real_gc)
|
| 403 |
+
es_gen_gc = ES_CI(gens_gc,real_gc)
|
| 404 |
+
es_opt_gc = ES_CI(opts_gc,real_gc)
|
| 405 |
+
es_rand_gc = ES_CI(rand_gc,real_gc)
|
| 406 |
+
|
| 407 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 408 |
+
|
| 409 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[0,2], palette=customPalette)
|
| 410 |
+
|
| 411 |
+
axs[0,2].set_ylabel("G/C Content")
|
| 412 |
+
axs[0,2].set_xlabel("")
|
| 413 |
+
|
| 414 |
+
########################################################### TE
|
| 415 |
+
|
| 416 |
+
randpreds = np.load('./files/te_optimus.npy',allow_pickle=True)
|
| 417 |
+
genpreds = np.load('./files/te_gens.npy',allow_pickle=True)
|
| 418 |
+
optpreds = np.load('./files/te_optimized.npy',allow_pickle=True)
|
| 419 |
+
realpreds = np.load('./files/te_reals.npy',allow_pickle=True)
|
| 420 |
+
|
| 421 |
+
randpreds = np.power(10,randpreds)
|
| 422 |
+
genpreds = np.power(10,genpreds)
|
| 423 |
+
optpreds = np.power(10,optpreds)
|
| 424 |
+
realpreds = np.power(10,realpreds)
|
| 425 |
+
|
| 426 |
+
real_x = ['Natural\n5\' UTR' for i in range(len(realpreds))]
|
| 427 |
+
gen_x = ['Generated' for i in range(len(genpreds))]
|
| 428 |
+
opt_x = ['Optimized' for i in range(len(optpreds))]
|
| 429 |
+
rand_x = ['Optimus\n5-Prime' for i in range(len(randpreds))]
|
| 430 |
+
|
| 431 |
+
x = np.concatenate((gen_x,opt_x,real_x,rand_x))
|
| 432 |
+
y = np.concatenate((genpreds,optpreds,realpreds,randpreds))
|
| 433 |
+
|
| 434 |
+
gent_te = ttest_ind(genpreds, realpreds)
|
| 435 |
+
randt_te = ttest_ind(randpreds, realpreds)
|
| 436 |
+
optt_te = ttest_ind(optpreds, realpreds)
|
| 437 |
+
genu_te = mannwhitneyu(genpreds, realpreds)
|
| 438 |
+
optu_te = mannwhitneyu(optpreds, realpreds)
|
| 439 |
+
randu_te = mannwhitneyu(randpreds, realpreds)
|
| 440 |
+
es_gen_te = ES_CI(genpreds,realpreds)
|
| 441 |
+
es_opt_te = ES_CI(optpreds,realpreds)
|
| 442 |
+
es_rand_te = ES_CI(randpreds,realpreds)
|
| 443 |
+
|
| 444 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 445 |
+
|
| 446 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[1,1], palette=customPalette)
|
| 447 |
+
|
| 448 |
+
axs[1,1].set_ylabel("Translation Efficiency")
|
| 449 |
+
axs[1,1].set_xlabel("")
|
| 450 |
+
|
| 451 |
+
############################################################
|
| 452 |
+
|
| 453 |
+
axs[1,0].set_title('D',weight='bold',fontsize=64,loc='left')
|
| 454 |
+
axs[1,1].set_title('E',weight='bold',fontsize=64,loc='left')
|
| 455 |
+
axs[1,2].set_title('F',weight='bold',fontsize=64,loc='left')
|
| 456 |
+
axs[0,0].set_title('A',weight='bold',fontsize=64,loc='left')
|
| 457 |
+
axs[0,1].set_title('B',weight='bold',fontsize=64,loc='left')
|
| 458 |
+
axs[0,2].set_title('C',weight='bold',fontsize=64,loc='left')
|
| 459 |
+
|
| 460 |
+
|
| 461 |
+
axs[0,0].tick_params(rotation=30)
|
| 462 |
+
axs[0,1].tick_params(rotation=30)
|
| 463 |
+
axs[1,0].tick_params(rotation=30)
|
| 464 |
+
axs[1,1].tick_params(rotation=30)
|
| 465 |
+
axs[0,2].tick_params(rotation=30)
|
| 466 |
+
axs[1,2].tick_params(rotation=30)
|
| 467 |
+
|
| 468 |
+
fig.tight_layout(pad=2)
|
| 469 |
+
|
| 470 |
+
plt.savefig('./plots/violins_all.png')
|
| 471 |
+
|
| 472 |
+
print("Mean Ribosome Load KStest:")
|
| 473 |
+
print("Generated Samples Test:")
|
| 474 |
+
print(gent_mrl)
|
| 475 |
+
print(genu_mrl)
|
| 476 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 477 |
+
print(es_gen_mrl)
|
| 478 |
+
print("Random Samples Test:")
|
| 479 |
+
print(randt_mrl)
|
| 480 |
+
print(randu_mrl)
|
| 481 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 482 |
+
print(es_rand_mrl)
|
| 483 |
+
print("Optimized Samples Test:")
|
| 484 |
+
print(optt_mrl)
|
| 485 |
+
print(optu_mrl)
|
| 486 |
+
print("Optimized Samples Effect Size and Confidence Interval:")
|
| 487 |
+
print(es_opt_mrl)
|
| 488 |
+
print("Minimum Free Energy KStest:")
|
| 489 |
+
print("Generated Samples Test:")
|
| 490 |
+
print(gent_mfe)
|
| 491 |
+
print(genu_mfe)
|
| 492 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 493 |
+
print(es_gen_mfe)
|
| 494 |
+
print("Random Samples Test:")
|
| 495 |
+
print(randt_mfe)
|
| 496 |
+
print(randu_mfe)
|
| 497 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 498 |
+
print(es_rand_mfe)
|
| 499 |
+
print("Optimized Samples Test:")
|
| 500 |
+
print(optt_mfe)
|
| 501 |
+
print(optu_mfe)
|
| 502 |
+
print("Optimized Samples Effect Size and Confidence Interval:")
|
| 503 |
+
print(es_opt_mfe)
|
| 504 |
+
print("Levenshtien Distance KStest:")
|
| 505 |
+
print("Generated Samples Test:")
|
| 506 |
+
print(gent_dist)
|
| 507 |
+
print(genu_dist)
|
| 508 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 509 |
+
print(es_gen_lev)
|
| 510 |
+
print("Random Samples Test:")
|
| 511 |
+
print(randt_dist)
|
| 512 |
+
print(randu_dist)
|
| 513 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 514 |
+
print(es_rand_lev)
|
| 515 |
+
print("Optimized Samples Test:")
|
| 516 |
+
print(optt_dist)
|
| 517 |
+
print(optu_dist)
|
| 518 |
+
print("Optimized Samples Effect Size and Confidence Interval:")
|
| 519 |
+
print(es_opt_lev)
|
| 520 |
+
print("4-mer Distribution Distance KStest:")
|
| 521 |
+
print("Generated Samples Test:")
|
| 522 |
+
print(gent_dist2)
|
| 523 |
+
print(genu_dist2)
|
| 524 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 525 |
+
print(es_gen_4mer)
|
| 526 |
+
print("Random Samples Test:")
|
| 527 |
+
print(randt_dist2)
|
| 528 |
+
print(randu_dist2)
|
| 529 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 530 |
+
print(es_rand_4mer)
|
| 531 |
+
print("Optimized Samples Test:")
|
| 532 |
+
print(optt_dist2)
|
| 533 |
+
print(optu_dist2)
|
| 534 |
+
print("Optimized Samples Effect Size and Confidence Interval:")
|
| 535 |
+
print(es_opt_4mer)
|
| 536 |
+
print("GC Content KStest:")
|
| 537 |
+
print("Generated Samples Test:")
|
| 538 |
+
print(gent_gc)
|
| 539 |
+
print(genu_gc)
|
| 540 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 541 |
+
print(es_gen_gc)
|
| 542 |
+
print("Random Samples Test:")
|
| 543 |
+
print(randt_gc)
|
| 544 |
+
print(randu_gc)
|
| 545 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 546 |
+
print(es_rand_gc)
|
| 547 |
+
print("Optimized Samples Test:")
|
| 548 |
+
print(optt_gc)
|
| 549 |
+
print(optu_gc)
|
| 550 |
+
print("Optimized Samples Effect Size and Confidence Interval:")
|
| 551 |
+
print(es_opt_gc)
|
| 552 |
+
print("TE KStest:")
|
| 553 |
+
print("Generated Samples Test:")
|
| 554 |
+
print(gent_te)
|
| 555 |
+
print(genu_te)
|
| 556 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 557 |
+
print(es_gen_te)
|
| 558 |
+
print("Random Samples Test:")
|
| 559 |
+
print(randt_te)
|
| 560 |
+
print(randu_te)
|
| 561 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 562 |
+
print(es_rand_te)
|
| 563 |
+
print("Optimized Samples Test:")
|
| 564 |
+
print(optt_te)
|
| 565 |
+
print(optu_te)
|
| 566 |
+
print("Optimized Samples Effect Size and Confidence Interval:")
|
| 567 |
+
print(es_opt_te)
|
conf/analysis/violin_dists.py
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from matplotlib import colors
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import matplotlib.pyplot as plt
|
| 5 |
+
import matplotlib.patches as mpatches
|
| 6 |
+
import random
|
| 7 |
+
from scipy.stats import ks_2samp,kstest,ttest_ind, mannwhitneyu, norm
|
| 8 |
+
from cliffs_delta import cliffs_delta
|
| 9 |
+
import seaborn as sns
|
| 10 |
+
from tqdm import tqdm
|
| 11 |
+
import random
|
| 12 |
+
random.seed(1337)
|
| 13 |
+
import os
|
| 14 |
+
import numpy as np
|
| 15 |
+
np.random.seed(1337)
|
| 16 |
+
import pandas as pd
|
| 17 |
+
pd.options.mode.chained_assignment = None
|
| 18 |
+
import RNA
|
| 19 |
+
from polyleven import levenshtein
|
| 20 |
+
import time
|
| 21 |
+
import itertools
|
| 22 |
+
import tensorflow as tf
|
| 23 |
+
from tensorflow.keras import backend as K
|
| 24 |
+
from tensorflow.keras.models import load_model
|
| 25 |
+
from tensorflow.keras.layers import Layer
|
| 26 |
+
|
| 27 |
+
from utils.util import *
|
| 28 |
+
from utils.framepool import *
|
| 29 |
+
|
| 30 |
+
colors = ["#3c5068", "#acbab6", "#dcd3cd", "#d4a6a6"]
|
| 31 |
+
|
| 32 |
+
tf.compat.v1.enable_eager_execution()
|
| 33 |
+
|
| 34 |
+
# os.environ["CUDA_VISIBLE_DEVICES"] = '5'
|
| 35 |
+
|
| 36 |
+
def ES_CI(d1, d2):
|
| 37 |
+
n1 = len(d1)
|
| 38 |
+
n2 = len(d2)
|
| 39 |
+
|
| 40 |
+
u1 = np.mean(d1)
|
| 41 |
+
u2 = np.mean(d2)
|
| 42 |
+
|
| 43 |
+
s1 = np.std(d1)
|
| 44 |
+
s2 = np.std(d2)
|
| 45 |
+
|
| 46 |
+
s = np.sqrt(((n1 - 1) * np.power(s1,2) + (n2 - 1) * np.power(s2,2)) / (n1 + n2 - 2))
|
| 47 |
+
|
| 48 |
+
effect_size = (u1 - u2)/s
|
| 49 |
+
effect_size = cliffs_delta(d1, d2)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
ct1 = n1 #items in dataset 1
|
| 54 |
+
ct2 = n2 #items in dataset 2
|
| 55 |
+
ds1 = d1
|
| 56 |
+
ds2 = d2
|
| 57 |
+
alpha = 0.05 #95% confidence interval
|
| 58 |
+
N = norm.ppf(1 - alpha/2) # percent point function - inverse of cdf
|
| 59 |
+
|
| 60 |
+
# The confidence interval for the difference between the two population
|
| 61 |
+
# medians is derived through these nxm differences.
|
| 62 |
+
diffs = sorted([i-j for i in ds1 for j in ds2])
|
| 63 |
+
|
| 64 |
+
# For an approximate 100(1-a)% confidence interval first calculate K:
|
| 65 |
+
k = int(round(ct1*ct2/2 - (N * (ct1*ct2*(ct1+ct2+1)/12)**0.5)))
|
| 66 |
+
|
| 67 |
+
# The Kth smallest to the Kth largest of the n x m differences
|
| 68 |
+
# ct1 and ct2 should be > ~20
|
| 69 |
+
CI = (diffs[k], diffs[len(diffs)-k])
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
return effect_size, CI
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
customPalette = {'Generated':colors[0],'Random':colors[3],'Natural':colors[1]}
|
| 76 |
+
|
| 77 |
+
UTR_LEN = 128
|
| 78 |
+
Z_DIM = 40
|
| 79 |
+
DIM = Z_DIM
|
| 80 |
+
BATCH_SIZE = 2048
|
| 81 |
+
MAX_LEN = UTR_LEN
|
| 82 |
+
gpath = './../models/checkpoint_3000.h5'
|
| 83 |
+
data_path = './../data/utrdb2.csv'
|
| 84 |
+
mrl_path = './../models/utr_model_combined_residual_new.h5'
|
| 85 |
+
|
| 86 |
+
sns.set()
|
| 87 |
+
sns.set_style('ticks')
|
| 88 |
+
|
| 89 |
+
#POSTER
|
| 90 |
+
params = {'legend.fontsize': 48,
|
| 91 |
+
'figure.figsize': (54, 32),
|
| 92 |
+
'axes.labelsize': 60,
|
| 93 |
+
'axes.titlesize':60,
|
| 94 |
+
'xtick.labelsize':60,
|
| 95 |
+
'ytick.labelsize':60}
|
| 96 |
+
|
| 97 |
+
plt.rcParams.update(params)
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
model = load_framepool(mrl_path)
|
| 101 |
+
|
| 102 |
+
gens = generate_data(path=gpath, UTR_LEN=UTR_LEN, BATCH_SIZE=BATCH_SIZE, DIM=DIM)
|
| 103 |
+
gens2 = generate_data(path=gpath, UTR_LEN=UTR_LEN, BATCH_SIZE=4096, DIM=DIM)
|
| 104 |
+
gens_encoded = np.array([encode_seq_framepool(seq) for seq in gens])
|
| 105 |
+
randoms = random_data(length=UTR_LEN, size=BATCH_SIZE)
|
| 106 |
+
randoms_encoded = np.array([encode_seq_framepool(seq) for seq in randoms])
|
| 107 |
+
naturals = read_real(data_path, UTR_LEN=UTR_LEN, all=False, samples=BATCH_SIZE)
|
| 108 |
+
naturals2 = read_real(data_path, UTR_LEN=UTR_LEN, all=False, samples=10000)
|
| 109 |
+
naturals_encoded = np.array([encode_seq_framepool(seq) for seq in naturals])
|
| 110 |
+
naturals_all = read_real(data_path, UTR_LEN=UTR_LEN, all=True)
|
| 111 |
+
naturals_encoded_all = np.array([encode_seq_framepool(seq) for seq in naturals_all])
|
| 112 |
+
############################# MRL PREDICTION ####################################
|
| 113 |
+
|
| 114 |
+
######### Gens
|
| 115 |
+
|
| 116 |
+
gens_tensor = tf.convert_to_tensor(gens_encoded,dtype=tf.float32)
|
| 117 |
+
pred_gens = model(gens_tensor)
|
| 118 |
+
pred_gens = tf.reshape(pred_gens,(-1))
|
| 119 |
+
genpreds = pred_gens.numpy().astype('float')
|
| 120 |
+
|
| 121 |
+
######### Randoms
|
| 122 |
+
|
| 123 |
+
randoms_tensor = tf.convert_to_tensor(randoms_encoded,dtype=tf.float32)
|
| 124 |
+
pred_randoms = model(randoms_tensor)
|
| 125 |
+
pred_randoms = tf.reshape(pred_randoms,(-1))
|
| 126 |
+
randpreds = pred_randoms.numpy().astype('float')
|
| 127 |
+
|
| 128 |
+
######## Labeled
|
| 129 |
+
|
| 130 |
+
naturals_tensors = tf.convert_to_tensor(naturals_encoded_all,dtype=tf.float32)
|
| 131 |
+
pred_naturals = model(naturals_tensors)
|
| 132 |
+
pred_naturals = tf.reshape(pred_naturals,(-1))
|
| 133 |
+
realpreds = pred_naturals.numpy().astype('float')
|
| 134 |
+
|
| 135 |
+
############
|
| 136 |
+
|
| 137 |
+
bins = np.linspace(2.5, 9, 30)
|
| 138 |
+
|
| 139 |
+
fig, axs = plt.subplots(2,3)
|
| 140 |
+
|
| 141 |
+
real_x = ['Natural' for i in range(len(realpreds))]
|
| 142 |
+
gen_x = ['Generated' for i in range(len(genpreds))]
|
| 143 |
+
rand_x = ['Random' for i in range(len(randpreds))]
|
| 144 |
+
|
| 145 |
+
x = np.concatenate((gen_x,real_x,rand_x))
|
| 146 |
+
y = np.concatenate((genpreds,realpreds,randpreds))
|
| 147 |
+
|
| 148 |
+
gent_mrl = ttest_ind(genpreds,realpreds)
|
| 149 |
+
randt_mrl = ttest_ind(randpreds,realpreds)
|
| 150 |
+
genu_mrl = mannwhitneyu(genpreds, realpreds)
|
| 151 |
+
randu_mrl = mannwhitneyu(randpreds, realpreds)
|
| 152 |
+
es_gen_mrl = ES_CI(genpreds,realpreds)
|
| 153 |
+
es_rand_mrl = ES_CI(randpreds,realpreds)
|
| 154 |
+
|
| 155 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 156 |
+
|
| 157 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[1,0],palette=customPalette)
|
| 158 |
+
|
| 159 |
+
axs[1,0].set_ylabel("Mean Ribosome Load")
|
| 160 |
+
axs[1,0].set_xlabel("")
|
| 161 |
+
|
| 162 |
+
############################# MFE PREDICTION ####################################
|
| 163 |
+
|
| 164 |
+
genpreds = []
|
| 165 |
+
|
| 166 |
+
for i in range(len(gens)):
|
| 167 |
+
(ss, mfe) = RNA.fold(gens[i])
|
| 168 |
+
genpreds.append(mfe)
|
| 169 |
+
|
| 170 |
+
randpreds = []
|
| 171 |
+
|
| 172 |
+
for i in range(len(randoms)):
|
| 173 |
+
(ss, mfe) = RNA.fold(randoms[i])
|
| 174 |
+
randpreds.append(mfe)
|
| 175 |
+
|
| 176 |
+
realpreds = []
|
| 177 |
+
|
| 178 |
+
for i in range(len(naturals_all)):
|
| 179 |
+
(ss, mfe) = RNA.fold(naturals_all[i])
|
| 180 |
+
realpreds.append(mfe)
|
| 181 |
+
|
| 182 |
+
real_x = ['Natural' for i in range(len(realpreds))]
|
| 183 |
+
gen_x = ['Generated' for i in range(len(genpreds))]
|
| 184 |
+
rand_x = ['Random' for i in range(len(randpreds))]
|
| 185 |
+
|
| 186 |
+
gent_mfe = ttest_ind(genpreds,realpreds)
|
| 187 |
+
randt_mfe = ttest_ind(randpreds,realpreds)
|
| 188 |
+
randu_mfe = mannwhitneyu(randpreds, realpreds)
|
| 189 |
+
genu_mfe = mannwhitneyu(genpreds, realpreds)
|
| 190 |
+
es_gen_mfe = ES_CI(genpreds,realpreds)
|
| 191 |
+
es_rand_mfe = ES_CI(randpreds,realpreds)
|
| 192 |
+
|
| 193 |
+
x = np.concatenate((gen_x,real_x,rand_x))
|
| 194 |
+
y = np.concatenate((genpreds,realpreds,randpreds))
|
| 195 |
+
|
| 196 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 197 |
+
|
| 198 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[1,2],palette=customPalette)
|
| 199 |
+
|
| 200 |
+
axs[1,2].set_ylabel("Minimum Free Energy")
|
| 201 |
+
axs[1,2].set_xlabel("")
|
| 202 |
+
|
| 203 |
+
############################# Levenshtein Distance ####################################
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
DIST = 'S'
|
| 208 |
+
|
| 209 |
+
if DIST == 'KMER':
|
| 210 |
+
dist_rand = calc_dist_kmer(randoms, naturals)
|
| 211 |
+
dist_gen = calc_dist_kmer(gens, naturals)
|
| 212 |
+
dist_real = calc_dist_kmer(naturals, naturals)
|
| 213 |
+
else:
|
| 214 |
+
if os.path.exists('./files/rand_ham_new.npy'):
|
| 215 |
+
dist_rand = np.load('./files/rand_ham_new.npy', allow_pickle=True)
|
| 216 |
+
else:
|
| 217 |
+
dist_rand = hamming_dist(randoms,naturals_all)
|
| 218 |
+
with open("./files/rand_ham_new.npy", 'wb') as f:
|
| 219 |
+
np.save(f,dist_rand)
|
| 220 |
+
|
| 221 |
+
if os.path.exists('./files/real_ham_new.npy'):
|
| 222 |
+
dist_real = np.load('./files/real_ham_new.npy', allow_pickle=True)
|
| 223 |
+
else:
|
| 224 |
+
dist_real = hamming_dist(naturals, naturals_all)
|
| 225 |
+
with open("./files/real_ham_new.npy", 'wb') as f:
|
| 226 |
+
np.save(f,dist_real)
|
| 227 |
+
|
| 228 |
+
if os.path.exists('./files/gen_ham_new.npy'):
|
| 229 |
+
dist_gen = np.load('./files/gen_ham_new.npy', allow_pickle=True)
|
| 230 |
+
else:
|
| 231 |
+
dist_gen = hamming_dist(gens, naturals_all)
|
| 232 |
+
with open("./files/gen_ham_new.npy", 'wb') as f:
|
| 233 |
+
np.save(f,dist_gen)
|
| 234 |
+
|
| 235 |
+
# filter:
|
| 236 |
+
dist_real_filtered = []
|
| 237 |
+
for i in range(len(dist_real)):
|
| 238 |
+
if dist_real[i] > 21:
|
| 239 |
+
dist_real_filtered.append(dist_real[i])
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
dist_real = dist_real_filtered
|
| 243 |
+
|
| 244 |
+
real_x = ['Natural' for i in range(len(dist_real))]
|
| 245 |
+
gen_x = ['Generated' for i in range(len(dist_gen))]
|
| 246 |
+
rand_x = ['Random' for i in range(len(dist_rand))]
|
| 247 |
+
|
| 248 |
+
gent_dist = ttest_ind(dist_gen,dist_real)
|
| 249 |
+
randt_dist = ttest_ind(dist_rand,dist_real)
|
| 250 |
+
genu_dist = mannwhitneyu(dist_gen, dist_real)
|
| 251 |
+
randu_dist = mannwhitneyu(dist_rand, dist_real)
|
| 252 |
+
es_gen_lev = ES_CI(dist_gen,dist_real)
|
| 253 |
+
es_rand_lev = ES_CI(dist_rand,dist_real)
|
| 254 |
+
|
| 255 |
+
x = np.concatenate((gen_x,real_x,rand_x))
|
| 256 |
+
y = np.concatenate((dist_gen,dist_real,dist_rand))
|
| 257 |
+
|
| 258 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 259 |
+
|
| 260 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[0,0], palette=customPalette)
|
| 261 |
+
|
| 262 |
+
if DIST == 'KMER':
|
| 263 |
+
|
| 264 |
+
|
| 265 |
+
axs[0,0].set_ylabel("Min. 4-mer Distance")
|
| 266 |
+
axs[0,0].set_xlabel("")
|
| 267 |
+
|
| 268 |
+
else:
|
| 269 |
+
|
| 270 |
+
axs[0,0].set_ylabel("Min. Levenshtein Distance")
|
| 271 |
+
axs[0,0].set_xlabel("")
|
| 272 |
+
|
| 273 |
+
############################################################################
|
| 274 |
+
|
| 275 |
+
if os.path.exists('./files/rand_4mer_new.npy'):
|
| 276 |
+
dist_rand = np.load('./files/rand_4mer_new.npy', allow_pickle=True)
|
| 277 |
+
else:
|
| 278 |
+
dist_rand = calc_dist_kmer(randoms, naturals_all)
|
| 279 |
+
with open("./files/rand_4mer_new.npy", 'wb') as f:
|
| 280 |
+
np.save(f,dist_rand)
|
| 281 |
+
|
| 282 |
+
if os.path.exists('./files/real_4mer_new.npy'):
|
| 283 |
+
dist_real = np.load('./files/real_4mer_new.npy', allow_pickle=True)
|
| 284 |
+
else:
|
| 285 |
+
dist_real = calc_dist_kmer(naturals, naturals_all)
|
| 286 |
+
with open("./files/real_4mer_new.npy", 'wb') as f:
|
| 287 |
+
np.save(f,dist_real)
|
| 288 |
+
|
| 289 |
+
if os.path.exists('./files/gen_4mer_new.npy'):
|
| 290 |
+
dist_gen = np.load('./files/gen_4mer_new.npy', allow_pickle=True)
|
| 291 |
+
else:
|
| 292 |
+
dist_gen = calc_dist_kmer(gens, naturals_all)
|
| 293 |
+
with open("./files/gen_4mer_new.npy", 'wb') as f:
|
| 294 |
+
np.save(f,dist_gen)
|
| 295 |
+
|
| 296 |
+
anomalies = 0
|
| 297 |
+
|
| 298 |
+
dist_real_filtered = []
|
| 299 |
+
for i in range(len(dist_real)):
|
| 300 |
+
if dist_real[i] > 7.5:
|
| 301 |
+
dist_real_filtered.append(dist_real[i])
|
| 302 |
+
else:
|
| 303 |
+
anomalies += 1
|
| 304 |
+
|
| 305 |
+
print(anomalies)
|
| 306 |
+
|
| 307 |
+
dist_real = dist_real_filtered
|
| 308 |
+
|
| 309 |
+
real_x = ['Natural' for i in range(len(dist_real))]
|
| 310 |
+
gen_x = ['Generated' for i in range(len(dist_gen))]
|
| 311 |
+
rand_x = ['Random' for i in range(len(dist_rand))]
|
| 312 |
+
|
| 313 |
+
gent_dist2 = ttest_ind(dist_gen,dist_real)
|
| 314 |
+
randt_dist2 = ttest_ind(dist_rand,dist_real)
|
| 315 |
+
genu_dist2 = mannwhitneyu(dist_gen, dist_real)
|
| 316 |
+
randu_dist2 = mannwhitneyu(dist_rand, dist_real)
|
| 317 |
+
es_gen_4mer = ES_CI(dist_gen,dist_real)
|
| 318 |
+
es_rand_4mer = ES_CI(dist_rand,dist_real)
|
| 319 |
+
|
| 320 |
+
x = np.concatenate((gen_x,real_x,rand_x))
|
| 321 |
+
y = np.concatenate((dist_gen,dist_real,dist_rand))
|
| 322 |
+
|
| 323 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 324 |
+
|
| 325 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[0,1], palette = customPalette)
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
axs[0,1].set_ylabel("Min. 4-mer Distance")
|
| 329 |
+
axs[0,1].set_xlabel("")
|
| 330 |
+
|
| 331 |
+
|
| 332 |
+
############################# GC Content ####################################
|
| 333 |
+
|
| 334 |
+
rand_gc = get_gc_content_many(randoms)
|
| 335 |
+
real_gc = get_gc_content_many(naturals_all)
|
| 336 |
+
gens_gc = get_gc_content_many(gens)
|
| 337 |
+
|
| 338 |
+
real_x = ['Natural' for i in range(len(real_gc))]
|
| 339 |
+
gen_x = ['Generated' for i in range(len(gens_gc))]
|
| 340 |
+
rand_x = ['Random' for i in range(len(rand_gc))]
|
| 341 |
+
|
| 342 |
+
x = np.concatenate((gen_x,real_x,rand_x))
|
| 343 |
+
y = np.concatenate((gens_gc,real_gc,rand_gc))
|
| 344 |
+
|
| 345 |
+
gent_gc = ttest_ind(gens_gc, real_gc)
|
| 346 |
+
randt_gc = ttest_ind(rand_gc, real_gc)
|
| 347 |
+
genu_gc = mannwhitneyu(gens_gc, real_gc)
|
| 348 |
+
randu_gc = mannwhitneyu(rand_gc, real_gc)
|
| 349 |
+
es_gen_gc = ES_CI(gens_gc,real_gc)
|
| 350 |
+
es_rand_gc = ES_CI(rand_gc,real_gc)
|
| 351 |
+
|
| 352 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 353 |
+
|
| 354 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[0,2], palette=customPalette)
|
| 355 |
+
|
| 356 |
+
axs[0,2].set_ylabel("G/C Content")
|
| 357 |
+
axs[0,2].set_xlabel("")
|
| 358 |
+
|
| 359 |
+
########################################################### TE
|
| 360 |
+
|
| 361 |
+
randpreds = np.load('./files/te_rands.npy',allow_pickle=True)
|
| 362 |
+
genpreds = np.load('./files/te_gens.npy',allow_pickle=True)
|
| 363 |
+
realpreds = np.load('./files/te_reals.npy',allow_pickle=True)
|
| 364 |
+
|
| 365 |
+
real_x = ['Natural' for i in range(len(realpreds))]
|
| 366 |
+
gen_x = ['Generated' for i in range(len(genpreds))]
|
| 367 |
+
rand_x = ['Random' for i in range(len(randpreds))]
|
| 368 |
+
|
| 369 |
+
x = np.concatenate((gen_x,real_x,rand_x))
|
| 370 |
+
y = np.concatenate((genpreds,realpreds,randpreds))
|
| 371 |
+
|
| 372 |
+
gent_te = ttest_ind(genpreds, realpreds)
|
| 373 |
+
randt_te = ttest_ind(randpreds, realpreds)
|
| 374 |
+
genu_te = mannwhitneyu(genpreds, realpreds)
|
| 375 |
+
randu_te = mannwhitneyu(randpreds, realpreds)
|
| 376 |
+
es_gen_te = ES_CI(genpreds,realpreds)
|
| 377 |
+
es_rand_te = ES_CI(randpreds,realpreds)
|
| 378 |
+
|
| 379 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 380 |
+
|
| 381 |
+
sns.violinplot(x=df['x'],y=df['y'],ax=axs[1,1], palette=customPalette)
|
| 382 |
+
|
| 383 |
+
axs[1,1].set_ylabel("Translation Efficiency")
|
| 384 |
+
axs[1,1].set_xlabel("")
|
| 385 |
+
|
| 386 |
+
############################################################
|
| 387 |
+
|
| 388 |
+
axs[1,0].set_title('D',weight='bold',fontsize=64,loc='left')
|
| 389 |
+
axs[1,1].set_title('E',weight='bold',fontsize=64,loc='left')
|
| 390 |
+
axs[1,2].set_title('F',weight='bold',fontsize=64,loc='left')
|
| 391 |
+
axs[0,0].set_title('A',weight='bold',fontsize=64,loc='left')
|
| 392 |
+
axs[0,1].set_title('B',weight='bold',fontsize=64,loc='left')
|
| 393 |
+
axs[0,2].set_title('C',weight='bold',fontsize=64,loc='left')
|
| 394 |
+
fig.tight_layout(pad=2)
|
| 395 |
+
|
| 396 |
+
plt.savefig('./plots/violins_all.png')
|
| 397 |
+
|
| 398 |
+
print("Mean Ribosome Load KStest:")
|
| 399 |
+
print("Generated Samples Test:")
|
| 400 |
+
print(gent_mrl)
|
| 401 |
+
print(genu_mrl)
|
| 402 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 403 |
+
print(es_gen_mrl)
|
| 404 |
+
print("Random Samples Test:")
|
| 405 |
+
print(randt_mrl)
|
| 406 |
+
print(randu_mrl)
|
| 407 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 408 |
+
print(es_rand_mrl)
|
| 409 |
+
print("Minimum Free Energy KStest:")
|
| 410 |
+
print("Generated Samples Test:")
|
| 411 |
+
print(gent_mfe)
|
| 412 |
+
print(genu_mfe)
|
| 413 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 414 |
+
print(es_gen_mfe)
|
| 415 |
+
print("Random Samples Test:")
|
| 416 |
+
print(randt_mfe)
|
| 417 |
+
print(randu_mfe)
|
| 418 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 419 |
+
print(es_rand_mfe)
|
| 420 |
+
print("Levenshtien Distance KStest:")
|
| 421 |
+
print("Generated Samples Test:")
|
| 422 |
+
print(gent_dist)
|
| 423 |
+
print(genu_dist)
|
| 424 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 425 |
+
print(es_gen_lev)
|
| 426 |
+
print("Random Samples Test:")
|
| 427 |
+
print(randt_dist)
|
| 428 |
+
print(randu_dist)
|
| 429 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 430 |
+
print(es_rand_lev)
|
| 431 |
+
print("4-mer Distribution Distance KStest:")
|
| 432 |
+
print("Generated Samples Test:")
|
| 433 |
+
print(gent_dist2)
|
| 434 |
+
print(genu_dist2)
|
| 435 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 436 |
+
print(es_gen_4mer)
|
| 437 |
+
print("Random Samples Test:")
|
| 438 |
+
print(randt_dist2)
|
| 439 |
+
print(randu_dist2)
|
| 440 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 441 |
+
print(es_rand_4mer)
|
| 442 |
+
print("GC Content KStest:")
|
| 443 |
+
print("Generated Samples Test:")
|
| 444 |
+
print(gent_gc)
|
| 445 |
+
print(genu_gc)
|
| 446 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 447 |
+
print(es_gen_gc)
|
| 448 |
+
print("Random Samples Test:")
|
| 449 |
+
print(randt_gc)
|
| 450 |
+
print(randu_gc)
|
| 451 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 452 |
+
print(es_rand_gc)
|
| 453 |
+
print("TE KStest:")
|
| 454 |
+
print("Generated Samples Test:")
|
| 455 |
+
print(gent_te)
|
| 456 |
+
print(genu_te)
|
| 457 |
+
print("Generated Samples Effect Size and Confidence Interval:")
|
| 458 |
+
print(es_gen_te)
|
| 459 |
+
print("Random Samples Test:")
|
| 460 |
+
print(randt_te)
|
| 461 |
+
print(randu_te)
|
| 462 |
+
print("Random Samples Effect Size and Confidence Interval:")
|
| 463 |
+
print(es_rand_te)
|
conf/config.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"runtime": {
|
| 3 |
+
"python": "3.11",
|
| 4 |
+
"dtk": "26.04",
|
| 5 |
+
"tensorflow": "2.18.0+das.opt1.dtk2604",
|
| 6 |
+
"torch": "2.5.1+das.opt1.dtk2604",
|
| 7 |
+
"tf_use_legacy_keras": true
|
| 8 |
+
},
|
| 9 |
+
"paths": {
|
| 10 |
+
"dataset": "conf/data/utrdb2.csv",
|
| 11 |
+
"motifs": "conf/data/motifs.csv",
|
| 12 |
+
"generator": "weight/checkpoint_3000.h5",
|
| 13 |
+
"framepool": "weight/utr_model_combined_residual_new.h5",
|
| 14 |
+
"mttrans_te": "weight/mttrans/RL_hard_share_MTL/3R/schedule_MTL-model_best_cv1.pth",
|
| 15 |
+
"output_dir": "outputs"
|
| 16 |
+
},
|
| 17 |
+
"defaults": {
|
| 18 |
+
"sequence_length": 128,
|
| 19 |
+
"latent_dimension": 40,
|
| 20 |
+
"batch_size": 64,
|
| 21 |
+
"learning_rate_exponent": 5
|
| 22 |
+
}
|
| 23 |
+
}
|
conf/data/motifs.csv
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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11 |
+
9,CGCTGCTGG,-0.085
|
| 12 |
+
10,CAAAGAATG,-0.502
|
| 13 |
+
11,TTTTAAAAT,0.187
|
| 14 |
+
12,GGCCGCCCC,-0.223
|
| 15 |
+
13,GGCGGGCCC,-0.161
|
| 16 |
+
14,CGCCCCGGC,-0.302
|
| 17 |
+
15,GGCGCCCTC,-0.191
|
| 18 |
+
16,ATTTGAGCG,-0.085
|
| 19 |
+
17,CGCCCGGGC,-0.236
|
| 20 |
+
18,GTTGATCAT,0.17
|
| 21 |
+
19,CTGTGCTCT,-0.005
|
| 22 |
+
20,ACCCCCCCC,-0.231
|
| 23 |
+
21,CGGGATCCG,-0.097
|
| 24 |
+
22,GTTCCTTCC,0.142
|
| 25 |
+
23,GCCGCCCTG,-0.221
|
| 26 |
+
24,CATTTTGGT,0.157
|
| 27 |
+
25,GGCCTGAGA,-0.042
|
| 28 |
+
26,GTGGGGAGT,-0.112
|
| 29 |
+
27,CAGCAATGA,-0.395
|
| 30 |
+
28,GTCCGGCCG,-0.189
|
| 31 |
+
29,TGGCTCCTC,0.095
|
| 32 |
+
30,GGCAGGCCC,-0.174
|
| 33 |
+
31,CGGGCCCGC,-0.288
|
| 34 |
+
32,GGACACCCA,-0.055
|
| 35 |
+
33,GGCGCCCGC,-0.198
|
| 36 |
+
34,TTTTTGGAT,0.085
|
| 37 |
+
35,CCGGGGCGG,-0.403
|
| 38 |
+
36,ATTTGTAAA,0.194
|
| 39 |
+
37,GCCGTAGGC,-0.049
|
| 40 |
+
38,CAGTGTAGG,0.046
|
| 41 |
+
39,AACATGGGG,-0.183
|
| 42 |
+
40,CTTCATGTC,0.115
|
| 43 |
+
41,TTTTTTTGT,0.254
|
| 44 |
+
42,CCGCGGTGC,-0.334
|
| 45 |
+
43,GGCGGCCCG,-0.183
|
| 46 |
+
44,CCCCCCCCC,0.002
|
| 47 |
+
45,TTTTGAAAT,0.17
|
| 48 |
+
46,ATTGTTGAA,0.123
|
| 49 |
+
47,GGCCCTGGC,-0.258
|
| 50 |
+
48,CCAATATTG,-0.355
|
| 51 |
+
49,TTTTTTTAA,0.236
|
| 52 |
+
50,CCAGCGGCG,-0.435
|
| 53 |
+
51,GGATGACGG,-0.204
|
| 54 |
+
52,TCTGTTGCT,0.207
|
| 55 |
+
53,CTGCCTAAG,-0.048
|
| 56 |
+
54,CGTGGGGGG,-0.08
|
| 57 |
+
55,CTGTGACGC,0.039
|
| 58 |
+
56,CTTTGATGC,0.056
|
| 59 |
+
57,GGAGCAATG,-0.284
|
| 60 |
+
58,GTTCAGGGC,-0.007
|
| 61 |
+
59,CATTTAAAC,0.086
|
| 62 |
+
60,GTCCCCCTG,-0.035
|
| 63 |
+
61,GCCCCGTGG,-0.244
|
| 64 |
+
62,TGTCTCTTT,0.267
|
| 65 |
+
63,CATCAGGTC,0.006
|
| 66 |
+
64,AATGATGAC,-0.014
|
| 67 |
+
65,CCGCCCCCC,-0.105
|
| 68 |
+
66,AAATGACAA,-0.106
|
| 69 |
+
67,GGTAGCTAC,0.124
|
| 70 |
+
68,CCCGGCCGC,-0.473
|
| 71 |
+
69,CTCTGATGA,-0.257
|
| 72 |
+
70,CTTAAGGGG,-0.014
|
| 73 |
+
71,ATGTTGACG,-0.186
|
| 74 |
+
72,CTTTAAGCA,0.022
|
| 75 |
+
73,GCCGCCGCC,0.008
|
| 76 |
+
74,CGTAGTCGC,0.102
|
| 77 |
+
75,TCGGCCCGC,-0.185
|
| 78 |
+
76,GGCGCCCGC,-0.271
|
| 79 |
+
77,GAAAGATGG,-0.237
|
| 80 |
+
78,GCCCCGGGG,-0.506
|
| 81 |
+
79,CCCGGCGCG,-0.149
|
| 82 |
+
80,CCGGGGGGG,-0.367
|
| 83 |
+
81,TTACTGGGG,0.158
|
| 84 |
+
82,GGGGGGGGG,-0.213
|
| 85 |
+
83,CGGGGGCGC,-0.271
|
| 86 |
+
84,CGTATGATA,-0.074
|
| 87 |
+
85,CGCTCCCCC,-0.249
|
| 88 |
+
86,GCCACTGAG,-0.25
|
| 89 |
+
87,GCATGCCCC,-0.149
|
| 90 |
+
88,GCGGGGCGC,-0.393
|
| 91 |
+
89,GGTGGAGGA,-0.088
|
| 92 |
+
90,GGAAGATGG,-0.337
|
| 93 |
+
91,GCCGGGACC,0.037
|
| 94 |
+
92,GAGCTGGCG,-0.154
|
| 95 |
+
93,ACCCCCCCC,0.053
|
| 96 |
+
94,GGAGGGGGA,-0.108
|
| 97 |
+
95,GGTATGTGA,-0.109
|
| 98 |
+
96,CGGGGGGCT,-0.123
|
| 99 |
+
97,GTGGTGGGG,0.02
|
| 100 |
+
98,AGTTTTTGA,0.094
|
| 101 |
+
99,AGGTGGTGG,-0.083
|
| 102 |
+
100,ATTGTTTGT,0.2
|
| 103 |
+
101,CGCTGTGGG,0.177
|
| 104 |
+
102,GCGGGGGCC,-0.314
|
| 105 |
+
103,CGGCGGGGC,-0.233
|
| 106 |
+
104,CCGGCCCCC,-0.265
|
| 107 |
+
105,AGCGTTGAG,0.005
|
| 108 |
+
106,CCGGGATGG,-0.402
|
| 109 |
+
107,GCCCTGTGG,-0.21
|
| 110 |
+
108,CGCTAACGC,0.087
|
| 111 |
+
109,CGCCCTGGC,-0.262
|
| 112 |
+
110,CCAACGGGG,-0.172
|
| 113 |
+
111,CCGCCCCCC,-0.251
|
| 114 |
+
112,TGTCTCCGT,-0.008
|
| 115 |
+
113,CCCAGCCCC,0.028
|
| 116 |
+
114,AGGGGGGGC,-0.169
|
| 117 |
+
115,CAGCTAGCT,0.024
|
| 118 |
+
116,CCCGTGAGC,-0.061
|
| 119 |
+
117,GGCCGGCCC,-0.25
|
| 120 |
+
118,TCTTGAAAA,0.219
|
| 121 |
+
119,AACCTTTAA,0.143
|
| 122 |
+
120,CCCCTAAAA,0.133
|
| 123 |
+
121,GAGAGGGTT,-0.108
|
| 124 |
+
122,CTGAGCTGG,-0.28
|
| 125 |
+
123,GCCCATGTG,-0.176
|
| 126 |
+
124,GTCTGATAA,0.221
|
| 127 |
+
125,GAAAAAAGT,-0.124
|
| 128 |
+
126,GCCCCCGGG,-0.289
|
| 129 |
+
127,GTGAAGGAT,0.095
|
| 130 |
+
128,TTAAGAAGG,-0.072
|
| 131 |
+
129,TAATAATGA,-0.159
|
| 132 |
+
130,CGGCCTCTG,-0.041
|
| 133 |
+
131,CGTTATGAT,0.071
|
| 134 |
+
132,GGACTTCCA,0.038
|
| 135 |
+
133,CGCCCGGGC,-0.174
|
| 136 |
+
134,GAGTTTGAA,0.201
|
| 137 |
+
135,TGGCACGAT,0.087
|
| 138 |
+
136,GGCGCCCGC,-0.24
|
| 139 |
+
137,CTGCCGAGC,-0.055
|
| 140 |
+
138,TAAAACAAA,0.223
|
| 141 |
+
139,CCCTTGGGC,-0.061
|
| 142 |
+
140,GCCGCCGCC,-0.322
|
| 143 |
+
141,CCCTCTAGG,0.048
|
| 144 |
+
142,CACGCCGCG,-0.219
|
| 145 |
+
143,CTGTGCCTC,0.043
|
| 146 |
+
144,CCCCTGGCT,-0.095
|
| 147 |
+
145,ATATGCTCG,-0.106
|
| 148 |
+
146,GATTAAAAA,0.196
|
| 149 |
+
147,ATTTTCTGC,0.084
|
| 150 |
+
148,CCATGGCCC,-0.271
|
| 151 |
+
149,CAAATGGGG,-0.091
|
| 152 |
+
150,CCCTAGCAG,0.002
|
| 153 |
+
151,GGGCAGGGT,-0.167
|
| 154 |
+
152,GTTCTAAGG,-0.032
|
| 155 |
+
153,CCCGCCCGG,-0.352
|
| 156 |
+
154,GGGGCGGGC,-0.24
|
| 157 |
+
155,GGGCTCCAG,0.039
|
| 158 |
+
156,TTTAATAAA,0.137
|
| 159 |
+
157,GGCCCTGAG,-0.084
|
| 160 |
+
158,TGCTCGGCC,0.013
|
| 161 |
+
159,CGGCGGGGG,-0.232
|
| 162 |
+
160,GCCCCCCCG,-0.127
|
| 163 |
+
161,GCCCCCGGC,-0.166
|
| 164 |
+
162,AAATCGGGA,-0.136
|
| 165 |
+
163,CAATTCCCT,-0.078
|
| 166 |
+
164,CGTCCGCCC,-0.111
|
| 167 |
+
165,TTGTGACCC,0.014
|
| 168 |
+
166,CCGTAAGCG,0.017
|
| 169 |
+
167,GGGGAGGCG,-0.093
|
| 170 |
+
168,GCGTGGCAG,-0.158
|
| 171 |
+
169,CCTTTGCTC,0.151
|
| 172 |
+
170,CCGGGGCCC,-0.306
|
| 173 |
+
171,TGGGGGGGC,-0.037
|
| 174 |
+
172,CTCCGTAGA,0.049
|
| 175 |
+
173,CCGGCCGCC,-0.052
|
| 176 |
+
174,CGGCCTTGA,-0.125
|
| 177 |
+
175,GTTGCTGTG,-0.062
|
| 178 |
+
176,GCGGTGTAG,-0.067
|
| 179 |
+
177,ATTTGGGGG,-0.069
|
| 180 |
+
178,GGGATGGGG,-0.382
|
| 181 |
+
179,TTGTCCATG,-0.074
|
| 182 |
+
180,CTCTTACCC,0.263
|
| 183 |
+
181,TCTGCTCCC,0.127
|
| 184 |
+
182,TCTGTCCCA,0.126
|
| 185 |
+
183,AAAAATGAT,0.135
|
| 186 |
+
184,CCGACTCCA,0.049
|
| 187 |
+
185,CGGCCCGGC,-0.206
|
| 188 |
+
186,AAGTTTTTT,0.218
|
| 189 |
+
187,TGTTGAGCC,-0.013
|
| 190 |
+
188,CAGATGGGG,-0.119
|
| 191 |
+
189,ATGGGGGGG,-0.18
|
| 192 |
+
190,GTCGATGGG,-0.269
|
| 193 |
+
191,CTTCGCCAC,0.032
|
| 194 |
+
192,GCGGCGCCC,-0.107
|
| 195 |
+
193,GGCCCATGC,-0.261
|
| 196 |
+
194,CCGGGGGGC,-0.332
|
| 197 |
+
195,CCCGCTCAG,0.038
|
| 198 |
+
196,CCCGTGAGC,0.052
|
| 199 |
+
197,ATGGCCGCC,-0.216
|
| 200 |
+
198,TAAAAATGG,-0.245
|
| 201 |
+
199,GGCCGCCGG,-0.244
|
| 202 |
+
200,GCGGCCCTC,-0.074
|
| 203 |
+
201,GGGGGGTGG,-0.167
|
| 204 |
+
202,ACTTGTAAA,0.036
|
| 205 |
+
203,CTTTGAGAA,0.108
|
| 206 |
+
204,CTGGCGCGG,-0.22
|
| 207 |
+
205,CGGCCCTGA,-0.168
|
| 208 |
+
206,CCCCCCCCC,-0.032
|
| 209 |
+
207,ACCAGCATG,-0.002
|
| 210 |
+
208,CATCATGGC,0.053
|
| 211 |
+
209,CGCCGGGGC,-0.152
|
| 212 |
+
210,TTCAAGATG,0.012
|
| 213 |
+
211,TGGGTGAAC,0.034
|
| 214 |
+
212,TGGGGCCCC,-0.274
|
| 215 |
+
213,CCCTGGCTC,-0.108
|
| 216 |
+
214,GCCTGGGGG,-0.239
|
| 217 |
+
215,GAGCTAAGC,0.014
|
| 218 |
+
216,ATTTTTTCT,0.089
|
| 219 |
+
217,TGAGGAAGG,-0.264
|
| 220 |
+
218,CCGGCCCGG,-0.423
|
| 221 |
+
219,CGCCGCCAC,-0.048
|
| 222 |
+
220,GGCCGGCAG,-0.133
|
| 223 |
+
221,CCCCCTCCC,0.077
|
| 224 |
+
222,TCTGTTGTT,0.127
|
| 225 |
+
223,GAAACGTAG,0.06
|
| 226 |
+
224,CCCTGGGTG,-0.205
|
| 227 |
+
225,TCAGTGATG,0.018
|
| 228 |
+
226,TGCCCCCCC,-0.024
|
| 229 |
+
227,CGGGGGCCC,-0.331
|
| 230 |
+
228,CAACCAAAA,0.213
|
| 231 |
+
229,CCAGGATGG,-0.347
|
| 232 |
+
230,CAGCGCGGC,-0.215
|
| 233 |
+
231,TTTTAAGTA,0.227
|
| 234 |
+
232,CGTGGGGGG,-0.147
|
| 235 |
+
233,GGCGGCCCG,-0.288
|
| 236 |
+
234,CCTGTAAAC,0.138
|
| 237 |
+
235,TCTCTTCCC,0.153
|
| 238 |
+
236,CCTCCCCCG,-0.17
|
| 239 |
+
237,CGTGGATTA,-0.185
|
| 240 |
+
238,GCGGTAACG,-0.065
|
| 241 |
+
239,AAAACATTC,0.068
|
| 242 |
+
240,CAGGTAAGT,0.115
|
| 243 |
+
241,AGCCCCTGG,-0.095
|
| 244 |
+
242,GGCGGGCCG,-0.282
|
| 245 |
+
243,TCCTAAGCC,0.122
|
| 246 |
+
244,GCAGCCTGG,-0.159
|
| 247 |
+
245,TTCTAAGTT,0.067
|
| 248 |
+
246,CCATGATGC,-0.12
|
| 249 |
+
247,CTGTGAGCT,0.034
|
| 250 |
+
248,CGACCCCAG,-0.049
|
| 251 |
+
249,CGTGTAAGC,-0.055
|
| 252 |
+
250,GTGGGCCCC,-0.095
|
| 253 |
+
251,TCTTTTCAA,0.193
|
| 254 |
+
252,GTTTAATAA,0.108
|
| 255 |
+
253,GCCCCCCGC,-0.113
|
| 256 |
+
254,GGCTCTAAG,0.022
|
| 257 |
+
255,GTATGATGG,-0.258
|
conf/data/utrdb2.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f2ac8227b6084f0164d75a3f1dde738daa93199a156dc60601a53e7204360120
|
| 3 |
+
size 20420229
|
conf/environment.yml
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: utrgan
|
| 2 |
+
channels:
|
| 3 |
+
- bioconda
|
| 4 |
+
- conda-forge
|
| 5 |
+
- https://repo.anaconda.com/pkgs/main
|
| 6 |
+
- https://repo.anaconda.com/pkgs/r
|
| 7 |
+
dependencies:
|
| 8 |
+
- _libgcc_mutex=0.1
|
| 9 |
+
- _openmp_mutex=4.5
|
| 10 |
+
- absl-py=2.2.0
|
| 11 |
+
- aiohappyeyeballs=2.6.1
|
| 12 |
+
- aiohttp=3.11.16
|
| 13 |
+
- aiosignal=1.3.2
|
| 14 |
+
- anyio=4.9.0
|
| 15 |
+
- argon2-cffi=23.1.0
|
| 16 |
+
- argon2-cffi-bindings=21.2.0
|
| 17 |
+
- arrow=1.3.0
|
| 18 |
+
- asttokens=3.0.0
|
| 19 |
+
- astunparse=1.6.3
|
| 20 |
+
- async-lru=2.0.5
|
| 21 |
+
- async-timeout=5.0.1
|
| 22 |
+
- attrs=25.3.0
|
| 23 |
+
- babel=2.17.0
|
| 24 |
+
- beautifulsoup4=4.13.3
|
| 25 |
+
- biopython=1.85
|
| 26 |
+
- bleach=6.2.0
|
| 27 |
+
- bleach-with-css=6.2.0
|
| 28 |
+
- blinker=1.9.0
|
| 29 |
+
- brotli=1.1.0
|
| 30 |
+
- brotli-bin=1.1.0
|
| 31 |
+
- brotli-python=1.1.0
|
| 32 |
+
- bzip2=1.0.8
|
| 33 |
+
- c-ares=1.34.5
|
| 34 |
+
- ca-certificates=2025.1.31
|
| 35 |
+
- cached_property=1.5.2
|
| 36 |
+
- cachetools=5.5.2
|
| 37 |
+
- certifi=2025.1.31
|
| 38 |
+
- cffi=1.17.1
|
| 39 |
+
- charset-normalizer=3.4.1
|
| 40 |
+
- click=8.1.8
|
| 41 |
+
- colorama=0.4.6
|
| 42 |
+
- comm=0.2.2
|
| 43 |
+
- contourpy=1.3.0
|
| 44 |
+
- cpython=3.9.22
|
| 45 |
+
- cryptography=39.0.0
|
| 46 |
+
- cuda-version=11.8
|
| 47 |
+
- cudatoolkit=11.8.0
|
| 48 |
+
- cudnn=8.9.7.29
|
| 49 |
+
- cycler=0.12.1
|
| 50 |
+
- debugpy=1.8.14
|
| 51 |
+
- decorator=5.2.1
|
| 52 |
+
- defusedxml=0.7.1
|
| 53 |
+
- einops=0.8.1
|
| 54 |
+
- exceptiongroup=1.2.2
|
| 55 |
+
- executing=2.1.0
|
| 56 |
+
- filelock=3.18.0
|
| 57 |
+
- flatbuffers=22.12.06
|
| 58 |
+
- fonttools=4.57.0
|
| 59 |
+
- fqdn=1.5.1
|
| 60 |
+
- freetype=2.13.3
|
| 61 |
+
- frozenlist=1.5.0
|
| 62 |
+
- gast=0.4.0
|
| 63 |
+
- giflib=5.2.2
|
| 64 |
+
- gmp=6.3.0
|
| 65 |
+
- gmpy2=2.1.5
|
| 66 |
+
- google-auth=2.39.0
|
| 67 |
+
- google-auth-oauthlib=0.4.6
|
| 68 |
+
- google-pasta=0.2.0
|
| 69 |
+
- grpcio=1.51.1
|
| 70 |
+
- gsl=2.7
|
| 71 |
+
- h11=0.14.0
|
| 72 |
+
- h2=4.2.0
|
| 73 |
+
- h5py=3.9.0
|
| 74 |
+
- hdf5=1.14.0
|
| 75 |
+
- hpack=4.1.0
|
| 76 |
+
- httpcore=1.0.7
|
| 77 |
+
- httpx=0.28.1
|
| 78 |
+
- hyperframe=6.1.0
|
| 79 |
+
- icu=70.1
|
| 80 |
+
- idna=3.10
|
| 81 |
+
- importlib-metadata=8.6.1
|
| 82 |
+
- importlib-resources=6.5.2
|
| 83 |
+
- importlib_resources=6.5.2
|
| 84 |
+
- ipykernel=6.29.5
|
| 85 |
+
- ipython=8.18.1
|
| 86 |
+
- isoduration=20.11.0
|
| 87 |
+
- jedi=0.19.2
|
| 88 |
+
- jinja2=3.1.6
|
| 89 |
+
- joblib=1.4.2
|
| 90 |
+
- jpeg=9e
|
| 91 |
+
- json5=0.12.0
|
| 92 |
+
- jsonpointer=3.0.0
|
| 93 |
+
- jsonschema=4.23.0
|
| 94 |
+
- jsonschema-specifications=2024.10.1
|
| 95 |
+
- jsonschema-with-format-nongpl=4.23.0
|
| 96 |
+
- jupyter-lsp=2.2.5
|
| 97 |
+
- jupyter_client=8.6.3
|
| 98 |
+
- jupyter_core=5.7.2
|
| 99 |
+
- jupyter_events=0.12.0
|
| 100 |
+
- jupyter_server=2.15.0
|
| 101 |
+
- jupyter_server_terminals=0.5.3
|
| 102 |
+
- jupyterlab=4.4.0
|
| 103 |
+
- jupyterlab_pygments=0.3.0
|
| 104 |
+
- jupyterlab_server=2.27.3
|
| 105 |
+
- keras=2.11.0
|
| 106 |
+
- keras-preprocessing=1.1.2
|
| 107 |
+
- keyutils=1.6.1
|
| 108 |
+
- kiwisolver=1.4.7
|
| 109 |
+
- krb5=1.20.1
|
| 110 |
+
- lcms2=2.15
|
| 111 |
+
- ld_impl_linux-64=2.43
|
| 112 |
+
- lerc=4.0.0
|
| 113 |
+
- libabseil=20220623.0
|
| 114 |
+
- libaec=1.1.3
|
| 115 |
+
- libblas=3.9.0
|
| 116 |
+
- libbrotlicommon=1.1.0
|
| 117 |
+
- libbrotlidec=1.1.0
|
| 118 |
+
- libbrotlienc=1.1.0
|
| 119 |
+
- libcblas=3.9.0
|
| 120 |
+
- libcurl=7.87.0
|
| 121 |
+
- libdeflate=1.17
|
| 122 |
+
- libedit=3.1.20250104
|
| 123 |
+
- libev=4.33
|
| 124 |
+
- libexpat=2.7.0
|
| 125 |
+
- libffi=3.4.6
|
| 126 |
+
- libgcc=14.2.0
|
| 127 |
+
- libgcc-ng=14.2.0
|
| 128 |
+
- libgfortran=14.2.0
|
| 129 |
+
- libgfortran-ng=14.2.0
|
| 130 |
+
- libgfortran5=14.2.0
|
| 131 |
+
- libgomp=14.2.0
|
| 132 |
+
- libgrpc=1.51.1
|
| 133 |
+
- libhwloc=2.9.1
|
| 134 |
+
- libiconv=1.18
|
| 135 |
+
- libjpeg-turbo=2.1.4
|
| 136 |
+
- liblapack=3.9.0
|
| 137 |
+
- liblzma=5.8.1
|
| 138 |
+
- liblzma-devel=5.8.1
|
| 139 |
+
- libmagma=2.7.1
|
| 140 |
+
- libmagma_sparse=2.7.1
|
| 141 |
+
- libnghttp2=1.51.0
|
| 142 |
+
- libnsl=2.0.1
|
| 143 |
+
- libopenblas=0.3.29
|
| 144 |
+
- libpng=1.6.47
|
| 145 |
+
- libprotobuf=3.21.12
|
| 146 |
+
- libsodium=1.0.18
|
| 147 |
+
- libsqlite=3.49.1
|
| 148 |
+
- libssh2=1.10.0
|
| 149 |
+
- libstdcxx=14.2.0
|
| 150 |
+
- libstdcxx-ng=14.2.0
|
| 151 |
+
- libtiff=4.5.0
|
| 152 |
+
- libuuid=2.38.1
|
| 153 |
+
- libwebp-base=1.5.0
|
| 154 |
+
- libxcb=1.13
|
| 155 |
+
- libxcrypt=4.4.36
|
| 156 |
+
- libxml2=2.10.3
|
| 157 |
+
- libzlib=1.3.1
|
| 158 |
+
- llvm-openmp=20.1.2
|
| 159 |
+
- magma=2.7.1
|
| 160 |
+
- markdown=3.6
|
| 161 |
+
- markupsafe=3.0.2
|
| 162 |
+
- matplotlib-base=3.9.4
|
| 163 |
+
- matplotlib-inline=0.1.7
|
| 164 |
+
- mistune=3.1.3
|
| 165 |
+
- mkl=2022.2.1
|
| 166 |
+
- ml_dtypes=0.2.0
|
| 167 |
+
- mpc=1.3.1
|
| 168 |
+
- mpfr=4.2.1
|
| 169 |
+
- mpmath=1.3.0
|
| 170 |
+
- multidict=6.3.2
|
| 171 |
+
- munkres=1.1.4
|
| 172 |
+
- nbclient=0.10.2
|
| 173 |
+
- nbconvert-core=7.16.6
|
| 174 |
+
- nbformat=5.10.4
|
| 175 |
+
- nccl=2.26.2.1
|
| 176 |
+
- ncurses=6.5
|
| 177 |
+
- nest-asyncio=1.6.0
|
| 178 |
+
- networkx=3.2.1
|
| 179 |
+
- notebook=7.4.0
|
| 180 |
+
- notebook-shim=0.2.4
|
| 181 |
+
- numpy=1.26.4
|
| 182 |
+
- oauthlib=3.2.2
|
| 183 |
+
- openjpeg=2.5.0
|
| 184 |
+
- openssl=1.1.1w
|
| 185 |
+
- opt_einsum=3.4.0
|
| 186 |
+
- overrides=7.7.0
|
| 187 |
+
- packaging=24.2
|
| 188 |
+
- pandas=2.2.3
|
| 189 |
+
- pandocfilters=1.5.0
|
| 190 |
+
- parso=0.8.4
|
| 191 |
+
- patsy=1.0.1
|
| 192 |
+
- perl=5.32.1
|
| 193 |
+
- pexpect=4.9.0
|
| 194 |
+
- pickleshare=0.7.5
|
| 195 |
+
- pillow=9.4.0
|
| 196 |
+
- pip=25.0.1=pyh8b19718_0
|
| 197 |
+
- pkgutil-resolve-name=1.3.10
|
| 198 |
+
- platformdirs=4.3.7
|
| 199 |
+
- polyleven=0.9.0
|
| 200 |
+
- prometheus_client=0.21.1
|
| 201 |
+
- prompt-toolkit=3.0.50
|
| 202 |
+
- propcache=0.3.1
|
| 203 |
+
- protobuf=4.21.12
|
| 204 |
+
- psutil=7.0.0
|
| 205 |
+
- pthread-stubs=0.4
|
| 206 |
+
- ptyprocess=0.7.0
|
| 207 |
+
- pure_eval=0.2.3
|
| 208 |
+
- pyasn1=0.6.1
|
| 209 |
+
- pyasn1-modules=0.4.2
|
| 210 |
+
- pycparser=2.22
|
| 211 |
+
- pygments=2.19.1
|
| 212 |
+
- pyjwt=2.10.1
|
| 213 |
+
- pyopenssl=23.2.0
|
| 214 |
+
- pyparsing=3.2.3
|
| 215 |
+
- pysocks=1.7.1
|
| 216 |
+
- python=3.9.15
|
| 217 |
+
- python-dateutil=2.9.0.post0
|
| 218 |
+
- python-fastjsonschema=2.21.1
|
| 219 |
+
- python-flatbuffers=25.2.10
|
| 220 |
+
- python-json-logger=2.0.7
|
| 221 |
+
- python-tzdata=2025.2
|
| 222 |
+
- python_abi=3.9
|
| 223 |
+
- pytorch=2.0.0
|
| 224 |
+
- pytz=2025.2
|
| 225 |
+
- pyu2f=0.1.5
|
| 226 |
+
- pyyaml=6.0.2
|
| 227 |
+
- pyzmq=26.2.0
|
| 228 |
+
- qhull=2020.2
|
| 229 |
+
- re2=2022.06.01
|
| 230 |
+
- readline=8.2
|
| 231 |
+
- referencing=0.36.2
|
| 232 |
+
- requests=2.32.3
|
| 233 |
+
- requests-oauthlib=2.0.0
|
| 234 |
+
- rfc3339-validator=0.1.4
|
| 235 |
+
- rfc3986-validator=0.1.1
|
| 236 |
+
- rpds-py=0.24.0
|
| 237 |
+
- rsa=4.9
|
| 238 |
+
- scikit-learn=1.6.1
|
| 239 |
+
- scipy=1.13.1
|
| 240 |
+
- seaborn=0.13.2
|
| 241 |
+
- seaborn-base=0.13.2
|
| 242 |
+
- send2trash=1.8.3
|
| 243 |
+
- setuptools=78.1.0
|
| 244 |
+
- six=1.17.0
|
| 245 |
+
- sleef=3.8
|
| 246 |
+
- snappy=1.1.10
|
| 247 |
+
- sniffio=1.3.1
|
| 248 |
+
- soupsieve=2.5
|
| 249 |
+
- stack_data=0.6.3
|
| 250 |
+
- statsmodels=0.14.4
|
| 251 |
+
- sympy=1.13.3
|
| 252 |
+
- tbb=2021.9.0
|
| 253 |
+
- tensorboard=2.11.2
|
| 254 |
+
- tensorboard-data-server=0.6.1
|
| 255 |
+
- tensorboard-plugin-wit=1.8.1
|
| 256 |
+
- tensorflow=2.11.0
|
| 257 |
+
- tensorflow-base=2.11.0
|
| 258 |
+
- tensorflow-estimator=2.11.0
|
| 259 |
+
- tensorflow-gpu=2.11.0
|
| 260 |
+
- termcolor=3.0.1
|
| 261 |
+
- terminado=0.18.1
|
| 262 |
+
- threadpoolctl=3.6.0
|
| 263 |
+
- tinycss2=1.4.0
|
| 264 |
+
- tk=8.6.13
|
| 265 |
+
- tomli=2.2.1
|
| 266 |
+
- tornado=6.4.2
|
| 267 |
+
- tqdm=4.67.1
|
| 268 |
+
- traitlets=5.14.3
|
| 269 |
+
- types-python-dateutil=2.9.0.20241206
|
| 270 |
+
- typing-extensions=4.13.2
|
| 271 |
+
- typing_extensions=4.13.2
|
| 272 |
+
- typing_utils=0.1.0
|
| 273 |
+
- tzdata=2025b
|
| 274 |
+
- unicodedata2=16.0.0
|
| 275 |
+
- uri-template=1.3.0
|
| 276 |
+
- viennarna=2.7.0
|
| 277 |
+
- wcwidth=0.2.13
|
| 278 |
+
- webcolors=24.11.1
|
| 279 |
+
- webencodings=0.5.1
|
| 280 |
+
- websocket-client=1.8.0
|
| 281 |
+
- werkzeug=3.1.3
|
| 282 |
+
- wheel=0.45.1
|
| 283 |
+
- wrapt=1.14.1
|
| 284 |
+
- xorg-libxau=1.0.12
|
| 285 |
+
- xorg-libxdmcp=1.1.5
|
| 286 |
+
- xz=5.8.1
|
| 287 |
+
- xz-gpl-tools=5.8.1
|
| 288 |
+
- xz-tools=5.8.1
|
| 289 |
+
- yaml=0.2.5
|
| 290 |
+
- yarl=1.18.3
|
| 291 |
+
- zeromq=4.3.5
|
| 292 |
+
- zipp=3.21.0
|
| 293 |
+
- zlib=1.3.1
|
| 294 |
+
- zstandard=0.23.0
|
| 295 |
+
- zstd=1.5.7
|
| 296 |
+
- pip:
|
| 297 |
+
- urllib3==1.26.20
|
conf/img/pipeline.png
ADDED
|
Git LFS Details
|
conf/notebooks/exp_optimization_multiple.ipynb
ADDED
|
@@ -0,0 +1,1053 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 2,
|
| 6 |
+
"id": "47fa042d",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [
|
| 9 |
+
{
|
| 10 |
+
"ename": "ImportError",
|
| 11 |
+
"evalue": "cannot import name 'Modules' from 'models' (unknown location)",
|
| 12 |
+
"output_type": "error",
|
| 13 |
+
"traceback": [
|
| 14 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
| 15 |
+
"\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)",
|
| 16 |
+
"Cell \u001b[0;32mIn[2], line 26\u001b[0m\n\u001b[1;32m 24\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m 25\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mrequests\u001b[39;00m\u001b[38;5;241m,\u001b[39m \u001b[38;5;21;01msys\u001b[39;00m\n\u001b[0;32m---> 26\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01msrc\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mexp_optimization\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpopen\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Auto_popen\n\u001b[1;32m 28\u001b[0m abs_path \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m./src/mrl_te_optimization/log/Backbone/RL_hard_share/3M/small_repective_filed_strides1113.ini\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 29\u001b[0m Configuration \u001b[38;5;241m=\u001b[39m Auto_popen(abs_path)\n",
|
| 17 |
+
"File \u001b[0;32m~/Documents/bilkent/utrgan/bioinformatics advances/code/UTRGAN/src/exp_optimization/popen.py:5\u001b[0m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mnumpy\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mnp\u001b[39;00m\n\u001b[1;32m 4\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mjson\u001b[39;00m\n\u001b[0;32m----> 5\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mmodels\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Modules\n\u001b[1;32m 6\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mconfigparser\u001b[39;00m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mlogging\u001b[39;00m\n",
|
| 18 |
+
"\u001b[0;31mImportError\u001b[0m: cannot import name 'Modules' from 'models' (unknown location)"
|
| 19 |
+
]
|
| 20 |
+
}
|
| 21 |
+
],
|
| 22 |
+
"source": [
|
| 23 |
+
"import requests\n",
|
| 24 |
+
"import json\n",
|
| 25 |
+
"import time\n",
|
| 26 |
+
"import numpy as np\n",
|
| 27 |
+
"import os\n",
|
| 28 |
+
"from re import A, L\n",
|
| 29 |
+
"import numpy as np\n",
|
| 30 |
+
"import pandas as pd\n",
|
| 31 |
+
"from tqdm import tqdm\n",
|
| 32 |
+
"import torch\n",
|
| 33 |
+
"import tensorflow as tf\n",
|
| 34 |
+
"import tensorflow.keras.backend as K\n",
|
| 35 |
+
"from tensorflow.keras import Model\n",
|
| 36 |
+
"from tensorflow.keras.models import load_model\n",
|
| 37 |
+
"import sys\n",
|
| 38 |
+
"import argparse\n",
|
| 39 |
+
"from src.exp_optimization.util import *\n",
|
| 40 |
+
"from src.exp_optimization.framepool import *\n",
|
| 41 |
+
"\n",
|
| 42 |
+
"tf.compat.v1.enable_eager_execution()\n",
|
| 43 |
+
"\n",
|
| 44 |
+
"from Bio import SeqIO\n",
|
| 45 |
+
"import pandas as pd\n",
|
| 46 |
+
"import numpy as np\n",
|
| 47 |
+
"import requests, sys\n",
|
| 48 |
+
"from src.exp_optimization.popen import Auto_popen\n",
|
| 49 |
+
"\n",
|
| 50 |
+
"abs_path = './src/mrl_te_optimization/log/Backbone/RL_hard_share/3M/small_repective_filed_strides1113.ini'\n",
|
| 51 |
+
"Configuration = Auto_popen(abs_path)\n",
|
| 52 |
+
"\n",
|
| 53 |
+
"np.random.seed(25)\n",
|
| 54 |
+
"\n",
|
| 55 |
+
"BATCH_SIZE = 100\n",
|
| 56 |
+
"N_GENES = 8\n",
|
| 57 |
+
"LR = 0.001\n",
|
| 58 |
+
"GPU = '0'\n",
|
| 59 |
+
"STEPS = 10\n",
|
| 60 |
+
"\n",
|
| 61 |
+
"if GPU == '-1':\n",
|
| 62 |
+
" device = 'cpu'\n",
|
| 63 |
+
"else:\n",
|
| 64 |
+
" os.environ['CUDA_VISIBLE_DEVICES'] = GPU\n",
|
| 65 |
+
" device = 'cuda'\n",
|
| 66 |
+
"\n",
|
| 67 |
+
"SEQ_BATCH = N_GENES\n",
|
| 68 |
+
"UTR_LEN = 128\n",
|
| 69 |
+
"DIM = 40\n",
|
| 70 |
+
"gpath = './models/checkpoint_3000.h5'\n",
|
| 71 |
+
"mrl_path = './models/utr_model_combined_residual_new.h5'\n",
|
| 72 |
+
"exp_path = './models/humanMedian_trainepoch.11-0.426.h5'\n",
|
| 73 |
+
"tpath = './src/exp_optimization/script/checkpoint/RL_hard_share_MTL/3R/schedule_MTL-model_best_cv1.pth'\n",
|
| 74 |
+
"LR = np.exp(-int(LR))\n",
|
| 75 |
+
"\n",
|
| 76 |
+
"gene_names = [\"MYOC\", \"TIGD4\", \"ATP6V1B2\", \"TAGLN\", \"COX7A2L\", \"IFNGR2\", \"TNFRSF21\", \"SETD6\"]\n",
|
| 77 |
+
"\n",
|
| 78 |
+
"target_genes = [\"ANTXR2\", \"NFIL3\", \"UNC13D\", \"DHRS2\", \"RPS13\", \"HBD\", \"METAP1D\", \"NCALD\"]\n",
|
| 79 |
+
"\n"
|
| 80 |
+
]
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"cell_type": "code",
|
| 84 |
+
"execution_count": 1,
|
| 85 |
+
"id": "3a95c1ae",
|
| 86 |
+
"metadata": {},
|
| 87 |
+
"outputs": [
|
| 88 |
+
{
|
| 89 |
+
"ename": "NameError",
|
| 90 |
+
"evalue": "name 'Model' is not defined",
|
| 91 |
+
"output_type": "error",
|
| 92 |
+
"traceback": [
|
| 93 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
| 94 |
+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
| 95 |
+
"Cell \u001b[0;32mIn[1], line 387\u001b[0m\n\u001b[1;32m 375\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124mGenerated \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mn_utrs\u001b[38;5;250m \u001b[39m\u001b[38;5;241m*\u001b[39m\u001b[38;5;250m \u001b[39mn_genes\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m modified sequences (expected: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mexpected_count\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m)\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 377\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m all_modified_sequences\n\u001b[0;32m--> 387\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mconvert_model\u001b[39m(model_:\u001b[43mModel\u001b[49m):\n\u001b[1;32m 389\u001b[0m input_ \u001b[38;5;241m=\u001b[39m tf\u001b[38;5;241m.\u001b[39mkeras\u001b[38;5;241m.\u001b[39mlayers\u001b[38;5;241m.\u001b[39mInput(shape\u001b[38;5;241m=\u001b[39m( \u001b[38;5;241m10500\u001b[39m, \u001b[38;5;241m4\u001b[39m))\n\u001b[1;32m 390\u001b[0m \u001b[38;5;28minput\u001b[39m \u001b[38;5;241m=\u001b[39m input_\n",
|
| 96 |
+
"\u001b[0;31mNameError\u001b[0m: name 'Model' is not defined"
|
| 97 |
+
]
|
| 98 |
+
}
|
| 99 |
+
],
|
| 100 |
+
"source": [
|
| 101 |
+
"\n",
|
| 102 |
+
"\n",
|
| 103 |
+
"def reverse_complement(sequence):\n",
|
| 104 |
+
" \"\"\"Compute the reverse complement of a DNA sequence.\"\"\"\n",
|
| 105 |
+
" complement = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', \n",
|
| 106 |
+
" 'a': 't', 't': 'a', 'c': 'g', 'g': 'c', 'N': 'N', 'n': 'N'}\n",
|
| 107 |
+
" return ''.join(complement.get(base, 'N') for base in reversed(sequence))\n",
|
| 108 |
+
"\n",
|
| 109 |
+
"class GeneInfoRetriever:\n",
|
| 110 |
+
" def __init__(self):\n",
|
| 111 |
+
" self.base_url = \"https://rest.ensembl.org\"\n",
|
| 112 |
+
" self.headers = {\"Content-Type\": \"application/json\"}\n",
|
| 113 |
+
" self.sleep_time = 0.5 # Respect Ensembl API rate limits\n",
|
| 114 |
+
"\n",
|
| 115 |
+
" def _make_request(self, endpoint):\n",
|
| 116 |
+
" \"\"\"Make a request to the Ensembl REST API.\"\"\"\n",
|
| 117 |
+
" url = self.base_url + endpoint\n",
|
| 118 |
+
" try:\n",
|
| 119 |
+
" response = requests.get(url, headers=self.headers)\n",
|
| 120 |
+
" time.sleep(self.sleep_time)\n",
|
| 121 |
+
" if response.status_code == 200:\n",
|
| 122 |
+
" return response.json()\n",
|
| 123 |
+
" else:\n",
|
| 124 |
+
" print(f\"Error: {response.status_code} - {response.text}\")\n",
|
| 125 |
+
" return None\n",
|
| 126 |
+
" except Exception as e:\n",
|
| 127 |
+
" print(f\"Request error: {e}\")\n",
|
| 128 |
+
" return None\n",
|
| 129 |
+
"\n",
|
| 130 |
+
" def get_gene_id(self, gene_symbol, species=\"homo_sapiens\"):\n",
|
| 131 |
+
" \"\"\"Retrieve the Ensembl gene ID for a gene symbol.\"\"\"\n",
|
| 132 |
+
" endpoint = f\"/lookup/symbol/{species}/{gene_symbol}\"\n",
|
| 133 |
+
" response = self._make_request(endpoint)\n",
|
| 134 |
+
" return response.get(\"id\") if response else None\n",
|
| 135 |
+
"\n",
|
| 136 |
+
" def get_gene_coordinates(self, gene_id):\n",
|
| 137 |
+
" \"\"\"Retrieve genomic coordinates for a gene ID.\"\"\"\n",
|
| 138 |
+
" endpoint = f\"/lookup/id/{gene_id}?expand=1\"\n",
|
| 139 |
+
" response = self._make_request(endpoint)\n",
|
| 140 |
+
" if response:\n",
|
| 141 |
+
" return {\n",
|
| 142 |
+
" \"chromosome\": response.get(\"seq_region_name\"),\n",
|
| 143 |
+
" \"start\": response.get(\"start\"),\n",
|
| 144 |
+
" \"end\": response.get(\"end\"),\n",
|
| 145 |
+
" \"strand\": response.get(\"strand\")\n",
|
| 146 |
+
" }\n",
|
| 147 |
+
" return None\n",
|
| 148 |
+
"\n",
|
| 149 |
+
" def get_tss_and_utr(self, gene_id):\n",
|
| 150 |
+
" \"\"\"Retrieve TSS and 5' UTR coordinates for the canonical transcript.\"\"\"\n",
|
| 151 |
+
" endpoint = f\"/lookup/id/{gene_id}?expand=1&utr=1\"\n",
|
| 152 |
+
" response = self._make_request(endpoint)\n",
|
| 153 |
+
" if not response or \"Transcript\" not in response:\n",
|
| 154 |
+
" return None\n",
|
| 155 |
+
"\n",
|
| 156 |
+
" # Find canonical transcript\n",
|
| 157 |
+
" canonical_transcript = None\n",
|
| 158 |
+
" for transcript in response[\"Transcript\"]:\n",
|
| 159 |
+
" if transcript.get(\"is_canonical\", 0) == 1:\n",
|
| 160 |
+
" canonical_transcript = transcript\n",
|
| 161 |
+
" break\n",
|
| 162 |
+
" if not canonical_transcript:\n",
|
| 163 |
+
" for transcript in response[\"Transcript\"]:\n",
|
| 164 |
+
" if transcript.get(\"biotype\") == \"protein_coding\":\n",
|
| 165 |
+
" canonical_transcript = transcript\n",
|
| 166 |
+
" break\n",
|
| 167 |
+
" if not canonical_transcript:\n",
|
| 168 |
+
" canonical_transcript = response[\"Transcript\"][0] if response[\"Transcript\"] else None\n",
|
| 169 |
+
"\n",
|
| 170 |
+
" if not canonical_transcript:\n",
|
| 171 |
+
" return None\n",
|
| 172 |
+
"\n",
|
| 173 |
+
" # Determine TSS and 5' UTR\n",
|
| 174 |
+
" strand = canonical_transcript.get(\"strand\")\n",
|
| 175 |
+
" tss = canonical_transcript[\"start\"] if strand == 1 else canonical_transcript[\"end\"]\n",
|
| 176 |
+
" five_prime_utr = None\n",
|
| 177 |
+
"\n",
|
| 178 |
+
" if \"UTR\" in canonical_transcript:\n",
|
| 179 |
+
" for utr in canonical_transcript[\"UTR\"]:\n",
|
| 180 |
+
" if utr.get(\"object_type\") == \"five_prime_UTR\":\n",
|
| 181 |
+
" five_prime_utr = {\n",
|
| 182 |
+
" \"start\": utr.get(\"start\"),\n",
|
| 183 |
+
" \"end\": utr.get(\"end\")\n",
|
| 184 |
+
" }\n",
|
| 185 |
+
" break\n",
|
| 186 |
+
"\n",
|
| 187 |
+
" # Verify TSS matches 5' UTR start\n",
|
| 188 |
+
" if five_prime_utr:\n",
|
| 189 |
+
" expected_tss = five_prime_utr[\"start\"] if strand == 1 else five_prime_utr[\"end\"]\n",
|
| 190 |
+
" if expected_tss != tss:\n",
|
| 191 |
+
" print(f\"Warning: Adjusting TSS from {tss} to match 5' UTR {'start' if strand == 1 else 'end'} ({expected_tss})\")\n",
|
| 192 |
+
" tss = expected_tss\n",
|
| 193 |
+
"\n",
|
| 194 |
+
" return {\n",
|
| 195 |
+
" \"tss\": tss,\n",
|
| 196 |
+
" \"strand\": strand,\n",
|
| 197 |
+
" \"chromosome\": canonical_transcript.get(\"seq_region_name\"),\n",
|
| 198 |
+
" \"five_prime_utr\": five_prime_utr,\n",
|
| 199 |
+
" \"transcript_id\": canonical_transcript.get(\"id\")\n",
|
| 200 |
+
" }\n",
|
| 201 |
+
"\n",
|
| 202 |
+
" def get_promoter_sequence(self, gene_id, upstream=8000, downstream=4000):\n",
|
| 203 |
+
" \"\"\"Retrieve sequence around TSS (8kb upstream, 4kb downstream).\"\"\"\n",
|
| 204 |
+
" tss_info = self.get_tss_and_utr(gene_id)\n",
|
| 205 |
+
" if not tss_info:\n",
|
| 206 |
+
" return None, None\n",
|
| 207 |
+
"\n",
|
| 208 |
+
" chromosome = tss_info[\"chromosome\"]\n",
|
| 209 |
+
" strand = tss_info[\"strand\"]\n",
|
| 210 |
+
" tss_position = tss_info[\"tss\"]\n",
|
| 211 |
+
"\n",
|
| 212 |
+
" # Calculate region based on strand\n",
|
| 213 |
+
" if strand == 1:\n",
|
| 214 |
+
" seq_start = tss_position - upstream\n",
|
| 215 |
+
" seq_end = tss_position + downstream - 1\n",
|
| 216 |
+
" else:\n",
|
| 217 |
+
" seq_start = tss_position - downstream\n",
|
| 218 |
+
" seq_end = tss_position + upstream - 1\n",
|
| 219 |
+
"\n",
|
| 220 |
+
" seq_start = max(1, seq_start)\n",
|
| 221 |
+
"\n",
|
| 222 |
+
" # Store sequence coordinates\n",
|
| 223 |
+
" sequence_coords = {\n",
|
| 224 |
+
" \"chromosome\": chromosome,\n",
|
| 225 |
+
" \"start\": seq_start,\n",
|
| 226 |
+
" \"end\": seq_end,\n",
|
| 227 |
+
" \"strand\": 1 if strand == 1 else -1\n",
|
| 228 |
+
" }\n",
|
| 229 |
+
"\n",
|
| 230 |
+
" # Validate 5' UTR inclusion\n",
|
| 231 |
+
" if tss_info[\"five_prime_utr\"]:\n",
|
| 232 |
+
" utr_start = tss_info[\"five_prime_utr\"][\"start\"]\n",
|
| 233 |
+
" utr_end = tss_info[\"five_prime_utr\"][\"end\"]\n",
|
| 234 |
+
" if not (seq_start <= utr_start <= seq_end and seq_start <= utr_end <= seq_end):\n",
|
| 235 |
+
" print(f\"Warning: 5' UTR ({utr_start}-{utr_end}) not fully within sequence ({seq_start}-{seq_end})\")\n",
|
| 236 |
+
"\n",
|
| 237 |
+
" # Get sequence\n",
|
| 238 |
+
" strand_str = \"1\" if strand == 1 else \"-1\"\n",
|
| 239 |
+
" endpoint = f\"/sequence/region/human/{chromosome}:{seq_start}..{seq_end}:{strand_str}\"\n",
|
| 240 |
+
" response = self._make_request(endpoint)\n",
|
| 241 |
+
" return response.get(\"seq\") if response else None, sequence_coords\n",
|
| 242 |
+
"\n",
|
| 243 |
+
" def get_gene_info(self, gene_symbol, species=\"homo_sapiens\", output_json=\"gene_info.json\"):\n",
|
| 244 |
+
" \n",
|
| 245 |
+
" if not os.path.exists(os.path.join('./.cache/',f\"{gene_symbol}_info.json\")):\n",
|
| 246 |
+
"\n",
|
| 247 |
+
" \"\"\"Retrieve and save promoter sequence, TSS, 5' UTR, and coordinates.\"\"\"\n",
|
| 248 |
+
" # Get gene ID\n",
|
| 249 |
+
" gene_id = self.get_gene_id(gene_symbol, species)\n",
|
| 250 |
+
" if not gene_id:\n",
|
| 251 |
+
" return {\"error\": f\"Gene {gene_symbol} not found\"}\n",
|
| 252 |
+
"\n",
|
| 253 |
+
" # Get TSS and 5' UTR\n",
|
| 254 |
+
" tss_info = self.get_tss_and_utr(gene_id)\n",
|
| 255 |
+
" if not tss_info:\n",
|
| 256 |
+
" return {\"error\": \"Could not retrieve TSS or transcript information\"}\n",
|
| 257 |
+
"\n",
|
| 258 |
+
" # Get promoter sequence and coordinates\n",
|
| 259 |
+
" promoter_sequence, sequence_coords = self.get_promoter_sequence(gene_id)\n",
|
| 260 |
+
" if not promoter_sequence:\n",
|
| 261 |
+
" return {\"error\": \"Could not retrieve promoter sequence\"}\n",
|
| 262 |
+
"\n",
|
| 263 |
+
" # Compile gene information\n",
|
| 264 |
+
" gene_info = {\n",
|
| 265 |
+
" \"gene_symbol\": gene_symbol,\n",
|
| 266 |
+
" \"gene_id\": gene_id,\n",
|
| 267 |
+
" \"promoter_sequence\": promoter_sequence,\n",
|
| 268 |
+
" \"sequence_length\": len(promoter_sequence),\n",
|
| 269 |
+
" \"sequence_coordinates\": sequence_coords,\n",
|
| 270 |
+
" \"tss\": {\n",
|
| 271 |
+
" \"chromosome\": tss_info[\"chromosome\"],\n",
|
| 272 |
+
" \"position\": tss_info[\"tss\"],\n",
|
| 273 |
+
" \"strand\": \"+\" if tss_info[\"strand\"] == 1 else \"-\"\n",
|
| 274 |
+
" },\n",
|
| 275 |
+
" \"five_prime_utr\": tss_info[\"five_prime_utr\"],\n",
|
| 276 |
+
" \"transcript_id\": tss_info[\"transcript_id\"]\n",
|
| 277 |
+
" }\n",
|
| 278 |
+
"\n",
|
| 279 |
+
" # Save to JSON\n",
|
| 280 |
+
" try:\n",
|
| 281 |
+
" os.makedirs(os.path.dirname('./.cache/'), exist_ok=True)\n",
|
| 282 |
+
" with open(os.path.join('./.cache/',f\"{gene_symbol}_info.json\"), \"w\") as f:\n",
|
| 283 |
+
" json.dump(gene_info, f, indent=2)\n",
|
| 284 |
+
" print(f\"Saved gene information to {output_json}\")\n",
|
| 285 |
+
" except Exception as e:\n",
|
| 286 |
+
" print(f\"Error saving JSON: {e}\")\n",
|
| 287 |
+
"\n",
|
| 288 |
+
" else:\n",
|
| 289 |
+
"\n",
|
| 290 |
+
" with open(os.path.join('./.cache/',f\"{gene_symbol}_info.json\"), \"r\") as f:\n",
|
| 291 |
+
" gene_info = json.load(f)\n",
|
| 292 |
+
"\n",
|
| 293 |
+
" return gene_info\n",
|
| 294 |
+
"\n",
|
| 295 |
+
" def reverse_complement(self, sequence):\n",
|
| 296 |
+
" \"\"\"Compute the reverse complement of a DNA sequence.\"\"\"\n",
|
| 297 |
+
" complement = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', \n",
|
| 298 |
+
" 'a': 't', 't': 'a', 'c': 'g', 'g': 'c', 'N': 'N', 'n': 'N'}\n",
|
| 299 |
+
" return ''.join(complement.get(base, 'N') for base in reversed(sequence))\n",
|
| 300 |
+
"\n",
|
| 301 |
+
" def replace_utr_in_sequence(self, gene_info_file, generated_utrs, target_length=10500, output_prefix=\"modified_sequence\", write_json=False, verbose=False):\n",
|
| 302 |
+
" \"\"\"\n",
|
| 303 |
+
" Replace original 5' UTR with generated UTRs, ensuring 10,500nt output.\n",
|
| 304 |
+
" \n",
|
| 305 |
+
" Parameters:\n",
|
| 306 |
+
" gene_info_file (str): Path to JSON file with gene information\n",
|
| 307 |
+
" generated_utrs (list): List of generated 5' UTR sequences (64-128nt)\n",
|
| 308 |
+
" target_length (int): Desired output sequence length (default: 10500)\n",
|
| 309 |
+
" output_prefix (str): Prefix for output JSON files\n",
|
| 310 |
+
" \n",
|
| 311 |
+
" Returns:\n",
|
| 312 |
+
" list: List of modified sequences with metadata\n",
|
| 313 |
+
" \"\"\"\n",
|
| 314 |
+
" try:\n",
|
| 315 |
+
" # Read gene information\n",
|
| 316 |
+
" with open(gene_info_file, \"r\") as f:\n",
|
| 317 |
+
" gene_info = json.load(f)\n",
|
| 318 |
+
"\n",
|
| 319 |
+
" original_sequence = gene_info[\"promoter_sequence\"]\n",
|
| 320 |
+
" strand = gene_info[\"tss\"][\"strand\"]\n",
|
| 321 |
+
" tss_position = gene_info[\"tss\"][\"position\"]\n",
|
| 322 |
+
" sequence_coords = gene_info[\"sequence_coordinates\"]\n",
|
| 323 |
+
" seq_start = sequence_coords[\"start\"]\n",
|
| 324 |
+
" seq_end = sequence_coords[\"end\"]\n",
|
| 325 |
+
" five_prime_utr = gene_info[\"five_prime_utr\"]\n",
|
| 326 |
+
" gene_symbol = gene_info[\"gene_symbol\"]\n",
|
| 327 |
+
" transcript_id = gene_info[\"transcript_id\"]\n",
|
| 328 |
+
"\n",
|
| 329 |
+
" if not five_prime_utr:\n",
|
| 330 |
+
" print(f\"Error: No 5' UTR information available for {gene_symbol}\")\n",
|
| 331 |
+
" return []\n",
|
| 332 |
+
"\n",
|
| 333 |
+
" # Calculate original 5' UTR position in sequence\n",
|
| 334 |
+
" if strand == \"+\":\n",
|
| 335 |
+
" utr_start_genomic = five_prime_utr[\"start\"]\n",
|
| 336 |
+
" utr_end_genomic = five_prime_utr[\"end\"]\n",
|
| 337 |
+
" utr_start_seq = utr_start_genomic - seq_start\n",
|
| 338 |
+
" utr_end_seq = utr_end_genomic - seq_start\n",
|
| 339 |
+
" else:\n",
|
| 340 |
+
" utr_start_genomic = five_prime_utr[\"end\"] # TSS\n",
|
| 341 |
+
" utr_end_genomic = five_prime_utr[\"start\"]\n",
|
| 342 |
+
" utr_start_seq = seq_end - utr_start_genomic\n",
|
| 343 |
+
" utr_end_seq = seq_end - utr_end_genomic\n",
|
| 344 |
+
"\n",
|
| 345 |
+
" # Validate UTR positions\n",
|
| 346 |
+
" seq_length = len(original_sequence)\n",
|
| 347 |
+
" if not (0 <= utr_start_seq <= seq_length and 0 <= utr_end_seq <= seq_length):\n",
|
| 348 |
+
" print(f\"Error: 5' UTR coordinates (seq indices {utr_start_seq}-{utr_end_seq}) out of sequence bounds (0-{seq_length}) for {gene_symbol}\")\n",
|
| 349 |
+
" return []\n",
|
| 350 |
+
"\n",
|
| 351 |
+
" original_utr_length = abs(utr_end_genomic - utr_start_genomic) + 1\n",
|
| 352 |
+
" if verbose:\n",
|
| 353 |
+
" print(f\"Original 5' UTR length for {gene_symbol}: {original_utr_length} nt\")\n",
|
| 354 |
+
"\n",
|
| 355 |
+
" modified_sequences = []\n",
|
| 356 |
+
" for i, new_utr in enumerate(generated_utrs):\n",
|
| 357 |
+
" new_utr_length = len(new_utr)\n",
|
| 358 |
+
" if not 64 <= new_utr_length <= 128:\n",
|
| 359 |
+
" if verbose:\n",
|
| 360 |
+
" print(f\"Warning: Generated UTR {i+1} length ({new_utr_length}) outside 64-128nt range for {gene_symbol}\")\n",
|
| 361 |
+
" continue\n",
|
| 362 |
+
"\n",
|
| 363 |
+
" # Construct new sequence\n",
|
| 364 |
+
" if strand == \"+\":\n",
|
| 365 |
+
" new_sequence = (\n",
|
| 366 |
+
" original_sequence[:utr_start_seq] +\n",
|
| 367 |
+
" new_utr +\n",
|
| 368 |
+
" original_sequence[utr_end_seq + 1:]\n",
|
| 369 |
+
" )\n",
|
| 370 |
+
" new_utr_start_genomic = utr_start_genomic\n",
|
| 371 |
+
" new_utr_end_genomic = utr_start_genomic + new_utr_length - 1\n",
|
| 372 |
+
" if len(new_sequence) > target_length:\n",
|
| 373 |
+
" new_sequence = new_sequence[:target_length]\n",
|
| 374 |
+
" sequence_coords[\"end\"] = seq_start + target_length - 1\n",
|
| 375 |
+
" elif len(new_sequence) < target_length:\n",
|
| 376 |
+
" if verbose:\n",
|
| 377 |
+
" print(f\"Error: Sequence too short ({len(new_sequence)} nt) after UTR replacement for {gene_symbol}\")\n",
|
| 378 |
+
" continue\n",
|
| 379 |
+
" else:\n",
|
| 380 |
+
" new_utr_rc = reverse_complement(new_utr)\n",
|
| 381 |
+
" new_sequence = (\n",
|
| 382 |
+
" original_sequence[:min(utr_start_seq, utr_end_seq)] +\n",
|
| 383 |
+
" new_utr_rc +\n",
|
| 384 |
+
" original_sequence[max(utr_start_seq, utr_end_seq) + 1:]\n",
|
| 385 |
+
" )\n",
|
| 386 |
+
" new_utr_start_genomic = utr_start_genomic\n",
|
| 387 |
+
" new_utr_end_genomic = utr_start_genomic - new_utr_length + 1\n",
|
| 388 |
+
" if len(new_sequence) > target_length:\n",
|
| 389 |
+
" trim_amount = len(new_sequence) - target_length\n",
|
| 390 |
+
" new_sequence = new_sequence[trim_amount:]\n",
|
| 391 |
+
" sequence_coords[\"start\"] = seq_start + trim_amount\n",
|
| 392 |
+
" elif len(new_sequence) < target_length:\n",
|
| 393 |
+
" if verbose:\n",
|
| 394 |
+
" print(f\"Error: Sequence too short ({len(new_sequence)} nt) after UTR replacement for {gene_symbol}\")\n",
|
| 395 |
+
" continue\n",
|
| 396 |
+
"\n",
|
| 397 |
+
" # Store modified sequence and metadata\n",
|
| 398 |
+
" modified_info = {\n",
|
| 399 |
+
" \"gene_symbol\": gene_symbol,\n",
|
| 400 |
+
" \"transcript_id\": transcript_id,\n",
|
| 401 |
+
" \"modified_sequence\": new_sequence,\n",
|
| 402 |
+
" \"sequence_length\": len(new_sequence),\n",
|
| 403 |
+
" \"sequence_coordinates\": sequence_coords.copy(),\n",
|
| 404 |
+
" \"tss\": gene_info[\"tss\"],\n",
|
| 405 |
+
" \"five_prime_utr\": {\n",
|
| 406 |
+
" \"start\": new_utr_start_genomic,\n",
|
| 407 |
+
" \"end\": new_utr_end_genomic,\n",
|
| 408 |
+
" \"sequence\": new_utr if strand == \"+\" else new_utr_rc\n",
|
| 409 |
+
" },\n",
|
| 410 |
+
" \"original_utr_length\": original_utr_length,\n",
|
| 411 |
+
" \"new_utr_length\": new_utr_length,\n",
|
| 412 |
+
" \"utr_index\": i + 1\n",
|
| 413 |
+
" }\n",
|
| 414 |
+
"\n",
|
| 415 |
+
" # Save to JSON\n",
|
| 416 |
+
" if write_json:\n",
|
| 417 |
+
" output_file = f\"{output_prefix}_{gene_symbol}_utr_{i+1}.json\"\n",
|
| 418 |
+
" try:\n",
|
| 419 |
+
" os.makedirs(os.path.dirname(output_file), exist_ok=True)\n",
|
| 420 |
+
" with open(output_file, \"w\") as f:\n",
|
| 421 |
+
" json.dump(modified_info, f, indent=2)\n",
|
| 422 |
+
" print(f\"Saved modified sequence {i+1} for {gene_symbol} to {output_file}\")\n",
|
| 423 |
+
" except Exception as e:\n",
|
| 424 |
+
" print(f\"Error saving modified sequence {i+1} for {gene_symbol}: {e}\")\n",
|
| 425 |
+
"\n",
|
| 426 |
+
" modified_sequences.append(modified_info[\"modified_sequence\"])\n",
|
| 427 |
+
"\n",
|
| 428 |
+
" return modified_sequences\n",
|
| 429 |
+
"\n",
|
| 430 |
+
" except Exception as e:\n",
|
| 431 |
+
" print(f\"Error processing UTR replacement for {gene_info.get('gene_symbol', 'unknown')}: {e}\")\n",
|
| 432 |
+
" return []\n",
|
| 433 |
+
"\n",
|
| 434 |
+
"\n",
|
| 435 |
+
" def replace_utr_in_multiple_sequences(self, gene_symbols, generated_utrs, target_length=10500, cache_dir=\"./.cache\", output_prefix=\"modified_sequence\", verbose=False):\n",
|
| 436 |
+
" \"\"\"\n",
|
| 437 |
+
" Replace 5' UTRs for multiple genes with generated UTRs.\n",
|
| 438 |
+
" \n",
|
| 439 |
+
" Parameters:\n",
|
| 440 |
+
" gene_symbols (list): List of gene names\n",
|
| 441 |
+
" generated_utrs (list): List of generated 5' UTR sequences (64-128nt)\n",
|
| 442 |
+
" target_length (int): Desired output sequence length (default: 10500)\n",
|
| 443 |
+
" cache_dir (str): Directory containing cached gene info JSON files\n",
|
| 444 |
+
" output_prefix (str): Prefix for output JSON files\n",
|
| 445 |
+
" \n",
|
| 446 |
+
" Returns:\n",
|
| 447 |
+
" list: List of n_utrs * n_genes modified sequences with metadata\n",
|
| 448 |
+
" \"\"\"\n",
|
| 449 |
+
" all_modified_sequences = []\n",
|
| 450 |
+
" n_utrs = len(generated_utrs)\n",
|
| 451 |
+
" n_genes = len(gene_symbols)\n",
|
| 452 |
+
"\n",
|
| 453 |
+
" for gene_symbol in gene_symbols:\n",
|
| 454 |
+
" json_file = os.path.join(cache_dir, f\"{gene_symbol}_info.json\")\n",
|
| 455 |
+
" if not os.path.exists(json_file):\n",
|
| 456 |
+
" print(f\"Error: Gene info file {json_file} not found\")\n",
|
| 457 |
+
" continue\n",
|
| 458 |
+
" \n",
|
| 459 |
+
" if verbose:\n",
|
| 460 |
+
" print(f\"\\nProcessing gene: {gene_symbol}\")\n",
|
| 461 |
+
" modified_sequences = self.replace_utr_in_sequence(\n",
|
| 462 |
+
" gene_info_file=json_file,\n",
|
| 463 |
+
" generated_utrs=generated_utrs,\n",
|
| 464 |
+
" target_length=target_length,\n",
|
| 465 |
+
" output_prefix=os.path.join(cache_dir, output_prefix)\n",
|
| 466 |
+
" )\n",
|
| 467 |
+
"\n",
|
| 468 |
+
" if modified_sequences:\n",
|
| 469 |
+
" all_modified_sequences.extend(modified_sequences)\n",
|
| 470 |
+
" else:\n",
|
| 471 |
+
" if verbose:\n",
|
| 472 |
+
" print(f\"No modified sequences generated for {gene_symbol}\")\n",
|
| 473 |
+
"\n",
|
| 474 |
+
" expected_count = n_utrs * n_genes\n",
|
| 475 |
+
"\n",
|
| 476 |
+
" if verbose:\n",
|
| 477 |
+
" print(f\"\\nGenerated {n_utrs * n_genes} modified sequences (expected: {expected_count})\")\n",
|
| 478 |
+
"\n",
|
| 479 |
+
" return all_modified_sequences\n",
|
| 480 |
+
"\n",
|
| 481 |
+
"\n",
|
| 482 |
+
"\n",
|
| 483 |
+
"\n",
|
| 484 |
+
"\n",
|
| 485 |
+
"\n",
|
| 486 |
+
"\n",
|
| 487 |
+
"\n",
|
| 488 |
+
"\n",
|
| 489 |
+
"def convert_model(model_:Model):\n",
|
| 490 |
+
"\n",
|
| 491 |
+
" input_ = tf.keras.layers.Input(shape=( 10500, 4))\n",
|
| 492 |
+
" input = input_\n",
|
| 493 |
+
" for i in range(len(model_.layers)-1):\n",
|
| 494 |
+
"\n",
|
| 495 |
+
" \n",
|
| 496 |
+
" if isinstance(model_.layers[i+1],tf.keras.layers.Concatenate):\n",
|
| 497 |
+
" paddings = tf.constant([[0,0],[0,6]])\n",
|
| 498 |
+
" output = tf.pad(input, paddings, 'CONSTANT')\n",
|
| 499 |
+
" input = output\n",
|
| 500 |
+
" else:\n",
|
| 501 |
+
" if not isinstance(model_.layers[i+1],tf.keras.layers.InputLayer):\n",
|
| 502 |
+
" output = model_.layers[i+1](input)\n",
|
| 503 |
+
" input = output\n",
|
| 504 |
+
"\n",
|
| 505 |
+
" if isinstance(model_.layers[i+1],tf.keras.layers.Conv1D):\n",
|
| 506 |
+
" pass\n",
|
| 507 |
+
"\n",
|
| 508 |
+
" model = tf.keras.Model(inputs=input_, outputs=output)\n",
|
| 509 |
+
" model.compile(loss=\"mse\", optimizer=\"adam\")\n",
|
| 510 |
+
" return model\n",
|
| 511 |
+
"\n",
|
| 512 |
+
"def one_hot(seq):\n",
|
| 513 |
+
" convert = True\n",
|
| 514 |
+
" if isinstance(seq, tf.Tensor):\n",
|
| 515 |
+
" seq = seq.numpy().astype(str)\n",
|
| 516 |
+
" convert = True\n",
|
| 517 |
+
"\n",
|
| 518 |
+
" num_seqs = len(seq)\n",
|
| 519 |
+
" seq_len = len(seq[0])\n",
|
| 520 |
+
" seqindex = {'A':0, 'C':1, 'G':2, 'T':3, 'a':0, 'c':1, 'g':2, 't':3}\n",
|
| 521 |
+
" seq_vec = np.zeros((num_seqs,seq_len,4), dtype='bool')\n",
|
| 522 |
+
" for i in range(num_seqs):\n",
|
| 523 |
+
" thisseq = seq[i]\n",
|
| 524 |
+
" for j in range(seq_len):\n",
|
| 525 |
+
" try:\n",
|
| 526 |
+
" seq_vec[i,j,seqindex[thisseq[j]]] = 1\n",
|
| 527 |
+
" except:\n",
|
| 528 |
+
" pass\n",
|
| 529 |
+
" \n",
|
| 530 |
+
" if convert:\n",
|
| 531 |
+
" seq_vec = tf.convert_to_tensor(seq_vec,dtype=tf.float32)\n",
|
| 532 |
+
"\n",
|
| 533 |
+
"\n",
|
| 534 |
+
" return seq_vec\n",
|
| 535 |
+
"\n",
|
| 536 |
+
"\n",
|
| 537 |
+
"def select_best(scores, seqs, gc_control=False, GC=-1, per_gene=False):\n",
|
| 538 |
+
" selected_scores = []\n",
|
| 539 |
+
" selected_seqs = []\n",
|
| 540 |
+
" if per_gene: \n",
|
| 541 |
+
"\n",
|
| 542 |
+
" scores = np.asarray(scores)\n",
|
| 543 |
+
" seqs = np.asarray(seqs)\n",
|
| 544 |
+
" \n",
|
| 545 |
+
" A, B, C = np.shape(scores)\n",
|
| 546 |
+
" selected_scores = []\n",
|
| 547 |
+
" selected_seqs = []\n",
|
| 548 |
+
" \n",
|
| 549 |
+
" for b in range(B):\n",
|
| 550 |
+
"\n",
|
| 551 |
+
" best_score = np.max(scores[0, b, :]) \n",
|
| 552 |
+
" best_seq = seqs[0, :] \n",
|
| 553 |
+
" \n",
|
| 554 |
+
" for a in range(1, A):\n",
|
| 555 |
+
" current_score = np.max(scores[a, b, :]) \n",
|
| 556 |
+
" \n",
|
| 557 |
+
" if current_score > best_score:\n",
|
| 558 |
+
" if gc_control:\n",
|
| 559 |
+
"\n",
|
| 560 |
+
" gc_content = get_gc_content(seqs[a, :])\n",
|
| 561 |
+
" if gc_content < GC:\n",
|
| 562 |
+
" best_score = current_score\n",
|
| 563 |
+
" best_seq = seqs[a, :]\n",
|
| 564 |
+
" best_a = a\n",
|
| 565 |
+
" else:\n",
|
| 566 |
+
" best_score = current_score\n",
|
| 567 |
+
" best_seq = seqs[a, :]\n",
|
| 568 |
+
" best_a = a\n",
|
| 569 |
+
" \n",
|
| 570 |
+
" selected_scores.append(best_score)\n",
|
| 571 |
+
" selected_seqs.append(best_seq)\n",
|
| 572 |
+
" \n",
|
| 573 |
+
"\n",
|
| 574 |
+
" selected_scores = np.array(selected_scores) \n",
|
| 575 |
+
" selected_seqs = np.array(selected_seqs) \n",
|
| 576 |
+
" else:\n",
|
| 577 |
+
" for i in range(len(scores[0])):\n",
|
| 578 |
+
" best = scores[1][i]\n",
|
| 579 |
+
" best_seq = seqs[1][i]\n",
|
| 580 |
+
" for j in range(len(scores)-1):\n",
|
| 581 |
+
" if scores[j+1][i] > best:\n",
|
| 582 |
+
" if gc_control:\n",
|
| 583 |
+
" if get_gc_content(seqs[j][i]) < GC:\n",
|
| 584 |
+
" best = scores[j+1][i]\n",
|
| 585 |
+
" best_seq = seqs[j+1][i]\n",
|
| 586 |
+
" else:\n",
|
| 587 |
+
" best = scores[j+1][i]\n",
|
| 588 |
+
" best_seq = seqs[j+1][i]\n",
|
| 589 |
+
"\n",
|
| 590 |
+
" selected_scores.append(best)\n",
|
| 591 |
+
" selected_seqs.append(best_seq)\n",
|
| 592 |
+
"\n",
|
| 593 |
+
" return selected_seqs, selected_scores"
|
| 594 |
+
]
|
| 595 |
+
},
|
| 596 |
+
{
|
| 597 |
+
"cell_type": "code",
|
| 598 |
+
"execution_count": 3,
|
| 599 |
+
"id": "9dcefb89",
|
| 600 |
+
"metadata": {},
|
| 601 |
+
"outputs": [
|
| 602 |
+
{
|
| 603 |
+
"name": "stdout",
|
| 604 |
+
"output_type": "stream",
|
| 605 |
+
"text": [
|
| 606 |
+
"WARNING:tensorflow:Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer.\n",
|
| 607 |
+
"WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n",
|
| 608 |
+
"Saved gene information to MYOC_info.json\n",
|
| 609 |
+
"Saved gene information to TIGD4_info.json\n",
|
| 610 |
+
"Saved gene information to ATP6V1B2_info.json\n",
|
| 611 |
+
"Saved gene information to TAGLN_info.json\n",
|
| 612 |
+
"Saved gene information to COX7A2L_info.json\n",
|
| 613 |
+
"Saved gene information to IFNGR2_info.json\n",
|
| 614 |
+
"Saved gene information to TNFRSF21_info.json\n",
|
| 615 |
+
"Saved gene information to SETD6_info.json\n"
|
| 616 |
+
]
|
| 617 |
+
},
|
| 618 |
+
{
|
| 619 |
+
"name": "stderr",
|
| 620 |
+
"output_type": "stream",
|
| 621 |
+
"text": [
|
| 622 |
+
"100%|██████████| 10/10 [00:40<00:00, 4.08s/it]\n"
|
| 623 |
+
]
|
| 624 |
+
},
|
| 625 |
+
{
|
| 626 |
+
"name": "stdout",
|
| 627 |
+
"output_type": "stream",
|
| 628 |
+
"text": [
|
| 629 |
+
"(8,)\n",
|
| 630 |
+
"\n",
|
| 631 |
+
"Evaluation of Optimization on Original Genes (Log TPM):\n",
|
| 632 |
+
"\n",
|
| 633 |
+
"Expression Levels (Log TPM):\n",
|
| 634 |
+
" Average Initial Log TPM: -0.1834 (TPM: 0.6555)\n",
|
| 635 |
+
" Average Optimized Log TPM: -0.0183 (TPM: 0.9587)\n",
|
| 636 |
+
" Log TPM Difference: 0.1651\n",
|
| 637 |
+
" TPM Improvement: 0.3032 (+46.25% (increase))\n",
|
| 638 |
+
"Genes:\n",
|
| 639 |
+
"['MYOC', 'TIGD4', 'ATP6V1B2', 'TAGLN', 'COX7A2L', 'IFNGR2', 'TNFRSF21', 'SETD6']\n",
|
| 640 |
+
"Average Initial Expression: -0.1834263348579407\n",
|
| 641 |
+
"Best Expression: -0.018321754410862923\n",
|
| 642 |
+
"Error processing UTR replacement for DHRS2: ufunc 'add' did not contain a loop with signature matching types (dtype('<U8000'), dtype('<U128')) -> None\n",
|
| 643 |
+
"Error processing UTR replacement for METAP1D: ufunc 'add' did not contain a loop with signature matching types (dtype('<U8000'), dtype('<U128')) -> None\n",
|
| 644 |
+
"\n",
|
| 645 |
+
"Evaluation of Optimization on Target Genes (Log TPM):\n",
|
| 646 |
+
"Original Genes: ['MYOC', 'TIGD4', 'ATP6V1B2', 'TAGLN', 'COX7A2L', 'IFNGR2', 'TNFRSF21', 'SETD6']\n",
|
| 647 |
+
"Target Genes: ['ANTXR2', 'NFIL3', 'UNC13D', 'DHRS2', 'RPS13', 'HBD', 'METAP1D', 'NCALD']\n",
|
| 648 |
+
"\n",
|
| 649 |
+
"Expression Levels (Log TPM):\n",
|
| 650 |
+
" Average Initial Log TPM: -0.5353 (TPM: 0.2915)\n",
|
| 651 |
+
" Average Optimized Log TPM: -0.4488 (TPM: 0.3558)\n",
|
| 652 |
+
" Log TPM Difference: 0.0865\n",
|
| 653 |
+
" TPM Improvement: 0.0643 (+22.05% (increase))\n",
|
| 654 |
+
"\n",
|
| 655 |
+
"Per-Gene Expression Levels (Log TPM):\n",
|
| 656 |
+
" ANTXR2: Initial Log TPM = -0.1230 (TPM: 0.7534), Optimized Log TPM = -0.5100 (TPM: 0.3091), TPM Improvement = -0.4443 (-58.98% (decrease))\n",
|
| 657 |
+
" NFIL3: Initial Log TPM = 0.7915 (TPM: 6.1874), Optimized Log TPM = 0.3522 (TPM: 2.2503), TPM Improvement = -3.9371 (-63.63% (decrease))\n",
|
| 658 |
+
" UNC13D: Initial Log TPM = -0.4673 (TPM: 0.3409), Optimized Log TPM = 0.3383 (TPM: 2.1793), TPM Improvement = 1.8384 (+539.22% (increase))\n",
|
| 659 |
+
" DHRS2: Initial Log TPM = -1.1142 (TPM: 0.0769), Optimized Log TPM = -0.5517 (TPM: 0.2807), TPM Improvement = 0.2038 (+265.13% (increase))\n",
|
| 660 |
+
" RPS13: Initial Log TPM = 0.1343 (TPM: 1.3622), Optimized Log TPM = 0.0449 (TPM: 1.1090), TPM Improvement = -0.2533 (-18.59% (decrease))\n",
|
| 661 |
+
" HBD: Initial Log TPM = -1.3306 (TPM: 0.0467), Optimized Log TPM = -0.8894 (TPM: 0.1290), TPM Improvement = 0.0823 (+176.14% (increase))\n",
|
| 662 |
+
" METAP1D: Initial Log TPM = -1.1724 (TPM: 0.0672), Optimized Log TPM = -1.2720 (TPM: 0.0535), TPM Improvement = -0.0138 (-20.50% (decrease))\n",
|
| 663 |
+
" NCALD: Initial Log TPM = -1.0010 (TPM: 0.0998), Optimized Log TPM = -1.1027 (TPM: 0.0789), TPM Improvement = -0.0208 (-20.88% (decrease))\n"
|
| 664 |
+
]
|
| 665 |
+
}
|
| 666 |
+
],
|
| 667 |
+
"source": [
|
| 668 |
+
"\n",
|
| 669 |
+
"model = tf.keras.models.load_model(exp_path)\n",
|
| 670 |
+
"\n",
|
| 671 |
+
"model = convert_model(model)\n",
|
| 672 |
+
"\n",
|
| 673 |
+
"wgan = tf.keras.models.load_model(gpath)\n",
|
| 674 |
+
"\n",
|
| 675 |
+
"\"\"\"\n",
|
| 676 |
+
"Data:\n",
|
| 677 |
+
"\"\"\"\n",
|
| 678 |
+
"\n",
|
| 679 |
+
"\n",
|
| 680 |
+
"noise = tf.Variable(tf.random.normal(shape=[BATCH_SIZE,40]))\n",
|
| 681 |
+
"\n",
|
| 682 |
+
"tf.random.set_seed(25)\n",
|
| 683 |
+
"\n",
|
| 684 |
+
"diffs = []\n",
|
| 685 |
+
"init_exps = []\n",
|
| 686 |
+
"\n",
|
| 687 |
+
"opt_exps = []\n",
|
| 688 |
+
"\n",
|
| 689 |
+
"orig_vals = []\n",
|
| 690 |
+
"\n",
|
| 691 |
+
"noise = tf.Variable(tf.random.normal(shape=[BATCH_SIZE,40]))\n",
|
| 692 |
+
"noise_small = tf.random.normal(shape=[BATCH_SIZE,40],stddev=1e-5)\n",
|
| 693 |
+
"\n",
|
| 694 |
+
"optimizer = tf.keras.optimizers.Adam(learning_rate=LR)\n",
|
| 695 |
+
"\n",
|
| 696 |
+
"'''\n",
|
| 697 |
+
"Optimization takes place here.\n",
|
| 698 |
+
"'''\n",
|
| 699 |
+
"\n",
|
| 700 |
+
"bind_scores_list = []\n",
|
| 701 |
+
"bind_scores_means = []\n",
|
| 702 |
+
"sequences_list = []\n",
|
| 703 |
+
"\n",
|
| 704 |
+
"means = []\n",
|
| 705 |
+
"maxes = []\n",
|
| 706 |
+
"\n",
|
| 707 |
+
"iters_ = []\n",
|
| 708 |
+
"\n",
|
| 709 |
+
"OPTIMIZE = True\n",
|
| 710 |
+
"\n",
|
| 711 |
+
"DNA_SEL = False\n",
|
| 712 |
+
"\n",
|
| 713 |
+
"retriever = GeneInfoRetriever()\n",
|
| 714 |
+
"refs = []\n",
|
| 715 |
+
"for i in range(len(gene_names)):\n",
|
| 716 |
+
" output_json = f\"{gene_names[i]}_info.json\"\n",
|
| 717 |
+
"\n",
|
| 718 |
+
" if not os.path.exists(os.path.join('./.cache/',output_json)):\n",
|
| 719 |
+
"\n",
|
| 720 |
+
" # Retrieve gene information\n",
|
| 721 |
+
" gene_info = retriever.get_gene_info(gene_names[i], output_json=output_json)\n",
|
| 722 |
+
"\n",
|
| 723 |
+
" if \"error\" in gene_info:\n",
|
| 724 |
+
" print(f\"Error: {gene_info['error']}\")\n",
|
| 725 |
+
" else:\n",
|
| 726 |
+
" refs.append(gene_info[\"promoter_sequence\"]) \n",
|
| 727 |
+
" else:\n",
|
| 728 |
+
" with open(os.path.join('./.cache/',output_json), \"r\") as f:\n",
|
| 729 |
+
" gene_info = json.load(f)\n",
|
| 730 |
+
" refs.append(gene_info[\"promoter_sequence\"])\n",
|
| 731 |
+
"\n",
|
| 732 |
+
"sequences_init = wgan(noise)\n",
|
| 733 |
+
"\n",
|
| 734 |
+
"gen_seqs_init = sequences_init.numpy().astype('float')\n",
|
| 735 |
+
"\n",
|
| 736 |
+
"seqs_gen_init = recover_seq(gen_seqs_init, rev_rna_vocab)\n",
|
| 737 |
+
"\n",
|
| 738 |
+
"seqs_init = retriever.replace_utr_in_multiple_sequences(gene_names, seqs_gen_init, target_length=10500, cache_dir=\"./.cache\", output_prefix=\"modified_sequence\")\n",
|
| 739 |
+
"\n",
|
| 740 |
+
"seqs_init = one_hot(seqs_init)\n",
|
| 741 |
+
"\n",
|
| 742 |
+
"pred_init = model(seqs_init) \n",
|
| 743 |
+
"\n",
|
| 744 |
+
"pred_init = tf.reshape(pred_init,(SEQ_BATCH,-1))\n",
|
| 745 |
+
"\n",
|
| 746 |
+
"average_initial_prediction = tf.reduce_mean(pred_init,axis=0).numpy().astype('float')\n",
|
| 747 |
+
"\n",
|
| 748 |
+
"# %%\n",
|
| 749 |
+
"\n",
|
| 750 |
+
"seqs_collection = []\n",
|
| 751 |
+
"scores_collection = []\n",
|
| 752 |
+
"scores_collection_genes = []\n",
|
| 753 |
+
"if OPTIMIZE:\n",
|
| 754 |
+
"\n",
|
| 755 |
+
" iter_ = 0\n",
|
| 756 |
+
" for opt_iter in tqdm(range(STEPS)):\n",
|
| 757 |
+
" \n",
|
| 758 |
+
" with tf.GradientTape() as gtape:\n",
|
| 759 |
+
" gtape.watch(noise)\n",
|
| 760 |
+
" \n",
|
| 761 |
+
" sequences = wgan(noise)\n",
|
| 762 |
+
"\n",
|
| 763 |
+
" seqs_gen = recover_seq(sequences, rev_rna_vocab)\n",
|
| 764 |
+
" seqs_collection.append(seqs_gen)\n",
|
| 765 |
+
"\n",
|
| 766 |
+
" g1_ = tf.zeros_like(sequences)\n",
|
| 767 |
+
"\n",
|
| 768 |
+
" scores_collection_temp = []\n",
|
| 769 |
+
"\n",
|
| 770 |
+
" for gene in gene_names:\n",
|
| 771 |
+
"\n",
|
| 772 |
+
" seqs_dna = retriever.replace_utr_in_sequence(f\"./.cache/{gene}_info.json\", seqs_gen, target_length=10500, output_prefix=\"modified_sequence\") \n",
|
| 773 |
+
" \n",
|
| 774 |
+
" seqs = one_hot(seqs_dna)\n",
|
| 775 |
+
" \n",
|
| 776 |
+
" with tf.GradientTape() as ptape:\n",
|
| 777 |
+
" ptape.watch(seqs)\n",
|
| 778 |
+
"\n",
|
| 779 |
+
" pred = model(seqs)\n",
|
| 780 |
+
" t = tf.reshape(pred,(-1))\n",
|
| 781 |
+
" scores_collection_temp.append(t.numpy().astype('float'))\n",
|
| 782 |
+
" nt = t.numpy().astype('float')\n",
|
| 783 |
+
"\n",
|
| 784 |
+
" g1 = ptape.gradient(pred,seqs)\n",
|
| 785 |
+
" g1 = tf.math.scalar_mul(-1.0, g1)\n",
|
| 786 |
+
" g1 = tf.slice(g1,[0,7000,0],[-1,128,-1])\n",
|
| 787 |
+
"\n",
|
| 788 |
+
" tmp_g = g1.numpy().astype('float')\n",
|
| 789 |
+
" tmp_seqs = seqs_gen\n",
|
| 790 |
+
"\n",
|
| 791 |
+
" # Initialize tmp_lst with correct size\n",
|
| 792 |
+
" batch_size = min(len(tmp_seqs), tmp_g.shape[0])\n",
|
| 793 |
+
" tmp_lst = np.zeros(shape=(batch_size, 128, 5))\n",
|
| 794 |
+
"\n",
|
| 795 |
+
" # Loop on the batch size and update the UTR only\n",
|
| 796 |
+
" for i in range(batch_size):\n",
|
| 797 |
+
" len_ = min(len(tmp_seqs[i]), tmp_g.shape[1]) # Prevent exceeding tmp_g's dimensions\n",
|
| 798 |
+
" edited_g = tmp_g[i][:len_, :]\n",
|
| 799 |
+
" edited_g = np.pad(edited_g, ((0, 128-len_), (0, 1)), 'constant')\n",
|
| 800 |
+
" tmp_lst[i] = edited_g\n",
|
| 801 |
+
"\n",
|
| 802 |
+
" g1 = tf.convert_to_tensor(tmp_lst, dtype=tf.float32)\n",
|
| 803 |
+
"\n",
|
| 804 |
+
" g1_ = tf.math.add(g1, g1_)\n",
|
| 805 |
+
"\n",
|
| 806 |
+
" scores_collection.append(np.mean(scores_collection_temp,axis=0))\n",
|
| 807 |
+
" scores_collection_genes.append(scores_collection_temp)\n",
|
| 808 |
+
" g2 = gtape.gradient(sequences,noise,output_gradients=g1_)\n",
|
| 809 |
+
"\n",
|
| 810 |
+
"\n",
|
| 811 |
+
" a1 = g2 + noise_small\n",
|
| 812 |
+
" change = [(a1,noise)]\n",
|
| 813 |
+
"\n",
|
| 814 |
+
" optimizer.apply_gradients(change)\n",
|
| 815 |
+
"\n",
|
| 816 |
+
" iters_.append(iter_)\n",
|
| 817 |
+
" iter_ += 1\n",
|
| 818 |
+
"\n",
|
| 819 |
+
" sequences_opt = wgan(noise)\n",
|
| 820 |
+
"\n",
|
| 821 |
+
" gen_seqs_opt = sequences_opt.numpy().astype('float')\n",
|
| 822 |
+
"\n",
|
| 823 |
+
" seqs_gen_opt = recover_seq(gen_seqs_opt, rev_rna_vocab)\n",
|
| 824 |
+
"\n",
|
| 825 |
+
" seqs_opt = retriever.replace_utr_in_multiple_sequences(gene_names, seqs_gen_opt, target_length=10500, cache_dir=\"./.cache\", output_prefix=\"modified_sequence\")\n",
|
| 826 |
+
"\n",
|
| 827 |
+
" seqs_opt = one_hot(seqs_opt)\n",
|
| 828 |
+
"\n",
|
| 829 |
+
" pred_opt = model(seqs_opt)\n",
|
| 830 |
+
"\n",
|
| 831 |
+
" pred_opt = tf.reshape(pred_opt,(SEQ_BATCH,-1))\n",
|
| 832 |
+
"\n",
|
| 833 |
+
"\n",
|
| 834 |
+
" average_optimized_prediction = tf.reduce_mean(pred_opt,axis=0).numpy().astype('float')\n",
|
| 835 |
+
"\n",
|
| 836 |
+
"\n",
|
| 837 |
+
"best_seqs, best_scores = select_best(scores_collection_genes, seqs_collection, per_gene=True)\n",
|
| 838 |
+
"\n",
|
| 839 |
+
"\n",
|
| 840 |
+
"# %%\n",
|
| 841 |
+
"print(np.shape(best_scores))\n",
|
| 842 |
+
"\n",
|
| 843 |
+
"# %%\n",
|
| 844 |
+
"\n",
|
| 845 |
+
"with open('./outputs/mul_init_exps.txt', 'w') as f:\n",
|
| 846 |
+
" for item in average_initial_prediction:\n",
|
| 847 |
+
" f.write(f'{item}\\n')\n",
|
| 848 |
+
"\n",
|
| 849 |
+
"with open('./outputs/mul_best_exps.txt', 'w') as f:\n",
|
| 850 |
+
" for item in best_scores:\n",
|
| 851 |
+
" f.write(f'{item}\\n')\n",
|
| 852 |
+
"\n",
|
| 853 |
+
"with open('./outputs/mul_opt_exps.txt', 'w') as f:\n",
|
| 854 |
+
" for item in average_optimized_prediction:\n",
|
| 855 |
+
" f.write(f'{item}\\n')\n",
|
| 856 |
+
"\n",
|
| 857 |
+
"with open('./outputs/mul_best_seqs.txt', 'w') as f:\n",
|
| 858 |
+
" for item in best_seqs:\n",
|
| 859 |
+
" f.write(f'{item}\\n')\n",
|
| 860 |
+
"\n",
|
| 861 |
+
"with open('./outputs/mul_init_seqs.txt', 'w') as f:\n",
|
| 862 |
+
" for item in seqs_gen_init:\n",
|
| 863 |
+
" f.write(f'{item}\\n')\n",
|
| 864 |
+
"\n",
|
| 865 |
+
"# Compute average Log TPM per gene\n",
|
| 866 |
+
"init_log_tpm_target = tf.reduce_mean(pred_init, axis=1).numpy().astype('float')\n",
|
| 867 |
+
"opt_log_tpm_target = tf.reduce_mean(pred_opt, axis=1).numpy().astype('float')\n",
|
| 868 |
+
"opt_log_tpm_target = best_scores\n",
|
| 869 |
+
"\n",
|
| 870 |
+
"# Compute overall average Log TPM across target genes\n",
|
| 871 |
+
"avg_init_log_tpm = np.average(init_log_tpm_target)\n",
|
| 872 |
+
"avg_opt_log_tpm = np.average(opt_log_tpm_target)\n",
|
| 873 |
+
"\n",
|
| 874 |
+
"# Convert Log TPM to TPM for percentage improvement\n",
|
| 875 |
+
"# Assuming Log TPM is base-10 (common for TPM), TPM = 10^LogTPM\n",
|
| 876 |
+
"avg_init_tpm = np.power(10, avg_init_log_tpm)\n",
|
| 877 |
+
"avg_opt_tpm = np.power(10, avg_opt_log_tpm)\n",
|
| 878 |
+
"\n",
|
| 879 |
+
"# Compute improvement\n",
|
| 880 |
+
"log_tpm_diff = avg_opt_log_tpm - avg_init_log_tpm\n",
|
| 881 |
+
"tpm_improvement = avg_opt_tpm - avg_init_tpm\n",
|
| 882 |
+
"# Percentage improvement based on TPM: ((opt - init) / init) * 100\n",
|
| 883 |
+
"if avg_init_tpm != 0: # Avoid division by zero\n",
|
| 884 |
+
" tpm_percent_change = (tpm_improvement / avg_init_tpm) * 100\n",
|
| 885 |
+
"else:\n",
|
| 886 |
+
" tpm_percent_change = float('inf') if tpm_improvement > 0 else 0.0\n",
|
| 887 |
+
"\n",
|
| 888 |
+
"# Handle negative and positive percentages\n",
|
| 889 |
+
"percent_str = f\"{tpm_percent_change:.2f}%\"\n",
|
| 890 |
+
"if tpm_percent_change < 0:\n",
|
| 891 |
+
" percent_str = f\"{tpm_percent_change:.2f}% (decrease)\"\n",
|
| 892 |
+
"elif tpm_percent_change > 0:\n",
|
| 893 |
+
" percent_str = f\"+{tpm_percent_change:.2f}% (increase)\"\n",
|
| 894 |
+
"\n",
|
| 895 |
+
"# Print evaluation results\n",
|
| 896 |
+
"print(\"\\nEvaluation of Optimization on Original Genes (Log TPM):\")\n",
|
| 897 |
+
"print(\"\\nExpression Levels (Log TPM):\")\n",
|
| 898 |
+
"print(f\" Average Initial Log TPM: {avg_init_log_tpm:.4f} (TPM: {avg_init_tpm:.4f})\")\n",
|
| 899 |
+
"print(f\" Average Optimized Log TPM: {avg_opt_log_tpm:.4f} (TPM: {avg_opt_tpm:.4f})\")\n",
|
| 900 |
+
"print(f\" Log TPM Difference: {log_tpm_diff:.4f}\")\n",
|
| 901 |
+
"print(f\" TPM Improvement: {tpm_improvement:.4f} ({percent_str})\")\n",
|
| 902 |
+
"\n",
|
| 903 |
+
"\n",
|
| 904 |
+
"print(\"Genes:\")\n",
|
| 905 |
+
"print(gene_names)\n",
|
| 906 |
+
"print(f\"Average Initial Expression: {np.average(average_initial_prediction)}\")\n",
|
| 907 |
+
"print(f\"Best Expression: {np.average(best_scores)}\")\n",
|
| 908 |
+
"\n",
|
| 909 |
+
"\n",
|
| 910 |
+
"target_refs = []\n",
|
| 911 |
+
"for gene in target_genes:\n",
|
| 912 |
+
" output_json = f\"{gene}_info.json\"\n",
|
| 913 |
+
" cache_path = os.path.join('./.cache/', output_json)\n",
|
| 914 |
+
" \n",
|
| 915 |
+
" if not os.path.exists(cache_path):\n",
|
| 916 |
+
" # Retrieve gene information\n",
|
| 917 |
+
" gene_info = retriever.get_gene_info(gene, output_json=output_json)\n",
|
| 918 |
+
" if \"error\" in gene_info:\n",
|
| 919 |
+
" print(f\"Error retrieving info for {gene}: {gene_info['error']}\")\n",
|
| 920 |
+
" target_refs.append(None) # Handle errors gracefully\n",
|
| 921 |
+
" else:\n",
|
| 922 |
+
" target_refs.append(gene_info[\"promoter_sequence\"])\n",
|
| 923 |
+
" else:\n",
|
| 924 |
+
" with open(cache_path, \"r\") as f:\n",
|
| 925 |
+
" gene_info = json.load(f)\n",
|
| 926 |
+
" target_refs.append(gene_info[\"promoter_sequence\"])\n",
|
| 927 |
+
"\n",
|
| 928 |
+
"\n",
|
| 929 |
+
"valid_indices = [i for i, ref in enumerate(target_refs) if ref is not None]\n",
|
| 930 |
+
"target_genes = [target_genes[i] for i in valid_indices]\n",
|
| 931 |
+
"target_refs = [target_refs[i] for i in valid_indices]\n",
|
| 932 |
+
"\n",
|
| 933 |
+
"if not target_genes:\n",
|
| 934 |
+
" print(\"No valid target genes retrieved. Exiting evaluation.\")\n",
|
| 935 |
+
"else:\n",
|
| 936 |
+
"\n",
|
| 937 |
+
" seqs_gen_init = seqs_gen_init \n",
|
| 938 |
+
" seqs_gen_opt = best_seqs \n",
|
| 939 |
+
"\n",
|
| 940 |
+
"\n",
|
| 941 |
+
" seqs_init_target = retriever.replace_utr_in_multiple_sequences(\n",
|
| 942 |
+
" target_genes, seqs_gen_init, target_length=10500, cache_dir=\"./.cache\", output_prefix=\"target_modified_sequence\"\n",
|
| 943 |
+
" )\n",
|
| 944 |
+
" seqs_opt_target = retriever.replace_utr_in_multiple_sequences(\n",
|
| 945 |
+
" target_genes, seqs_gen_opt, target_length=10500, cache_dir=\"./.cache\", output_prefix=\"target_modified_sequence\"\n",
|
| 946 |
+
" )\n",
|
| 947 |
+
"\n",
|
| 948 |
+
"\n",
|
| 949 |
+
" seqs_init_target = one_hot(seqs_init_target)\n",
|
| 950 |
+
" seqs_opt_target = one_hot(seqs_opt_target)\n",
|
| 951 |
+
"\n",
|
| 952 |
+
"\n",
|
| 953 |
+
" pred_init_target = model(seqs_init_target)\n",
|
| 954 |
+
" pred_opt_target = model(seqs_opt_target)\n",
|
| 955 |
+
"\n",
|
| 956 |
+
" pred_init_target = tf.reshape(pred_init_target, (len(target_genes), -1))\n",
|
| 957 |
+
" pred_opt_target = tf.reshape(pred_opt_target, (len(target_genes), -1))\n",
|
| 958 |
+
"\n",
|
| 959 |
+
" # Compute average Log TPM per gene\n",
|
| 960 |
+
" init_log_tpm_target = tf.reduce_mean(pred_init_target, axis=1).numpy().astype('float')\n",
|
| 961 |
+
" opt_log_tpm_target = tf.reduce_mean(pred_opt_target, axis=1).numpy().astype('float')\n",
|
| 962 |
+
"\n",
|
| 963 |
+
" # Compute overall average Log TPM across target genes\n",
|
| 964 |
+
" avg_init_log_tpm = np.average(init_log_tpm_target)\n",
|
| 965 |
+
" avg_opt_log_tpm = np.average(opt_log_tpm_target)\n",
|
| 966 |
+
"\n",
|
| 967 |
+
" # Convert Log TPM to TPM for percentage improvement\n",
|
| 968 |
+
" avg_init_tpm = np.power(10, avg_init_log_tpm)\n",
|
| 969 |
+
" avg_opt_tpm = np.power(10, avg_opt_log_tpm)\n",
|
| 970 |
+
"\n",
|
| 971 |
+
" # Compute improvement\n",
|
| 972 |
+
" log_tpm_diff = avg_opt_log_tpm - avg_init_log_tpm\n",
|
| 973 |
+
" tpm_improvement = avg_opt_tpm - avg_init_tpm\n",
|
| 974 |
+
" # Percentage improvement based on TPM: ((opt - init) / init) * 100\n",
|
| 975 |
+
" if avg_init_tpm != 0: # Avoid division by zero\n",
|
| 976 |
+
" tpm_percent_change = (tpm_improvement / avg_init_tpm) * 100\n",
|
| 977 |
+
" else:\n",
|
| 978 |
+
" tpm_percent_change = float('inf') if tpm_improvement > 0 else 0.0\n",
|
| 979 |
+
"\n",
|
| 980 |
+
" # Handle negative and positive percentages\n",
|
| 981 |
+
" percent_str = f\"{tpm_percent_change:.2f}%\"\n",
|
| 982 |
+
" if tpm_percent_change < 0:\n",
|
| 983 |
+
" percent_str = f\"{tpm_percent_change:.2f}% (decrease)\"\n",
|
| 984 |
+
" elif tpm_percent_change > 0:\n",
|
| 985 |
+
" percent_str = f\"+{tpm_percent_change:.2f}% (increase)\"\n",
|
| 986 |
+
"\n",
|
| 987 |
+
" # Print evaluation results\n",
|
| 988 |
+
" print(\"\\nEvaluation of Optimization on Target Genes (Log TPM):\")\n",
|
| 989 |
+
" print(f\"Original Genes: {gene_names}\")\n",
|
| 990 |
+
" print(f\"Target Genes: {target_genes}\")\n",
|
| 991 |
+
" print(\"\\nExpression Levels (Log TPM):\")\n",
|
| 992 |
+
" print(f\" Average Initial Log TPM: {avg_init_log_tpm:.4f} (TPM: {avg_init_tpm:.4f})\")\n",
|
| 993 |
+
" print(f\" Average Optimized Log TPM: {avg_opt_log_tpm:.4f} (TPM: {avg_opt_tpm:.4f})\")\n",
|
| 994 |
+
" print(f\" Log TPM Difference: {log_tpm_diff:.4f}\")\n",
|
| 995 |
+
" print(f\" TPM Improvement: {tpm_improvement:.4f} ({percent_str})\")\n",
|
| 996 |
+
"\n",
|
| 997 |
+
" # Save evaluation results to a file\n",
|
| 998 |
+
" with open('./outputs/target_genes_evaluation.txt', 'w') as f:\n",
|
| 999 |
+
" f.write(\"Evaluation of Optimization on Target Genes (Log TPM)\\n\")\n",
|
| 1000 |
+
" f.write(f\"Original Genes: {gene_names}\\n\")\n",
|
| 1001 |
+
" f.write(f\"Target Genes: {target_genes}\\n\\n\")\n",
|
| 1002 |
+
" f.write(\"Expression Levels (Log TPM):\\n\")\n",
|
| 1003 |
+
" f.write(f\" Average Initial Log TPM: {avg_init_log_tpm:.4f} (TPM: {avg_init_tpm:.4f})\\n\")\n",
|
| 1004 |
+
" f.write(f\" Average Optimized Log TPM: {avg_opt_log_tpm:.4f} (TPM: {avg_opt_tpm:.4f})\\n\")\n",
|
| 1005 |
+
" f.write(f\" Log TPM Difference: {log_tpm_diff:.4f}\\n\")\n",
|
| 1006 |
+
" f.write(f\" TPM Improvement: {tpm_improvement:.4f} ({percent_str})\\n\")\n",
|
| 1007 |
+
"\n",
|
| 1008 |
+
" # Optional: Per-gene breakdown\n",
|
| 1009 |
+
" print(\"\\nPer-Gene Expression Levels (Log TPM):\")\n",
|
| 1010 |
+
" for gene, init_log, opt_log in zip(target_genes, init_log_tpm_target, opt_log_tpm_target):\n",
|
| 1011 |
+
" init_tpm = np.power(10, init_log)\n",
|
| 1012 |
+
" opt_tpm = np.power(10, opt_log)\n",
|
| 1013 |
+
" tpm_diff = opt_tpm - init_tpm\n",
|
| 1014 |
+
" if init_tpm != 0:\n",
|
| 1015 |
+
" gene_percent = (tpm_diff / init_tpm) * 100\n",
|
| 1016 |
+
" else:\n",
|
| 1017 |
+
" gene_percent = float('inf') if tpm_diff > 0 else 0.0\n",
|
| 1018 |
+
" gene_percent_str = f\"{gene_percent:.2f}%\"\n",
|
| 1019 |
+
" if gene_percent < 0:\n",
|
| 1020 |
+
" gene_percent_str = f\"{gene_percent:.2f}% (decrease)\"\n",
|
| 1021 |
+
" elif gene_percent > 0:\n",
|
| 1022 |
+
" gene_percent_str = f\"+{gene_percent:.2f}% (increase)\"\n",
|
| 1023 |
+
" print(f\" {gene}: Initial Log TPM = {init_log:.4f} (TPM: {init_tpm:.4f}), \"\n",
|
| 1024 |
+
" f\"Optimized Log TPM = {opt_log:.4f} (TPM: {opt_tpm:.4f}), \"\n",
|
| 1025 |
+
" f\"TPM Improvement = {tpm_diff:.4f} ({gene_percent_str})\")\n",
|
| 1026 |
+
"\n",
|
| 1027 |
+
"\n",
|
| 1028 |
+
"\n"
|
| 1029 |
+
]
|
| 1030 |
+
}
|
| 1031 |
+
],
|
| 1032 |
+
"metadata": {
|
| 1033 |
+
"kernelspec": {
|
| 1034 |
+
"display_name": "utrgan",
|
| 1035 |
+
"language": "python",
|
| 1036 |
+
"name": "python3"
|
| 1037 |
+
},
|
| 1038 |
+
"language_info": {
|
| 1039 |
+
"codemirror_mode": {
|
| 1040 |
+
"name": "ipython",
|
| 1041 |
+
"version": 3
|
| 1042 |
+
},
|
| 1043 |
+
"file_extension": ".py",
|
| 1044 |
+
"mimetype": "text/x-python",
|
| 1045 |
+
"name": "python",
|
| 1046 |
+
"nbconvert_exporter": "python",
|
| 1047 |
+
"pygments_lexer": "ipython3",
|
| 1048 |
+
"version": "3.10.8"
|
| 1049 |
+
}
|
| 1050 |
+
},
|
| 1051 |
+
"nbformat": 4,
|
| 1052 |
+
"nbformat_minor": 5
|
| 1053 |
+
}
|
conf/notebooks/exp_optimization_single.ipynb
ADDED
|
@@ -0,0 +1,906 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 1,
|
| 6 |
+
"id": "d9c44f69",
|
| 7 |
+
"metadata": {},
|
| 8 |
+
"outputs": [
|
| 9 |
+
{
|
| 10 |
+
"name": "stdout",
|
| 11 |
+
"output_type": "stream",
|
| 12 |
+
"text": [
|
| 13 |
+
"/Users/sbarazan/Documents/bilkent/utrgan/bioinformatics advances/code/UTRGAN/src/exp_optimization\n"
|
| 14 |
+
]
|
| 15 |
+
}
|
| 16 |
+
],
|
| 17 |
+
"source": [
|
| 18 |
+
"import requests\n",
|
| 19 |
+
"import json\n",
|
| 20 |
+
"import time\n",
|
| 21 |
+
"import numpy as np\n",
|
| 22 |
+
"import os\n",
|
| 23 |
+
"from uuid import uuid4\n",
|
| 24 |
+
"from re import A, L\n",
|
| 25 |
+
"import numpy as np\n",
|
| 26 |
+
"import pandas as pd\n",
|
| 27 |
+
"import argparse\n",
|
| 28 |
+
"from tqdm import tqdm\n",
|
| 29 |
+
"import torch\n",
|
| 30 |
+
"import tensorflow as tf\n",
|
| 31 |
+
"import tensorflow.keras.backend as K\n",
|
| 32 |
+
"from tensorflow.keras import Model\n",
|
| 33 |
+
"from tensorflow.keras.models import load_model\n",
|
| 34 |
+
"import sys\n",
|
| 35 |
+
"import socket\n",
|
| 36 |
+
"import datetime\n",
|
| 37 |
+
"import random\n",
|
| 38 |
+
"import os\n",
|
| 39 |
+
"import matplotlib.pyplot as plt\n",
|
| 40 |
+
"from Bio import SeqIO\n",
|
| 41 |
+
"import pandas as pd\n",
|
| 42 |
+
"import numpy as np\n",
|
| 43 |
+
"import requests, sys\n",
|
| 44 |
+
"from src.exp_optimization.util import *\n",
|
| 45 |
+
"from src.exp_optimization.framepool import *\n",
|
| 46 |
+
"from src.exp_optimization.popen import Auto_popen\n",
|
| 47 |
+
"\n",
|
| 48 |
+
"tf.compat.v1.enable_eager_execution()\n",
|
| 49 |
+
"\n",
|
| 50 |
+
"SEQ_LEN=128\n",
|
| 51 |
+
"TF_ENABLE_ONEDNN_OPTS=0\n",
|
| 52 |
+
"\n",
|
| 53 |
+
"DATA = './../../data/utrdb2.csv'\n",
|
| 54 |
+
"BATCH_SIZE = 500\n",
|
| 55 |
+
"GENE = 'VEGFA'\n",
|
| 56 |
+
"GC_LIMIT = -1.00\n",
|
| 57 |
+
"LR = 0.005\n",
|
| 58 |
+
"GPU = '0'\n",
|
| 59 |
+
"STEPS = 2\n",
|
| 60 |
+
"\n",
|
| 61 |
+
"if GPU == '-1':\n",
|
| 62 |
+
" device = 'cpu'\n",
|
| 63 |
+
"else:\n",
|
| 64 |
+
" os.environ['CUDA_VISIBLE_DEVICES'] = GPU\n",
|
| 65 |
+
" device = 'cuda'\n",
|
| 66 |
+
"\n",
|
| 67 |
+
"\n",
|
| 68 |
+
"def reverse_complement(sequence):\n",
|
| 69 |
+
" \"\"\"Compute the reverse complement of a DNA sequence.\"\"\"\n",
|
| 70 |
+
" complement = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', \n",
|
| 71 |
+
" 'a': 't', 't': 'a', 'c': 'g', 'g': 'c', 'N': 'N', 'n': 'N'}\n",
|
| 72 |
+
" return ''.join(complement.get(base, 'N') for base in reversed(sequence))\n",
|
| 73 |
+
"\n",
|
| 74 |
+
"\n",
|
| 75 |
+
"class GeneInfoRetriever:\n",
|
| 76 |
+
" def __init__(self):\n",
|
| 77 |
+
" self.base_url = \"https://rest.ensembl.org\"\n",
|
| 78 |
+
" self.headers = {\"Content-Type\": \"application/json\"}\n",
|
| 79 |
+
" self.sleep_time = 0.5 # Respect Ensembl API rate limits\n",
|
| 80 |
+
"\n",
|
| 81 |
+
" def _make_request(self, endpoint):\n",
|
| 82 |
+
" \"\"\"Make a request to the Ensembl REST API.\"\"\"\n",
|
| 83 |
+
" url = self.base_url + endpoint\n",
|
| 84 |
+
" try:\n",
|
| 85 |
+
" response = requests.get(url, headers=self.headers)\n",
|
| 86 |
+
" time.sleep(self.sleep_time)\n",
|
| 87 |
+
" if response.status_code == 200:\n",
|
| 88 |
+
" return response.json()\n",
|
| 89 |
+
" else:\n",
|
| 90 |
+
" print(f\"Error: {response.status_code} - {response.text}\")\n",
|
| 91 |
+
" return None\n",
|
| 92 |
+
" except Exception as e:\n",
|
| 93 |
+
" print(f\"Request error: {e}\")\n",
|
| 94 |
+
" return None\n",
|
| 95 |
+
"\n",
|
| 96 |
+
" def get_gene_id(self, gene_symbol, species=\"homo_sapiens\"):\n",
|
| 97 |
+
" \"\"\"Retrieve the Ensembl gene ID for a gene symbol.\"\"\"\n",
|
| 98 |
+
" endpoint = f\"/lookup/symbol/{species}/{gene_symbol}\"\n",
|
| 99 |
+
" response = self._make_request(endpoint)\n",
|
| 100 |
+
" return response.get(\"id\") if response else None\n",
|
| 101 |
+
"\n",
|
| 102 |
+
" def get_gene_coordinates(self, gene_id):\n",
|
| 103 |
+
" \"\"\"Retrieve genomic coordinates for a gene ID.\"\"\"\n",
|
| 104 |
+
" endpoint = f\"/lookup/id/{gene_id}?expand=1\"\n",
|
| 105 |
+
" response = self._make_request(endpoint)\n",
|
| 106 |
+
" if response:\n",
|
| 107 |
+
" return {\n",
|
| 108 |
+
" \"chromosome\": response.get(\"seq_region_name\"),\n",
|
| 109 |
+
" \"start\": response.get(\"start\"),\n",
|
| 110 |
+
" \"end\": response.get(\"end\"),\n",
|
| 111 |
+
" \"strand\": response.get(\"strand\")\n",
|
| 112 |
+
" }\n",
|
| 113 |
+
" return None\n",
|
| 114 |
+
"\n",
|
| 115 |
+
" def get_tss_and_utr(self, gene_id):\n",
|
| 116 |
+
" \"\"\"Retrieve TSS and 5' UTR coordinates for the canonical transcript.\"\"\"\n",
|
| 117 |
+
" endpoint = f\"/lookup/id/{gene_id}?expand=1&utr=1\"\n",
|
| 118 |
+
" response = self._make_request(endpoint)\n",
|
| 119 |
+
" if not response or \"Transcript\" not in response:\n",
|
| 120 |
+
" return None\n",
|
| 121 |
+
"\n",
|
| 122 |
+
" # Find canonical transcript\n",
|
| 123 |
+
" canonical_transcript = None\n",
|
| 124 |
+
" for transcript in response[\"Transcript\"]:\n",
|
| 125 |
+
" if transcript.get(\"is_canonical\", 0) == 1:\n",
|
| 126 |
+
" canonical_transcript = transcript\n",
|
| 127 |
+
" break\n",
|
| 128 |
+
" if not canonical_transcript:\n",
|
| 129 |
+
" for transcript in response[\"Transcript\"]:\n",
|
| 130 |
+
" if transcript.get(\"biotype\") == \"protein_coding\":\n",
|
| 131 |
+
" canonical_transcript = transcript\n",
|
| 132 |
+
" break\n",
|
| 133 |
+
" if not canonical_transcript:\n",
|
| 134 |
+
" canonical_transcript = response[\"Transcript\"][0] if response[\"Transcript\"] else None\n",
|
| 135 |
+
"\n",
|
| 136 |
+
" if not canonical_transcript:\n",
|
| 137 |
+
" return None\n",
|
| 138 |
+
"\n",
|
| 139 |
+
" # Determine TSS and 5' UTR\n",
|
| 140 |
+
" strand = canonical_transcript.get(\"strand\")\n",
|
| 141 |
+
" tss = canonical_transcript[\"start\"] if strand == 1 else canonical_transcript[\"end\"]\n",
|
| 142 |
+
" five_prime_utr = None\n",
|
| 143 |
+
"\n",
|
| 144 |
+
" if \"UTR\" in canonical_transcript:\n",
|
| 145 |
+
" for utr in canonical_transcript[\"UTR\"]:\n",
|
| 146 |
+
" if utr.get(\"object_type\") == \"five_prime_UTR\":\n",
|
| 147 |
+
" five_prime_utr = {\n",
|
| 148 |
+
" \"start\": utr.get(\"start\"),\n",
|
| 149 |
+
" \"end\": utr.get(\"end\")\n",
|
| 150 |
+
" }\n",
|
| 151 |
+
" break\n",
|
| 152 |
+
"\n",
|
| 153 |
+
" # Verify TSS matches 5' UTR start\n",
|
| 154 |
+
" if five_prime_utr:\n",
|
| 155 |
+
" expected_tss = five_prime_utr[\"start\"] if strand == 1 else five_prime_utr[\"end\"]\n",
|
| 156 |
+
" if expected_tss != tss:\n",
|
| 157 |
+
" print(f\"Warning: Adjusting TSS from {tss} to match 5' UTR {'start' if strand == 1 else 'end'} ({expected_tss})\")\n",
|
| 158 |
+
" tss = expected_tss\n",
|
| 159 |
+
"\n",
|
| 160 |
+
" return {\n",
|
| 161 |
+
" \"tss\": tss,\n",
|
| 162 |
+
" \"strand\": strand,\n",
|
| 163 |
+
" \"chromosome\": canonical_transcript.get(\"seq_region_name\"),\n",
|
| 164 |
+
" \"five_prime_utr\": five_prime_utr,\n",
|
| 165 |
+
" \"transcript_id\": canonical_transcript.get(\"id\")\n",
|
| 166 |
+
" }\n",
|
| 167 |
+
"\n",
|
| 168 |
+
" def get_promoter_sequence(self, gene_id, upstream=7000, downstream=4000):\n",
|
| 169 |
+
" \"\"\"Retrieve sequence around TSS (8kb upstream, 4kb downstream).\"\"\"\n",
|
| 170 |
+
" tss_info = self.get_tss_and_utr(gene_id)\n",
|
| 171 |
+
" if not tss_info:\n",
|
| 172 |
+
" return None, None\n",
|
| 173 |
+
"\n",
|
| 174 |
+
" chromosome = tss_info[\"chromosome\"]\n",
|
| 175 |
+
" strand = tss_info[\"strand\"]\n",
|
| 176 |
+
" tss_position = tss_info[\"tss\"]\n",
|
| 177 |
+
"\n",
|
| 178 |
+
" # Calculate region based on strand\n",
|
| 179 |
+
" if strand == 1:\n",
|
| 180 |
+
" seq_start = tss_position - upstream\n",
|
| 181 |
+
" seq_end = tss_position + downstream - 1\n",
|
| 182 |
+
" else:\n",
|
| 183 |
+
" seq_start = tss_position - downstream\n",
|
| 184 |
+
" seq_end = tss_position + upstream - 1\n",
|
| 185 |
+
"\n",
|
| 186 |
+
" seq_start = max(1, seq_start)\n",
|
| 187 |
+
"\n",
|
| 188 |
+
" # Store sequence coordinates\n",
|
| 189 |
+
" sequence_coords = {\n",
|
| 190 |
+
" \"chromosome\": chromosome,\n",
|
| 191 |
+
" \"start\": seq_start,\n",
|
| 192 |
+
" \"end\": seq_end,\n",
|
| 193 |
+
" \"strand\": 1 if strand == 1 else -1\n",
|
| 194 |
+
" }\n",
|
| 195 |
+
"\n",
|
| 196 |
+
" # Validate 5' UTR inclusion\n",
|
| 197 |
+
" if tss_info[\"five_prime_utr\"]:\n",
|
| 198 |
+
" utr_start = tss_info[\"five_prime_utr\"][\"start\"]\n",
|
| 199 |
+
" utr_end = tss_info[\"five_prime_utr\"][\"end\"]\n",
|
| 200 |
+
" if not (seq_start <= utr_start <= seq_end and seq_start <= utr_end <= seq_end):\n",
|
| 201 |
+
" print(f\"Warning: 5' UTR ({utr_start}-{utr_end}) not fully within sequence ({seq_start}-{seq_end})\")\n",
|
| 202 |
+
"\n",
|
| 203 |
+
" # Get sequence\n",
|
| 204 |
+
" strand_str = \"1\" if strand == 1 else \"-1\"\n",
|
| 205 |
+
" endpoint = f\"/sequence/region/human/{chromosome}:{seq_start}..{seq_end}:{strand_str}\"\n",
|
| 206 |
+
" response = self._make_request(endpoint)\n",
|
| 207 |
+
" return response.get(\"seq\") if response else None, sequence_coords\n",
|
| 208 |
+
"\n",
|
| 209 |
+
" def get_gene_info(self, gene_symbol, species=\"homo_sapiens\", output_json=\"gene_info.json\"):\n",
|
| 210 |
+
" \n",
|
| 211 |
+
" if not os.path.exists(os.path.join('./.cache/',f\"{gene_symbol}_info.json\")):\n",
|
| 212 |
+
"\n",
|
| 213 |
+
" \"\"\"Retrieve and save promoter sequence, TSS, 5' UTR, and coordinates.\"\"\"\n",
|
| 214 |
+
" # Get gene ID\n",
|
| 215 |
+
" gene_id = self.get_gene_id(gene_symbol, species)\n",
|
| 216 |
+
" if not gene_id:\n",
|
| 217 |
+
" return {\"error\": f\"Gene {gene_symbol} not found\"}\n",
|
| 218 |
+
"\n",
|
| 219 |
+
" # Get TSS and 5' UTR\n",
|
| 220 |
+
" tss_info = self.get_tss_and_utr(gene_id)\n",
|
| 221 |
+
" if not tss_info:\n",
|
| 222 |
+
" return {\"error\": \"Could not retrieve TSS or transcript information\"}\n",
|
| 223 |
+
"\n",
|
| 224 |
+
" # Get promoter sequence and coordinates\n",
|
| 225 |
+
" promoter_sequence, sequence_coords = self.get_promoter_sequence(gene_id)\n",
|
| 226 |
+
" if not promoter_sequence:\n",
|
| 227 |
+
" return {\"error\": \"Could not retrieve promoter sequence\"}\n",
|
| 228 |
+
"\n",
|
| 229 |
+
" # Compile gene information\n",
|
| 230 |
+
" gene_info = {\n",
|
| 231 |
+
" \"gene_symbol\": gene_symbol,\n",
|
| 232 |
+
" \"gene_id\": gene_id,\n",
|
| 233 |
+
" \"promoter_sequence\": promoter_sequence,\n",
|
| 234 |
+
" \"sequence_length\": len(promoter_sequence),\n",
|
| 235 |
+
" \"sequence_coordinates\": sequence_coords,\n",
|
| 236 |
+
" \"tss\": {\n",
|
| 237 |
+
" \"chromosome\": tss_info[\"chromosome\"],\n",
|
| 238 |
+
" \"position\": tss_info[\"tss\"],\n",
|
| 239 |
+
" \"strand\": \"+\" if tss_info[\"strand\"] == 1 else \"-\"\n",
|
| 240 |
+
" },\n",
|
| 241 |
+
" \"five_prime_utr\": tss_info[\"five_prime_utr\"],\n",
|
| 242 |
+
" \"transcript_id\": tss_info[\"transcript_id\"]\n",
|
| 243 |
+
" }\n",
|
| 244 |
+
"\n",
|
| 245 |
+
" # Save to JSON\n",
|
| 246 |
+
" try:\n",
|
| 247 |
+
" os.makedirs(os.path.dirname('./.cache/'), exist_ok=True)\n",
|
| 248 |
+
" with open(os.path.join('./.cache/',f\"{gene_symbol}_info.json\"), \"w\") as f:\n",
|
| 249 |
+
" json.dump(gene_info, f, indent=2)\n",
|
| 250 |
+
" print(f\"Saved gene information to {output_json}\")\n",
|
| 251 |
+
" except Exception as e:\n",
|
| 252 |
+
" print(f\"Error saving JSON: {e}\")\n",
|
| 253 |
+
"\n",
|
| 254 |
+
" else:\n",
|
| 255 |
+
"\n",
|
| 256 |
+
" with open(os.path.join('./.cache/',f\"{gene_symbol}_info.json\"), \"r\") as f:\n",
|
| 257 |
+
" gene_info = json.load(f)\n",
|
| 258 |
+
"\n",
|
| 259 |
+
" return gene_info\n",
|
| 260 |
+
"\n",
|
| 261 |
+
" def reverse_complement(self, sequence):\n",
|
| 262 |
+
" \"\"\"Compute the reverse complement of a DNA sequence.\"\"\"\n",
|
| 263 |
+
" complement = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C', \n",
|
| 264 |
+
" 'a': 't', 't': 'a', 'c': 'g', 'g': 'c', 'N': 'N', 'n': 'N'}\n",
|
| 265 |
+
" return ''.join(complement.get(base, 'N') for base in reversed(sequence))\n",
|
| 266 |
+
"\n",
|
| 267 |
+
" def replace_utr_in_sequence(self, gene_info_file, generated_utrs, target_length=10500, output_prefix=\"modified_sequence\", write_json=False, verbose=False):\n",
|
| 268 |
+
" \"\"\"\n",
|
| 269 |
+
" Replace original 5' UTR with generated UTRs, ensuring 10,500nt output.\n",
|
| 270 |
+
" \n",
|
| 271 |
+
" Parameters:\n",
|
| 272 |
+
" gene_info_file (str): Path to JSON file with gene information\n",
|
| 273 |
+
" generated_utrs (list): List of generated 5' UTR sequences (64-128nt)\n",
|
| 274 |
+
" target_length (int): Desired output sequence length (default: 10500)\n",
|
| 275 |
+
" output_prefix (str): Prefix for output JSON files\n",
|
| 276 |
+
" \n",
|
| 277 |
+
" Returns:\n",
|
| 278 |
+
" list: List of modified sequences with metadata\n",
|
| 279 |
+
" \"\"\"\n",
|
| 280 |
+
" try:\n",
|
| 281 |
+
" # Read gene information\n",
|
| 282 |
+
" with open(gene_info_file, \"r\") as f:\n",
|
| 283 |
+
" gene_info = json.load(f)\n",
|
| 284 |
+
"\n",
|
| 285 |
+
" original_sequence = gene_info[\"promoter_sequence\"]\n",
|
| 286 |
+
" strand = gene_info[\"tss\"][\"strand\"]\n",
|
| 287 |
+
" tss_position = gene_info[\"tss\"][\"position\"]\n",
|
| 288 |
+
" sequence_coords = gene_info[\"sequence_coordinates\"]\n",
|
| 289 |
+
" seq_start = sequence_coords[\"start\"]\n",
|
| 290 |
+
" seq_end = sequence_coords[\"end\"]\n",
|
| 291 |
+
" five_prime_utr = gene_info[\"five_prime_utr\"]\n",
|
| 292 |
+
" gene_symbol = gene_info[\"gene_symbol\"]\n",
|
| 293 |
+
" transcript_id = gene_info[\"transcript_id\"]\n",
|
| 294 |
+
"\n",
|
| 295 |
+
" if not five_prime_utr:\n",
|
| 296 |
+
" print(f\"Error: No 5' UTR information available for {gene_symbol}\")\n",
|
| 297 |
+
" return []\n",
|
| 298 |
+
"\n",
|
| 299 |
+
" # Calculate original 5' UTR position in sequence\n",
|
| 300 |
+
" if strand == \"+\":\n",
|
| 301 |
+
" utr_start_genomic = five_prime_utr[\"start\"]\n",
|
| 302 |
+
" utr_end_genomic = five_prime_utr[\"end\"]\n",
|
| 303 |
+
" utr_start_seq = utr_start_genomic - seq_start\n",
|
| 304 |
+
" utr_end_seq = utr_end_genomic - seq_start\n",
|
| 305 |
+
" else:\n",
|
| 306 |
+
" utr_start_genomic = five_prime_utr[\"end\"] # TSS\n",
|
| 307 |
+
" utr_end_genomic = five_prime_utr[\"start\"]\n",
|
| 308 |
+
" utr_start_seq = seq_end - utr_start_genomic\n",
|
| 309 |
+
" utr_end_seq = seq_end - utr_end_genomic\n",
|
| 310 |
+
"\n",
|
| 311 |
+
" # Validate UTR positions\n",
|
| 312 |
+
" seq_length = len(original_sequence)\n",
|
| 313 |
+
" if not (0 <= utr_start_seq <= seq_length and 0 <= utr_end_seq <= seq_length):\n",
|
| 314 |
+
" print(f\"Error: 5' UTR coordinates (seq indices {utr_start_seq}-{utr_end_seq}) out of sequence bounds (0-{seq_length}) for {gene_symbol}\")\n",
|
| 315 |
+
" return []\n",
|
| 316 |
+
"\n",
|
| 317 |
+
" original_utr_length = abs(utr_end_genomic - utr_start_genomic) + 1\n",
|
| 318 |
+
" if verbose:\n",
|
| 319 |
+
" print(f\"Original 5' UTR length for {gene_symbol}: {original_utr_length} nt\")\n",
|
| 320 |
+
"\n",
|
| 321 |
+
" modified_sequences = []\n",
|
| 322 |
+
" for i, new_utr in enumerate(generated_utrs):\n",
|
| 323 |
+
" new_utr_length = len(new_utr)\n",
|
| 324 |
+
"\n",
|
| 325 |
+
" # Construct new sequence\n",
|
| 326 |
+
" if strand == \"+\":\n",
|
| 327 |
+
" new_sequence = (\n",
|
| 328 |
+
" original_sequence[:utr_start_seq] +\n",
|
| 329 |
+
" new_utr +\n",
|
| 330 |
+
" original_sequence[utr_end_seq + 1:]\n",
|
| 331 |
+
" )\n",
|
| 332 |
+
" new_utr_start_genomic = utr_start_genomic\n",
|
| 333 |
+
" new_utr_end_genomic = utr_start_genomic + new_utr_length - 1\n",
|
| 334 |
+
" if len(new_sequence) > target_length:\n",
|
| 335 |
+
" new_sequence = new_sequence[:target_length]\n",
|
| 336 |
+
" sequence_coords[\"end\"] = seq_start + target_length - 1\n",
|
| 337 |
+
" elif len(new_sequence) < target_length:\n",
|
| 338 |
+
" if verbose:\n",
|
| 339 |
+
" print(f\"Error: Sequence too short ({len(new_sequence)} nt) after UTR replacement for {gene_symbol}\")\n",
|
| 340 |
+
" continue\n",
|
| 341 |
+
" else:\n",
|
| 342 |
+
" new_utr_rc = reverse_complement(new_utr)\n",
|
| 343 |
+
" new_sequence = (\n",
|
| 344 |
+
" original_sequence[:min(utr_start_seq, utr_end_seq)] +\n",
|
| 345 |
+
" new_utr_rc +\n",
|
| 346 |
+
" original_sequence[max(utr_start_seq, utr_end_seq) + 1:]\n",
|
| 347 |
+
" )\n",
|
| 348 |
+
" new_utr_start_genomic = utr_start_genomic\n",
|
| 349 |
+
" new_utr_end_genomic = utr_start_genomic - new_utr_length + 1\n",
|
| 350 |
+
" if len(new_sequence) > target_length:\n",
|
| 351 |
+
" trim_amount = len(new_sequence) - target_length\n",
|
| 352 |
+
" new_sequence = new_sequence[trim_amount:]\n",
|
| 353 |
+
" sequence_coords[\"start\"] = seq_start + trim_amount\n",
|
| 354 |
+
" elif len(new_sequence) < target_length:\n",
|
| 355 |
+
" if verbose:\n",
|
| 356 |
+
" print(f\"Error: Sequence too short ({len(new_sequence)} nt) after UTR replacement for {gene_symbol}\")\n",
|
| 357 |
+
" continue\n",
|
| 358 |
+
"\n",
|
| 359 |
+
" # Store modified sequence and metadata\n",
|
| 360 |
+
" modified_info = {\n",
|
| 361 |
+
" \"gene_symbol\": gene_symbol,\n",
|
| 362 |
+
" \"transcript_id\": transcript_id,\n",
|
| 363 |
+
" \"modified_sequence\": new_sequence,\n",
|
| 364 |
+
" \"sequence_length\": len(new_sequence),\n",
|
| 365 |
+
" \"sequence_coordinates\": sequence_coords.copy(),\n",
|
| 366 |
+
" \"tss\": gene_info[\"tss\"],\n",
|
| 367 |
+
" \"five_prime_utr\": {\n",
|
| 368 |
+
" \"start\": new_utr_start_genomic,\n",
|
| 369 |
+
" \"end\": new_utr_end_genomic,\n",
|
| 370 |
+
" \"sequence\": new_utr if strand == \"+\" else new_utr_rc\n",
|
| 371 |
+
" },\n",
|
| 372 |
+
" \"original_utr_length\": original_utr_length,\n",
|
| 373 |
+
" \"new_utr_length\": new_utr_length,\n",
|
| 374 |
+
" \"utr_index\": i + 1\n",
|
| 375 |
+
" }\n",
|
| 376 |
+
"\n",
|
| 377 |
+
" # Save to JSON\n",
|
| 378 |
+
" if write_json:\n",
|
| 379 |
+
" output_file = f\"{output_prefix}_{gene_symbol}_utr_{i+1}.json\"\n",
|
| 380 |
+
" try:\n",
|
| 381 |
+
" os.makedirs(os.path.dirname(output_file), exist_ok=True)\n",
|
| 382 |
+
" with open(output_file, \"w\") as f:\n",
|
| 383 |
+
" json.dump(modified_info, f, indent=2)\n",
|
| 384 |
+
" print(f\"Saved modified sequence {i+1} for {gene_symbol} to {output_file}\")\n",
|
| 385 |
+
" except Exception as e:\n",
|
| 386 |
+
" print(f\"Error saving modified sequence {i+1} for {gene_symbol}: {e}\")\n",
|
| 387 |
+
"\n",
|
| 388 |
+
" modified_sequences.append(modified_info[\"modified_sequence\"])\n",
|
| 389 |
+
"\n",
|
| 390 |
+
" return modified_sequences\n",
|
| 391 |
+
"\n",
|
| 392 |
+
" except Exception as e:\n",
|
| 393 |
+
" # print(f\"Error processing UTR replacement for {gene_info.get('gene_symbol', 'unknown')}: {e}\")\n",
|
| 394 |
+
" print(f\"Error processing UTR replacement for gene: {e}\")\n",
|
| 395 |
+
" return []\n",
|
| 396 |
+
"\n",
|
| 397 |
+
"\n",
|
| 398 |
+
" def replace_utr_in_multiple_sequences(self, gene_symbols, generated_utrs, target_length=10500, cache_dir=\"./.cache\", output_prefix=\"modified_sequence\", verbose=False):\n",
|
| 399 |
+
" \"\"\"\n",
|
| 400 |
+
" Replace 5' UTRs for multiple genes with generated UTRs.\n",
|
| 401 |
+
" \n",
|
| 402 |
+
" Parameters:\n",
|
| 403 |
+
" gene_symbols (list): List of gene names\n",
|
| 404 |
+
" generated_utrs (list): List of generated 5' UTR sequences (64-128nt)\n",
|
| 405 |
+
" target_length (int): Desired output sequence length (default: 10500)\n",
|
| 406 |
+
" cache_dir (str): Directory containing cached gene info JSON files\n",
|
| 407 |
+
" output_prefix (str): Prefix for output JSON files\n",
|
| 408 |
+
" \n",
|
| 409 |
+
" Returns:\n",
|
| 410 |
+
" list: List of n_utrs * n_genes modified sequences with metadata\n",
|
| 411 |
+
" \"\"\"\n",
|
| 412 |
+
" all_modified_sequences = []\n",
|
| 413 |
+
" n_utrs = len(generated_utrs)\n",
|
| 414 |
+
" n_genes = len(gene_symbols)\n",
|
| 415 |
+
"\n",
|
| 416 |
+
" for gene_symbol in gene_symbols:\n",
|
| 417 |
+
" json_file = os.path.join(cache_dir, f\"{gene_symbol}_info.json\")\n",
|
| 418 |
+
" if not os.path.exists(json_file):\n",
|
| 419 |
+
" print(f\"Error: Gene info file {json_file} not found\")\n",
|
| 420 |
+
" continue\n",
|
| 421 |
+
" \n",
|
| 422 |
+
" if verbose:\n",
|
| 423 |
+
" print(f\"\\nProcessing gene: {gene_symbol}\")\n",
|
| 424 |
+
" modified_sequences = self.replace_utr_in_sequence(\n",
|
| 425 |
+
" gene_info_file=json_file,\n",
|
| 426 |
+
" generated_utrs=generated_utrs,\n",
|
| 427 |
+
" target_length=target_length,\n",
|
| 428 |
+
" output_prefix=os.path.join(cache_dir, output_prefix)\n",
|
| 429 |
+
" )\n",
|
| 430 |
+
"\n",
|
| 431 |
+
" if modified_sequences:\n",
|
| 432 |
+
" all_modified_sequences.extend(modified_sequences)\n",
|
| 433 |
+
" else:\n",
|
| 434 |
+
" if verbose:\n",
|
| 435 |
+
" print(f\"No modified sequences generated for {gene_symbol}\")\n",
|
| 436 |
+
"\n",
|
| 437 |
+
" expected_count = n_utrs * n_genes\n",
|
| 438 |
+
" actual_count = len(all_modified_sequences)\n",
|
| 439 |
+
" if verbose:\n",
|
| 440 |
+
" print(f\"\\nGenerated {actual_count} modified sequences (expected: {expected_count})\")\n",
|
| 441 |
+
"\n",
|
| 442 |
+
" return all_modified_sequences\n",
|
| 443 |
+
"\n",
|
| 444 |
+
"def convert_model(model_:Model):\n",
|
| 445 |
+
" input_ = tf.keras.layers.Input(shape=( 10500, 4))\n",
|
| 446 |
+
" input = input_\n",
|
| 447 |
+
" for i in range(len(model_.layers)-1):\n",
|
| 448 |
+
"\n",
|
| 449 |
+
" \n",
|
| 450 |
+
" if isinstance(model_.layers[i+1],tf.keras.layers.Concatenate):\n",
|
| 451 |
+
" paddings = tf.constant([[0,0],[0,6]])\n",
|
| 452 |
+
" output = tf.pad(input, paddings, 'CONSTANT')\n",
|
| 453 |
+
" input = output\n",
|
| 454 |
+
" else:\n",
|
| 455 |
+
" if not isinstance(model_.layers[i+1],tf.keras.layers.InputLayer):\n",
|
| 456 |
+
" output = model_.layers[i+1](input)\n",
|
| 457 |
+
" input = output\n",
|
| 458 |
+
"\n",
|
| 459 |
+
" if isinstance(model_.layers[i+1],tf.keras.layers.Conv1D):\n",
|
| 460 |
+
" pass\n",
|
| 461 |
+
"\n",
|
| 462 |
+
" model = tf.keras.Model(inputs=input_, outputs=output)\n",
|
| 463 |
+
" model.compile(loss=\"mse\", optimizer=\"adam\")\n",
|
| 464 |
+
" return model\n",
|
| 465 |
+
"\n",
|
| 466 |
+
"def one_hot(seq):\n",
|
| 467 |
+
" convert = False\n",
|
| 468 |
+
" if isinstance(seq, tf.Tensor):\n",
|
| 469 |
+
" seq = seq.numpy().astype(str)\n",
|
| 470 |
+
" convert = True\n",
|
| 471 |
+
"\n",
|
| 472 |
+
" num_seqs = len(seq)\n",
|
| 473 |
+
" seq_len = len(seq[0])\n",
|
| 474 |
+
" seqindex = {'A':0, 'C':1, 'G':2, 'T':3, 'a':0, 'c':1, 'g':2, 't':3}\n",
|
| 475 |
+
" seq_vec = np.zeros((num_seqs,seq_len,4), dtype='bool')\n",
|
| 476 |
+
" for i in range(num_seqs):\n",
|
| 477 |
+
" thisseq = seq[i]\n",
|
| 478 |
+
" for j in range(seq_len):\n",
|
| 479 |
+
" try:\n",
|
| 480 |
+
" seq_vec[i,j,seqindex[thisseq[j]]] = 1\n",
|
| 481 |
+
" except:\n",
|
| 482 |
+
" pass\n",
|
| 483 |
+
" \n",
|
| 484 |
+
" if convert:\n",
|
| 485 |
+
" seq_vec = tf.convert_to_tensor(seq_vec,dtype=tf.float32)\n",
|
| 486 |
+
"\n",
|
| 487 |
+
"\n",
|
| 488 |
+
" return seq_vec\n",
|
| 489 |
+
"\n",
|
| 490 |
+
"def gen_random_dna(len=10500,size=SEQ_LEN):\n",
|
| 491 |
+
" list_ = ['A','C','G','T']\n",
|
| 492 |
+
" dnas = []\n",
|
| 493 |
+
" for i in range(size):\n",
|
| 494 |
+
" \n",
|
| 495 |
+
" list_ = ['A','C','G','T']\n",
|
| 496 |
+
" mydna = 'AGT'\n",
|
| 497 |
+
" for i in range(len-3):\n",
|
| 498 |
+
" char = list_[random.randint(0,3)]\n",
|
| 499 |
+
" mydna = mydna + char\n",
|
| 500 |
+
" dnas.append(mydna)\n",
|
| 501 |
+
"\n",
|
| 502 |
+
"\n",
|
| 503 |
+
" return dnas\n",
|
| 504 |
+
" \n",
|
| 505 |
+
"def select_dna_single(fname='small_seqs.npy',batch_size=64):\n",
|
| 506 |
+
" refs = np.load(fname)\n",
|
| 507 |
+
" indice = random.sample(range(0,refs.shape[0]),1)\n",
|
| 508 |
+
" refs = refs\n",
|
| 509 |
+
" return indice[0], refs \n",
|
| 510 |
+
"\n",
|
| 511 |
+
"def recover_seq(samples, rev_charmap):\n",
|
| 512 |
+
" \"\"\"Convert samples to strings and save to log directory.\"\"\"\n",
|
| 513 |
+
" if isinstance(samples,tf.Tensor):\n",
|
| 514 |
+
" samples = samples.numpy()\n",
|
| 515 |
+
"\n",
|
| 516 |
+
" char_probs = samples\n",
|
| 517 |
+
" argmax = np.argmax(char_probs, 2)\n",
|
| 518 |
+
" seqs = []\n",
|
| 519 |
+
" for line in argmax:\n",
|
| 520 |
+
" s = \"\".join(rev_charmap[d] for d in line)\n",
|
| 521 |
+
" s = s.replace('*','')\n",
|
| 522 |
+
" seqs.append(s)\n",
|
| 523 |
+
"\n",
|
| 524 |
+
" seqs = np.array(seqs)\n",
|
| 525 |
+
" return seqs\n",
|
| 526 |
+
"\n",
|
| 527 |
+
"\n",
|
| 528 |
+
"rna_vocab = {\"A\":0,\n",
|
| 529 |
+
" \"C\":1,\n",
|
| 530 |
+
" \"G\":2,\n",
|
| 531 |
+
" \"U\":3,\n",
|
| 532 |
+
" \"*\":4}\n",
|
| 533 |
+
"\n",
|
| 534 |
+
"rev_rna_vocab = {v:k for k,v in rna_vocab.items()}\n",
|
| 535 |
+
"\n",
|
| 536 |
+
"def select_best(scores, seqs, gc_control=False, GC=-1):\n",
|
| 537 |
+
" t = np.max(scores,axis=1)\n",
|
| 538 |
+
" # print(scores)\n",
|
| 539 |
+
" maxinds = np.argmax(scores,axis=0)\n",
|
| 540 |
+
" selected_scores = []\n",
|
| 541 |
+
" selected_seqs = []\n",
|
| 542 |
+
" for i in range(len(maxinds)):\n",
|
| 543 |
+
" selected_seqs.append(seqs[maxinds[i]][i])\n",
|
| 544 |
+
" selected_scores.append(scores[maxinds[i]][i])\n",
|
| 545 |
+
"\n",
|
| 546 |
+
"\n",
|
| 547 |
+
" return selected_seqs, selected_scores"
|
| 548 |
+
]
|
| 549 |
+
},
|
| 550 |
+
{
|
| 551 |
+
"cell_type": "code",
|
| 552 |
+
"execution_count": 2,
|
| 553 |
+
"id": "1b365284",
|
| 554 |
+
"metadata": {},
|
| 555 |
+
"outputs": [
|
| 556 |
+
{
|
| 557 |
+
"name": "stdout",
|
| 558 |
+
"output_type": "stream",
|
| 559 |
+
"text": [
|
| 560 |
+
"WARNING:tensorflow:Error in loading the saved optimizer state. As a result, your model is starting with a freshly initialized optimizer.\n",
|
| 561 |
+
"WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n"
|
| 562 |
+
]
|
| 563 |
+
}
|
| 564 |
+
],
|
| 565 |
+
"source": [
|
| 566 |
+
"\n",
|
| 567 |
+
"\n",
|
| 568 |
+
"\n",
|
| 569 |
+
"\n",
|
| 570 |
+
"DIM = 40\n",
|
| 571 |
+
"SEQ_LEN = 128\n",
|
| 572 |
+
"gpath = './models/checkpoint_3000.h5'\n",
|
| 573 |
+
"exp_path = './models/humanMedian_trainepoch.11-0.426.h5'\n",
|
| 574 |
+
"tpath = './src/exp_optimization/script/checkpoint/RL_hard_share_MTL/3R/schedule_MTL-model_best_cv1.pth'\n",
|
| 575 |
+
"\n",
|
| 576 |
+
"CELL_LINE = ''\n",
|
| 577 |
+
"# CELL_LINE = 'K562_'\n",
|
| 578 |
+
"# CELL_LINE = 'GM12878_'\n",
|
| 579 |
+
"\n",
|
| 580 |
+
"# Set seeds\n",
|
| 581 |
+
"# seed = 65\n",
|
| 582 |
+
"# np.random.seed(seed)\n",
|
| 583 |
+
"# tf.random.set_seed(seed)\n",
|
| 584 |
+
"# torch.manual_seed(seed)\n",
|
| 585 |
+
"# torch.cuda.manual_seed(seed) # If using CUDA\n",
|
| 586 |
+
"# random.seed(seed)\n",
|
| 587 |
+
"\n",
|
| 588 |
+
"# # Ensure deterministic behavior in PyTorch\n",
|
| 589 |
+
"# torch.backends.cudnn.deterministic = True\n",
|
| 590 |
+
"# torch.backends.cudnn.benchmark = False\n",
|
| 591 |
+
"\n",
|
| 592 |
+
"model = load_model(exp_path)\n",
|
| 593 |
+
"\n",
|
| 594 |
+
"model = convert_model(model)\n",
|
| 595 |
+
"\n",
|
| 596 |
+
"gene_name = GENE\n",
|
| 597 |
+
"\n",
|
| 598 |
+
"retriever = GeneInfoRetriever()\n",
|
| 599 |
+
" \n",
|
| 600 |
+
"ref = ''\n",
|
| 601 |
+
"\n",
|
| 602 |
+
"output_json = f\"{gene_name}_info.json\"\n",
|
| 603 |
+
"\n",
|
| 604 |
+
"if not os.path.exists(os.path.join('./.cache/',output_json)):\n",
|
| 605 |
+
"\n",
|
| 606 |
+
" # Retrieve gene information\n",
|
| 607 |
+
" gene_info = retriever.get_gene_info(gene_name, output_json=output_json)\n",
|
| 608 |
+
"\n",
|
| 609 |
+
" if \"error\" in gene_info:\n",
|
| 610 |
+
" print(f\"Error: {gene_info['error']}\")\n",
|
| 611 |
+
" else:\n",
|
| 612 |
+
" ref = gene_info[\"promoter_sequence\"] \n",
|
| 613 |
+
"else:\n",
|
| 614 |
+
" with open(os.path.join('./.cache/',output_json), \"r\") as f:\n",
|
| 615 |
+
" gene_info = json.load(f)\n",
|
| 616 |
+
" ref = gene_info[\"promoter_sequence\"]\n",
|
| 617 |
+
"\n",
|
| 618 |
+
"original_gene_sequence = ref\n",
|
| 619 |
+
"\n",
|
| 620 |
+
"wgan = tf.keras.models.load_model(gpath)\n",
|
| 621 |
+
"\n",
|
| 622 |
+
"\"\"\"\n",
|
| 623 |
+
"Data:\n",
|
| 624 |
+
"\"\"\"\n",
|
| 625 |
+
"\n",
|
| 626 |
+
"noise = tf.Variable(tf.random.normal(shape=[BATCH_SIZE,DIM]))\n",
|
| 627 |
+
"\n",
|
| 628 |
+
"\n",
|
| 629 |
+
"diffs = []\n",
|
| 630 |
+
"init_exps = []\n",
|
| 631 |
+
"\n",
|
| 632 |
+
"opt_exps = []\n",
|
| 633 |
+
"\n",
|
| 634 |
+
"orig_vals = []\n",
|
| 635 |
+
"\n",
|
| 636 |
+
"\n",
|
| 637 |
+
"noise = tf.Variable(tf.random.normal(shape=[BATCH_SIZE,DIM]))\n",
|
| 638 |
+
"# noise = tf.random.normal(shape=[BATCH_SIZE,40])\n",
|
| 639 |
+
"noise_small = tf.random.normal(shape=[BATCH_SIZE,DIM],stddev=1e-5)\n",
|
| 640 |
+
"\n",
|
| 641 |
+
"optimizer = tf.keras.optimizers.Adam(learning_rate=0.1)\n",
|
| 642 |
+
"\n",
|
| 643 |
+
"'''\n",
|
| 644 |
+
"Original Gene Expression\n",
|
| 645 |
+
"'''\n",
|
| 646 |
+
"\n",
|
| 647 |
+
"seqs_orig = one_hot([original_gene_sequence[:10500]])\n",
|
| 648 |
+
"pred_orig = model(seqs_orig) \n",
|
| 649 |
+
"pred_orig = tf.reshape(pred_orig,(-1)).numpy().astype('float')[0]\n",
|
| 650 |
+
"\n",
|
| 651 |
+
"'''\n",
|
| 652 |
+
"Optimization takes place here.\n",
|
| 653 |
+
"'''\n",
|
| 654 |
+
"\n",
|
| 655 |
+
"\n",
|
| 656 |
+
"\n",
|
| 657 |
+
"bind_scores_list = []\n",
|
| 658 |
+
"bind_scores_means = []\n",
|
| 659 |
+
"sequences_list = []\n",
|
| 660 |
+
"\n",
|
| 661 |
+
"\"\"\" LOW Start Mode \"\"\"\n",
|
| 662 |
+
"\n",
|
| 663 |
+
"best = 100\n",
|
| 664 |
+
"\n",
|
| 665 |
+
"LOW_START = False\n",
|
| 666 |
+
"\n",
|
| 667 |
+
"if LOW_START:\n",
|
| 668 |
+
"\n",
|
| 669 |
+
" for i in tqdm(range(1000)):\n",
|
| 670 |
+
" tempnoise = tf.random.normal(shape=[BATCH_SIZE,DIM])\n",
|
| 671 |
+
" sequences = wgan(tempnoise)\n",
|
| 672 |
+
"\n",
|
| 673 |
+
" seqs_gen = recover_seq(sequences, rev_rna_vocab)\n",
|
| 674 |
+
"\n",
|
| 675 |
+
" seqs = retriever.replace_utr_in_sequence(f\"./.cache/{gene_name}_info.json\", seqs_gen)\n",
|
| 676 |
+
"\n",
|
| 677 |
+
" seqs = one_hot(seqs)\n",
|
| 678 |
+
" \n",
|
| 679 |
+
" pred = model(seqs)\n",
|
| 680 |
+
"\n",
|
| 681 |
+
" score = np.mean(tf.reshape(pred,(-1)).numpy().astype('float'))\n",
|
| 682 |
+
"\n",
|
| 683 |
+
" if score < best:\n",
|
| 684 |
+
" best = score\n",
|
| 685 |
+
" selectednoise = tempnoise\n",
|
| 686 |
+
" noise = tf.Variable(selectednoise)\n",
|
| 687 |
+
"else:\n",
|
| 688 |
+
" noise = tf.Variable(tf.random.normal(shape=[BATCH_SIZE,DIM]))\n",
|
| 689 |
+
"\n",
|
| 690 |
+
"\n",
|
| 691 |
+
"#######################\n",
|
| 692 |
+
"\n",
|
| 693 |
+
"iters_ = []\n",
|
| 694 |
+
"\n",
|
| 695 |
+
"OPTIMIZE = True\n",
|
| 696 |
+
"\n",
|
| 697 |
+
"DNA_SEL = False\n",
|
| 698 |
+
"\n",
|
| 699 |
+
"sequences_init = wgan(noise)\n",
|
| 700 |
+
"\n",
|
| 701 |
+
"gen_seqs_init = sequences_init.numpy().astype('float')\n",
|
| 702 |
+
"\n",
|
| 703 |
+
"seqs_gen_init = recover_seq(gen_seqs_init, rev_rna_vocab)\n",
|
| 704 |
+
"\n",
|
| 705 |
+
"seqs_init = retriever.replace_utr_in_sequence(f\"./.cache/{gene_name}_info.json\", seqs_gen_init)\n",
|
| 706 |
+
"\n",
|
| 707 |
+
"seqs_init = one_hot(seqs_init)\n",
|
| 708 |
+
"\n",
|
| 709 |
+
"pred_init = model(seqs_init) \n",
|
| 710 |
+
"\n",
|
| 711 |
+
"init_t = tf.reshape(pred_init,(-1)).numpy().astype('float')\n",
|
| 712 |
+
"\n",
|
| 713 |
+
"STEPS = STEPS\n",
|
| 714 |
+
"\n",
|
| 715 |
+
"seqs_collection = []\n",
|
| 716 |
+
"scores_collection = []\n",
|
| 717 |
+
"\n",
|
| 718 |
+
"GC_CONTROL = False\n",
|
| 719 |
+
"\n",
|
| 720 |
+
"if GC_LIMIT > 0.:\n",
|
| 721 |
+
" GC_CONTROL = True"
|
| 722 |
+
]
|
| 723 |
+
},
|
| 724 |
+
{
|
| 725 |
+
"cell_type": "code",
|
| 726 |
+
"execution_count": 5,
|
| 727 |
+
"id": "9dcefb89",
|
| 728 |
+
"metadata": {},
|
| 729 |
+
"outputs": [
|
| 730 |
+
{
|
| 731 |
+
"name": "stderr",
|
| 732 |
+
"output_type": "stream",
|
| 733 |
+
"text": [
|
| 734 |
+
" 0%| | 0/2 [00:00<?, ?it/s]\n"
|
| 735 |
+
]
|
| 736 |
+
},
|
| 737 |
+
{
|
| 738 |
+
"ename": "KeyboardInterrupt",
|
| 739 |
+
"evalue": "",
|
| 740 |
+
"output_type": "error",
|
| 741 |
+
"traceback": [
|
| 742 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
| 743 |
+
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
| 744 |
+
"Cell \u001b[0;32mIn[5], line 17\u001b[0m\n\u001b[1;32m 13\u001b[0m seqs_collection\u001b[38;5;241m.\u001b[39mappend(seqs_gen)\n\u001b[1;32m 15\u001b[0m seqs2 \u001b[38;5;241m=\u001b[39m retriever\u001b[38;5;241m.\u001b[39mreplace_utr_in_sequence(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m./.cache/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mgene_name\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m_info.json\u001b[39m\u001b[38;5;124m\"\u001b[39m, seqs_gen)\n\u001b[0;32m---> 17\u001b[0m seqs \u001b[38;5;241m=\u001b[39m \u001b[43mone_hot\u001b[49m\u001b[43m(\u001b[49m\u001b[43mseqs2\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 18\u001b[0m seqs \u001b[38;5;241m=\u001b[39m tf\u001b[38;5;241m.\u001b[39mconvert_to_tensor(seqs,dtype\u001b[38;5;241m=\u001b[39mtf\u001b[38;5;241m.\u001b[39mfloat32)\n\u001b[1;32m 21\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m tf\u001b[38;5;241m.\u001b[39mGradientTape() \u001b[38;5;28;01mas\u001b[39;00m ptape:\n",
|
| 745 |
+
"Cell \u001b[0;32mIn[1], line 463\u001b[0m, in \u001b[0;36mone_hot\u001b[0;34m(seq)\u001b[0m\n\u001b[1;32m 461\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m j \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mrange\u001b[39m(seq_len):\n\u001b[1;32m 462\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m--> 463\u001b[0m seq_vec[i,j,seqindex[thisseq[j]]] \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n\u001b[1;32m 464\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m:\n\u001b[1;32m 465\u001b[0m \u001b[38;5;28;01mpass\u001b[39;00m\n",
|
| 746 |
+
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
|
| 747 |
+
]
|
| 748 |
+
}
|
| 749 |
+
],
|
| 750 |
+
"source": [
|
| 751 |
+
"\n",
|
| 752 |
+
"\n",
|
| 753 |
+
"if OPTIMIZE:\n",
|
| 754 |
+
" \n",
|
| 755 |
+
" iter_ = 0\n",
|
| 756 |
+
" for opt_iter in tqdm(range(STEPS)):\n",
|
| 757 |
+
" \n",
|
| 758 |
+
" with tf.GradientTape() as gtape:\n",
|
| 759 |
+
"\n",
|
| 760 |
+
" gtape.watch(noise)\n",
|
| 761 |
+
" \n",
|
| 762 |
+
" sequences = wgan(noise)\n",
|
| 763 |
+
"\n",
|
| 764 |
+
" seqs_gen = recover_seq(sequences, rev_rna_vocab)\n",
|
| 765 |
+
" seqs_collection.append(seqs_gen)\n",
|
| 766 |
+
"\n",
|
| 767 |
+
" seqs2 = retriever.replace_utr_in_sequence(f\"./.cache/{gene_name}_info.json\", seqs_gen)\n",
|
| 768 |
+
" \n",
|
| 769 |
+
" seqs = one_hot(seqs2)\n",
|
| 770 |
+
" seqs = tf.convert_to_tensor(seqs,dtype=tf.float32)\n",
|
| 771 |
+
"\n",
|
| 772 |
+
"\n",
|
| 773 |
+
" with tf.GradientTape() as ptape:\n",
|
| 774 |
+
"\n",
|
| 775 |
+
" ptape.watch(seqs)\n",
|
| 776 |
+
"\n",
|
| 777 |
+
" pred = model(seqs)\n",
|
| 778 |
+
" t = tf.reshape(pred,(-1))\n",
|
| 779 |
+
" scores_collection.append(t.numpy().astype('float'))\n",
|
| 780 |
+
"\n",
|
| 781 |
+
" pred = tf.math.scalar_mul(-1.0, pred)\n",
|
| 782 |
+
"\n",
|
| 783 |
+
" g1 = ptape.gradient(pred,seqs)\n",
|
| 784 |
+
"\n",
|
| 785 |
+
" g1 = tf.slice(g1,[0,7000,0],[-1,SEQ_LEN,-1])\n",
|
| 786 |
+
"\n",
|
| 787 |
+
"\n",
|
| 788 |
+
" tmp_g = g1.numpy().astype('float')\n",
|
| 789 |
+
" tmp_seqs = seqs_gen\n",
|
| 790 |
+
"\n",
|
| 791 |
+
" tmp_lst = np.zeros(shape=(BATCH_SIZE,SEQ_LEN,5))\n",
|
| 792 |
+
" for i in range(len(tmp_seqs)):\n",
|
| 793 |
+
" len_ = len(tmp_seqs[i])\n",
|
| 794 |
+
" \n",
|
| 795 |
+
" edited_g = tmp_g[i][:len_,:]\n",
|
| 796 |
+
"\n",
|
| 797 |
+
" edited_g = np.pad(edited_g,((0,SEQ_LEN-len_),(0,1)),'constant') \n",
|
| 798 |
+
" \n",
|
| 799 |
+
" tmp_lst[i] = edited_g\n",
|
| 800 |
+
" \n",
|
| 801 |
+
" g1 = tf.convert_to_tensor(tmp_lst,dtype=tf.float32)\n",
|
| 802 |
+
"\n",
|
| 803 |
+
" g2 = gtape.gradient(sequences,noise,output_gradients=g1)\n",
|
| 804 |
+
"\n",
|
| 805 |
+
" a1 = g2 + noise_small\n",
|
| 806 |
+
" change = [(a1,noise)]\n",
|
| 807 |
+
" \n",
|
| 808 |
+
" optimizer.apply_gradients(change)\n",
|
| 809 |
+
"\n",
|
| 810 |
+
" iters_.append(iter_)\n",
|
| 811 |
+
" iter_ += 1\n",
|
| 812 |
+
"\n",
|
| 813 |
+
" sequences_opt = wgan(noise)\n",
|
| 814 |
+
"\n",
|
| 815 |
+
" gen_seqs_opt = sequences_opt.numpy().astype('float')\n",
|
| 816 |
+
"\n",
|
| 817 |
+
" seqs_gen_opt = recover_seq(gen_seqs_opt, rev_rna_vocab)\n",
|
| 818 |
+
"\n",
|
| 819 |
+
" seqs_opt= retriever.replace_utr_in_sequence(f\"./.cache/{gene_name}_info.json\", seqs_gen_opt, target_length=10500, output_prefix=\"modified_sequence\")\n",
|
| 820 |
+
"\n",
|
| 821 |
+
" seqs_opt = one_hot(seqs_opt)\n",
|
| 822 |
+
"\n",
|
| 823 |
+
" pred_opt = model(seqs_opt)\n",
|
| 824 |
+
"\n",
|
| 825 |
+
" t = tf.reshape(pred_opt,(-1))\n",
|
| 826 |
+
" opt_t = t.numpy().astype('float')\n",
|
| 827 |
+
"\n",
|
| 828 |
+
"\n",
|
| 829 |
+
" if GC_CONTROL:\n",
|
| 830 |
+
" best_seqs, best_scores = select_best(scores_collection, seqs_collection, True, GC_LIMIT)\n",
|
| 831 |
+
" else:\n",
|
| 832 |
+
" best_seqs, best_scores = select_best(scores_collection, seqs_collection)\n",
|
| 833 |
+
"\n",
|
| 834 |
+
"\n",
|
| 835 |
+
" if GC_CONTROL:\n",
|
| 836 |
+
"\n",
|
| 837 |
+
" with open(f'./outputs/{CELL_LINE}gc_init_exps_'+gene_name+'.txt', 'w') as f:\n",
|
| 838 |
+
" for item in init_t:\n",
|
| 839 |
+
" f.write(f'{item}\\n')\n",
|
| 840 |
+
"\n",
|
| 841 |
+
" with open(f'./outputs/{CELL_LINE}gc_opt_exps_'+gene_name+'.txt', 'w') as f:\n",
|
| 842 |
+
" for item in best_scores:\n",
|
| 843 |
+
" f.write(f'{item}\\n')\n",
|
| 844 |
+
"\n",
|
| 845 |
+
" with open(f'./outputs/{CELL_LINE}gc_best_seqs_'+gene_name+'.txt', 'w') as f:\n",
|
| 846 |
+
" for item in best_seqs:\n",
|
| 847 |
+
" f.write(f'{item}\\n')\n",
|
| 848 |
+
"\n",
|
| 849 |
+
" with open(f'./outputs/{CELL_LINE}gc_init_seqs_'+gene_name+'.txt', 'w') as f:\n",
|
| 850 |
+
" for item in seqs_gen_init:\n",
|
| 851 |
+
" f.write(f'{item}\\n')\n",
|
| 852 |
+
"\n",
|
| 853 |
+
" else:\n",
|
| 854 |
+
" with open(f'./outputs/{CELL_LINE}init_exps_{gene_name}.txt', 'w') as f:\n",
|
| 855 |
+
" for item in init_t:\n",
|
| 856 |
+
" f.write(f'{item}\\n')\n",
|
| 857 |
+
"\n",
|
| 858 |
+
" with open(f'./outputs/{CELL_LINE}opt_exps_{gene_name}.txt', 'w') as f:\n",
|
| 859 |
+
" for item in best_scores:\n",
|
| 860 |
+
" f.write(f'{item}\\n')\n",
|
| 861 |
+
"\n",
|
| 862 |
+
" with open(f'./outputs/{CELL_LINE}best_seqs_{gene_name}.txt', 'w') as f:\n",
|
| 863 |
+
" for item in best_seqs:\n",
|
| 864 |
+
" f.write(f'{item}\\n')\n",
|
| 865 |
+
"\n",
|
| 866 |
+
" with open(f'./outputs/{CELL_LINE}init_seqs_{gene_name}.txt', 'w') as f:\n",
|
| 867 |
+
" for item in seqs_gen_init:\n",
|
| 868 |
+
" f.write(f'{item}\\n')\n",
|
| 869 |
+
"\n",
|
| 870 |
+
"\n",
|
| 871 |
+
" print(f\"Results for {gene_name} saved to ./outputs/\")\n",
|
| 872 |
+
" print(f\"Natural 5' UTR Expression: {np.power(10,pred_orig):.4f}\")\n",
|
| 873 |
+
" print(f\"Average Initial Expression: {np.power(10,np.average(init_t)):.4f}\")\n",
|
| 874 |
+
" print(f\"Max Initial Expression: {np.power(10,np.max(init_t)):.4f}\")\n",
|
| 875 |
+
" print(f\"Max Best Expression: {np.power(10,np.max(best_scores)):.4f}\")\n",
|
| 876 |
+
" print(f\"Average Improvement: {np.average((np.power(10,best_scores) - np.power(10,init_t))/np.power(10,init_t))*100:.2f}%\")\n",
|
| 877 |
+
" print(f\"Max Improvement: {np.max((np.power(10,best_scores) - np.power(10,init_t))/np.power(10,init_t))*100:.2f}%\")\n",
|
| 878 |
+
" print(f\"Average Improvement (wrt to Natural 5'UTR): {np.average((np.power(10,best_scores) - math.pow(10,pred_orig))/math.pow(10,pred_orig))*100:.2f}%\")\n",
|
| 879 |
+
" print(f\"Max Improvement (wrt to Natural 5'UTR): {np.max((np.power(10,best_scores) - math.pow(10,pred_orig))/math.pow(10,pred_orig))*100:.2f}%\")\n",
|
| 880 |
+
"\n",
|
| 881 |
+
"\n"
|
| 882 |
+
]
|
| 883 |
+
}
|
| 884 |
+
],
|
| 885 |
+
"metadata": {
|
| 886 |
+
"kernelspec": {
|
| 887 |
+
"display_name": "utrgan",
|
| 888 |
+
"language": "python",
|
| 889 |
+
"name": "python3"
|
| 890 |
+
},
|
| 891 |
+
"language_info": {
|
| 892 |
+
"codemirror_mode": {
|
| 893 |
+
"name": "ipython",
|
| 894 |
+
"version": 3
|
| 895 |
+
},
|
| 896 |
+
"file_extension": ".py",
|
| 897 |
+
"mimetype": "text/x-python",
|
| 898 |
+
"name": "python",
|
| 899 |
+
"nbconvert_exporter": "python",
|
| 900 |
+
"pygments_lexer": "ipython3",
|
| 901 |
+
"version": "3.10.8"
|
| 902 |
+
}
|
| 903 |
+
},
|
| 904 |
+
"nbformat": 4,
|
| 905 |
+
"nbformat_minor": 5
|
| 906 |
+
}
|
conf/notebooks/optimize_te_mrl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+
"\n",
|
| 10 |
+
"from tqdm import tqdm\n",
|
| 11 |
+
"import random\n",
|
| 12 |
+
"random.seed(1337)\n",
|
| 13 |
+
"import matplotlib.pyplot as plt\n",
|
| 14 |
+
"import argparse\n",
|
| 15 |
+
"import numpy as np\n",
|
| 16 |
+
"np.random.seed(1337)\n",
|
| 17 |
+
"import pandas as pd\n",
|
| 18 |
+
"import os\n",
|
| 19 |
+
"import torch\n",
|
| 20 |
+
"import sys\n",
|
| 21 |
+
"\n",
|
| 22 |
+
"from src.mrl_te_optimization.framepool import *\n",
|
| 23 |
+
"from src.mrl_te_optimization.util import *\n",
|
| 24 |
+
"import keras\n",
|
| 25 |
+
"\n",
|
| 26 |
+
"import random\n",
|
| 27 |
+
"random.seed(1337)\n",
|
| 28 |
+
"\n",
|
| 29 |
+
"\n",
|
| 30 |
+
"import scipy.stats as stats\n",
|
| 31 |
+
"\n",
|
| 32 |
+
"import tensorflow as tf\n",
|
| 33 |
+
"from tensorflow.keras import backend as K\n",
|
| 34 |
+
"from tensorflow.keras.models import load_model\n",
|
| 35 |
+
"\n",
|
| 36 |
+
"tf.compat.v1.enable_eager_execution()\n",
|
| 37 |
+
"\n",
|
| 38 |
+
"import pandas as pd\n",
|
| 39 |
+
"import numpy as np\n",
|
| 40 |
+
"import requests, sys\n",
|
| 41 |
+
"\n",
|
| 42 |
+
"DATA = './data/utrdb2.csv'\n",
|
| 43 |
+
"motifs_path = './data/motifs.csv'\n",
|
| 44 |
+
"BATCH_SIZE = 64\n",
|
| 45 |
+
"TASK = \"mrl\"\n",
|
| 46 |
+
"GPU = '-1'\n",
|
| 47 |
+
"STEPS = 10\n",
|
| 48 |
+
"\n",
|
| 49 |
+
"if GPU == '-1':\n",
|
| 50 |
+
" device = 'cpu'\n",
|
| 51 |
+
"else:\n",
|
| 52 |
+
" os.environ['CUDA_VISIBLE_DEVICES'] = GPU\n",
|
| 53 |
+
" device = 'cuda'\n",
|
| 54 |
+
" if ',' in GPU:\n",
|
| 55 |
+
" device = 'cuda:1'\n",
|
| 56 |
+
"\n",
|
| 57 |
+
"def prepare_mttrans(seqs):\n",
|
| 58 |
+
" seqs_init = torch.tensor(np.array(one_hot_all_motif(seqs),dtype=np.float32))\n",
|
| 59 |
+
"\n",
|
| 60 |
+
" seqs_init = torch.transpose(seqs_init, 1, 2)\n",
|
| 61 |
+
" seqs_init = torch.tensor(seqs_init,dtype=torch.float32).to(device)\n",
|
| 62 |
+
" return seqs_init\n",
|
| 63 |
+
"\n",
|
| 64 |
+
"def prepare_framepool(seqs):\n",
|
| 65 |
+
" return tf.convert_to_tensor(np.array([encode_seq_framepool(seq) for seq in seqs]),dtype=tf.float32)\n",
|
| 66 |
+
"\n",
|
| 67 |
+
"\n",
|
| 68 |
+
"\n",
|
| 69 |
+
"DIM = 40\n",
|
| 70 |
+
"SEQ_LEN = 128\n",
|
| 71 |
+
"UTR_LEN = 128\n",
|
| 72 |
+
"gpath = './models/checkpoint_3000.h5'\n",
|
| 73 |
+
"\n",
|
| 74 |
+
"\n",
|
| 75 |
+
"if TASK == 'te':\n",
|
| 76 |
+
" path = './src/mrl_te_optimization/script/checkpoint/RL_hard_share_MTL/3R/schedule_MTL-model_best_cv1.pth'\n",
|
| 77 |
+
" OPT = 'TE'\n",
|
| 78 |
+
"else:\n",
|
| 79 |
+
" path = './models/utr_model_combined_residual_new.h5'\n",
|
| 80 |
+
" OPT = 'FMRL'\n",
|
| 81 |
+
"\n",
|
| 82 |
+
"\n",
|
| 83 |
+
"out_folder = './outputs/'\n",
|
| 84 |
+
"os.makedirs(out_folder, exist_ok=True)"
|
| 85 |
+
]
|
| 86 |
+
},
|
| 87 |
+
{
|
| 88 |
+
"cell_type": "code",
|
| 89 |
+
"execution_count": 6,
|
| 90 |
+
"metadata": {},
|
| 91 |
+
"outputs": [
|
| 92 |
+
{
|
| 93 |
+
"name": "stdout",
|
| 94 |
+
"output_type": "stream",
|
| 95 |
+
"text": [
|
| 96 |
+
"GPU is not available. Using CPU instead.\n"
|
| 97 |
+
]
|
| 98 |
+
}
|
| 99 |
+
],
|
| 100 |
+
"source": [
|
| 101 |
+
"# Check for GPU availability\n",
|
| 102 |
+
"gpus = tf.config.list_physical_devices('GPU')\n",
|
| 103 |
+
"\n",
|
| 104 |
+
"if gpus:\n",
|
| 105 |
+
" print(f\"GPU is available. Using GPU:{GPU} for computation.\")\n",
|
| 106 |
+
" print(\"List of GPUs:\", gpus)\n",
|
| 107 |
+
"else:\n",
|
| 108 |
+
" print(\"GPU is not available. Using CPU instead.\")"
|
| 109 |
+
]
|
| 110 |
+
},
|
| 111 |
+
{
|
| 112 |
+
"cell_type": "code",
|
| 113 |
+
"execution_count": null,
|
| 114 |
+
"metadata": {},
|
| 115 |
+
"outputs": [
|
| 116 |
+
{
|
| 117 |
+
"name": "stdout",
|
| 118 |
+
"output_type": "stream",
|
| 119 |
+
"text": [
|
| 120 |
+
"WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.\n"
|
| 121 |
+
]
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"ename": "NameError",
|
| 125 |
+
"evalue": "name 'LR' is not defined",
|
| 126 |
+
"output_type": "error",
|
| 127 |
+
"traceback": [
|
| 128 |
+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
| 129 |
+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
|
| 130 |
+
"Cell \u001b[0;32mIn[7], line 49\u001b[0m\n\u001b[1;32m 47\u001b[0m DIM \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m40\u001b[39m\n\u001b[1;32m 48\u001b[0m MAX_LEN \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m128\u001b[39m\n\u001b[0;32m---> 49\u001b[0m LR \u001b[38;5;241m=\u001b[39m np\u001b[38;5;241m.\u001b[39mexp(\u001b[38;5;241m-\u001b[39m\u001b[43mLR\u001b[49m)\n\u001b[1;32m 51\u001b[0m tempnoise \u001b[38;5;241m=\u001b[39m tf\u001b[38;5;241m.\u001b[39mrandom\u001b[38;5;241m.\u001b[39mnormal(shape\u001b[38;5;241m=\u001b[39m[BATCH_SIZE,DIM])\n\u001b[1;32m 52\u001b[0m selectednoise \u001b[38;5;241m=\u001b[39m tempnoise\n",
|
| 131 |
+
"\u001b[0;31mNameError\u001b[0m: name 'LR' is not defined"
|
| 132 |
+
]
|
| 133 |
+
}
|
| 134 |
+
],
|
| 135 |
+
"source": [
|
| 136 |
+
"\n",
|
| 137 |
+
"\n",
|
| 138 |
+
"def select_best(scores, seqs):\n",
|
| 139 |
+
" selected_scores = []\n",
|
| 140 |
+
" selected_seqs = []\n",
|
| 141 |
+
" for i in range(len(scores[0])):\n",
|
| 142 |
+
" best = scores[0][i]\n",
|
| 143 |
+
" best_seq = seqs[0][i]\n",
|
| 144 |
+
" for j in range(len(scores)-1):\n",
|
| 145 |
+
" if scores[j+1][i] > best:\n",
|
| 146 |
+
" best = scores[j+1][i]\n",
|
| 147 |
+
" best_seq = seqs[j+1][i]\n",
|
| 148 |
+
" selected_scores.append(best)\n",
|
| 149 |
+
" selected_seqs.append(best_seq)\n",
|
| 150 |
+
"\n",
|
| 151 |
+
" return selected_seqs, selected_scores\n",
|
| 152 |
+
"\n",
|
| 153 |
+
"if __name__ == '__main__':\n",
|
| 154 |
+
" \n",
|
| 155 |
+
" if OPT == 'FMRL':\n",
|
| 156 |
+
" Optimize_FrameSlice = True\n",
|
| 157 |
+
" else:\n",
|
| 158 |
+
" Optimize_FrameSlice = False\n",
|
| 159 |
+
"\n",
|
| 160 |
+
"\n",
|
| 161 |
+
"\n",
|
| 162 |
+
" if Optimize_FrameSlice:\n",
|
| 163 |
+
" model = load_framepool(path)\n",
|
| 164 |
+
"\n",
|
| 165 |
+
" else:\n",
|
| 166 |
+
"\n",
|
| 167 |
+
" model = torch.load(path,map_location=torch.device(device))['state_dict'] \n",
|
| 168 |
+
" model.train() \n",
|
| 169 |
+
" \n",
|
| 170 |
+
"\n",
|
| 171 |
+
" wgan = tf.keras.models.load_model(gpath)\n",
|
| 172 |
+
"\n",
|
| 173 |
+
" \"\"\"\n",
|
| 174 |
+
" Data:\n",
|
| 175 |
+
" \"\"\"\n",
|
| 176 |
+
"\n",
|
| 177 |
+
" tf.random.set_seed(33)\n",
|
| 178 |
+
" np.random.seed(33)\n",
|
| 179 |
+
"\n",
|
| 180 |
+
" diffs = []\n",
|
| 181 |
+
" init_exps = []\n",
|
| 182 |
+
" opt_exps = []\n",
|
| 183 |
+
" orig_vals = []\n",
|
| 184 |
+
"\n",
|
| 185 |
+
"\n",
|
| 186 |
+
" LR = 0.001\n",
|
| 187 |
+
" DIM = 40\n",
|
| 188 |
+
" MAX_LEN = 128\n",
|
| 189 |
+
" \n",
|
| 190 |
+
"\n",
|
| 191 |
+
" tempnoise = tf.random.normal(shape=[BATCH_SIZE,DIM])\n",
|
| 192 |
+
" selectednoise = tempnoise\n",
|
| 193 |
+
"\n",
|
| 194 |
+
" best = 10\n",
|
| 195 |
+
"\n",
|
| 196 |
+
" LOW_START = False\n",
|
| 197 |
+
"\n",
|
| 198 |
+
"\n",
|
| 199 |
+
" if LOW_START:\n",
|
| 200 |
+
" \n",
|
| 201 |
+
" for i in range(10000):\n",
|
| 202 |
+
" tempnoise = tf.random.normal(shape=[BATCH_SIZE,DIM])\n",
|
| 203 |
+
" sequences = wgan(tempnoise)\n",
|
| 204 |
+
"\n",
|
| 205 |
+
" seqs_gen = recover_seq(sequences, rev_rna_vocab)\n",
|
| 206 |
+
" seqs_str = seqs_gen\n",
|
| 207 |
+
"\n",
|
| 208 |
+
" shape_ = tf.shape(np.array([encode_seq_framepool(seq) for seq in recover_seq(sequences, rev_rna_vocab)]))\n",
|
| 209 |
+
"\n",
|
| 210 |
+
" seqs = tf.convert_to_tensor(np.array([encode_seq_framepool(seq) for seq in recover_seq(sequences, rev_rna_vocab)]),dtype=tf.float32)\n",
|
| 211 |
+
"\n",
|
| 212 |
+
" \n",
|
| 213 |
+
" pred = model(seqs)\n",
|
| 214 |
+
"\n",
|
| 215 |
+
" t = tf.reshape(pred,(-1))\n",
|
| 216 |
+
" t = t.numpy().astype('float')\n",
|
| 217 |
+
" score = np.mean(t)\n",
|
| 218 |
+
"\n",
|
| 219 |
+
" if score < best:\n",
|
| 220 |
+
" best = score\n",
|
| 221 |
+
" selectednoise = tempnoise\n",
|
| 222 |
+
" noise = tf.Variable(selectednoise)\n",
|
| 223 |
+
" else:\n",
|
| 224 |
+
" noise = tf.Variable(tf.random.normal(shape=[BATCH_SIZE,DIM]))\n",
|
| 225 |
+
" \n",
|
| 226 |
+
"\n",
|
| 227 |
+
" noise_small = tf.random.normal(shape=[BATCH_SIZE,DIM],stddev=1e-4)\n",
|
| 228 |
+
"\n",
|
| 229 |
+
" optimizer = tf.keras.optimizers.Adam(learning_rate=np.power(np.e,LR))\n",
|
| 230 |
+
"\n",
|
| 231 |
+
" '''\n",
|
| 232 |
+
" Optimization takes place here.\n",
|
| 233 |
+
" '''\n",
|
| 234 |
+
"\n",
|
| 235 |
+
" bind_scores_list = []\n",
|
| 236 |
+
" bind_scores_means = []\n",
|
| 237 |
+
" sequences_list = []\n",
|
| 238 |
+
"\n",
|
| 239 |
+
" means = []\n",
|
| 240 |
+
" maxes = []\n",
|
| 241 |
+
" iters_ = []\n",
|
| 242 |
+
"\n",
|
| 243 |
+
" OPTIMIZE = True\n",
|
| 244 |
+
"\n",
|
| 245 |
+
" DNA_SEL = False\n",
|
| 246 |
+
"\n",
|
| 247 |
+
"\n",
|
| 248 |
+
" sequences_init = wgan(noise)\n",
|
| 249 |
+
"\n",
|
| 250 |
+
" gen_seqs_init = sequences_init.numpy().astype('float')\n",
|
| 251 |
+
"\n",
|
| 252 |
+
" seqs_gen_init = recover_seq(gen_seqs_init, rev_rna_vocab)\n",
|
| 253 |
+
"\n",
|
| 254 |
+
" init_pos, init_neg = motif_count(seqs_gen_init,motifs_path)\n",
|
| 255 |
+
" \n",
|
| 256 |
+
" if Optimize_FrameSlice:\n",
|
| 257 |
+
" seqs = prepare_framepool(seqs_gen_init)\n",
|
| 258 |
+
"\n",
|
| 259 |
+
" seqs_init = prepare_mttrans(seqs_gen_init)\n",
|
| 260 |
+
"\n",
|
| 261 |
+
" pred_init = model(seqs)\n",
|
| 262 |
+
" \n",
|
| 263 |
+
" else:\n",
|
| 264 |
+
"\n",
|
| 265 |
+
"\n",
|
| 266 |
+
" one_hots = one_hot_all_motif(np.array(seqs_gen_init))\n",
|
| 267 |
+
" seqs = torch.tensor(one_hots,dtype=torch.double)\n",
|
| 268 |
+
" seqs = torch.transpose(seqs, 1, 2)\n",
|
| 269 |
+
" seqs = seqs.float().to(device)\n",
|
| 270 |
+
"\n",
|
| 271 |
+
"\n",
|
| 272 |
+
" pred_init = model.forward(seqs)\n",
|
| 273 |
+
" \n",
|
| 274 |
+
" if Optimize_FrameSlice:\n",
|
| 275 |
+
"\n",
|
| 276 |
+
" t = tf.reshape(pred_init,(-1))\n",
|
| 277 |
+
"\n",
|
| 278 |
+
" init_t = t.numpy().astype('float')\n",
|
| 279 |
+
" \n",
|
| 280 |
+
" else:\n",
|
| 281 |
+
" \n",
|
| 282 |
+
" t = torch.flatten(pred_init)\n",
|
| 283 |
+
" t.float()\n",
|
| 284 |
+
" \n",
|
| 285 |
+
" init_t = t.cpu().detach().numpy()\n",
|
| 286 |
+
"\n",
|
| 287 |
+
" init_exp = np.mean(init_t)\n",
|
| 288 |
+
"\n",
|
| 289 |
+
" max_init = np.max(init_t)\n",
|
| 290 |
+
"\n",
|
| 291 |
+
" min_init = np.min(init_t)\n",
|
| 292 |
+
" \n",
|
| 293 |
+
" predicted_mrls = []\n",
|
| 294 |
+
"\n",
|
| 295 |
+
" STEPS = STEPS\n",
|
| 296 |
+
"\n",
|
| 297 |
+
" seqs_collection = []\n",
|
| 298 |
+
" scores_collection = []\n",
|
| 299 |
+
" if OPTIMIZE:\n",
|
| 300 |
+
" iter_ = 0\n",
|
| 301 |
+
" for opt_iter in tqdm(range(int(STEPS))):\n",
|
| 302 |
+
" \n",
|
| 303 |
+
" with tf.GradientTape() as gtape:\n",
|
| 304 |
+
" gtape.watch(noise)\n",
|
| 305 |
+
" sequences = wgan(noise)\n",
|
| 306 |
+
"\n",
|
| 307 |
+
" seqs_gen = recover_seq(sequences, rev_rna_vocab)\n",
|
| 308 |
+
" seqs_collection.append(seqs_gen)\n",
|
| 309 |
+
" seqs_str = seqs_gen\n",
|
| 310 |
+
" \n",
|
| 311 |
+
" if Optimize_FrameSlice:\n",
|
| 312 |
+
"\n",
|
| 313 |
+
" seqs = tf.convert_to_tensor(np.array([encode_seq_framepool(seq) for seq in recover_seq(sequences, rev_rna_vocab)]),dtype=tf.float32)\n",
|
| 314 |
+
" \n",
|
| 315 |
+
" else:\n",
|
| 316 |
+
" seqs = torch.tensor(np.array(one_hot_all_motif(seqs_gen),dtype=np.float32)) \n",
|
| 317 |
+
"\n",
|
| 318 |
+
" if Optimize_FrameSlice:\n",
|
| 319 |
+
"\n",
|
| 320 |
+
" with tf.GradientTape() as ptape:\n",
|
| 321 |
+
" ptape.watch(seqs)\n",
|
| 322 |
+
"\n",
|
| 323 |
+
" pred = model(seqs)\n",
|
| 324 |
+
" score = tf.reduce_mean(pred)\n",
|
| 325 |
+
" t = tf.reshape(pred,(-1))\n",
|
| 326 |
+
" mx = t.numpy().astype('float')\n",
|
| 327 |
+
" scores_collection.append(mx)\n",
|
| 328 |
+
" mx = np.max(mx)\n",
|
| 329 |
+
" \n",
|
| 330 |
+
" sum_ = tf.reduce_sum(t).numpy().astype('float')\n",
|
| 331 |
+
" \n",
|
| 332 |
+
" maxes.append(mx)\n",
|
| 333 |
+
" predicted_mrls.append(sum_/BATCH_SIZE)\n",
|
| 334 |
+
" means.append(sum_/BATCH_SIZE)\n",
|
| 335 |
+
"\n",
|
| 336 |
+
" g1 = ptape.gradient(score,seqs)\n",
|
| 337 |
+
"\n",
|
| 338 |
+
" OPTIMIZE_FULL = False\n",
|
| 339 |
+
" if OPTIMIZE_FULL:\n",
|
| 340 |
+
" tmp_g = g1.numpy().astype('float')\n",
|
| 341 |
+
" tmp_seqs = seqs_gen\n",
|
| 342 |
+
" tmp_lst = np.zeros(shape=(BATCH_SIZE,MAX_LEN,5))\n",
|
| 343 |
+
" for i in range(len(tmp_seqs)):\n",
|
| 344 |
+
" \n",
|
| 345 |
+
" len_ = len(tmp_seqs[i])\n",
|
| 346 |
+
" edited_g = tmp_g[i][:len_,:]\n",
|
| 347 |
+
" edited_g = np.pad(edited_g,((0,MAX_LEN-len_),(0,1)),'constant') \n",
|
| 348 |
+
" tmp_lst[i] = edited_g \n",
|
| 349 |
+
" \n",
|
| 350 |
+
" g1 = tf.convert_to_tensor(tmp_lst,dtype=tf.float32)\n",
|
| 351 |
+
"\n",
|
| 352 |
+
" else:\n",
|
| 353 |
+
" \n",
|
| 354 |
+
" g1 = tf.pad(g1,tf.constant([[0, 0], [0, 0], [0, 1]]),\"CONSTANT\")\n",
|
| 355 |
+
"\n",
|
| 356 |
+
" g1 = tf.math.scalar_mul(-1.0,g1)\n",
|
| 357 |
+
"\n",
|
| 358 |
+
" \n",
|
| 359 |
+
" else:\n",
|
| 360 |
+
" \n",
|
| 361 |
+
" seqs = torch.transpose(seqs, 1, 2)\n",
|
| 362 |
+
" seqs = seqs.float()\n",
|
| 363 |
+
" seqs = torch.tensor(seqs.to(device), requires_grad=True)\n",
|
| 364 |
+
" pred = model(seqs)\n",
|
| 365 |
+
" pred = torch.flatten(pred)\n",
|
| 366 |
+
" predicted_mrls.append(np.average(pred.cpu().detach().numpy()))\n",
|
| 367 |
+
" scores_collection.append(pred.cpu().detach().numpy())\n",
|
| 368 |
+
" score = torch.mean(pred)\n",
|
| 369 |
+
" t = torch.flatten(pred)\n",
|
| 370 |
+
" mx = t.cpu().detach().numpy()\n",
|
| 371 |
+
" mx = np.max(mx)\n",
|
| 372 |
+
" \n",
|
| 373 |
+
" sum_ = torch.mean(t).cpu().detach().numpy()\n",
|
| 374 |
+
" \n",
|
| 375 |
+
" maxes.append(mx)\n",
|
| 376 |
+
" means.append(sum_/BATCH_SIZE)\n",
|
| 377 |
+
" pred.backward(torch.ones_like(pred))\n",
|
| 378 |
+
" \n",
|
| 379 |
+
" g1 = seqs.grad\n",
|
| 380 |
+
" \n",
|
| 381 |
+
" g1 = g1.cpu().detach().numpy()\n",
|
| 382 |
+
" g1 = tf.convert_to_tensor(g1)\n",
|
| 383 |
+
" g1 = tf.transpose(g1, perm=[0,2,1])\n",
|
| 384 |
+
" g1 = tf.pad(g1,tf.constant([[0, 0], [0, 0], [0, 1]]),\"CONSTANT\")\n",
|
| 385 |
+
" g1 = tf.math.scalar_mul(-1.0,g1)\n",
|
| 386 |
+
" \n",
|
| 387 |
+
" \n",
|
| 388 |
+
" g2 = gtape.gradient(sequences,noise,output_gradients=g1)\n",
|
| 389 |
+
"\n",
|
| 390 |
+
" a1 = g2 + noise_small\n",
|
| 391 |
+
" change = [(a1,noise)]\n",
|
| 392 |
+
" optimizer.apply_gradients(change)\n",
|
| 393 |
+
"\n",
|
| 394 |
+
" iters_.append(iter_)\n",
|
| 395 |
+
" iter_ += 1\n",
|
| 396 |
+
"\n",
|
| 397 |
+
" best_seqs, best_scores = select_best(scores_collection, seqs_collection)\n",
|
| 398 |
+
"\n",
|
| 399 |
+
" sequences_opt = wgan(noise)\n",
|
| 400 |
+
" \n",
|
| 401 |
+
" gen_seqs_opt = sequences_opt.numpy().astype('float')\n",
|
| 402 |
+
"\n",
|
| 403 |
+
" seqs_gen_opt = recover_seq(gen_seqs_opt, rev_rna_vocab)\n",
|
| 404 |
+
"\n",
|
| 405 |
+
" opt_pos, opt_neg = motif_count(seqs_gen_opt,motifs_path)\n",
|
| 406 |
+
" \n",
|
| 407 |
+
" if Optimize_FrameSlice:\n",
|
| 408 |
+
" \n",
|
| 409 |
+
" seqs_opt = prepare_framepool(seqs_gen_opt)\n",
|
| 410 |
+
"\n",
|
| 411 |
+
"\n",
|
| 412 |
+
" \n",
|
| 413 |
+
" else: \n",
|
| 414 |
+
"\n",
|
| 415 |
+
" one_hots = np.array(one_hot_all_motif(seqs_gen_opt))\n",
|
| 416 |
+
" # print(np.shape(one_hots))\n",
|
| 417 |
+
" seqs = torch.tensor(one_hots,dtype=torch.double)\n",
|
| 418 |
+
" seqs = torch.transpose(seqs, 1, 2)\n",
|
| 419 |
+
" seqs = seqs.float().to(device)\n",
|
| 420 |
+
"\n",
|
| 421 |
+
" pred_opt = model(seqs)\n",
|
| 422 |
+
" \n",
|
| 423 |
+
" if Optimize_FrameSlice:\n",
|
| 424 |
+
"\n",
|
| 425 |
+
" t = tf.reshape(pred_opt,(-1))\n",
|
| 426 |
+
" \n",
|
| 427 |
+
" opt_t = t.numpy().astype('float')\n",
|
| 428 |
+
" \n",
|
| 429 |
+
" else:\n",
|
| 430 |
+
" \n",
|
| 431 |
+
" t = torch.flatten(pred_opt)\n",
|
| 432 |
+
" \n",
|
| 433 |
+
" \n",
|
| 434 |
+
" opt_t = t.cpu().detach().numpy()\n",
|
| 435 |
+
"\n",
|
| 436 |
+
" opt_exp = np.mean(opt_t)\n",
|
| 437 |
+
"\n",
|
| 438 |
+
" min_opt = np.min(opt_t)\n",
|
| 439 |
+
" max_opt = np.max(opt_t)\n",
|
| 440 |
+
"\n",
|
| 441 |
+
" with open(f'./src/mrl_te_optimization/outputs/init_mrl_{OPT}.txt', 'w') as f:\n",
|
| 442 |
+
" f.writelines([str(x)+'\\n' for x in init_t])\n",
|
| 443 |
+
"\n",
|
| 444 |
+
" with open(f'./src/mrl_te_optimization/outputs/opt_mrl_{OPT}.txt', 'w') as f:\n",
|
| 445 |
+
" f.writelines([str(x)+'\\n' for x in best_scores])\n",
|
| 446 |
+
"\n",
|
| 447 |
+
" with open(f'./src/mrl_te_optimization/outputs/opt_seqs_{OPT}.txt', 'w') as f:\n",
|
| 448 |
+
" f.writelines([str(x)+'\\n' for x in best_seqs])\n",
|
| 449 |
+
"\n",
|
| 450 |
+
" with open(f'./src/mrl_te_optimization/outputs/init_seqs_{OPT}.txt', 'w') as f:\n",
|
| 451 |
+
" f.writelines([str(x)+'\\n' for x in seqs_gen_init])\n",
|
| 452 |
+
" \n",
|
| 453 |
+
"\n",
|
| 454 |
+
" print(f\"Average Initial Pred: {np.average(init_t)}\")\n",
|
| 455 |
+
" print(f\"Max Initial Pred: {np.max(init_t)}\")\n",
|
| 456 |
+
" print(f\"Average Opt. Pred: {np.average(best_scores)}\")\n",
|
| 457 |
+
" print(f\"Max Opt. Pred: {np.max(best_scores)}\")\n",
|
| 458 |
+
"\n"
|
| 459 |
+
]
|
| 460 |
+
}
|
| 461 |
+
],
|
| 462 |
+
"metadata": {
|
| 463 |
+
"kernelspec": {
|
| 464 |
+
"display_name": "utrgan",
|
| 465 |
+
"language": "python",
|
| 466 |
+
"name": "python3"
|
| 467 |
+
},
|
| 468 |
+
"language_info": {
|
| 469 |
+
"codemirror_mode": {
|
| 470 |
+
"name": "ipython",
|
| 471 |
+
"version": 3
|
| 472 |
+
},
|
| 473 |
+
"file_extension": ".py",
|
| 474 |
+
"mimetype": "text/x-python",
|
| 475 |
+
"name": "python",
|
| 476 |
+
"nbconvert_exporter": "python",
|
| 477 |
+
"pygments_lexer": "ipython3",
|
| 478 |
+
"version": "3.10.8"
|
| 479 |
+
}
|
| 480 |
+
},
|
| 481 |
+
"nbformat": 4,
|
| 482 |
+
"nbformat_minor": 2
|
| 483 |
+
}
|
configuration.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model_name": "UTRGAN",
|
| 3 |
+
"framework": "TensorFlow + PyTorch",
|
| 4 |
+
"task": "5utr-generation-and-translation-optimization",
|
| 5 |
+
"entry_points": {
|
| 6 |
+
"inference": "scripts/predict.py",
|
| 7 |
+
"predict": "scripts/predict.py",
|
| 8 |
+
"optimize": "scripts/optimize_te_mrl.py",
|
| 9 |
+
"train": "scripts/train.py"
|
| 10 |
+
},
|
| 11 |
+
"source_package": "model/src",
|
| 12 |
+
"config": "conf/config.json",
|
| 13 |
+
"data_dir": "conf/data",
|
| 14 |
+
"weight_dir": "weight",
|
| 15 |
+
"required_dtk": "26.04",
|
| 16 |
+
"license": "CC-BY-NC-SA-2.0"
|
| 17 |
+
}
|
model/__init__.py
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""UTRGAN model sources.
|
| 2 |
+
|
| 3 |
+
The upstream ``src`` package is intentionally retained below this directory
|
| 4 |
+
because released PyTorch checkpoints refer to its original module names.
|
| 5 |
+
"""
|
model/src/__init__.py
ADDED
|
File without changes
|
model/src/__pycache__/__init__.cpython-311.pyc
ADDED
|
Binary file (160 Bytes). View file
|
|
|
model/src/exp_optimization/__init__.py
ADDED
|
File without changes
|
model/src/exp_optimization/exp_joint.py
ADDED
|
@@ -0,0 +1,571 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
| 8 |
+
import torch
|
| 9 |
+
import argparse
|
| 10 |
+
from util import *
|
| 11 |
+
sns.set()
|
| 12 |
+
sns.set_style('ticks')
|
| 13 |
+
|
| 14 |
+
device = 'cpu'
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
#POSTER
|
| 18 |
+
params = {'legend.fontsize': 50,
|
| 19 |
+
'figure.figsize': (54, 54),
|
| 20 |
+
'axes.labelsize':60,
|
| 21 |
+
'axes.titlesize':60,
|
| 22 |
+
'xtick.labelsize':60,
|
| 23 |
+
'ytick.labelsize':40}
|
| 24 |
+
|
| 25 |
+
plt.rcParams.update(params)
|
| 26 |
+
|
| 27 |
+
colors = ["#3c5068", "#acbab6", "#dcd3cd", "#d4a6a6", '#451120']
|
| 28 |
+
|
| 29 |
+
np.random.seed(25)
|
| 30 |
+
|
| 31 |
+
fig, axs = plt.subplots(4,2, )
|
| 32 |
+
|
| 33 |
+
def prepare_mttrans(seqs):
|
| 34 |
+
seqs_init = torch.tensor(np.array(one_hot_all_motif(seqs),dtype=np.float32))
|
| 35 |
+
|
| 36 |
+
seqs_init = torch.transpose(seqs_init, 1, 2)
|
| 37 |
+
seqs_init = torch.tensor(seqs_init,dtype=torch.float32).to('cpu')
|
| 38 |
+
return seqs_init
|
| 39 |
+
|
| 40 |
+
DISPLAY_DIFF = True
|
| 41 |
+
|
| 42 |
+
root_path = './outputs/'
|
| 43 |
+
mpath = './scripts/checkpoint/RL_hard_share_MTL/3M/schedule_lr-model_best_cv1.pth'
|
| 44 |
+
gpath = './../../models/checkpoint_3000.h5'
|
| 45 |
+
mrl_path = './../../models/utr_model_combined_residual_new.h5'
|
| 46 |
+
exp_path = './../../models/humanMedian_trainepoch.11-0.426.h5'
|
| 47 |
+
tpath = './scripts/checkpoint/RL_hard_share_MTL/3R/schedule_MTL-model_best_cv1.pth'
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
K = 64
|
| 51 |
+
|
| 52 |
+
# if DISPLAY_DIFF:
|
| 53 |
+
gene_name = 'IFNG'
|
| 54 |
+
|
| 55 |
+
init = []
|
| 56 |
+
with open('./outputs_joint/init_exps_'+gene_name+'.txt') as f:
|
| 57 |
+
scores = f.readlines()
|
| 58 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 59 |
+
|
| 60 |
+
opt = []
|
| 61 |
+
with open('./outputs_joint/opt_exps_'+gene_name+'.txt') as f:
|
| 62 |
+
scores = f.readlines()
|
| 63 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 64 |
+
|
| 65 |
+
init_seqs = []
|
| 66 |
+
with open('./outputs_joint/init_seqs_'+gene_name+'.txt') as f:
|
| 67 |
+
scores = f.readlines()
|
| 68 |
+
init_seqs = [score.replace('\n','') for score in scores]
|
| 69 |
+
|
| 70 |
+
opt_seqs = []
|
| 71 |
+
with open('./outputs_joint/best_seqs_'+gene_name+'.txt') as f:
|
| 72 |
+
scores = f.readlines()
|
| 73 |
+
opt_seqs = [score.replace('\n','') for score in scores]
|
| 74 |
+
|
| 75 |
+
te_model = torch.load(tpath,map_location=torch.device(device))['state_dict']
|
| 76 |
+
te_model.train().to(device)
|
| 77 |
+
|
| 78 |
+
mrl_model = torch.load(mpath,map_location=torch.device(device))['state_dict']
|
| 79 |
+
mrl_model.train().to(device)
|
| 80 |
+
|
| 81 |
+
te_seqs_init = prepare_mttrans(init_seqs)
|
| 82 |
+
te_seqs_opt = prepare_mttrans(opt_seqs)
|
| 83 |
+
|
| 84 |
+
te_preds_init = np.reshape(te_model.forward(te_seqs_init).cpu().data.numpy(),(-1))
|
| 85 |
+
te_preds_opt = np.reshape(te_model.forward(te_seqs_opt).cpu().data.numpy(),(-1))
|
| 86 |
+
|
| 87 |
+
mrl_preds_init = np.reshape(mrl_model.forward(te_seqs_init).cpu().data.numpy(),(-1))
|
| 88 |
+
mrl_preds_opt = np.reshape(mrl_model.forward(te_seqs_opt).cpu().data.numpy(),(-1))
|
| 89 |
+
|
| 90 |
+
init = np.power(10,init)
|
| 91 |
+
opt = np.power(10,opt)
|
| 92 |
+
|
| 93 |
+
selected = random.choices([i for i in range(len(init))],k=64)
|
| 94 |
+
init = init[selected]
|
| 95 |
+
opt = opt[selected]
|
| 96 |
+
|
| 97 |
+
print(gene_name)
|
| 98 |
+
print(f"Average Opt: {np.average(opt)}")
|
| 99 |
+
print(f"Average Init: {np.average(init)}")
|
| 100 |
+
print(f"Max Opt: {np.max(opt)}")
|
| 101 |
+
print(f"Max Init: {np.max(init)}")
|
| 102 |
+
print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
|
| 103 |
+
print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
|
| 104 |
+
print(f"Max Increase (wrt Natural) : {np.max(opt/np.power(10,-0.63))}")
|
| 105 |
+
|
| 106 |
+
diffs = (opt - init)/init
|
| 107 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")
|
| 108 |
+
print(f"Max TE after opt: {np.max(te_preds_opt)}")
|
| 109 |
+
|
| 110 |
+
indices = np.argsort(opt)[::-1]
|
| 111 |
+
|
| 112 |
+
init_large = []
|
| 113 |
+
init_small = []
|
| 114 |
+
opt_large = []
|
| 115 |
+
opt_small = []
|
| 116 |
+
|
| 117 |
+
for i in range(len(indices)):
|
| 118 |
+
if diffs[indices[i]] >= 0:
|
| 119 |
+
init_small.append(init[indices[i]])
|
| 120 |
+
init_large.append(0)
|
| 121 |
+
opt_small.append(0)
|
| 122 |
+
opt_large.append(opt[indices[i]])
|
| 123 |
+
else:
|
| 124 |
+
init_large.append(init[indices[i]])
|
| 125 |
+
init_small.append(0)
|
| 126 |
+
opt_large.append(0)
|
| 127 |
+
opt_small.append(opt[indices[i]])
|
| 128 |
+
|
| 129 |
+
width = 1.0/(len(indices))
|
| 130 |
+
bins = [(i+1) * width for i in range(len(indices))]
|
| 131 |
+
|
| 132 |
+
ns = [i * width for i in range(len(indices))]
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
axs[0,0].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
|
| 136 |
+
axs[0,0].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
|
| 137 |
+
axs[0,0].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
|
| 138 |
+
axs[0,0].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
|
| 139 |
+
axs[0,0].axhline(y = np.power(10,-1.09), color = colors[4], linestyle = '-', linewidth = 5)
|
| 140 |
+
|
| 141 |
+
axs[0,0].set_title(gene_name,loc='left',style='italic')
|
| 142 |
+
axs[0,0].set_xticks([])
|
| 143 |
+
|
| 144 |
+
real_x = ['Optimized' for i in range(len(init))]
|
| 145 |
+
gen_x = ['Initial' for i in range(len(opt))]
|
| 146 |
+
|
| 147 |
+
# Expression
|
| 148 |
+
|
| 149 |
+
x = np.concatenate((gen_x,real_x))
|
| 150 |
+
y = np.concatenate((init,opt))
|
| 151 |
+
|
| 152 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 153 |
+
|
| 154 |
+
# MRL
|
| 155 |
+
|
| 156 |
+
x = np.concatenate((gen_x,real_x))
|
| 157 |
+
y = np.concatenate((mrl_preds_init,mrl_preds_opt))
|
| 158 |
+
|
| 159 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 160 |
+
|
| 161 |
+
# TE
|
| 162 |
+
|
| 163 |
+
x = np.concatenate((gen_x,real_x))
|
| 164 |
+
y = np.concatenate((te_preds_init,te_preds_opt))
|
| 165 |
+
|
| 166 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 167 |
+
|
| 168 |
+
sns.boxplot(x=df['x'],y=df['y'],ax=axs[0,1],palette={'Initial':colors[3],'Optimized':colors[0]})
|
| 169 |
+
|
| 170 |
+
orange_patch = mpatches.Patch(color='tab:orange', label='Initial Expression')
|
| 171 |
+
blue_patch = mpatches.Patch(color='tab:blue', label='Optimized Expression')
|
| 172 |
+
|
| 173 |
+
gene_name = 'TLR6'
|
| 174 |
+
|
| 175 |
+
init = []
|
| 176 |
+
with open('./outputs_joint/init_exps_'+gene_name+'.txt') as f:
|
| 177 |
+
scores = f.readlines()
|
| 178 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 179 |
+
|
| 180 |
+
opt = []
|
| 181 |
+
with open('./outputs_joint/opt_exps_'+gene_name+'.txt') as f:
|
| 182 |
+
scores = f.readlines()
|
| 183 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 184 |
+
|
| 185 |
+
init_seqs = []
|
| 186 |
+
with open('./outputs_joint/init_seqs_'+gene_name+'.txt') as f:
|
| 187 |
+
scores = f.readlines()
|
| 188 |
+
init_seqs = [score.replace('\n','') for score in scores]
|
| 189 |
+
|
| 190 |
+
opt_seqs = []
|
| 191 |
+
with open('./outputs_joint/best_seqs_'+gene_name+'.txt') as f:
|
| 192 |
+
scores = f.readlines()
|
| 193 |
+
opt_seqs = [score.replace('\n','') for score in scores]
|
| 194 |
+
|
| 195 |
+
te_model = torch.load(tpath,map_location=torch.device(device))['state_dict']
|
| 196 |
+
te_model.train().to(device)
|
| 197 |
+
|
| 198 |
+
mrl_model = torch.load(mpath,map_location=torch.device(device))['state_dict']
|
| 199 |
+
mrl_model.train().to(device)
|
| 200 |
+
|
| 201 |
+
te_seqs_init = prepare_mttrans(init_seqs)
|
| 202 |
+
te_seqs_opt = prepare_mttrans(opt_seqs)
|
| 203 |
+
|
| 204 |
+
te_preds_init = np.reshape(te_model.forward(te_seqs_init).cpu().data.numpy(),(-1))
|
| 205 |
+
te_preds_opt = np.reshape(te_model.forward(te_seqs_opt).cpu().data.numpy(),(-1))
|
| 206 |
+
|
| 207 |
+
mrl_preds_init = np.reshape(mrl_model.forward(te_seqs_init).cpu().data.numpy(),(-1))
|
| 208 |
+
mrl_preds_opt = np.reshape(mrl_model.forward(te_seqs_opt).cpu().data.numpy(),(-1))
|
| 209 |
+
|
| 210 |
+
init = np.power(10,init)
|
| 211 |
+
opt = np.power(10,opt)
|
| 212 |
+
|
| 213 |
+
selected = random.choices([i for i in range(len(init))],k=64)
|
| 214 |
+
init = init[selected]
|
| 215 |
+
opt = opt[selected]
|
| 216 |
+
|
| 217 |
+
print(gene_name)
|
| 218 |
+
print(f"Average Opt: {np.average(opt)}")
|
| 219 |
+
print(f"Average Init: {np.average(init)}")
|
| 220 |
+
print(f"Max Opt: {np.max(opt)}")
|
| 221 |
+
print(f"Max Init: {np.max(init)}")
|
| 222 |
+
print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
|
| 223 |
+
print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
|
| 224 |
+
print(f"Max Increase (wrt Natural) : {np.max(opt/np.power(10,-0.63))}")
|
| 225 |
+
|
| 226 |
+
diffs = (opt - init)/init
|
| 227 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")
|
| 228 |
+
print(f"Max TE after opt: {np.max(te_preds_opt)}")
|
| 229 |
+
|
| 230 |
+
indices = np.argsort(opt)[::-1]
|
| 231 |
+
|
| 232 |
+
init_large = []
|
| 233 |
+
init_small = []
|
| 234 |
+
opt_large = []
|
| 235 |
+
opt_small = []
|
| 236 |
+
|
| 237 |
+
for i in range(len(indices)):
|
| 238 |
+
if diffs[indices[i]] >= 0:
|
| 239 |
+
init_small.append(init[indices[i]])
|
| 240 |
+
init_large.append(0)
|
| 241 |
+
opt_small.append(0)
|
| 242 |
+
opt_large.append(opt[indices[i]])
|
| 243 |
+
else:
|
| 244 |
+
init_large.append(init[indices[i]])
|
| 245 |
+
init_small.append(0)
|
| 246 |
+
opt_large.append(0)
|
| 247 |
+
opt_small.append(opt[indices[i]])
|
| 248 |
+
|
| 249 |
+
width = 1.0/(len(indices))
|
| 250 |
+
bins = [(i+1) * width for i in range(len(indices))]
|
| 251 |
+
|
| 252 |
+
ns = [i * width for i in range(len(indices))]
|
| 253 |
+
|
| 254 |
+
axs[1,0].bar(x=ns, bottom=0, width=width, height=opt_large, color= colors[0], edgecolor="white")
|
| 255 |
+
axs[1,0].bar(x=ns, bottom=0, width=width, height=opt_small, color= colors[0], edgecolor="white")
|
| 256 |
+
axs[1,0].bar(x=ns, bottom=0, width=width, height=init_small, color= colors[3], edgecolor="white")
|
| 257 |
+
axs[1,0].bar(x=ns, bottom=0, width=width, height=init_large, color= colors[3], edgecolor="white")
|
| 258 |
+
axs[1,0].axhline(y = np.power(10,-0.37), color = colors[4], linestyle = '-', linewidth = 5)
|
| 259 |
+
|
| 260 |
+
axs[1,0].set_title(gene_name,loc='left',style='italic')
|
| 261 |
+
|
| 262 |
+
axs[1,0].set_xticks([])
|
| 263 |
+
|
| 264 |
+
real_x = ['Optimized' for i in range(len(init))]
|
| 265 |
+
gen_x = ['Initial' for i in range(len(opt))]
|
| 266 |
+
|
| 267 |
+
# Expression
|
| 268 |
+
|
| 269 |
+
x = np.concatenate((gen_x,real_x))
|
| 270 |
+
y = np.concatenate((init,opt))
|
| 271 |
+
|
| 272 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 273 |
+
|
| 274 |
+
# MRL
|
| 275 |
+
|
| 276 |
+
x = np.concatenate((gen_x,real_x))
|
| 277 |
+
y = np.concatenate((mrl_preds_init,mrl_preds_opt))
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
# TE
|
| 284 |
+
|
| 285 |
+
x = np.concatenate((gen_x,real_x))
|
| 286 |
+
y = np.concatenate((te_preds_init,te_preds_opt))
|
| 287 |
+
|
| 288 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 289 |
+
|
| 290 |
+
sns.boxplot(x=df['x'],y=df['y'],ax=axs[1,1],palette={'Initial':colors[3],'Optimized':colors[0]})
|
| 291 |
+
|
| 292 |
+
orange_patch = mpatches.Patch(color='tab:orange', label='Initial Expression')
|
| 293 |
+
blue_patch = mpatches.Patch(color='tab:blue', label='Optimized Expression')
|
| 294 |
+
|
| 295 |
+
gene_name = 'TNF'
|
| 296 |
+
|
| 297 |
+
init = []
|
| 298 |
+
with open('./outputs_joint/init_exps_'+gene_name+'.txt') as f:
|
| 299 |
+
scores = f.readlines()
|
| 300 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 301 |
+
|
| 302 |
+
opt = []
|
| 303 |
+
with open('./outputs_joint/opt_exps_'+gene_name+'.txt') as f:
|
| 304 |
+
scores = f.readlines()
|
| 305 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 306 |
+
|
| 307 |
+
init_seqs = []
|
| 308 |
+
with open('./outputs_joint/init_seqs_'+gene_name+'.txt') as f:
|
| 309 |
+
scores = f.readlines()
|
| 310 |
+
init_seqs = [score.replace('\n','') for score in scores]
|
| 311 |
+
|
| 312 |
+
opt_seqs = []
|
| 313 |
+
with open('./outputs_joint/best_seqs_'+gene_name+'.txt') as f:
|
| 314 |
+
scores = f.readlines()
|
| 315 |
+
opt_seqs = [score.replace('\n','') for score in scores]
|
| 316 |
+
|
| 317 |
+
te_model = torch.load(tpath,map_location=torch.device(device))['state_dict']
|
| 318 |
+
te_model.train().to(device)
|
| 319 |
+
|
| 320 |
+
mrl_model = torch.load(mpath,map_location=torch.device(device))['state_dict']
|
| 321 |
+
mrl_model.train().to(device)
|
| 322 |
+
|
| 323 |
+
te_seqs_init = prepare_mttrans(init_seqs)
|
| 324 |
+
te_seqs_opt = prepare_mttrans(opt_seqs)
|
| 325 |
+
|
| 326 |
+
te_preds_init = np.reshape(te_model.forward(te_seqs_init).cpu().data.numpy(),(-1))
|
| 327 |
+
te_preds_opt = np.reshape(te_model.forward(te_seqs_opt).cpu().data.numpy(),(-1))
|
| 328 |
+
|
| 329 |
+
mrl_preds_init = np.reshape(mrl_model.forward(te_seqs_init).cpu().data.numpy(),(-1))
|
| 330 |
+
mrl_preds_opt = np.reshape(mrl_model.forward(te_seqs_opt).cpu().data.numpy(),(-1))
|
| 331 |
+
|
| 332 |
+
init = np.power(10,init)
|
| 333 |
+
opt = np.power(10,opt)
|
| 334 |
+
|
| 335 |
+
selected = random.choices([i for i in range(len(init))],k=64)
|
| 336 |
+
init = init[selected]
|
| 337 |
+
opt = opt[selected]
|
| 338 |
+
|
| 339 |
+
print(gene_name)
|
| 340 |
+
print(f"Average Opt: {np.average(opt)}")
|
| 341 |
+
print(f"Average Init: {np.average(init)}")
|
| 342 |
+
print(f"Max Opt: {np.max(opt)}")
|
| 343 |
+
print(f"Max Init: {np.max(init)}")
|
| 344 |
+
print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
|
| 345 |
+
print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
|
| 346 |
+
print(f"Max Increase (wrt Natural) : {np.max(opt/np.power(10,-0.63))}")
|
| 347 |
+
|
| 348 |
+
diffs = (opt - init)/init
|
| 349 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")
|
| 350 |
+
print(f"Max TE after opt: {np.max(te_preds_opt)}")
|
| 351 |
+
|
| 352 |
+
indices = np.argsort(opt)[::-1]
|
| 353 |
+
|
| 354 |
+
init_large = []
|
| 355 |
+
init_small = []
|
| 356 |
+
opt_large = []
|
| 357 |
+
opt_small = []
|
| 358 |
+
|
| 359 |
+
for i in range(len(indices)):
|
| 360 |
+
if diffs[indices[i]] >= 0:
|
| 361 |
+
init_small.append(init[indices[i]])
|
| 362 |
+
init_large.append(0)
|
| 363 |
+
opt_small.append(0)
|
| 364 |
+
opt_large.append(opt[indices[i]])
|
| 365 |
+
else:
|
| 366 |
+
init_large.append(init[indices[i]])
|
| 367 |
+
init_small.append(0)
|
| 368 |
+
opt_large.append(0)
|
| 369 |
+
opt_small.append(opt[indices[i]])
|
| 370 |
+
|
| 371 |
+
width = 1.0/(len(indices))
|
| 372 |
+
bins = [(i+1) * width for i in range(len(indices))]
|
| 373 |
+
|
| 374 |
+
ns = [i * width for i in range(len(indices))]
|
| 375 |
+
|
| 376 |
+
axs[2,0].bar(x=ns, bottom=0, width=width, height=opt_large, color= colors[0], edgecolor="white")
|
| 377 |
+
axs[2,0].bar(x=ns, bottom=0, width=width, height=opt_small, color= colors[0], edgecolor="white")
|
| 378 |
+
axs[2,0].bar(x=ns, bottom=0, width=width, height=init_small, color= colors[3], edgecolor="white")
|
| 379 |
+
axs[2,0].bar(x=ns, bottom=0, width=width, height=init_large, color= colors[3], edgecolor="white")
|
| 380 |
+
axs[2,0].axhline(y = np.power(10,-0.91), color = colors[4], linestyle = '-', linewidth = 5)
|
| 381 |
+
|
| 382 |
+
axs[2,0].set_title(gene_name,loc='left',style='italic')
|
| 383 |
+
axs[2,0].set_xticks([])
|
| 384 |
+
|
| 385 |
+
real_x = ['Optimized' for i in range(len(init))]
|
| 386 |
+
gen_x = ['Initial' for i in range(len(opt))]
|
| 387 |
+
|
| 388 |
+
# Expression
|
| 389 |
+
|
| 390 |
+
x = np.concatenate((gen_x,real_x))
|
| 391 |
+
y = np.concatenate((init,opt))
|
| 392 |
+
|
| 393 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 394 |
+
|
| 395 |
+
# MRL
|
| 396 |
+
|
| 397 |
+
x = np.concatenate((gen_x,real_x))
|
| 398 |
+
y = np.concatenate((mrl_preds_init,mrl_preds_opt))
|
| 399 |
+
|
| 400 |
+
# TE
|
| 401 |
+
|
| 402 |
+
x = np.concatenate((gen_x,real_x))
|
| 403 |
+
y = np.concatenate((te_preds_init,te_preds_opt))
|
| 404 |
+
|
| 405 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 406 |
+
|
| 407 |
+
sns.boxplot(x=df['x'],y=df['y'],ax=axs[2,1],palette={'Initial':colors[3],'Optimized':colors[0]})
|
| 408 |
+
|
| 409 |
+
orange_patch = mpatches.Patch(color='tab:orange', label='Initial Expression')
|
| 410 |
+
blue_patch = mpatches.Patch(color='tab:blue', label='Optimized Expression')
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
gene_name = 'TP53'
|
| 414 |
+
|
| 415 |
+
init = []
|
| 416 |
+
with open('./outputs_joint/init_exps_'+gene_name+'.txt') as f:
|
| 417 |
+
scores = f.readlines()
|
| 418 |
+
init = [float(score.replace('\n','')) for score in scores]
|
| 419 |
+
|
| 420 |
+
opt = []
|
| 421 |
+
with open('./outputs_joint/opt_exps_'+gene_name+'.txt') as f:
|
| 422 |
+
scores = f.readlines()
|
| 423 |
+
opt = [float(score.replace('\n','')) for score in scores]
|
| 424 |
+
|
| 425 |
+
init_seqs = []
|
| 426 |
+
with open('./outputs_joint/init_seqs_'+gene_name+'.txt') as f:
|
| 427 |
+
scores = f.readlines()
|
| 428 |
+
init_seqs = [score.replace('\n','') for score in scores]
|
| 429 |
+
|
| 430 |
+
opt_seqs = []
|
| 431 |
+
with open('./outputs_joint/best_seqs_'+gene_name+'.txt') as f:
|
| 432 |
+
scores = f.readlines()
|
| 433 |
+
opt_seqs = [score.replace('\n','') for score in scores]
|
| 434 |
+
|
| 435 |
+
te_model = torch.load(tpath,map_location=torch.device(device))['state_dict']
|
| 436 |
+
te_model.train().to(device)
|
| 437 |
+
|
| 438 |
+
mrl_model = torch.load(mpath,map_location=torch.device(device))['state_dict']
|
| 439 |
+
mrl_model.train().to(device)
|
| 440 |
+
|
| 441 |
+
te_seqs_init = prepare_mttrans(init_seqs)
|
| 442 |
+
te_seqs_opt = prepare_mttrans(opt_seqs)
|
| 443 |
+
|
| 444 |
+
te_preds_init = np.reshape(te_model.forward(te_seqs_init).cpu().data.numpy(),(-1))
|
| 445 |
+
te_preds_opt = np.reshape(te_model.forward(te_seqs_opt).cpu().data.numpy(),(-1))
|
| 446 |
+
|
| 447 |
+
mrl_preds_init = np.reshape(mrl_model.forward(te_seqs_init).cpu().data.numpy(),(-1))
|
| 448 |
+
mrl_preds_opt = np.reshape(mrl_model.forward(te_seqs_opt).cpu().data.numpy(),(-1))
|
| 449 |
+
|
| 450 |
+
init = np.power(10,init)
|
| 451 |
+
opt = np.power(10,opt)
|
| 452 |
+
|
| 453 |
+
selected = random.choices([i for i in range(len(init))],k=64)
|
| 454 |
+
init = init[selected]
|
| 455 |
+
opt = opt[selected]
|
| 456 |
+
|
| 457 |
+
print(gene_name)
|
| 458 |
+
print(f"Average Opt: {np.average(opt)}")
|
| 459 |
+
print(f"Average Init: {np.average(init)}")
|
| 460 |
+
print(f"Max Opt: {np.max(opt)}")
|
| 461 |
+
print(f"Max Init: {np.max(init)}")
|
| 462 |
+
print(f"Max Increase (wrt Init) : {np.max(opt/init)}")
|
| 463 |
+
print(f"Average Increase (wrt Init) : {np.mean(opt/init)}")
|
| 464 |
+
print(f"Max Increase (wrt Natural) : {np.max(opt/np.power(10,-0.63))}")
|
| 465 |
+
|
| 466 |
+
diffs = (opt - init)/init
|
| 467 |
+
print(f"Average Percent Increase (wrt Init): {np.average(diffs)}")
|
| 468 |
+
print(f"Max TE after opt: {np.max(te_preds_opt)}")
|
| 469 |
+
|
| 470 |
+
indices = np.argsort(opt)[::-1]
|
| 471 |
+
|
| 472 |
+
init_large = []
|
| 473 |
+
init_small = []
|
| 474 |
+
opt_large = []
|
| 475 |
+
opt_small = []
|
| 476 |
+
|
| 477 |
+
for i in range(len(indices)):
|
| 478 |
+
if diffs[indices[i]] >= 0:
|
| 479 |
+
init_small.append(init[indices[i]])
|
| 480 |
+
init_large.append(0)
|
| 481 |
+
opt_small.append(0)
|
| 482 |
+
opt_large.append(opt[indices[i]])
|
| 483 |
+
else:
|
| 484 |
+
init_large.append(init[indices[i]])
|
| 485 |
+
init_small.append(0)
|
| 486 |
+
opt_large.append(0)
|
| 487 |
+
opt_small.append(opt[indices[i]])
|
| 488 |
+
|
| 489 |
+
width = 1.0/(len(indices))
|
| 490 |
+
bins = [(i+1) * width for i in range(len(indices))]
|
| 491 |
+
|
| 492 |
+
ns = [i * width for i in range(len(indices))]
|
| 493 |
+
|
| 494 |
+
axs[3,0].bar(x=ns, bottom=0, width=width, height=opt_large, color=colors[0], edgecolor="white")
|
| 495 |
+
axs[3,0].bar(x=ns, bottom=0, width=width, height=opt_small, color=colors[0], edgecolor="white")
|
| 496 |
+
axs[3,0].bar(x=ns, bottom=0, width=width, height=init_small, color=colors[3], edgecolor="white")
|
| 497 |
+
axs[3,0].bar(x=ns, bottom=0, width=width, height=init_large, color=colors[3], edgecolor="white")
|
| 498 |
+
axs[3,0].axhline(y = np.power(10,-0.63), color = colors[4], linestyle = '-', linewidth = 5)# sns.barplot(x=ns,width=width,y=opt_large,color='r',ax=axs[0,0])
|
| 499 |
+
|
| 500 |
+
axs[3,0].set_title(gene_name,loc='left',style='italic')
|
| 501 |
+
axs[3,0].set_xticks([])
|
| 502 |
+
|
| 503 |
+
real_x = ['Optimized' for i in range(len(init))]
|
| 504 |
+
gen_x = ['Initial' for i in range(len(opt))]
|
| 505 |
+
|
| 506 |
+
# Expression
|
| 507 |
+
|
| 508 |
+
x = np.concatenate((gen_x,real_x))
|
| 509 |
+
y = np.concatenate((init,opt))
|
| 510 |
+
|
| 511 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 512 |
+
|
| 513 |
+
# MRL
|
| 514 |
+
|
| 515 |
+
x = np.concatenate((gen_x,real_x))
|
| 516 |
+
y = np.concatenate((mrl_preds_init,mrl_preds_opt))
|
| 517 |
+
|
| 518 |
+
print(len(x))
|
| 519 |
+
print(len(y))
|
| 520 |
+
|
| 521 |
+
print(x)
|
| 522 |
+
print(y)
|
| 523 |
+
|
| 524 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 525 |
+
|
| 526 |
+
# TE
|
| 527 |
+
|
| 528 |
+
x = np.concatenate((gen_x,real_x))
|
| 529 |
+
y = np.concatenate((te_preds_init,te_preds_opt))
|
| 530 |
+
|
| 531 |
+
df = pd.DataFrame({'x':x,'y':y})
|
| 532 |
+
|
| 533 |
+
sns.boxplot(x=df['x'],y=df['y'],ax=axs[3,1],palette={'Initial':colors[3],'Optimized':colors[0]})
|
| 534 |
+
|
| 535 |
+
orange_patch = mpatches.Patch(color=colors[3], label='Initial Expression')
|
| 536 |
+
blue_patch = mpatches.Patch(color=colors[0], label='Optimized Expression')
|
| 537 |
+
fig.legend(handles=[orange_patch,blue_patch],loc=(0.52,0.95))
|
| 538 |
+
|
| 539 |
+
axs[0,0].set_ylabel('TPM Expression')
|
| 540 |
+
axs[1,0].set_ylabel('TPM Expression')
|
| 541 |
+
axs[2,0].set_ylabel('TPM Expression')
|
| 542 |
+
axs[3,0].set_ylabel('TPM Expression')
|
| 543 |
+
axs[3,0].set_xlabel('UTR Samples')
|
| 544 |
+
|
| 545 |
+
axs[0,1].set_xlabel('')
|
| 546 |
+
axs[1,1].set_xlabel('')
|
| 547 |
+
axs[2,1].set_xlabel('')
|
| 548 |
+
axs[3,1].set_xlabel('')
|
| 549 |
+
axs[0,1].set_ylabel('Log Translation Efficiency')
|
| 550 |
+
axs[1,1].set_ylabel('Log Translation Efficiency')
|
| 551 |
+
axs[2,1].set_ylabel('Log Translation Efficiency')
|
| 552 |
+
axs[3,1].set_ylabel('Log Translation Efficiency')
|
| 553 |
+
axs[0,1].yaxis.tick_right()
|
| 554 |
+
axs[1,1].yaxis.tick_right()
|
| 555 |
+
axs[2,1].yaxis.tick_right()
|
| 556 |
+
axs[3,1].yaxis.tick_right()
|
| 557 |
+
axs[0,1].yaxis.set_label_position("right")
|
| 558 |
+
axs[1,1].yaxis.set_label_position("right")
|
| 559 |
+
axs[2,1].yaxis.set_label_position("right")
|
| 560 |
+
axs[3,1].yaxis.set_label_position("right")
|
| 561 |
+
|
| 562 |
+
fig.tight_layout()
|
| 563 |
+
|
| 564 |
+
plt.savefig(f'./../../analysis/plots/joint_all.png')
|
| 565 |
+
|
| 566 |
+
print('Figure saved in: "./../../analysis/plots/joint_all.png"')
|
| 567 |
+
|
| 568 |
+
|
| 569 |
+
|
| 570 |
+
|
| 571 |
+
|