Created
May 2, 2022 15:00
-
-
Save j6k4m8/919cc1a8162289dd4a6aeb965e800322 to your computer and use it in GitHub Desktop.
DotMotif-Search-in-Hemibrain.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "DotMotif-Search-in-Hemibrain.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"authorship_tag": "ABX9TyO170eGdApzRZtofHs3IiSH", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/j6k4m8/919cc1a8162289dd4a6aeb965e800322/dotmotif-search-in-custom-networkx.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"# Using DotMotif to search for motifs in the Janelia Hemibrain Dataset\n", | |
"\n", | |
"[DotMotif](https://github.com/aplbrain/dotmotif) is a performant, powerful query framework to search for network motifs.\n", | |
"\n", | |
"In this notebook, we search for subgraph structures in the [Janelia Hemibrain](https://neuprint.janelia.org) dataset." | |
], | |
"metadata": { | |
"id": "ZjweaPr1LtEk" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"%%capture\n", | |
"# Install dotmotif with one line.\n", | |
"# On your own computer, you can run this in the terminal.\n", | |
"!pip3 install dotmotif\n", | |
"\n", | |
"from dotmotif import Motif\n", | |
"from dotmotif.executors.NeuPrintExecutor import NeuPrintExecutor" | |
], | |
"metadata": { | |
"id": "qVIoPW6UK3rG" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# You will need an account on neuPrint in order to search for\n", | |
"# motifs using the free online database.\n", | |
"# To get a neuprint token, find your \"auth token\" on this page\n", | |
"# after creating an account:\n", | |
"# https://neuprint.janelia.org/account\n", | |
"MY_NEUPRINT_TOKEN = \" ... \"" | |
], | |
"metadata": { | |
"id": "-4U9mEOQK7rG" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# Create the search engine.\n", | |
"E = NeuPrintExecutor(host=\"neuprint.janelia.org\", token=MY_NEUPRINT_TOKEN, dataset=\"hemibrain:v1.2.1\")" | |
], | |
"metadata": { | |
"id": "ooxAE9DuLSyB" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"# Build your own motif here!\n", | |
"motif = Motif(\"\"\"\n", | |
"\n", | |
"EPG -> PEG\n", | |
"\n", | |
"EPG.type = \"EPG\"\n", | |
"PEG.type = \"PEG\"\n", | |
"\n", | |
"\"\"\")" | |
], | |
"metadata": { | |
"id": "B8_jzbUvLUHd" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"results = E.find(motif)" | |
], | |
"metadata": { | |
"id": "kTRYjBSDLWzY" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"print(f\"There are {len(results)} synapse edges from EPG neurons to PEG neurons.\")" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "b7paIFMBLYiZ", | |
"outputId": "77c21466-e6ca-4fab-d902-06c8d1fbe3b4" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"There are 280 synapse edges from EPG neurons to PEG neurons.\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"" | |
], | |
"metadata": { | |
"id": "7tqVQfx8O7cJ" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment