kartoun commited on
Commit
322d5a1
·
verified ·
1 Parent(s): cd5c612

Upload OligoTox_Phase2_Optional_Analysis_Notebook.ipynb

Browse files
OligoTox_Phase2_Optional_Analysis_Notebook.ipynb CHANGED
@@ -47,20 +47,16 @@
47
  "name": "stdout",
48
  "output_type": "stream",
49
  "text": [
50
- "Notebook outputs will be written to: notebook_outputs\n"
 
51
  ]
52
  }
53
  ],
54
  "source": [
55
  "from pathlib import Path\n",
56
- "\n",
57
- "def display_output_path(path):\n",
58
- " \"\"\"Return a submission-safe relative path for generated notebook outputs.\"\"\"\n",
59
- " p = Path(path)\n",
60
- " return r\"\\\\notebook_outputs\\\\\" + p.name\n",
61
- "\n",
62
  "import json\n",
63
  "import os\n",
 
64
  "import warnings\n",
65
  "\n",
66
  "import numpy as np\n",
@@ -73,8 +69,29 @@
73
  "pd.set_option(\"display.max_columns\", 120)\n",
74
  "pd.set_option(\"display.max_colwidth\", 160)\n",
75
  "\n",
76
- "# The notebook is intended to be run from the same folder as the dataset files.\n",
77
- "DATA_DIR = Path.cwd().resolve()\n",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  "\n",
79
  "required_files = [\n",
80
  " \"oligos.csv\",\n",
@@ -87,14 +104,24 @@
87
  "\n",
88
  "if missing_files:\n",
89
  " raise FileNotFoundError(\n",
90
- " \"This notebook must be run from the same folder as the dataset files. \"\n",
 
 
91
  " f\"Missing required file(s): {missing_files}\"\n",
92
  " )\n",
93
  "\n",
94
- "OUTPUT_DIR = DATA_DIR / \"notebook_outputs\"\n",
95
  "OUTPUT_DIR.mkdir(exist_ok=True)\n",
96
  "\n",
97
- "print(f\"Notebook outputs will be written to: {OUTPUT_DIR.name}\")\n"
 
 
 
 
 
 
 
 
98
  ]
99
  },
100
  {
@@ -4663,7 +4690,7 @@
4663
  "name": "stdout",
4664
  "output_type": "stream",
4665
  "text": [
4666
- "Saved: \\\\notebook_outputs\\\\notebook_label_distribution.png\n"
4667
  ]
4668
  },
4669
  {
@@ -4737,7 +4764,7 @@
4737
  " path = OUTPUT_DIR / name\n",
4738
  " plt.tight_layout()\n",
4739
  " plt.savefig(path, dpi=160, bbox_inches=\"tight\")\n",
4740
- " print(f\"Saved: {display_output_path(path)}\")\n",
4741
  "\n",
4742
  "# Label distribution.\n",
4743
  "label_counts = readouts[\"hepatotoxicity_label\"].value_counts().reindex([\"low\", \"moderate\", \"high\"])\n",
@@ -4760,7 +4787,7 @@
4760
  "name": "stdout",
4761
  "output_type": "stream",
4762
  "text": [
4763
- "Saved: \\\\notebook_outputs\\\\notebook_risk_score_distribution_by_label.png\n"
4764
  ]
4765
  },
4766
  {
@@ -4798,7 +4825,7 @@
4798
  "name": "stdout",
4799
  "output_type": "stream",
4800
  "text": [
4801
- "Saved: \\\\notebook_outputs\\\\notebook_label_mix_by_modality.png\n"
4802
  ]
4803
  },
4804
  {
@@ -4988,7 +5015,7 @@
4988
  "name": "stdout",
4989
  "output_type": "stream",
4990
  "text": [
4991
- "Saved: \\\\notebook_outputs\\\\notebook_median_risk_over_time.png\n"
4992
  ]
4993
  },
4994
  {
@@ -5179,7 +5206,7 @@
5179
  "name": "stdout",
5180
  "output_type": "stream",
5181
  "text": [
5182
- "Saved: \\\\notebook_outputs\\\\notebook_risk_vs_dose_nM.png\n"
5183
  ]
5184
  },
5185
  {
@@ -5196,7 +5223,7 @@
5196
  "name": "stdout",
5197
  "output_type": "stream",
5198
  "text": [
5199
- "Saved: \\\\notebook_outputs\\\\notebook_risk_vs_phosphorothioate_fraction.png\n"
5200
  ]
5201
  },
5202
  {
@@ -5213,7 +5240,7 @@
5213
  "name": "stdout",
5214
  "output_type": "stream",
5215
  "text": [
5216
- "Saved: \\\\notebook_outputs\\\\notebook_risk_vs_GC_content.png\n"
5217
  ]
5218
  },
5219
  {
@@ -5230,7 +5257,7 @@
5230
  "name": "stdout",
5231
  "output_type": "stream",
5232
  "text": [
5233
- "Saved: \\\\notebook_outputs\\\\notebook_risk_vs_predicted_offtarget_hybridization_burden.png\n"
5234
  ]
5235
  },
5236
  {
@@ -5498,7 +5525,7 @@
5498
  "name": "stdout",
5499
  "output_type": "stream",
5500
  "text": [
5501
- "Saved: \\\\notebook_outputs\\\\notebook_baseline_confusion_matrix.png\n"
5502
  ]
5503
  },
5504
  {
@@ -5826,7 +5853,7 @@
5826
  "name": "stdout",
5827
  "output_type": "stream",
5828
  "text": [
5829
- "Saved: \\\\notebook_outputs\\\\notebook_baseline_feature_importance.png\n"
5830
  ]
5831
  },
5832
  {
@@ -6064,14 +6091,14 @@
6064
  "source": [
6065
  "## 13. How this notebook supports the optional documentation package\n",
6066
  "\n",
6067
- "This notebook is useful as an optional supplement because it demonstrates four things that strengthen the submission package:\n",
6068
  "\n",
6069
  "1. **Ability to solve the challenge:** the dataset can be loaded, joined, modeled, and used for immediate in silico toxicity-label prediction experiments. \n",
6070
  "2. **Potential impact:** the source corpus, evidence modules, and information-gap map show how the dataset addresses gaps across oligo modality, chemistry, dose/exposure, liver context, and readout structure. \n",
6071
  "3. **Feasibility and rigor:** the schema, validation summary, relationship checks, and reproducibility manifest make the package inspectable rather than opaque. \n",
6072
  "4. **Transparency and reproducibility:** the notebook uses only the released files, stores derived artifacts locally, and avoids hidden inputs.\n",
6073
  "\n",
6074
- "The notebook should be presented as optional documentation support, not as a substitute for the dataset, schema, data dictionary, validation files, or source/provenance documentation."
6075
  ]
6076
  }
6077
  ],
 
47
  "name": "stdout",
48
  "output_type": "stream",
49
  "text": [
50
+ "Using dataset folder: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\n",
51
+ "Notebook outputs will be written to: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\n"
52
  ]
53
  }
54
  ],
55
  "source": [
56
  "from pathlib import Path\n",
 
 
 
 
 
 
57
  "import json\n",
58
  "import os\n",
59
+ "import sys\n",
60
  "import warnings\n",
61
  "\n",
62
  "import numpy as np\n",
 
69
  "pd.set_option(\"display.max_columns\", 120)\n",
70
  "pd.set_option(\"display.max_colwidth\", 160)\n",
71
  "\n",
72
+ "# Detect Google Colab / cloud environments where the dataset is not in the\n",
73
+ "# current working directory, and auto-download from Hugging Face if so.\n",
74
+ "def locate_dataset():\n",
75
+ " cwd = Path.cwd().resolve()\n",
76
+ " if (cwd / \"oligos.csv\").exists() and (cwd / \"toxicity_readouts.csv\").exists():\n",
77
+ " return cwd\n",
78
+ " is_colab = \"google.colab\" in sys.modules or \"COLAB_GPU\" in os.environ or \"COLAB_RELEASE_TAG\" in os.environ\n",
79
+ " if is_colab or not (cwd / \"oligos.csv\").exists():\n",
80
+ " try:\n",
81
+ " from huggingface_hub import snapshot_download\n",
82
+ " except ImportError:\n",
83
+ " print(\"Installing huggingface_hub for dataset download...\")\n",
84
+ " os.system(f\"{sys.executable} -m pip install --quiet huggingface_hub\")\n",
85
+ " from huggingface_hub import snapshot_download\n",
86
+ " print(\"Downloading dataset from Hugging Face: DBbun/oligotox-phase2-dataset ...\")\n",
87
+ " local_dir = Path(snapshot_download(\n",
88
+ " repo_id=\"DBbun/oligotox-phase2-dataset\",\n",
89
+ " repo_type=\"dataset\",\n",
90
+ " )).resolve()\n",
91
+ " return local_dir\n",
92
+ " return cwd\n",
93
+ "\n",
94
+ "DATA_DIR = locate_dataset()\n",
95
  "\n",
96
  "required_files = [\n",
97
  " \"oligos.csv\",\n",
 
104
  "\n",
105
  "if missing_files:\n",
106
  " raise FileNotFoundError(\n",
107
+ " \"Could not locate dataset files. To run this notebook, either: \"\n",
108
+ " \"(1) run from a folder containing the dataset CSVs, or \"\n",
109
+ " \"(2) ensure huggingface_hub is installed so the dataset can be auto-downloaded. \"\n",
110
  " f\"Missing required file(s): {missing_files}\"\n",
111
  " )\n",
112
  "\n",
113
+ "OUTPUT_DIR = Path.cwd() / \"notebook_outputs\"\n",
114
  "OUTPUT_DIR.mkdir(exist_ok=True)\n",
115
  "\n",
116
+ "# Helper for cleanly displaying file paths in cell outputs\n",
117
+ "def display_output_path(p):\n",
118
+ " try:\n",
119
+ " return str(Path(p).relative_to(Path.cwd()))\n",
120
+ " except ValueError:\n",
121
+ " return str(p)\n",
122
+ "\n",
123
+ "print(f\"Using dataset folder: {DATA_DIR}\")\n",
124
+ "print(f\"Notebook outputs will be written to: {OUTPUT_DIR}\")\n"
125
  ]
126
  },
127
  {
 
4690
  "name": "stdout",
4691
  "output_type": "stream",
4692
  "text": [
4693
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_label_distribution.png\n"
4694
  ]
4695
  },
4696
  {
 
4764
  " path = OUTPUT_DIR / name\n",
4765
  " plt.tight_layout()\n",
4766
  " plt.savefig(path, dpi=160, bbox_inches=\"tight\")\n",
4767
+ " print(f\"Saved: {path}\")\n",
4768
  "\n",
4769
  "# Label distribution.\n",
4770
  "label_counts = readouts[\"hepatotoxicity_label\"].value_counts().reindex([\"low\", \"moderate\", \"high\"])\n",
 
4787
  "name": "stdout",
4788
  "output_type": "stream",
4789
  "text": [
4790
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_risk_score_distribution_by_label.png\n"
4791
  ]
4792
  },
4793
  {
 
4825
  "name": "stdout",
4826
  "output_type": "stream",
4827
  "text": [
4828
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_label_mix_by_modality.png\n"
4829
  ]
4830
  },
4831
  {
 
5015
  "name": "stdout",
5016
  "output_type": "stream",
5017
  "text": [
5018
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_median_risk_over_time.png\n"
5019
  ]
5020
  },
5021
  {
 
5206
  "name": "stdout",
5207
  "output_type": "stream",
5208
  "text": [
5209
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_risk_vs_dose_nM.png\n"
5210
  ]
5211
  },
5212
  {
 
5223
  "name": "stdout",
5224
  "output_type": "stream",
5225
  "text": [
5226
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_risk_vs_phosphorothioate_fraction.png\n"
5227
  ]
5228
  },
5229
  {
 
5240
  "name": "stdout",
5241
  "output_type": "stream",
5242
  "text": [
5243
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_risk_vs_GC_content.png\n"
5244
  ]
5245
  },
5246
  {
 
5257
  "name": "stdout",
5258
  "output_type": "stream",
5259
  "text": [
5260
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_risk_vs_predicted_offtarget_hybridization_burden.png\n"
5261
  ]
5262
  },
5263
  {
 
5525
  "name": "stdout",
5526
  "output_type": "stream",
5527
  "text": [
5528
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_baseline_confusion_matrix.png\n"
5529
  ]
5530
  },
5531
  {
 
5853
  "name": "stdout",
5854
  "output_type": "stream",
5855
  "text": [
5856
+ "Saved: C:\\Users\\karto\\NIH-OligoTox Phase II\\dataset_root\\notebook_outputs\\notebook_baseline_feature_importance.png\n"
5857
  ]
5858
  },
5859
  {
 
6091
  "source": [
6092
  "## 13. How this notebook supports the optional documentation package\n",
6093
  "\n",
6094
+ "This notebook is useful as an optional supplement because it demonstrates four things reviewers often care about:\n",
6095
  "\n",
6096
  "1. **Ability to solve the challenge:** the dataset can be loaded, joined, modeled, and used for immediate in silico toxicity-label prediction experiments. \n",
6097
  "2. **Potential impact:** the source corpus, evidence modules, and information-gap map show how the dataset addresses gaps across oligo modality, chemistry, dose/exposure, liver context, and readout structure. \n",
6098
  "3. **Feasibility and rigor:** the schema, validation summary, relationship checks, and reproducibility manifest make the package inspectable rather than opaque. \n",
6099
  "4. **Transparency and reproducibility:** the notebook uses only the released files, stores derived artifacts locally, and avoids hidden inputs.\n",
6100
  "\n",
6101
+ "The notebook should be presented as optional reviewer support, not as a substitute for the dataset, schema, data dictionary, validation files, or source/provenance documentation."
6102
  ]
6103
  }
6104
  ],