Skip to content

Instantly share code, notes, and snippets.

@j6k4m8
Last active May 2, 2022 15:00
Show Gist options
  • Save j6k4m8/0c878f9fbd0bd691a005110e8043dbcd to your computer and use it in GitHub Desktop.
Save j6k4m8/0c878f9fbd0bd691a005110e8043dbcd to your computer and use it in GitHub Desktop.
DotMotif-Search-in-Hemibrain.ipynb
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
{
"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/0c878f9fbd0bd691a005110e8043dbcd/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": 7,
"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": 8,
"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": 9,
"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": 12,
"outputs": []
},
{
"cell_type": "code",
"source": [
"results = E.find(motif)"
],
"metadata": {
"id": "kTRYjBSDLWzY"
},
"execution_count": 19,
"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": 21,
"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