Team Ai
Modelpublic

softwareDevelopment/gene_priortization

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
0likes
Gene_prioritization.ipynb3550 linesDownload Raw Back to root
1{2  "nbformat": 4,3  "nbformat_minor": 0,4  "metadata": {5    "colab": {6      "provenance": []7    },8    "kernelspec": {9      "name": "python3",10      "display_name": "Python 3"11    },12    "language_info": {13      "name": "python"14    },15    "widgets": {16      "application/vnd.jupyter.widget-state+json": {17        "bfbe171b16554c748412ebd0edb7ce04": {18          "model_module": "@jupyter-widgets/controls",19          "model_name": "HBoxModel",20          "model_module_version": "1.5.0",21          "state": {22            "_dom_classes": [],23            "_model_module": "@jupyter-widgets/controls",24            "_model_module_version": "1.5.0",25            "_model_name": "HBoxModel",26            "_view_count": null,27            "_view_module": "@jupyter-widgets/controls",28            "_view_module_version": "1.5.0",29            "_view_name": "HBoxView",30            "box_style": "",31            "children": [32              "IPY_MODEL_be4c6ee1e29e40c39c37f50725f98c4d",33              "IPY_MODEL_4f28b060a18241ef996c1d559b2c03f5",34              "IPY_MODEL_7bbf74b73e3a4398b0352b3c0ca74dc3"35            ],36            "layout": "IPY_MODEL_0eb72e2a124941e0b6f84234e32db09b"37          }38        },39        "be4c6ee1e29e40c39c37f50725f98c4d": {40          "model_module": "@jupyter-widgets/controls",41          "model_name": "HTMLModel",42          "model_module_version": "1.5.0",43          "state": {44            "_dom_classes": [],45            "_model_module": "@jupyter-widgets/controls",46            "_model_module_version": "1.5.0",47            "_model_name": "HTMLModel",48            "_view_count": null,49            "_view_module": "@jupyter-widgets/controls",50            "_view_module_version": "1.5.0",51            "_view_name": "HTMLView",52            "description": "",53            "description_tooltip": null,54            "layout": "IPY_MODEL_7205878e8de5433c806b171a729e719d",55            "placeholder": "​",56            "style": "IPY_MODEL_ebf1f831510b4110b3d9e35de8094154",57            "value": "OS_model.dat: 100%"58          }59        },60        "4f28b060a18241ef996c1d559b2c03f5": {61          "model_module": "@jupyter-widgets/controls",62          "model_name": "FloatProgressModel",63          "model_module_version": "1.5.0",64          "state": {65            "_dom_classes": [],66            "_model_module": "@jupyter-widgets/controls",67            "_model_module_version": "1.5.0",68            "_model_name": "FloatProgressModel",69            "_view_count": null,70            "_view_module": "@jupyter-widgets/controls",71            "_view_module_version": "1.5.0",72            "_view_name": "ProgressView",73            "bar_style": "success",74            "description": "",75            "description_tooltip": null,76            "layout": "IPY_MODEL_5f3fed165f304da2b9b9a50a8b7b44d3",77            "max": 37547444993,78            "min": 0,79            "orientation": "horizontal",80            "style": "IPY_MODEL_9b758e4d9e4149f1b04e52bed42d4b3f",81            "value": 3754744499382          }83        },84        "7bbf74b73e3a4398b0352b3c0ca74dc3": {85          "model_module": "@jupyter-widgets/controls",86          "model_name": "HTMLModel",87          "model_module_version": "1.5.0",88          "state": {89            "_dom_classes": [],90            "_model_module": "@jupyter-widgets/controls",91            "_model_module_version": "1.5.0",92            "_model_name": "HTMLModel",93            "_view_count": null,94            "_view_module": "@jupyter-widgets/controls",95            "_view_module_version": "1.5.0",96            "_view_name": "HTMLView",97            "description": "",98            "description_tooltip": null,99            "layout": "IPY_MODEL_cfdf9acf45884014887a75233213a1f4",100            "placeholder": "​",101            "style": "IPY_MODEL_084b1b4db7a04cfcb6e642e02fedd623",102            "value": " 37.5G/37.5G [15:54&lt;00:00, 33.9MB/s]"103          }104        },105        "0eb72e2a124941e0b6f84234e32db09b": {106          "model_module": "@jupyter-widgets/base",107          "model_name": "LayoutModel",108          "model_module_version": "1.2.0",109          "state": {110            "_model_module": "@jupyter-widgets/base",111            "_model_module_version": "1.2.0",112            "_model_name": "LayoutModel",113            "_view_count": null,114            "_view_module": "@jupyter-widgets/base",115            "_view_module_version": "1.2.0",116            "_view_name": "LayoutView",117            "align_content": null,118            "align_items": null,119            "align_self": null,120            "border": null,121            "bottom": null,122            "display": null,123            "flex": null,124            "flex_flow": null,125            "grid_area": null,126            "grid_auto_columns": null,127            "grid_auto_flow": null,128            "grid_auto_rows": null,129            "grid_column": null,130            "grid_gap": null,131            "grid_row": null,132            "grid_template_areas": null,133            "grid_template_columns": null,134            "grid_template_rows": null,135            "height": null,136            "justify_content": null,137            "justify_items": null,138            "left": null,139            "margin": null,140            "max_height": null,141            "max_width": null,142            "min_height": null,143            "min_width": null,144            "object_fit": null,145            "object_position": null,146            "order": null,147            "overflow": null,148            "overflow_x": null,149            "overflow_y": null,150            "padding": null,151            "right": null,152            "top": null,153            "visibility": null,154            "width": null155          }156        },157        "7205878e8de5433c806b171a729e719d": {158          "model_module": "@jupyter-widgets/base",159          "model_name": "LayoutModel",160          "model_module_version": "1.2.0",161          "state": {162            "_model_module": "@jupyter-widgets/base",163            "_model_module_version": "1.2.0",164            "_model_name": "LayoutModel",165            "_view_count": null,166            "_view_module": "@jupyter-widgets/base",167            "_view_module_version": "1.2.0",168            "_view_name": "LayoutView",169            "align_content": null,170            "align_items": null,171            "align_self": null,172            "border": null,173            "bottom": null,174            "display": null,175            "flex": null,176            "flex_flow": null,177            "grid_area": null,178            "grid_auto_columns": null,179            "grid_auto_flow": null,180            "grid_auto_rows": null,181            "grid_column": null,182            "grid_gap": null,183            "grid_row": null,184            "grid_template_areas": null,185            "grid_template_columns": null,186            "grid_template_rows": null,187            "height": null,188            "justify_content": null,189            "justify_items": null,190            "left": null,191            "margin": null,192            "max_height": null,193            "max_width": null,194            "min_height": null,195            "min_width": null,196            "object_fit": null,197            "object_position": null,198            "order": null,199            "overflow": null,200            "overflow_x": null,201            "overflow_y": null,202            "padding": null,203            "right": null,204            "top": null,205            "visibility": null,206            "width": null207          }208        },209        "ebf1f831510b4110b3d9e35de8094154": {210          "model_module": "@jupyter-widgets/controls",211          "model_name": "DescriptionStyleModel",212          "model_module_version": "1.5.0",213          "state": {214            "_model_module": "@jupyter-widgets/controls",215            "_model_module_version": "1.5.0",216            "_model_name": "DescriptionStyleModel",217            "_view_count": null,218            "_view_module": "@jupyter-widgets/base",219            "_view_module_version": "1.2.0",220            "_view_name": "StyleView",221            "description_width": ""222          }223        },224        "5f3fed165f304da2b9b9a50a8b7b44d3": {225          "model_module": "@jupyter-widgets/base",226          "model_name": "LayoutModel",227          "model_module_version": "1.2.0",228          "state": {229            "_model_module": "@jupyter-widgets/base",230            "_model_module_version": "1.2.0",231            "_model_name": "LayoutModel",232            "_view_count": null,233            "_view_module": "@jupyter-widgets/base",234            "_view_module_version": "1.2.0",235            "_view_name": "LayoutView",236            "align_content": null,237            "align_items": null,238            "align_self": null,239            "border": null,240            "bottom": null,241            "display": null,242            "flex": null,243            "flex_flow": null,244            "grid_area": null,245            "grid_auto_columns": null,246            "grid_auto_flow": null,247            "grid_auto_rows": null,248            "grid_column": null,249            "grid_gap": null,250            "grid_row": null,251            "grid_template_areas": null,252            "grid_template_columns": null,253            "grid_template_rows": null,254            "height": null,255            "justify_content": null,256            "justify_items": null,257            "left": null,258            "margin": null,259            "max_height": null,260            "max_width": null,261            "min_height": null,262            "min_width": null,263            "object_fit": null,264            "object_position": null,265            "order": null,266            "overflow": null,267            "overflow_x": null,268            "overflow_y": null,269            "padding": null,270            "right": null,271            "top": null,272            "visibility": null,273            "width": null274          }275        },276        "9b758e4d9e4149f1b04e52bed42d4b3f": {277          "model_module": "@jupyter-widgets/controls",278          "model_name": "ProgressStyleModel",279          "model_module_version": "1.5.0",280          "state": {281            "_model_module": "@jupyter-widgets/controls",282            "_model_module_version": "1.5.0",283            "_model_name": "ProgressStyleModel",284            "_view_count": null,285            "_view_module": "@jupyter-widgets/base",286            "_view_module_version": "1.2.0",287            "_view_name": "StyleView",288            "bar_color": null,289            "description_width": ""290          }291        },292        "cfdf9acf45884014887a75233213a1f4": {293          "model_module": "@jupyter-widgets/base",294          "model_name": "LayoutModel",295          "model_module_version": "1.2.0",296          "state": {297            "_model_module": "@jupyter-widgets/base",298            "_model_module_version": "1.2.0",299            "_model_name": "LayoutModel",300            "_view_count": null,301            "_view_module": "@jupyter-widgets/base",302            "_view_module_version": "1.2.0",303            "_view_name": "LayoutView",304            "align_content": null,305            "align_items": null,306            "align_self": null,307            "border": null,308            "bottom": null,309            "display": null,310            "flex": null,311            "flex_flow": null,312            "grid_area": null,313            "grid_auto_columns": null,314            "grid_auto_flow": null,315            "grid_auto_rows": null,316            "grid_column": null,317            "grid_gap": null,318            "grid_row": null,319            "grid_template_areas": null,320            "grid_template_columns": null,321            "grid_template_rows": null,322            "height": null,323            "justify_content": null,324            "justify_items": null,325            "left": null,326            "margin": null,327            "max_height": null,328            "max_width": null,329            "min_height": null,330            "min_width": null,331            "object_fit": null,332            "object_position": null,333            "order": null,334            "overflow": null,335            "overflow_x": null,336            "overflow_y": null,337            "padding": null,338            "right": null,339            "top": null,340            "visibility": null,341            "width": null342          }343        },344        "084b1b4db7a04cfcb6e642e02fedd623": {345          "model_module": "@jupyter-widgets/controls",346          "model_name": "DescriptionStyleModel",347          "model_module_version": "1.5.0",348          "state": {349            "_model_module": "@jupyter-widgets/controls",350            "_model_module_version": "1.5.0",351            "_model_name": "DescriptionStyleModel",352            "_view_count": null,353            "_view_module": "@jupyter-widgets/base",354            "_view_module_version": "1.2.0",355            "_view_name": "StyleView",356            "description_width": ""357          }358        }359      }360    }361  },362  "cells": [363    {364      "cell_type": "markdown",365      "source": [366        "# 🧬 QTL Causal Gene Ranker\n",367        "\n",368        "Welcome! This tool ranks candidate causal genes within your QTL regions.\n",369        "\n",370        "**How to use:**\n",371        "1.   **Upload your data:** Use the file uploader on the right.\n",372        "2.   **Run the tool:** Click the play button ▶️ in the \"Run the Ranker\" section.\n",373        "3.   **Download results:** Your ranked gene list will download automatically.\n",374        "\n",375        "---"376      ],377      "metadata": {378        "id": "hB7rGRFldJSi"379      }380    },381    {382      "cell_type": "code",383      "source": [384        "pip install huggingface_hub"385      ],386      "metadata": {387        "colab": {388          "base_uri": "https://localhost:8080/"389        },390        "id": "Lt27bHti_wfZ",391        "outputId": "d8cec4da-25e0-48d1-ec41-5a39b7087820"392      },393      "execution_count": null,394      "outputs": [395        {396          "output_type": "stream",397          "name": "stdout",398          "text": [399            "Requirement already satisfied: huggingface_hub in /usr/local/lib/python3.12/dist-packages (0.34.4)\n",400            "Requirement already satisfied: filelock in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (3.19.1)\n",401            "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (2025.3.0)\n",402            "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (25.0)\n",403            "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (6.0.2)\n",404            "Requirement already satisfied: requests in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (2.32.4)\n",405            "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (4.67.1)\n",406            "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (4.15.0)\n",407            "Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (1.1.9)\n",408            "Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests->huggingface_hub) (3.4.3)\n",409            "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests->huggingface_hub) (3.10)\n",410            "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests->huggingface_hub) (2.5.0)\n",411            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests->huggingface_hub) (2025.8.3)\n"412          ]413        }414      ]415    },416    {417      "cell_type": "code",418      "source": [419        "# First install required packages\n",420        "!pip install transformers huggingface_hub\n",421        "\n",422        "from huggingface_hub import hf_hub_download\n",423        "import joblib\n",424        "\n",425        "# Download the model\n",426        "model_path = hf_hub_download(\n",427        "    repo_id=\"IRRI-SAH/Rice\",\n",428        "    filename=\"OS_model.dat\",\n",429        "      # Remove this if it's a public model\n",430        ")\n",431        "\n",432        "# Load the model (assuming it's a scikit-learn model saved with joblib)\n",433        "model = joblib.load(model_path)\n",434        "print(\"Model loaded successfully!\")"435      ],436      "metadata": {437        "colab": {438          "base_uri": "https://localhost:8080/",439          "height": 503,440          "referenced_widgets": [441            "bfbe171b16554c748412ebd0edb7ce04",442            "be4c6ee1e29e40c39c37f50725f98c4d",443            "4f28b060a18241ef996c1d559b2c03f5",444            "7bbf74b73e3a4398b0352b3c0ca74dc3",445            "0eb72e2a124941e0b6f84234e32db09b",446            "7205878e8de5433c806b171a729e719d",447            "ebf1f831510b4110b3d9e35de8094154",448            "5f3fed165f304da2b9b9a50a8b7b44d3",449            "9b758e4d9e4149f1b04e52bed42d4b3f",450            "cfdf9acf45884014887a75233213a1f4",451            "084b1b4db7a04cfcb6e642e02fedd623"452          ]453        },454        "id": "1dd-ZQyyLg0T",455        "outputId": "0a5720e4-b77d-4811-f90a-c6804015b319"456      },457      "execution_count": null,458      "outputs": [459        {460          "output_type": "stream",461          "name": "stdout",462          "text": [463            "Requirement already satisfied: transformers in /usr/local/lib/python3.12/dist-packages (4.56.1)\n",464            "Requirement already satisfied: huggingface_hub in /usr/local/lib/python3.12/dist-packages (0.34.4)\n",465            "Requirement already satisfied: filelock in /usr/local/lib/python3.12/dist-packages (from transformers) (3.19.1)\n",466            "Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.12/dist-packages (from transformers) (2.0.2)\n",467            "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.12/dist-packages (from transformers) (25.0)\n",468            "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.12/dist-packages (from transformers) (6.0.2)\n",469            "Requirement already satisfied: regex!=2019.12.17 in /usr/local/lib/python3.12/dist-packages (from transformers) (2024.11.6)\n",470            "Requirement already satisfied: requests in /usr/local/lib/python3.12/dist-packages (from transformers) (2.32.4)\n",471            "Requirement already satisfied: tokenizers<=0.23.0,>=0.22.0 in /usr/local/lib/python3.12/dist-packages (from transformers) (0.22.0)\n",472            "Requirement already satisfied: safetensors>=0.4.3 in /usr/local/lib/python3.12/dist-packages (from transformers) (0.6.2)\n",473            "Requirement already satisfied: tqdm>=4.27 in /usr/local/lib/python3.12/dist-packages (from transformers) (4.67.1)\n",474            "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (2025.3.0)\n",475            "Requirement already satisfied: typing-extensions>=3.7.4.3 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (4.15.0)\n",476            "Requirement already satisfied: hf-xet<2.0.0,>=1.1.3 in /usr/local/lib/python3.12/dist-packages (from huggingface_hub) (1.1.9)\n",477            "Requirement already satisfied: charset_normalizer<4,>=2 in /usr/local/lib/python3.12/dist-packages (from requests->transformers) (3.4.3)\n",478            "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/dist-packages (from requests->transformers) (3.10)\n",479            "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/dist-packages (from requests->transformers) (2.5.0)\n",480            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/dist-packages (from requests->transformers) (2025.8.3)\n"481          ]482        },483        {484          "output_type": "stream",485          "name": "stderr",486          "text": [487            "/usr/local/lib/python3.12/dist-packages/huggingface_hub/utils/_auth.py:94: UserWarning: \n",488            "The secret `HF_TOKEN` does not exist in your Colab secrets.\n",489            "To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n",490            "You will be able to reuse this secret in all of your notebooks.\n",491            "Please note that authentication is recommended but still optional to access public models or datasets.\n",492            "  warnings.warn(\n"493          ]494        },495        {496          "output_type": "display_data",497          "data": {498            "text/plain": [499              "OS_model.dat:   0%|          | 0.00/37.5G [00:00<?, ?B/s]"500            ],501            "application/vnd.jupyter.widget-view+json": {502              "version_major": 2,503              "version_minor": 0,504              "model_id": "bfbe171b16554c748412ebd0edb7ce04"505            }506          },507          "metadata": {}508        },509        {510          "output_type": "stream",511          "name": "stdout",512          "text": [513            "Model loaded successfully!\n"514          ]515        }516      ]517    },518    {519      "cell_type": "markdown",520      "source": [521        "Checking the directory"522      ],523      "metadata": {524        "id": "zfURH10JZMXc"525      }526    },527    {528      "cell_type": "code",529      "source": [530        "!ls -lh /content/"531      ],532      "metadata": {533        "colab": {534          "base_uri": "https://localhost:8080/"535        },536        "id": "P9r7FtE_PP0h",537        "outputId": "cc4fb1fb-0682-472b-cf5e-39cde41bb4e8"538      },539      "execution_count": null,540      "outputs": [541        {542          "output_type": "stream",543          "name": "stdout",544          "text": [545            "total 4.0K\n",546            "drwxr-xr-x 1 root root 4.0K Sep  9 13:46 sample_data\n"547          ]548        }549      ]550    },551    {552      "cell_type": "markdown",553      "source": [554        "Importing the model"555      ],556      "metadata": {557        "id": "mI8v86AfZPtm"558      }559    },560    {561      "cell_type": "code",562      "source": [563        "from huggingface_hub import hf_hub_download\n",564        "model_path = hf_hub_download(repo_id=\"IRRI-SAH/Rice\", filename=\"OS_model.dat\")\n",565        "print(model_path)"566      ],567      "metadata": {568        "colab": {569          "base_uri": "https://localhost:8080/"570        },571        "id": "eo3FyTHPQb6w",572        "outputId": "4eb93b03-e69f-4c1c-d60c-f29399f6548f"573      },574      "execution_count": null,575      "outputs": [576        {577          "output_type": "stream",578          "name": "stdout",579          "text": [580            "/root/.cache/huggingface/hub/models--IRRI-SAH--Rice/snapshots/abb2b0fe1abbc136064c530b452626f331e7962f/OS_model.dat\n"581          ]582        }583      ]584    },585    {586      "cell_type": "markdown",587      "source": [588        "Anaconda environment"589      ],590      "metadata": {591        "id": "WCaGXA6iZSwh"592      }593    },594    {595      "cell_type": "code",596      "source": [597        "!wget -q https://repo.anaconda.com/miniconda/Miniconda3-py38_4.12.0-Linux-x86_64.sh\n",598        "!bash Miniconda3-py38_4.12.0-Linux-x86_64.sh -b -p /content/miniconda\n",599        "!rm Miniconda3-py38_4.12.0-Linux-x86_64.sh\n",600        "!/content/miniconda/bin/conda install -y scikit-learn=0.21.2 pandas=1.0.5 numpy=1.18.5"601      ],602      "metadata": {603        "colab": {604          "base_uri": "https://localhost:8080/"605        },606        "id": "Es6OiOveWdRk",607        "outputId": "c76b6c02-2e97-4e93-8bc7-1c69d71d1ee5"608      },609      "execution_count": null,610      "outputs": [611        {612          "output_type": "stream",613          "name": "stdout",614          "text": [615            "PREFIX=/content/miniconda\n",616            "Unpacking payload ...\n",617            "Collecting package metadata (current_repodata.json): - \b\b\\ \b\bdone\n",618            "Solving environment: / \b\b- \b\b\\ \b\bdone\n",619            "\n",620            "## Package Plan ##\n",621            "\n",622            "  environment location: /content/miniconda\n",623            "\n",624            "  added / updated specs:\n",625            "    - _libgcc_mutex==0.1=main\n",626            "    - _openmp_mutex==4.5=1_gnu\n",627            "    - brotlipy==0.7.0=py38h27cfd23_1003\n",628            "    - ca-certificates==2022.3.29=h06a4308_1\n",629            "    - certifi==2021.10.8=py38h06a4308_2\n",630            "    - cffi==1.15.0=py38hd667e15_1\n",631            "    - charset-normalizer==2.0.4=pyhd3eb1b0_0\n",632            "    - colorama==0.4.4=pyhd3eb1b0_0\n",633            "    - conda-content-trust==0.1.1=pyhd3eb1b0_0\n",634            "    - conda-package-handling==1.8.1=py38h7f8727e_0\n",635            "    - conda==4.12.0=py38h06a4308_0\n",636            "    - cryptography==36.0.0=py38h9ce1e76_0\n",637            "    - idna==3.3=pyhd3eb1b0_0\n",638            "    - ld_impl_linux-64==2.35.1=h7274673_9\n",639            "    - libffi==3.3=he6710b0_2\n",640            "    - libgcc-ng==9.3.0=h5101ec6_17\n",641            "    - libgomp==9.3.0=h5101ec6_17\n",642            "    - libstdcxx-ng==9.3.0=hd4cf53a_17\n",643            "    - ncurses==6.3=h7f8727e_2\n",644            "    - openssl==1.1.1n=h7f8727e_0\n",645            "    - pip==21.2.4=py38h06a4308_0\n",646            "    - pycosat==0.6.3=py38h7b6447c_1\n",647            "    - pycparser==2.21=pyhd3eb1b0_0\n",648            "    - pyopenssl==22.0.0=pyhd3eb1b0_0\n",649            "    - pysocks==1.7.1=py38h06a4308_0\n",650            "    - python==3.8.13=h12debd9_0\n",651            "    - readline==8.1.2=h7f8727e_1\n",652            "    - requests==2.27.1=pyhd3eb1b0_0\n",653            "    - ruamel_yaml==0.15.100=py38h27cfd23_0\n",654            "    - setuptools==61.2.0=py38h06a4308_0\n",655            "    - six==1.16.0=pyhd3eb1b0_1\n",656            "    - sqlite==3.38.2=hc218d9a_0\n",657            "    - tk==8.6.11=h1ccaba5_0\n",658            "    - tqdm==4.63.0=pyhd3eb1b0_0\n",659            "    - urllib3==1.26.8=pyhd3eb1b0_0\n",660            "    - wheel==0.37.1=pyhd3eb1b0_0\n",661            "    - xz==5.2.5=h7b6447c_0\n",662            "    - yaml==0.2.5=h7b6447c_0\n",663            "    - zlib==1.2.12=h7f8727e_1\n",664            "\n",665            "\n",666            "The following NEW packages will be INSTALLED:\n",667            "\n",668            "  _libgcc_mutex      pkgs/main/linux-64::_libgcc_mutex-0.1-main\n",669            "  _openmp_mutex      pkgs/main/linux-64::_openmp_mutex-4.5-1_gnu\n",670            "  brotlipy           pkgs/main/linux-64::brotlipy-0.7.0-py38h27cfd23_1003\n",671            "  ca-certificates    pkgs/main/linux-64::ca-certificates-2022.3.29-h06a4308_1\n",672            "  certifi            pkgs/main/linux-64::certifi-2021.10.8-py38h06a4308_2\n",673            "  cffi               pkgs/main/linux-64::cffi-1.15.0-py38hd667e15_1\n",674            "  charset-normalizer pkgs/main/noarch::charset-normalizer-2.0.4-pyhd3eb1b0_0\n",675            "  colorama           pkgs/main/noarch::colorama-0.4.4-pyhd3eb1b0_0\n",676            "  conda              pkgs/main/linux-64::conda-4.12.0-py38h06a4308_0\n",677            "  conda-content-tru~ pkgs/main/noarch::conda-content-trust-0.1.1-pyhd3eb1b0_0\n",678            "  conda-package-han~ pkgs/main/linux-64::conda-package-handling-1.8.1-py38h7f8727e_0\n",679            "  cryptography       pkgs/main/linux-64::cryptography-36.0.0-py38h9ce1e76_0\n",680            "  idna               pkgs/main/noarch::idna-3.3-pyhd3eb1b0_0\n",681            "  ld_impl_linux-64   pkgs/main/linux-64::ld_impl_linux-64-2.35.1-h7274673_9\n",682            "  libffi             pkgs/main/linux-64::libffi-3.3-he6710b0_2\n",683            "  libgcc-ng          pkgs/main/linux-64::libgcc-ng-9.3.0-h5101ec6_17\n",684            "  libgomp            pkgs/main/linux-64::libgomp-9.3.0-h5101ec6_17\n",685            "  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-9.3.0-hd4cf53a_17\n",686            "  ncurses            pkgs/main/linux-64::ncurses-6.3-h7f8727e_2\n",687            "  openssl            pkgs/main/linux-64::openssl-1.1.1n-h7f8727e_0\n",688            "  pip                pkgs/main/linux-64::pip-21.2.4-py38h06a4308_0\n",689            "  pycosat            pkgs/main/linux-64::pycosat-0.6.3-py38h7b6447c_1\n",690            "  pycparser          pkgs/main/noarch::pycparser-2.21-pyhd3eb1b0_0\n",691            "  pyopenssl          pkgs/main/noarch::pyopenssl-22.0.0-pyhd3eb1b0_0\n",692            "  pysocks            pkgs/main/linux-64::pysocks-1.7.1-py38h06a4308_0\n",693            "  python             pkgs/main/linux-64::python-3.8.13-h12debd9_0\n",694            "  readline           pkgs/main/linux-64::readline-8.1.2-h7f8727e_1\n",695            "  requests           pkgs/main/noarch::requests-2.27.1-pyhd3eb1b0_0\n",696            "  ruamel_yaml        pkgs/main/linux-64::ruamel_yaml-0.15.100-py38h27cfd23_0\n",697            "  setuptools         pkgs/main/linux-64::setuptools-61.2.0-py38h06a4308_0\n",698            "  six                pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_1\n",699            "  sqlite             pkgs/main/linux-64::sqlite-3.38.2-hc218d9a_0\n",700            "  tk                 pkgs/main/linux-64::tk-8.6.11-h1ccaba5_0\n",701            "  tqdm               pkgs/main/noarch::tqdm-4.63.0-pyhd3eb1b0_0\n",702            "  urllib3            pkgs/main/noarch::urllib3-1.26.8-pyhd3eb1b0_0\n",703            "  wheel              pkgs/main/noarch::wheel-0.37.1-pyhd3eb1b0_0\n",704            "  xz                 pkgs/main/linux-64::xz-5.2.5-h7b6447c_0\n",705            "  yaml               pkgs/main/linux-64::yaml-0.2.5-h7b6447c_0\n",706            "  zlib               pkgs/main/linux-64::zlib-1.2.12-h7f8727e_1\n",707            "\n",708            "\n",709            "Preparing transaction: / \b\b- \b\b\\ \b\b| \b\bdone\n",710            "Executing transaction: - \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\bdone\n",711            "installation finished.\n",712            "WARNING:\n",713            "    You currently have a PYTHONPATH environment variable set. This may cause\n",714            "    unexpected behavior when running the Python interpreter in Miniconda3.\n",715            "    For best results, please verify that your PYTHONPATH only points to\n",716            "    directories of packages that are compatible with the Python interpreter\n",717            "    in Miniconda3: /content/miniconda\n",718            "Collecting package metadata (current_repodata.json): - \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\bdone\n",719            "Solving environment: - \b\bfailed with initial frozen solve. Retrying with flexible solve.\n",720            "Collecting package metadata (repodata.json): | \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\bdone\n",721            "Solving environment: / \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \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\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\bfailed with initial frozen solve. Retrying with flexible solve.\n",722            "Solving environment: | \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b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 \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \b\b/ \b\b- \b\b\\ \b\b| \n",723            "Found conflicts! Looking for incompatible packages.\n",724            "This can take several minutes.  Press CTRL-C to abort.\n",725            "\b\bfailed\n",726            "\n",727            "UnsatisfiableError: The following specifications were found\n",728            "to be incompatible with the existing python installation in your environment:\n",729            "\n",730            "Specifications:\n",731            "\n",732            "  - numpy=1.18.5 -> python[version='>=2.7,<2.8.0a0|>=3.10,<3.11.0a0|>=3.11,<3.12.0a0|>=3.13,<3.14.0a0|>=3.12,<3.13.0a0|>=3.9,<3.10.0a0|>=3.5,<3.6.0a0']\n",733            "  - pandas=1.0.5 -> python[version='>=2.7,<2.8.0a0|>=3.10,<3.11.0a0|>=3.9,<3.10.0a0|>=3.11,<3.12.0a0|>=3.12,<3.13.0a0|>=3.5,<3.6.0a0|>=3.13,<3.14.0a0']\n",734            "  - scikit-learn=0.21.2 -> python[version='>=3.6,<3.7.0a0|>=3.7,<3.8.0a0']\n",735            "\n",736            "Your python: python=3.8\n",737            "\n",738            "If python is on the left-most side of the chain, that's the version you've asked for.\n",739            "When python appears to the right, that indicates that the thing on the left is somehow\n",740            "not available for the python version you are constrained to. Note that conda will not\n",741            "change your python version to a different minor version unless you explicitly specify\n",742            "that.\n",743            "\n",744            "The following specifications were found to be incompatible with each other:\n",745            "\n",746            "Output in format: Requested package -> Available versions\n",747            "\n",748            "Package setuptools conflicts for:\n",749            "scikit-learn=0.21.2 -> joblib[version='>=0.11'] -> setuptools\n",750            "python=3.8 -> pip -> setuptools\n",751            "\n",752            "Package intel-openmp conflicts for:\n",753            "scikit-learn=0.21.2 -> mkl[version='>=2019.4,<2021.0a0'] -> intel-openmp[version='>=2021.4.0,<2022.0a0|>=2023.1.0,<2024.0a0']\n",754            "numpy=1.18.5 -> mkl[version='>=2019.4,<2021.0a0'] -> intel-openmp\n",755            "\n",756            "Package numpy conflicts for:\n",757            "pandas=1.0.5 -> numpy[version='>=1.14.6,<2.0a0']\n",758            "scikit-learn=0.21.2 -> numpy[version='>=1.11.3,<2.0a0']\n",759            "scikit-learn=0.21.2 -> scipy -> numpy[version='>=1.14.6,<2.0a0|>=1.16,<1.23|>=1.19,<1.25.0|>=1.19,<1.26.0|>=1.19,<3|>=1.21,<3|>=1.25.2,<2.6|>=1.23.5,<2.5|>=1.23.5,<2.3|>=1.22.4,<2.3|>=1.23.5,<1.29|>=1.26.4,<1.29|>=1.22.3,<1.29|>=1.22.4,<1.29|>=1.26.2,<1.28|>=1.21.5,<1.28|>=1.23.5,<1.28|>=1.26.0,<1.28|>=1.19.5,<1.27.0|>=1.23,<1.27.0|>=1.21,<1.27.0|>=1.21,<1.26.0|>=1.23,<1.26.0|>=1.21,<1.25.0|>=1.21,<1.23|>=1.16.6,<1.23.0|>=1.21.2,<1.23.0|>=1.16.6,<2.0a0|>=1.15.1,<2.0a0|>=1.9.3,<2.0a0']The following specifications were found to be incompatible with your system:\n",760            "\n",761            "  - feature:/linux-64::__glibc==2.35=0\n",762            "  - feature:|@/linux-64::__glibc==2.35=0\n",763            "  - numpy=1.18.5 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17|>=2.28,<3.0.a0']\n",764            "  - pandas=1.0.5 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17|>=2.28,<3.0.a0']\n",765            "  - scikit-learn=0.21.2 -> libgcc-ng[version='>=7.3.0'] -> __glibc[version='>=2.17,<3.0.a0|>=2.17|>=2.28,<3.0.a0']\n",766            "\n",767            "Your installed version is: 2.35\n",768            "\n",769            "\n"770          ]771        }772      ]773    },774    {775      "cell_type": "markdown",776      "source": [777        "Anaconda environment"778      ],779      "metadata": {780        "id": "Rm_SR8dBZWnL"781      }782    },783    {784      "cell_type": "code",785      "source": [786        "import os\n",787        "os.environ[\"PATH\"] = \"/content/miniconda/bin:\" + os.environ[\"PATH\"]"788      ],789      "metadata": {790        "id": "iqFd5wKSYHu5"791      },792      "execution_count": null,793      "outputs": []794    },795    {796      "cell_type": "markdown",797      "source": [798        "Running the model"799      ],800      "metadata": {801        "id": "V4-xANEiZZo1"802      }803    },804    {805      "cell_type": "code",806      "source": [807        "#!/usr/bin/python\n",808        "\n",809        "# Version 2.0\n",810        "# last update: 20200131\n",811        "# Purpose: Use for ranking causal genes in QTL regions with enhanced visualizations.\n",812        "# Usage: Run interactively in Colab – uploads gene input file from local system.\n",813        "# Note: OS_model.dat is loaded from Hugging Face Hub path.\n",814        "\n",815        "import numpy as np\n",816        "import pandas as pd\n",817        "import sklearn\n",818        "import time\n",819        "import itertools as it\n",820        "import joblib\n",821        "import os\n",822        "import requests\n",823        "import matplotlib.pyplot as plt\n",824        "import seaborn as sns\n",825        "from google.colab import files\n",826        "from sklearn.ensemble import RandomForestClassifier\n",827        "from imblearn.over_sampling import SMOTE  # For handling class imbalance\n",828        "\n",829        "print(\"sklearn__version\", sklearn.__version__)\n",830        "print(\"pandas__version\", pd.__version__)\n",831        "print(\"numpy__version\", np.__version__)\n",832        "\n",833        "def get_pathways(gene_id):\n",834        "    \"\"\"\n",835        "    Fetch pathways for a rice gene using KEGG REST API.\n",836        "    Assumes gene_id is in format like 'Os01g01010'.\n",837        "    \"\"\"\n",838        "    try:\n",839        "        url = f\"https://rest.kegg.jp/link/pathway/osa:{gene_id}\"\n",840        "        response = requests.get(url)\n",841        "        if response.status_code == 200:\n",842        "            lines = response.text.strip().split('\\n')\n",843        "            if lines[0] == '':\n",844        "                return 'No pathways found'\n",845        "            pathways = [line.split('\\t')[1] for line in lines]\n",846        "            return '; '.join(pathways)\n",847        "        else:\n",848        "            return 'No pathways found'\n",849        "    except Exception as e:\n",850        "        print(f\"Error fetching pathways for {gene_id}: {e}\")\n",851        "        return 'Error'\n",852        "\n",853        "def train_qtg(df, Validation_set_i, pik_f):\n",854        "    global QTL_name, Validation_set_ID_uni, gene_ex, feat_names\n",855        "    prediction_list = (len(Validation_set_i)) * [0]\n",856        "    validation_feature_all = Validation_set_i.drop(['class'], axis=1, errors='ignore')\n",857        "\n",858        "    if len(validation_feature_all) > 0:\n",859        "        try:\n",860        "            print(\"Validation features shape:\", validation_feature_all.shape)\n",861        "            print(\"Validation features columns:\", validation_feature_all.columns)\n",862        "\n",863        "            # Load model or train new one\n",864        "            model_obj = joblib.load(pik_f)\n",865        "\n",866        "            if isinstance(model_obj, pd.DataFrame):\n",867        "                print(\"OS_model.dat is a DataFrame, training a new RandomForestClassifier...\")\n",868        "                print(\"Training DataFrame columns:\", df.columns)\n",869        "                print(\"Class distribution:\\n\", df['class'].value_counts() if 'class' in df.columns else \"No 'class' column\")\n",870        "                X_train = df.drop(['class', 'ID'], axis=1, errors='ignore')\n",871        "                y_train = df['class']\n",872        "                if X_train.empty or y_train.empty:\n",873        "                    raise ValueError(\"Training data is empty. Check DataFrame columns and data.\")\n",874        "                # Align validation features with training features\n",875        "                common_cols = X_train.columns.intersection(validation_feature_all.columns)\n",876        "                if len(common_cols) == 0:\n",877        "                    raise ValueError(\"No common features between training and validation data.\")\n",878        "                X_train = X_train[common_cols]\n",879        "                validation_feature_all = validation_feature_all[common_cols]\n",880        "                print(\"Common features:\", common_cols)\n",881        "\n",882        "                # Apply SMOTE to balance classes\n",883        "                smote = SMOTE(random_state=42)\n",884        "                X_train_balanced, y_train_balanced = smote.fit_resample(X_train, y_train)\n",885        "                print(\"Balanced class distribution:\\n\", pd.Series(y_train_balanced).value_counts())\n",886        "\n",887        "                model = RandomForestClassifier(n_estimators=100, random_state=42, class_weight='balanced_subsample')\n",888        "                model.fit(X_train_balanced, y_train_balanced)\n",889        "                print(\"Model trained successfully.\")\n",890        "                feat_names = X_train.columns.tolist()\n",891        "            else:\n",892        "                print(\"Using pre-trained model from OS_model.dat...\")\n",893        "                model = model_obj\n",894        "                # Check feature compatibility\n",895        "                if hasattr(model, 'feature_names_in_'):\n",896        "                    expected_cols = model.feature_names_in_\n",897        "                    common_cols = validation_feature_all.columns.intersection(expected_cols)\n",898        "                    if len(common_cols) == 0:\n",899        "                        raise ValueError(\"Validation features do not match model features.\")\n",900        "                    validation_feature_all = validation_feature_all[common_cols]\n",901        "                    print(\"Using model features:\", common_cols)\n",902        "                    feat_names = expected_cols.tolist()\n",903        "                else:\n",904        "                    raise ValueError(\"Model does not have feature names.\")\n",905        "\n",906        "            # Predict probabilities\n",907        "            validation_pred = model.predict_proba(validation_feature_all)[:, 1]\n",908        "            print(\"Prediction probabilities:\", validation_pred)\n",909        "            if np.all(validation_pred == 0):\n",910        "                print(\"Warning: All prediction probabilities are 0. Falling back to default scores.\")\n",911        "                validation_pred = np.full_like(validation_pred, 0.5)  # Default to 0.5\n",912        "            prediction_list = validation_pred\n",913        "            prediction_list_all = np.array(prediction_list)\n",914        "            Ranks = prediction_list_all.argsort()[::-1].argsort()\n",915        "            prediction_list_freq = prediction_list\n",916        "            rank_list_df = pd.DataFrame({'ID': Validation_set_ID_uni, 'freq': prediction_list_freq})\n",917        "\n",918        "            for i in gene_ex:\n",919        "                rank_list_df = pd.concat([rank_list_df, pd.DataFrame([{'ID': i, 'freq': 0}])], ignore_index=True)\n",920        "            rank_list_df['Rank'] = rank_list_df['freq'].rank(ascending=0, method='average')\n",921        "            rank_list_df_sorted = rank_list_df.sort_values(by=['Rank'], ascending=True)\n",922        "            rank_list_df_sorted = rank_list_df_sorted.reset_index(drop=True)\n",923        "\n",924        "            # Add pathways\n",925        "            print(\"Fetching pathways for genes...\")\n",926        "            rank_list_df_sorted['Pathways'] = rank_list_df_sorted['ID'].apply(get_pathways)\n",927        "            print(\"Ranked genes with pathways:\\n\", rank_list_df_sorted[['ID', 'Rank', 'freq', 'Pathways']])\n",928        "\n",929        "            # Visualization 1: Ranked genes\n",930        "            plt.figure(figsize=(12, 8))\n",931        "            top_n = min(20, len(rank_list_df_sorted))\n",932        "            top_genes = rank_list_df_sorted.head(top_n)\n",933        "            plt.barh(range(top_n), top_genes['freq'])\n",934        "            plt.yticks(range(top_n), [f\"{id_}\\n({pathways[:30]}...)\" if len(str(top_genes['Pathways'].iloc[i])) > 30 else f\"{id_}\\n({top_genes['Pathways'].iloc[i]})\" for i, id_ in enumerate(top_genes['ID'])])\n",935        "            plt.xlabel('Prediction Score')\n",936        "            plt.title(f'Top {top_n} Ranked Genes for QTL: {QTL_name}\\n(with Pathways)')\n",937        "            plt.gca().invert_yaxis()\n",938        "            plt.tight_layout()\n",939        "            plt.savefig(f'/content/{QTL_name.replace(\"/\", \"_\")}_ranked_genes.png', dpi=300, bbox_inches='tight')\n",940        "            plt.show()\n",941        "\n",942        "            # Visualization 2: Feature Importances\n",943        "            if hasattr(model, 'feature_importances_'):\n",944        "                importances = model.feature_importances_\n",945        "                indices = np.argsort(importances)[::-1][:20]  # Top 20\n",946        "                plt.figure(figsize=(12, 8))\n",947        "                plt.title(f'Top 20 Feature Importances for QTL: {QTL_name}\\n(Criteria used for gene prioritization)')\n",948        "                plt.bar(range(len(indices)), importances[indices])\n",949        "                plt.xticks(range(len(indices)), [feat_names[i] for i in indices], rotation=90)\n",950        "                plt.xlabel('Features')\n",951        "                plt.ylabel('Importance')\n",952        "                plt.tight_layout()\n",953        "                plt.savefig(f'/content/{QTL_name.replace(\"/\", \"_\")}_feature_importances.png', dpi=300, bbox_inches='tight')\n",954        "                plt.show()\n",955        "            else:\n",956        "                print(\"Model does not support feature importances visualization.\")\n",957        "\n",958        "            # Visualization 3: Feature Correlation Heatmap\n",959        "            plt.figure(figsize=(10, 8))\n",960        "            corr_matrix = validation_feature_all.corr()\n",961        "            sns.heatmap(corr_matrix, annot=False, cmap='coolwarm', vmin=-1, vmax=1)\n",962        "            plt.title(f'Feature Correlation Heatmap for QTL: {QTL_name}')\n",963        "            plt.tight_layout()\n",964        "            plt.savefig(f'/content/{QTL_name.replace(\"/\", \"_\")}_correlation_heatmap.png', dpi=300, bbox_inches='tight')\n",965        "            plt.show()\n",966        "\n",967        "            # Visualization 4: Prediction Score Distribution\n",968        "            plt.figure(figsize=(10, 6))\n",969        "            plt.hist(rank_list_df_sorted['freq'], bins=20, edgecolor='black')\n",970        "            plt.title(f'Prediction Score Distribution for QTL: {QTL_name}')\n",971        "            plt.xlabel('Prediction Score')\n",972        "            plt.ylabel('Frequency')\n",973        "            plt.tight_layout()\n",974        "            plt.savefig(f'/content/{QTL_name.replace(\"/\", \"_\")}_score_distribution.png', dpi=300, bbox_inches='tight')\n",975        "            plt.show()\n",976        "\n",977        "            # Visualization 5: Feature Importance vs. Prediction Score Scatter\n",978        "            if hasattr(model, 'feature_importances_'):\n",979        "                top_feature_idx = np.argmax(importances)\n",980        "                top_feature_name = feat_names[top_feature_idx]\n",981        "                top_feature_values = validation_feature_all[top_feature_name]\n",982        "                plt.figure(figsize=(10, 6))\n",983        "                plt.scatter(top_feature_values, validation_pred, alpha=0.6)\n",984        "                plt.title(f'Top Feature ({top_feature_name}) vs. Prediction Score\\nfor QTL: {QTL_name}')\n",985        "                plt.xlabel(top_feature_name)\n",986        "                plt.ylabel('Prediction Score')\n",987        "                plt.tight_layout()\n",988        "                plt.savefig(f'/content/{QTL_name.replace(\"/\", \"_\")}_feature_vs_score.png', dpi=300, bbox_inches='tight')\n",989        "                plt.show()\n",990        "            else:\n",991        "                print(\"Cannot generate feature vs. score scatter plot without feature importances.\")\n",992        "\n",993        "        except Exception as e:\n",994        "            print(f\"Error in prediction: {e}\")\n",995        "            raise\n",996        "    else:\n",997        "        print(\"No valid validation features found.\")\n",998        "        if len(gene_ex) != 0:\n",999        "            rank_list_df_sorted = pd.DataFrame({'ID': list(gene_ex), 'freq': ['NA'] * len(gene_ex), 'Rank': ['NA'] * len(gene_ex)})\n",1000        "            # Add pathways\n",1001        "            print(\"Fetching pathways for genes...\")\n",1002        "            rank_list_df_sorted['Pathways'] = rank_list_df_sorted['ID'].apply(get_pathways)\n",1003        "            print(\"Ranked genes with pathways:\\n\", rank_list_df_sorted)\n",1004        "\n",1005        "    with open('/content/QTL_gene_rank.csv', 'a') as indenti_f:\n",1006        "        indenti_f.write('//' + '\\n' + QTL_name + '\\n')\n",1007        "        indenti_f.write('ID' + ',' + 'Rank_in_a_QTL' + ',' + 'Score' + ',' + 'Pathways' + '\\n')\n",1008        "        for i in range(len(rank_list_df_sorted)):\n",1009        "            pathways_str = str(rank_list_df_sorted['Pathways'][i]).replace(',', ';') if 'Pathways' in rank_list_df_sorted.columns else 'NA'\n",1010        "            indenti_f.write(str(rank_list_df_sorted['ID'][i]) + ',' + str(rank_list_df_sorted['Rank'][i]) + ',' + str(rank_list_df_sorted['freq'][i]) + ',' + pathways_str + '\\n')\n",1011        "\n",1012        "if __name__ == '__main__':\n",1013        "    # Model path from Hugging Face Hub\n",1014        "    model_path = '/root/.cache/huggingface/hub/models--IRRI-SAH--Rice/snapshots/abb2b0fe1abbc136064c530b452626f331e7962f/OS_model.dat'\n",1015        "\n",1016        "    start_time = time.time()\n",1017        "    if os.path.isfile(\"/content/QTL_gene_rank.csv\"):\n",1018        "        print(\"Old output file exists, removed\")\n",1019        "        os.remove(\"/content/QTL_gene_rank.csv\")\n",1020        "\n",1021        "    # Upload gene list file from local system\n",1022        "    print(\"Please upload your QTL gene list file (e.g., my_qtl_genes.csv):\")\n",1023        "    uploaded = files.upload()\n",1024        "    if not uploaded:\n",1025        "        raise FileNotFoundError(\"No file was uploaded. Please try again.\")\n",1026        "\n",1027        "    gl = list(uploaded.keys())[0]\n",1028        "    print(f\"Uploaded file: {gl}\")\n",1029        "\n",1030        "    if not os.path.isfile(model_path):\n",1031        "        raise FileNotFoundError(f\"Model file {model_path} not found. Please check the path.\")\n",1032        "\n",1033        "    with open(gl, 'r') as f:\n",1034        "        for key, group in it.groupby(f, lambda line: line.startswith('//')):\n",1035        "            if not key:\n",1036        "                with open(model_path, \"rb\") as pik_f:\n",1037        "                    try:\n",1038        "                        df = joblib.load(pik_f)\n",1039        "                        if not isinstance(df, pd.DataFrame):\n",1040        "                            print(f\"Warning: Expected DataFrame from {model_path}, got {type(df)}\")\n",1041        "                        else:\n",1042        "                            print(\"Loaded DataFrame columns:\", df.columns)\n",1043        "                            print(\"Class distribution:\\n\", df['class'].value_counts() if 'class' in df.columns else \"No 'class' column\")\n",1044        "                    except Exception as e:\n",1045        "                        print(f\"Error loading model: {e}\")\n",1046        "                        raise\n",1047        "                    group = list(group)\n",1048        "                    group = [i.strip('\\n') for i in group]\n",1049        "                    QTL_name = group[0]\n",1050        "                    print('QTL: ' + QTL_name)\n",1051        "                    genes_in_QTL = group[1:]\n",1052        "                    print(\"Genes in QTL:\", genes_in_QTL)\n",1053        "                    original_length = len(genes_in_QTL)\n",1054        "                    Validation_set = pd.DataFrame()\n",1055        "                    for i in range(len(genes_in_QTL)):\n",1056        "                        Validation_set = pd.concat([Validation_set, df[df.ID == genes_in_QTL[i]]])\n",1057        "                    print(\"Validation set shape:\", Validation_set.shape)\n",1058        "                    print(\"Validation set columns:\", Validation_set.columns)\n",1059        "                    print(\"Validation set:\\n\", Validation_set)\n",1060        "\n",1061        "                    df = df.drop(['ID'], axis=1, errors='ignore')\n",1062        "                    ind_for_exclusion = []\n",1063        "                    for t in range(len(Validation_set.index)):\n",1064        "                        if 'class' in Validation_set.columns and Validation_set['class'][Validation_set.index[t]] == 1:\n",1065        "                            ind_for_exclusion.append(t)\n",1066        "                            print('Known QTL causal gene or orthologs excluded: ')\n",1067        "                            print(Validation_set['ID'][Validation_set.index[t]])\n",1068        "                    Validation_set = Validation_set.drop(Validation_set.index[ind_for_exclusion])\n",1069        "                    Validation_set_ID_uni = list(Validation_set.ID)\n",1070        "                    print('Number of genes after exclusion:', len(Validation_set_ID_uni))\n",1071        "                    gene_ex = set(genes_in_QTL) - set(Validation_set_ID_uni)\n",1072        "                    print(\"Excluded genes:\", gene_ex)\n",1073        "                    Validation_set = Validation_set.drop(['ID'], axis=1, errors='ignore')\n",1074        "                    Validation_set_i = Validation_set.reset_index(drop=True)\n",1075        "                    print(\"Validation set for prediction:\\n\", Validation_set_i)\n",1076        "                    train_qtg(df, Validation_set_i, model_path)\n",1077        "    print(\"--- %s seconds ---\" % round((time.time() - start_time), 2))\n",1078        "\n",1079        "    files.download('/content/QTL_gene_rank.csv')\n",1080        "    # Download visualization files\n",1081        "    for vis_file in [\n",1082        "        f'{QTL_name.replace(\"/\", \"_\")}_ranked_genes.png',\n",1083        "        f'{QTL_name.replace(\"/\", \"_\")}_feature_importances.png',\n",1084        "        f'{QTL_name.replace(\"/\", \"_\")}_correlation_heatmap.png',\n",1085        "        f'{QTL_name.replace(\"/\", \"_\")}_score_distribution.png',\n",1086        "        f'{QTL_name.replace(\"/\", \"_\")}_feature_vs_score.png'\n",1087        "    ]:\n",1088        "        if os.path.exists(f'/content/{vis_file}'):\n",1089        "            files.download(f'/content/{vis_file}')\n",1090        "        else:\n",1091        "            print(f\"Visualization file {vis_file} not found, skipping download.\")"1092      ],1093      "metadata": {1094        "colab": {1095          "base_uri": "https://localhost:8080/",1096          "height": 10001097        },1098        "id": "7nb5XxLfuNoU",1099        "outputId": "00c2de69-f880-4967-e55f-7c0f044bc6a8"1100      },1101      "execution_count": null,1102      "outputs": [1103        {1104          "output_type": "stream",1105          "name": "stdout",1106          "text": [1107            "sklearn__version 1.6.1\n",1108            "pandas__version 2.2.2\n",1109            "numpy__version 2.0.2\n",1110            "Old output file exists, removed\n",1111            "Please upload your QTL gene list file (e.g., my_qtl_genes.csv):\n"1112          ]1113        },1114        {1115          "output_type": "display_data",1116          "data": {1117            "text/plain": [1118              "<IPython.core.display.HTML object>"1119            ],1120            "text/html": [1121              "\n",1122              "     <input type=\"file\" id=\"files-84f45029-d050-4845-a2fb-84dd4d8d031b\" name=\"files[]\" multiple disabled\n",1123              "        style=\"border:none\" />\n",1124              "     <output id=\"result-84f45029-d050-4845-a2fb-84dd4d8d031b\">\n",1125              "      Upload widget is only available when the cell has been executed in the\n",1126              "      current browser session. Please rerun this cell to enable.\n",1127              "      </output>\n",1128              "      <script>// Copyright 2017 Google LLC\n",1129              "//\n",1130              "// Licensed under the Apache License, Version 2.0 (the \"License\");\n",1131              "// you may not use this file except in compliance with the License.\n",1132              "// You may obtain a copy of the License at\n",1133              "//\n",1134              "//      http://www.apache.org/licenses/LICENSE-2.0\n",1135              "//\n",1136              "// Unless required by applicable law or agreed to in writing, software\n",1137              "// distributed under the License is distributed on an \"AS IS\" BASIS,\n",1138              "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",1139              "// See the License for the specific language governing permissions and\n",1140              "// limitations under the License.\n",1141              "\n",1142              "/**\n",1143              " * @fileoverview Helpers for google.colab Python module.\n",1144              " */\n",1145              "(function(scope) {\n",1146              "function span(text, styleAttributes = {}) {\n",1147              "  const element = document.createElement('span');\n",1148              "  element.textContent = text;\n",1149              "  for (const key of Object.keys(styleAttributes)) {\n",1150              "    element.style[key] = styleAttributes[key];\n",1151              "  }\n",1152              "  return element;\n",1153              "}\n",1154              "\n",1155              "// Max number of bytes which will be uploaded at a time.\n",1156              "const MAX_PAYLOAD_SIZE = 100 * 1024;\n",1157              "\n",1158              "function _uploadFiles(inputId, outputId) {\n",1159              "  const steps = uploadFilesStep(inputId, outputId);\n",1160              "  const outputElement = document.getElementById(outputId);\n",1161              "  // Cache steps on the outputElement to make it available for the next call\n",1162              "  // to uploadFilesContinue from Python.\n",1163              "  outputElement.steps = steps;\n",1164              "\n",1165              "  return _uploadFilesContinue(outputId);\n",1166              "}\n",1167              "\n",1168              "// This is roughly an async generator (not supported in the browser yet),\n",1169              "// where there are multiple asynchronous steps and the Python side is going\n",1170              "// to poll for completion of each step.\n",1171              "// This uses a Promise to block the python side on completion of each step,\n",1172              "// then passes the result of the previous step as the input to the next step.\n",1173              "function _uploadFilesContinue(outputId) {\n",1174              "  const outputElement = document.getElementById(outputId);\n",1175              "  const steps = outputElement.steps;\n",1176              "\n",1177              "  const next = steps.next(outputElement.lastPromiseValue);\n",1178              "  return Promise.resolve(next.value.promise).then((value) => {\n",1179              "    // Cache the last promise value to make it available to the next\n",1180              "    // step of the generator.\n",1181              "    outputElement.lastPromiseValue = value;\n",1182              "    return next.value.response;\n",1183              "  });\n",1184              "}\n",1185              "\n",1186              "/**\n",1187              " * Generator function which is called between each async step of the upload\n",1188              " * process.\n",1189              " * @param {string} inputId Element ID of the input file picker element.\n",1190              " * @param {string} outputId Element ID of the output display.\n",1191              " * @return {!Iterable<!Object>} Iterable of next steps.\n",1192              " */\n",1193              "function* uploadFilesStep(inputId, outputId) {\n",1194              "  const inputElement = document.getElementById(inputId);\n",1195              "  inputElement.disabled = false;\n",1196              "\n",1197              "  const outputElement = document.getElementById(outputId);\n",1198              "  outputElement.innerHTML = '';\n",1199              "\n",1200              "  const pickedPromise = new Promise((resolve) => {\n",

Showing the first 1,200 of 3550 lines. Download the file for the rest.