{
  "id": 402840,
  "title": "🧬 Graph Visualisation Kulyk 🧬",
  "url": "/competitions/cafa-5-protein-function-prediction/discussion/402840",
  "author_name": "",
  "post_date": "2023-04-19T21:55:30.618814800Z",
  "votes": 28,
  "comment_count": 2,
  "views": 0,
  "content": "<p>Based on excellent Kulyk's code <a href=\"https://www.kaggle.com/code/leonidkulyk/eda-cafa5-pfp-interactive-dags-plotly\" target=\"_blank\">[EDA] 🧬CAFA5-PFP ~ 🕸️Interactive DAGs | 📊Plotly</a> I improve graph visualisation to do it more compact and stylish </p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1313949%2Ff9726a776920fc16813d021068259a8e%2Fex%20(3).gif?generation=1681940906956477&amp;alt=media\" alt=\"\"></p>\n<p>The code snippet:</p>\n<pre><code>def plot_dag(graph, term, radius=1):\n    ng_graph = networkx.ego_graph(graph, term, radius=radius)\n\n    for n in ng_graph.nodes(data=True):\n        n[1][\"label\"] = \"\\n\".join(n[1][\"name\"].split(\" \"))\n        n[1][\"title\"] = n[0]\n\n    nt = Network(\n        height=1000,\n        directed=True, \n        notebook=True, \n        cdn_resources=\"in_line\",\n        select_menu=True,\n        bgcolor=\"#222222\", \n        font_color=\"white\", \n    )\n    nt.from_nx(ng_graph)\n\n    return nt.show(\"network.html\")\n</code></pre>",
  "messages": [
    {
      "id": "2227620",
      "postDate": "04/19/2023 21:55:30",
      "content": "<p>Based on excellent Kulyk's code <a href=\"https://www.kaggle.com/code/leonidkulyk/eda-cafa5-pfp-interactive-dags-plotly\" target=\"_blank\">[EDA] 🧬CAFA5-PFP ~ 🕸️Interactive DAGs | 📊Plotly</a> I improve graph visualisation to do it more compact and stylish </p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1313949%2Ff9726a776920fc16813d021068259a8e%2Fex%20(3).gif?generation=1681940906956477&amp;alt=media\" alt=\"\"></p>\n<p>The code snippet:</p>\n<pre><code>def plot_dag(graph, term, radius=1):\n    ng_graph = networkx.ego_graph(graph, term, radius=radius)\n\n    for n in ng_graph.nodes(data=True):\n        n[1][\"label\"] = \"\\n\".join(n[1][\"name\"].split(\" \"))\n        n[1][\"title\"] = n[0]\n\n    nt = Network(\n        height=1000,\n        directed=True, \n        notebook=True, \n        cdn_resources=\"in_line\",\n        select_menu=True,\n        bgcolor=\"#222222\", \n        font_color=\"white\", \n    )\n    nt.from_nx(ng_graph)\n\n    return nt.show(\"network.html\")\n</code></pre>",
      "rawMarkdown": "Based on excellent Kulyk's code [[EDA] 🧬CAFA5-PFP ~ 🕸️Interactive DAGs | 📊Plotly](https://www.kaggle.com/code/leonidkulyk/eda-cafa5-pfp-interactive-dags-plotly) I improve graph visualisation to do it more compact and stylish \n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1313949%2Ff9726a776920fc16813d021068259a8e%2Fex%20(3).gif?generation=1681940906956477&alt=media)\n\nThe code snippet:\n```\ndef plot_dag(graph, term, radius=1):\n    ng_graph = networkx.ego_graph(graph, term, radius=radius)\n\n    for n in ng_graph.nodes(data=True):\n        n[1][\"label\"] = \"\\n\".join(n[1][\"name\"].split(\" \"))\n        n[1][\"title\"] = n[0]\n\n    nt = Network(\n        height=1000,\n        directed=True, \n        notebook=True, \n        cdn_resources=\"in_line\",\n        select_menu=True,\n        bgcolor=\"#222222\", \n        font_color=\"white\", \n    )\n    nt.from_nx(ng_graph)\n    \n    return nt.show(\"network.html\")\n```",
      "votes": null
    },
    {
      "id": "2227624",
      "postDate": "04/19/2023 22:00:35",
      "content": "<p>Wow, quite a significant improvement. I especially liked the selection of nodes from the menu, it will be interesting to integrate similar functionality but for the selection of a term ☀️.</p>",
      "rawMarkdown": "Wow, quite a significant improvement. I especially liked the selection of nodes from the menu, it will be interesting to integrate similar functionality but for the selection of a term ☀️.",
      "votes": null
    },
    {
      "id": "2227626",
      "postDate": "04/19/2023 22:03:15",
      "content": "<p><a href=\"https://www.kaggle.com/leonidkulyk\" target=\"_blank\">@leonidkulyk</a> oh thanks for your much respected comment!&nbsp;Waiting for your future updates!</p>",
      "rawMarkdown": "leonidkulyk oh thanks for your much respected comment! Waiting for your future updates!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 2227624,
      "author_name": "leonidkulyk",
      "author_url": "",
      "post_date": "04/19/2023 22:00:35",
      "content": "<p>Wow, quite a significant improvement. I especially liked the selection of nodes from the menu, it will be interesting to integrate similar functionality but for the selection of a term ☀️.</p>",
      "votes": null,
      "replies": [
        {
          "id": 2227626,
          "author_name": "ihelon",
          "author_url": "",
          "post_date": "04/19/2023 22:03:15",
          "content": "<p><a href=\"https://www.kaggle.com/leonidkulyk\" target=\"_blank\">@leonidkulyk</a> oh thanks for your much respected comment!&nbsp;Waiting for your future updates!</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2227620": "Based on excellent Kulyk's code [[EDA] 🧬CAFA5-PFP ~ 🕸️Interactive DAGs | 📊Plotly](https://www.kaggle.com/code/leonidkulyk/eda-cafa5-pfp-interactive-dags-plotly) I improve graph visualisation to do it more compact and stylish \n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F1313949%2Ff9726a776920fc16813d021068259a8e%2Fex%20(3).gif?generation=1681940906956477&alt=media)\n\nThe code snippet:\n```\ndef plot_dag(graph, term, radius=1):\n    ng_graph = networkx.ego_graph(graph, term, radius=radius)\n\n    for n in ng_graph.nodes(data=True):\n        n[1][\"label\"] = \"\\n\".join(n[1][\"name\"].split(\" \"))\n        n[1][\"title\"] = n[0]\n\n    nt = Network(\n        height=1000,\n        directed=True, \n        notebook=True, \n        cdn_resources=\"in_line\",\n        select_menu=True,\n        bgcolor=\"#222222\", \n        font_color=\"white\", \n    )\n    nt.from_nx(ng_graph)\n    \n    return nt.show(\"network.html\")\n```",
    "2227624": "Wow, quite a significant improvement. I especially liked the selection of nodes from the menu, it will be interesting to integrate similar functionality but for the selection of a term ☀️.",
    "2227626": "leonidkulyk oh thanks for your much respected comment! Waiting for your future updates!"
  },
  "source": "meta"
}