Skip to content

Instantly share code, notes, and snippets.

@j6k4m8
Last active January 2, 2024 15:24
Show Gist options
  • Save j6k4m8/7c5cf55e7feb24685bd13a217cedda1d to your computer and use it in GitHub Desktop.
Save j6k4m8/7c5cf55e7feb24685bd13a217cedda1d to your computer and use it in GitHub Desktop.
DotMotif-Search-in-Pinky100.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "DotMotif-Search-in-Pinky100.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyM4Y1OB2B61m8qzOVdBfAHR",
"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/7c5cf55e7feb24685bd13a217cedda1d/dotmotif-search-in-pinky100.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 MICrONS Pinky100 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 triangular motifs (with edge attributes) in the Pinky100 dataset from the [IARPA MICrONS project](https://bossdb.org/project/microns-pinky).\n",
"\n",
"For more information about this dataset, see [here](https://www.microns-explorer.org/)."
],
"metadata": {
"id": "ZjweaPr1LtEk"
}
},
{
"cell_type": "code",
"source": [
"# Install dotmotif with one line.\n",
"# On your own computer, you can run this in the terminal.\n",
"!pip3 install dotmotif"
],
"metadata": {
"id": "qVIoPW6UK3rG"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"CSV_EDGELIST = \"https://github.com/aplbrain/dotmotif/files/8603540/soma_subgraph_synapses_spines_v185.csv\"\n",
"# You can also use the Zenodo link, but you will likely find that it is considerably slower, and may time out.\n",
"# CSV_EDGELIST = \"https://zenodo.org/record/3710459/files/soma_subgraph_synapses_spines_v185.csv?download=1\""
],
"metadata": {
"id": "-4U9mEOQK7rG"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"from dotmotif import Motif, GrandIsoExecutor\n",
"from dotmotif.ingest import CSVEdgelistConverter"
],
"metadata": {
"id": "cvnqgM_2LNQI"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"graph = CSVEdgelistConverter(\n",
" CSV_EDGELIST,\n",
" # Tell DotMotif which columns represent the \"source\" and \"target\"\n",
" # of the edgelist:\n",
" \"pre_root_id\",\n",
" \"post_root_id\",\n",
").to_graph()"
],
"metadata": {
"id": "BXbv8k09LPiP"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# Create the search engine.\n",
"E = GrandIsoExecutor(graph=graph)"
],
"metadata": {
"id": "ooxAE9DuLSyB"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"motif = Motif(\"\"\"\n",
"A -> B as AB\n",
"B -> C\n",
"C -> A\n",
"\n",
"AB.spine_vol_um3 > 0.25\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(len(results))"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "b7paIFMBLYiZ",
"outputId": "623b41a8-1cb2-44bb-97b3-975de6c6fc47"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"13\n"
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment