diff --git a/snippets/.ipynb_checkpoints/NeuroFly24_scratch-checkpoint.ipynb b/snippets/.ipynb_checkpoints/NeuroFly24_scratch-checkpoint.ipynb new file mode 100644 index 00000000..5a073601 --- /dev/null +++ b/snippets/.ipynb_checkpoints/NeuroFly24_scratch-checkpoint.ipynb @@ -0,0 +1,1196 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "6abdb2a7-5a76-41b6-92d7-198fa932fc3b", + "metadata": {}, + "outputs": [], + "source": [ + "PROFILE MATCH (up:Class:Neuron)<-[:SUBCLASSOF|INSTANCEOF*..]-(n1:Neuron:Individual) WHERE up.short_form = \"FBbt_00111272\" MATCH (n1)-[r:synapsed_to]->(n2:Neuron:Individual) WHERE r.weight[0] >= 5 OPTIONAL MATCH (n2)-[:SUBCLASSOF|INSTANCEOF*..]->(down:Class:Neuron) WHERE down.short_form = \"FBbt_00005106\" OPTIONAL MATCH (c1:Class)<-[:INSTANCEOF]-(n1), (c2:Class)<-[:INSTANCEOF]-(n2) OPTIONAL MATCH (n1)-[r1:database_cross_reference]->(s1:Site) WHERE exists(s1.is_data_source) AND s1.is_data_source = True OPTIONAL MATCH (n2)-[r2:database_cross_reference]->(s2:Site) WHERE exists(s1.is_data_source) AND s2.is_data_source = True RETURN n1.short_form as upstream_neuron_id, n1.label as upstream_neuron_name, r.weight[0] as weight, n2.short_form as downstream_neuron_id, n2.label as downstream_neuron_name, apoc.text.join(collect(distinct c1.label),'|') AS upstream_class, apoc.text.join(collect(distinct c2.label),'|') as downstream_class, s1.short_form AS up_data_source, r1.accession[0] as up_accession,s2.short_form AS down_source, r2.accession[0] AS down_accession" + ] + }, + { + "cell_type": "markdown", + "id": "c6ba843e-22d0-4ae8-8508-ff08f322e152", + "metadata": {}, + "source": [ + "Query starting point:\n", + "\tCell Type:\n", + "\t\tIn which datasets can I find this cell type (might start from a synonym)\n", + "\tWhat is NT for this cell type.\n", + "\tNTR profiles of starting neuron\n", + "\tConnectivity query by type → Upstream/Downstream neurons\n", + "\tWhat NT do these have? (Can we break this down by evidence?)\n", + "\tNTR profiles of downstream neurons corresponding to NT starting neuron \n", + "\tNTR profile of starting neuron corresponding to downstream neurons\n", + "\t\n", + "\tWhat motifs are users looking for? Looking for feedback motifs? E.g. excitatory → GABA ergic → feedback to starting excitatory neuron.\n", + "\n", + "\n", + " What's missing: Discovery query? Find which neurons we have transcriptomic data for before proceeding?\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "e5d0f997-9ba4-4474-9cb8-fd1dc16b57ee", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'vfb_connect'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mvfb_connect\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcross_server_tools\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m VfbConnect\n\u001b[1;32m 2\u001b[0m vc \u001b[38;5;241m=\u001b[39m VfbConnect()\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'vfb_connect'" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "79b73538-c858-4024-a017-59be3899f932", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting vfb_connect\n", + " Downloading vfb_connect-1.2.20-py3-none-any.whl (40 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m40.3/40.3 kB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: requests in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from vfb_connect) (2.31.0)\n", + "Requirement already satisfied: pandas in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from vfb_connect) (2.1.0)\n", + "Requirement already satisfied: jsonpath-rw in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from vfb_connect) (1.4.0)\n", + "Requirement already satisfied: six in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from jsonpath-rw->vfb_connect) (1.16.0)\n", + "Requirement already satisfied: decorator in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from jsonpath-rw->vfb_connect) (5.1.1)\n", + "Requirement already satisfied: ply in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from jsonpath-rw->vfb_connect) (3.11)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from pandas->vfb_connect) (2.8.2)\n", + "Requirement already satisfied: tzdata>=2022.1 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from pandas->vfb_connect) (2023.3)\n", + "Requirement already satisfied: numpy>=1.22.4 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from pandas->vfb_connect) (1.25.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from pandas->vfb_connect) (2023.3.post1)\n", + "Requirement already satisfied: idna<4,>=2.5 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from requests->vfb_connect) (3.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from requests->vfb_connect) (2.0.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from requests->vfb_connect) (2023.7.22)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from requests->vfb_connect) (3.2.0)\n", + "Installing collected packages: vfb_connect\n", + "Successfully installed vfb_connect-1.2.20\n", + "\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.2\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" + ] + } + ], + "source": [ + "!pip install vfb_connect" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "07853f0a-4b7d-4e0e-903a-a2daf53ec640", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020\n", + " warnings.warn(\n" + ] + } + ], + "source": [ + "from vfb_connect.cross_server_tools import VfbConnect\n", + "vc = VfbConnect()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "0f5441cd-f550-4f30-9ed1-be73dd88f6f0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'label': 'distal medullary amacrine neuron Dm9',\n", + " 'symbol': 'Dm9',\n", + " 'id': 'FBbt_00111271',\n", + " 'tags': 'Entity|Adult|Anatomy|Cell|Class|Glutamatergic|Nervous_system|Neuron|Visual_system|hasScRNAseq',\n", + " 'parents_label': 'Notch OFF hemilineage secondary neuron|adult glutamatergic neuron|distal medullary amacrine neuron',\n", + " 'parents_id': 'FBbt_00049542|FBbt_00058208|FBbt_00003767'}]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Cell Type:\n", + "#\t\tIn which datasets can I find this cell type (might start from a synonym)\n", + "#\tWhat is NT for this cell type.\n", + "\n", + "# We can't start from a synonym right now. Need to add a new lookup\n", + "# We can look at term info for an individual neuron\n", + "vc.neo_query_wrapper.get_type_TermInfo([vc.lookup_id('Dm9')], summary=True) \n", + "# Improvements: Make summary True by default. Support dataframe output by default for summary\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "dcf0e55a-fae0-41a3-8f6a-f377e160f4cc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Distal medullary wide-field amacrine neuron with arbors that span multiple columns in layers M1 and M6A and columnar processes between these two layers. The processes in M2 and M5 occupy a central column position and are closely associated with R7 and R8 photoreceptor axons, covering around 7 columns. There are around 110 Dm9 neurons per hemisphere. They are glutamatergic (Davis et al., 2020).'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# From this we can see that this type is glutamatergic. For whey we can look at description (although notes \n", + "#- in some cases the infor might be on a superclass)\n", + "vc.neo_query_wrapper.get_type_TermInfo([vc.lookup_id('Dm9')])[0]['term']['description'][0]\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "4753fc75-4801-42b3-bbf4-df5bb614b3d7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'core': {'symbol': '',\n", + " 'iri': 'http://flybase.org/reports/FBrf0228639',\n", + " 'types': ['Entity', 'Individual', 'pub'],\n", + " 'short_form': 'FBrf0228639',\n", + " 'unique_facets': ['pub'],\n", + " 'label': 'Nern et al., 2015, Proc. Natl. Acad. Sci. U.S.A. 112(22): E2967--E2976'},\n", + " 'FlyBase': 'FBrf0228639',\n", + " 'PubMed': '25964354',\n", + " 'DOI': '10.1073/pnas.1506763112'},\n", + " {'core': {'symbol': '',\n", + " 'iri': 'http://flybase.org/reports/FBrf0244935',\n", + " 'types': ['Entity', 'Individual', 'pub'],\n", + " 'short_form': 'FBrf0244935',\n", + " 'unique_facets': ['pub'],\n", + " 'label': 'Davis et al., 2020, eLife 9: e50901'},\n", + " 'FlyBase': 'FBrf0244935',\n", + " 'PubMed': '31939737',\n", + " 'DOI': '10.7554/eLife.50901'},\n", + " {'core': {'symbol': '',\n", + " 'iri': 'http://flybase.org/reports/FBrf0222324',\n", + " 'types': ['Entity', 'Individual', 'pub'],\n", + " 'short_form': 'FBrf0222324',\n", + " 'unique_facets': ['pub'],\n", + " 'label': 'Takemura et al., 2013, Nature 500(7461): 175--181'},\n", + " 'FlyBase': 'FBrf0222324',\n", + " 'PubMed': '23925240',\n", + " 'DOI': '10.1038/nature12450'},\n", + " {'core': {'symbol': '',\n", + " 'iri': 'http://flybase.org/reports/FBrf0252485',\n", + " 'types': ['Entity', 'Individual', 'pub'],\n", + " 'short_form': 'FBrf0252485',\n", + " 'unique_facets': ['pub'],\n", + " 'label': 'Kind et al., 2021, eLife 10: e71858'},\n", + " 'FlyBase': 'FBrf0252485',\n", + " 'PubMed': '34913436',\n", + " 'DOI': '10.7554/eLife.71858'}]" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.neo_query_wrapper.get_type_TermInfo([vc.lookup_id('Dm9')])[0]['def_pubs']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "438cb783-c5ef-4c7d-a061-064176c7624b", + "metadata": {}, + "outputs": [], + "source": [ + "# Supporting ref = label': 'Davis et al., 2020, eLife 9: e50901'" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "3175ccf6-7a1a-49fc-a10e-cc8ea6932d3d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
upstream_neuron_idupstream_neuron_nameweightdownstream_neuron_iddownstream_neuron_nameupstream_classdownstream_classup_data_sourceup_accessiondown_sourcedown_accession
0VFB_001029faDm9#7 (FAFB:11916195)2VFB_001029fcDm2#7 (FAFB:11918130)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm2NoneNoneNoneNone
1VFB_001029c5Dm9#2 (FAFB:11447061)4VFB_001029aiDm8#4 (FAFB:10208775)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm8NoneNoneNoneNone
2VFB_001029crDm9#1 (FAFB:11452427)2VFB_001029aiDm8#4 (FAFB:10208775)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm8NoneNoneNoneNone
3VFB_001029c5Dm9#2 (FAFB:11447061)3VFB_001029aeDm8#1 (FAFB:10109586)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm8NoneNoneNoneNone
4VFB_001029bqDm9#9 (FAFB:10657500)2VFB_001029asDm-DRA2#1 (FAFB:10411788)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm-DRA2NoneNoneNoneNone
\n", + "
" + ], + "text/plain": [ + " upstream_neuron_id upstream_neuron_name weight downstream_neuron_id \\\n", + "0 VFB_001029fa Dm9#7 (FAFB:11916195) 2 VFB_001029fc \n", + "1 VFB_001029c5 Dm9#2 (FAFB:11447061) 4 VFB_001029ai \n", + "2 VFB_001029cr Dm9#1 (FAFB:11452427) 2 VFB_001029ai \n", + "3 VFB_001029c5 Dm9#2 (FAFB:11447061) 3 VFB_001029ae \n", + "4 VFB_001029bq Dm9#9 (FAFB:10657500) 2 VFB_001029as \n", + "\n", + " downstream_neuron_name upstream_class \\\n", + "0 Dm2#7 (FAFB:11918130) distal medullary amacrine neuron Dm9 \n", + "1 Dm8#4 (FAFB:10208775) distal medullary amacrine neuron Dm9 \n", + "2 Dm8#4 (FAFB:10208775) distal medullary amacrine neuron Dm9 \n", + "3 Dm8#1 (FAFB:10109586) distal medullary amacrine neuron Dm9 \n", + "4 Dm-DRA2#1 (FAFB:10411788) distal medullary amacrine neuron Dm9 \n", + "\n", + " downstream_class up_data_source up_accession \\\n", + "0 distal medullary amacrine neuron Dm2 None None \n", + "1 distal medullary amacrine neuron Dm8 None None \n", + "2 distal medullary amacrine neuron Dm8 None None \n", + "3 distal medullary amacrine neuron Dm8 None None \n", + "4 distal medullary amacrine neuron Dm-DRA2 None None \n", + "\n", + " down_source down_accession \n", + "0 None None \n", + "1 None None \n", + "2 None None \n", + "3 None None \n", + "4 None None " + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.get_connected_neurons_by_type(upstream_type='Dm9', downstream_type='Dm', weight=1) # Note " + ] + }, + { + "cell_type": "markdown", + "id": "ba843645-d3dc-4e5d-a14f-42322b8874bc", + "metadata": {}, + "source": [ + "# Notes - \n", + "\n", + "* we have a problem with queries running indefinitely when we go above Dm as downstream neuron type.\n", + " * We could deal with this for the most general use-case - Neuron by making all args optional but failing if at least one of upstream or downstream are filled. There's no need to query up to neuron because we know this form the Semantic tag\n", + "* Need to fix typ on in data source return\n", + " ` \"WHERE exists(s1.is_data_source) AND s2.is_data_source = True \" \\`\n", + " -->\n", + " ` \"WHERE exists(s2.is_data_source) AND s2.is_data_source = True \" \\`\n", + "\n", + "With the second fixed we will return datasets - BUT the dataset names are really not easy to understand. THIS NEEDS TO BE FIXED. There has already been some work on this to add SYMBOLS. We need to be returning these in queries!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "28bba6ea-945d-4124-950b-d78f41f36b34", + "metadata": {}, + "outputs": [], + "source": [ + "# \tNTR profiles of downstream neurons corresponding to NT starting neuron \n" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "f98eacb7-c359-4439-b9e7-6169f828b0a9", + "metadata": {}, + "outputs": [], + "source": [ + "# Dm9 downstream types\n", + "dm9_ds_type= set(vc.get_connected_neurons_by_type(upstream_type='Dm9', downstream_type='Dm', weight=1)['downstream_class'])" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "ec1972a4-c388-4901-a61f-4ad91908e42a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'distal medullary amacrine neuron Dm-DRA2',\n", + " 'distal medullary amacrine neuron Dm2',\n", + " 'distal medullary amacrine neuron Dm8'}" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dm9_ds_type" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "8fd4b430-edc9-434d-ab12-999ffc3e5614", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Acetylcholine_receptor',\n", + " 'Calcium_binding',\n", + " 'Carbohydrate_binding',\n", + " 'Chaperone',\n", + " 'Cytoskeleton_binding',\n", + " 'DNA_binding',\n", + " 'Dopamine_receptor',\n", + " 'Enzyme',\n", + " 'GABA_receptor',\n", + " 'GPCR',\n", + " 'Glutamate_receptor',\n", + " 'Gustatory_receptor',\n", + " 'Histamine_receptor',\n", + " 'Hormone',\n", + " 'Ion_channel',\n", + " 'Ligand',\n", + " 'Lipid_binding',\n", + " 'Mechanosensory_ion_channel',\n", + " 'Metal_ion_binding',\n", + " 'Neuropeptide',\n", + " 'Neurotransmitter_receptor',\n", + " 'Octopamine_receptor',\n", + " 'Odorant_binding',\n", + " 'Olfactory_receptor',\n", + " 'Peptide_or_protein_hormone_receptor',\n", + " 'Photoreceptor',\n", + " 'RNA_binding',\n", + " 'Receptor',\n", + " 'Regulator',\n", + " 'Serotonin_receptor',\n", + " 'Small_molecule_binding',\n", + " 'Structural_molecule',\n", + " 'Thermosensory_ion_channel',\n", + " 'Transcription_factor',\n", + " 'Transporter',\n", + " 'Tyramine_receptor']" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.get_gene_function_filters()" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "49ee182c-29f8-4a5a-b439-47ed1297db34", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m\n", + "\u001b[0mvc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_transcriptomic_profile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mcell_type\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mgene_type\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mreturn_dataframe\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDocstring:\u001b[0m\n", + "Get gene expression data for a given cell_type.\n", + "\n", + "Returns a DataFrame of gene expression data for clusters of cells annotated as cell_type (or subtypes).\n", + "Can optionally restrict to a gene_type - these can be retrieved by running get_gene_function_filters.\n", + "If no data is found, returns False.\n", + "\n", + ":param cell_type: The ID, name or symbol of a class in the Drosophila Anatomy Ontology (FBbt).\n", + ":param gene_type: Optional. A gene function label - these can be retrieved by running get_gene_function_filters().\n", + ":return: DataFrame with gene expression data for clusters of cells annotated as cell_type (or subtypes).\n", + ":rtype: DataFrame\n", + "\u001b[0;31mFile:\u001b[0m ~/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages/vfb_connect/cross_server_tools.py\n", + "\u001b[0;31mType:\u001b[0m method" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "vc.get_transcriptomic_profile?\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "074296ba-829c-42e1-9b3f-228f4c75acf5", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "5b81af15-8d97-4400-b666-f2b2c48b00ea", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Getting transcriptomic profile for distal medullary amacrine neuron Dm-DRA2\n", + "Empty DataFrame\n", + "Columns: []\n", + "Index: []\n", + "Getting transcriptomic profile for distal medullary amacrine neuron Dm2\n", + " cell_type cell_type_id sample_sex \\\n", + "0 distal medullary amacrine neuron Dm2 FBbt_00003769 None \n", + "1 distal medullary amacrine neuron Dm2 FBbt_00003769 None \n", + "\n", + " sample_tissue ref gene \\\n", + "0 [adult optic lobe] Özel et al., 2021, Nature 589(7840): 88--95 GluClα \n", + "1 [adult optic lobe] Özel et al., 2021, Nature 589(7840): 88--95 GluRIB \n", + "\n", + " gene_id function extent \\\n", + "0 FBgn0024963 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.451883 \n", + "1 FBgn0264000 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.305439 \n", + "\n", + " level \n", + "0 1098.2018 \n", + "1 1094.0442 \n", + "Getting transcriptomic profile for distal medullary amacrine neuron Dm8\n", + " cell_type cell_type_id sample_sex \\\n", + "0 distal medullary amacrine neuron Dm8 FBbt_00013774 male organism \n", + "1 distal medullary amacrine neuron Dm8 FBbt_00013774 None \n", + "2 distal medullary amacrine neuron Dm8 FBbt_00013774 female organism \n", + "3 distal medullary amacrine neuron Dm8 FBbt_00013774 None \n", + "4 distal medullary amacrine neuron Dm8 FBbt_00013774 male organism \n", + "5 distal medullary amacrine neuron Dm8 FBbt_00013774 None \n", + "6 distal medullary amacrine neuron Dm8 FBbt_00013774 female organism \n", + "7 distal medullary amacrine neuron Dm8 FBbt_00013774 female organism \n", + "8 distal medullary amacrine neuron Dm8 FBbt_00013774 None \n", + "9 distal medullary amacrine neuron Dm8 FBbt_00013774 female organism \n", + "10 distal medullary amacrine neuron Dm8 FBbt_00013774 male organism \n", + "\n", + " sample_tissue \\\n", + "0 [wing, haltere, adult, adult pars intercerebra... \n", + "1 [adult head, proboscis, male reproductive syst... \n", + "2 [adult head, adult corpus cardiacum, antenna, ... \n", + "3 [adult optic lobe] \n", + "4 [wing, haltere, adult, adult pars intercerebra... \n", + "5 [adult head, proboscis, male reproductive syst... \n", + "6 [adult head, adult corpus cardiacum, antenna, ... \n", + "7 [adult head, adult corpus cardiacum, antenna, ... \n", + "8 [adult head, proboscis, male reproductive syst... \n", + "9 [adult head, adult corpus cardiacum, antenna, ... \n", + "10 [wing, haltere, adult, adult pars intercerebra... \n", + "\n", + " ref gene gene_id \\\n", + "0 Li et al., 2022, Science 375(6584): eabk2432 CG11155 FBgn0039927 \n", + "1 Li et al., 2022, Science 375(6584): eabk2432 CG11155 FBgn0039927 \n", + "2 Li et al., 2022, Science 375(6584): eabk2432 CG11155 FBgn0039927 \n", + "3 Özel et al., 2021, Nature 589(7840): 88--95 CG11155 FBgn0039927 \n", + "4 Li et al., 2022, Science 375(6584): eabk2432 GluClα FBgn0024963 \n", + "5 Li et al., 2022, Science 375(6584): eabk2432 GluClα FBgn0024963 \n", + "6 Li et al., 2022, Science 375(6584): eabk2432 GluClα FBgn0024963 \n", + "7 Li et al., 2022, Science 375(6584): eabk2432 GluRIB FBgn0264000 \n", + "8 Li et al., 2022, Science 375(6584): eabk2432 Nmdar2 FBgn0053513 \n", + "9 Li et al., 2022, Science 375(6584): eabk2432 Nmdar2 FBgn0053513 \n", + "10 Li et al., 2022, Science 375(6584): eabk2432 mGluR FBgn0019985 \n", + "\n", + " function extent level \n", + "0 [Receptor, Ion_channel, Transporter, Glutamate... 0.720000 1700.67880 \n", + "1 [Receptor, Ion_channel, Transporter, Glutamate... 0.633803 1543.74290 \n", + "2 [Receptor, Ion_channel, Transporter, Glutamate... 0.482759 1349.29880 \n", + "3 [Receptor, Ion_channel, Transporter, Glutamate... 0.226744 740.19415 \n", + "4 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.720000 1534.37680 \n", + "5 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.492958 1564.11840 \n", + "6 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.517241 1685.25260 \n", + "7 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.241379 848.22955 \n", + "8 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.225352 1295.88900 \n", + "9 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.206897 1154.15540 \n", + "10 [Small_molecule_binding, Receptor, GPCR, Lipid... 0.240000 968.85333 \n" + ] + } + ], + "source": [ + "for t in dm9_ds_type:\n", + " print(\"Getting transcriptomic profile for \" + t)\n", + " print(vc.get_transcriptomic_profile(t, gene_type='Glutamate_receptor'))\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "fdc6c493-7955-4feb-9200-31eeaf42239f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
cell_typecell_type_idsample_sexsample_tissuerefgenegene_idfunctionextentlevel
0distal medullary amacrine neuron Dm2FBbt_00003769None[adult optic lobe]Özel et al., 2021, Nature 589(7840): 88--95GluClαFBgn0024963[Receptor, Neurotransmitter_receptor, Ion_chan...0.4518831098.2018
1distal medullary amacrine neuron Dm2FBbt_00003769None[adult optic lobe]Özel et al., 2021, Nature 589(7840): 88--95GluRIBFBgn0264000[Receptor, Neurotransmitter_receptor, Ion_chan...0.3054391094.0442
\n", + "
" + ], + "text/plain": [ + " cell_type cell_type_id sample_sex \\\n", + "0 distal medullary amacrine neuron Dm2 FBbt_00003769 None \n", + "1 distal medullary amacrine neuron Dm2 FBbt_00003769 None \n", + "\n", + " sample_tissue ref gene \\\n", + "0 [adult optic lobe] Özel et al., 2021, Nature 589(7840): 88--95 GluClα \n", + "1 [adult optic lobe] Özel et al., 2021, Nature 589(7840): 88--95 GluRIB \n", + "\n", + " gene_id function extent \\\n", + "0 FBgn0024963 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.451883 \n", + "1 FBgn0264000 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.305439 \n", + "\n", + " level \n", + "0 1098.2018 \n", + "1 1094.0442 " + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.get_transcriptomic_profile('Dm2', gene_type='Glutamate_receptor')" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "5b08def5-58f1-45ee-ab96-01594e3e705b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
upstream_neuron_idupstream_neuron_nameweightdownstream_neuron_iddownstream_neuron_nameupstream_classdownstream_classup_data_sourceup_accessiondown_sourcedown_accession
0VFB_001029aiDm8#4 (FAFB:10208775)22VFB_001029crDm9#1 (FAFB:11452427)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
1VFB_001029aeDm8#1 (FAFB:10109586)23VFB_001029crDm9#1 (FAFB:11452427)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
2VFB_001029aeDm8#1 (FAFB:10109586)7VFB_001029eeDm9#4 (FAFB:11484679)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
3VFB_001029ahDm8#11 (FAFB:10196189)8VFB_001029eeDm9#4 (FAFB:11484679)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
4VFB_001029ahDm8#11 (FAFB:10196189)3VFB_001029c5Dm9#2 (FAFB:11447061)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
....................................
112VFB_001029ahDm8#11 (FAFB:10196189)2VFB_001029b7Dm#9 (FAFB:10537970)distal medullary amacrine neuron Dm8distal medullary amacrine neuronNoneNoneNoneNone
113VFB_001029clDm11#1 (FAFB:11450453)2VFB_001029b7Dm#9 (FAFB:10537970)distal medullary amacrine neuron Dm11distal medullary amacrine neuronNoneNoneNoneNone
114VFB_001029ceDm2#1 (FAFB:11448822)2VFB_001029b7Dm#9 (FAFB:10537970)distal medullary amacrine neuron Dm2distal medullary amacrine neuronNoneNoneNoneNone
115VFB_001029aeDm8#1 (FAFB:10109586)11VFB_001029cgDm#2 (FAFB:11448962)distal medullary amacrine neuron Dm8distal medullary amacrine neuronNoneNoneNoneNone
116VFB_001029ahDm8#11 (FAFB:10196189)5VFB_001029cgDm#2 (FAFB:11448962)distal medullary amacrine neuron Dm8distal medullary amacrine neuronNoneNoneNoneNone
\n", + "

117 rows × 11 columns

\n", + "
" + ], + "text/plain": [ + " upstream_neuron_id upstream_neuron_name weight downstream_neuron_id \\\n", + "0 VFB_001029ai Dm8#4 (FAFB:10208775) 22 VFB_001029cr \n", + "1 VFB_001029ae Dm8#1 (FAFB:10109586) 23 VFB_001029cr \n", + "2 VFB_001029ae Dm8#1 (FAFB:10109586) 7 VFB_001029ee \n", + "3 VFB_001029ah Dm8#11 (FAFB:10196189) 8 VFB_001029ee \n", + "4 VFB_001029ah Dm8#11 (FAFB:10196189) 3 VFB_001029c5 \n", + ".. ... ... ... ... \n", + "112 VFB_001029ah Dm8#11 (FAFB:10196189) 2 VFB_001029b7 \n", + "113 VFB_001029cl Dm11#1 (FAFB:11450453) 2 VFB_001029b7 \n", + "114 VFB_001029ce Dm2#1 (FAFB:11448822) 2 VFB_001029b7 \n", + "115 VFB_001029ae Dm8#1 (FAFB:10109586) 11 VFB_001029cg \n", + "116 VFB_001029ah Dm8#11 (FAFB:10196189) 5 VFB_001029cg \n", + "\n", + " downstream_neuron_name upstream_class \\\n", + "0 Dm9#1 (FAFB:11452427) distal medullary amacrine neuron Dm8 \n", + "1 Dm9#1 (FAFB:11452427) distal medullary amacrine neuron Dm8 \n", + "2 Dm9#4 (FAFB:11484679) distal medullary amacrine neuron Dm8 \n", + "3 Dm9#4 (FAFB:11484679) distal medullary amacrine neuron Dm8 \n", + "4 Dm9#2 (FAFB:11447061) distal medullary amacrine neuron Dm8 \n", + ".. ... ... \n", + "112 Dm#9 (FAFB:10537970) distal medullary amacrine neuron Dm8 \n", + "113 Dm#9 (FAFB:10537970) distal medullary amacrine neuron Dm11 \n", + "114 Dm#9 (FAFB:10537970) distal medullary amacrine neuron Dm2 \n", + "115 Dm#2 (FAFB:11448962) distal medullary amacrine neuron Dm8 \n", + "116 Dm#2 (FAFB:11448962) distal medullary amacrine neuron Dm8 \n", + "\n", + " downstream_class up_data_source up_accession \\\n", + "0 distal medullary amacrine neuron Dm9 None None \n", + "1 distal medullary amacrine neuron Dm9 None None \n", + "2 distal medullary amacrine neuron Dm9 None None \n", + "3 distal medullary amacrine neuron Dm9 None None \n", + "4 distal medullary amacrine neuron Dm9 None None \n", + ".. ... ... ... \n", + "112 distal medullary amacrine neuron None None \n", + "113 distal medullary amacrine neuron None None \n", + "114 distal medullary amacrine neuron None None \n", + "115 distal medullary amacrine neuron None None \n", + "116 distal medullary amacrine neuron None None \n", + "\n", + " down_source down_accession \n", + "0 None None \n", + "1 None None \n", + "2 None None \n", + "3 None None \n", + "4 None None \n", + ".. ... ... \n", + "112 None None \n", + "113 None None \n", + "114 None None \n", + "115 None None \n", + "116 None None \n", + "\n", + "[117 rows x 11 columns]" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.get_connected_neurons_by_type(upstream_type='Dm', downstream_type='Dm', weight=1)" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "5eba1f56-dafd-4dc8-8eea-347457a80482", + "metadata": {}, + "outputs": [], + "source": [ + "# Consider adding query that => detailed MF profile of each Gene returned?\n", + "\n", + "q = vc.nc.commit_list([\"MATCH (c:Class:Neuron)<-[:composed_primarily_of]-(:Individual)-[:expresses]->(g:Gene:Glutamate_receptor)-[]->(go:Class) where go.curie =~ 'GO:.*' return distinct c.label as neuron, g.label as gene, collect(distinct go.label) as molecular_functions order by c.label\"])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "197141cc-30ea-40aa-b05f-01f0b06bb807", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
neurongenemolecular_functions
0CCHamide-1 neuronNmdar2[NMDA glutamate receptor activity, transmitter...
1CCHamide-1 neuronKaiR1D[transmitter-gated monoatomic ion channel acti...
2CCHamide-1 neuronGluClα[Group 3 - Selective Cl- transport, neurotrans...
3CCHamide-1 neuronNmdar1[NMDA glutamate receptor activity, signaling r...
4CCHamide-1 neuronCG11155[Activation of highly calcium permeable postsy...
............
702transmedullary neuron Tm9GluClα[Group 3 - Selective Cl- transport, neurotrans...
703transmedullary neuron Tm9CG11155[Activation of highly calcium permeable postsy...
704transmedullary neuron Tm9GluRIB[transmitter-gated monoatomic ion channel acti...
705transmedullary neuron Tm9GluRIA[transmitter-gated monoatomic ion channel acti...
706transmedullary neuron Tm9mGluR[group II metabotropic glutamate receptor acti...
\n", + "

707 rows × 3 columns

\n", + "
" + ], + "text/plain": [ + " neuron gene \\\n", + "0 CCHamide-1 neuron Nmdar2 \n", + "1 CCHamide-1 neuron KaiR1D \n", + "2 CCHamide-1 neuron GluClα \n", + "3 CCHamide-1 neuron Nmdar1 \n", + "4 CCHamide-1 neuron CG11155 \n", + ".. ... ... \n", + "702 transmedullary neuron Tm9 GluClα \n", + "703 transmedullary neuron Tm9 CG11155 \n", + "704 transmedullary neuron Tm9 GluRIB \n", + "705 transmedullary neuron Tm9 GluRIA \n", + "706 transmedullary neuron Tm9 mGluR \n", + "\n", + " molecular_functions \n", + "0 [NMDA glutamate receptor activity, transmitter... \n", + "1 [transmitter-gated monoatomic ion channel acti... \n", + "2 [Group 3 - Selective Cl- transport, neurotrans... \n", + "3 [NMDA glutamate receptor activity, signaling r... \n", + "4 [Activation of highly calcium permeable postsy... \n", + ".. ... \n", + "702 [Group 3 - Selective Cl- transport, neurotrans... \n", + "703 [Activation of highly calcium permeable postsy... \n", + "704 [transmitter-gated monoatomic ion channel acti... \n", + "705 [transmitter-gated monoatomic ion channel acti... \n", + "706 [group II metabotropic glutamate receptor acti... \n", + "\n", + "[707 rows x 3 columns]" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from vfb_connect.neo.neo4j_tools import dict_cursor\n", + "import pandas as pd\n", + "pd.DataFrame.from_records(dict_cursor(q))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1d35e70e-eac5-4ea5-ae48-d602bd86c670", + "metadata": {}, + "outputs": [], + "source": [ + "# Consider adding queries to => broader GO annotation profiles for receptors ==> broader biological story." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/snippets/NeuroFly24_scratch.ipynb b/snippets/NeuroFly24_scratch.ipynb new file mode 100644 index 00000000..5a073601 --- /dev/null +++ b/snippets/NeuroFly24_scratch.ipynb @@ -0,0 +1,1196 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "6abdb2a7-5a76-41b6-92d7-198fa932fc3b", + "metadata": {}, + "outputs": [], + "source": [ + "PROFILE MATCH (up:Class:Neuron)<-[:SUBCLASSOF|INSTANCEOF*..]-(n1:Neuron:Individual) WHERE up.short_form = \"FBbt_00111272\" MATCH (n1)-[r:synapsed_to]->(n2:Neuron:Individual) WHERE r.weight[0] >= 5 OPTIONAL MATCH (n2)-[:SUBCLASSOF|INSTANCEOF*..]->(down:Class:Neuron) WHERE down.short_form = \"FBbt_00005106\" OPTIONAL MATCH (c1:Class)<-[:INSTANCEOF]-(n1), (c2:Class)<-[:INSTANCEOF]-(n2) OPTIONAL MATCH (n1)-[r1:database_cross_reference]->(s1:Site) WHERE exists(s1.is_data_source) AND s1.is_data_source = True OPTIONAL MATCH (n2)-[r2:database_cross_reference]->(s2:Site) WHERE exists(s1.is_data_source) AND s2.is_data_source = True RETURN n1.short_form as upstream_neuron_id, n1.label as upstream_neuron_name, r.weight[0] as weight, n2.short_form as downstream_neuron_id, n2.label as downstream_neuron_name, apoc.text.join(collect(distinct c1.label),'|') AS upstream_class, apoc.text.join(collect(distinct c2.label),'|') as downstream_class, s1.short_form AS up_data_source, r1.accession[0] as up_accession,s2.short_form AS down_source, r2.accession[0] AS down_accession" + ] + }, + { + "cell_type": "markdown", + "id": "c6ba843e-22d0-4ae8-8508-ff08f322e152", + "metadata": {}, + "source": [ + "Query starting point:\n", + "\tCell Type:\n", + "\t\tIn which datasets can I find this cell type (might start from a synonym)\n", + "\tWhat is NT for this cell type.\n", + "\tNTR profiles of starting neuron\n", + "\tConnectivity query by type → Upstream/Downstream neurons\n", + "\tWhat NT do these have? (Can we break this down by evidence?)\n", + "\tNTR profiles of downstream neurons corresponding to NT starting neuron \n", + "\tNTR profile of starting neuron corresponding to downstream neurons\n", + "\t\n", + "\tWhat motifs are users looking for? Looking for feedback motifs? E.g. excitatory → GABA ergic → feedback to starting excitatory neuron.\n", + "\n", + "\n", + " What's missing: Discovery query? Find which neurons we have transcriptomic data for before proceeding?\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "e5d0f997-9ba4-4474-9cb8-fd1dc16b57ee", + "metadata": {}, + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'vfb_connect'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[1], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mvfb_connect\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mcross_server_tools\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m VfbConnect\n\u001b[1;32m 2\u001b[0m vc \u001b[38;5;241m=\u001b[39m VfbConnect()\n", + "\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'vfb_connect'" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "79b73538-c858-4024-a017-59be3899f932", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting vfb_connect\n", + " Downloading vfb_connect-1.2.20-py3-none-any.whl (40 kB)\n", + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m40.3/40.3 kB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", + "\u001b[?25hRequirement already satisfied: requests in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from vfb_connect) (2.31.0)\n", + "Requirement already satisfied: pandas in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from vfb_connect) (2.1.0)\n", + "Requirement already satisfied: jsonpath-rw in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from vfb_connect) (1.4.0)\n", + "Requirement already satisfied: six in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from jsonpath-rw->vfb_connect) (1.16.0)\n", + "Requirement already satisfied: decorator in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from jsonpath-rw->vfb_connect) (5.1.1)\n", + "Requirement already satisfied: ply in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from jsonpath-rw->vfb_connect) (3.11)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from pandas->vfb_connect) (2.8.2)\n", + "Requirement already satisfied: tzdata>=2022.1 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from pandas->vfb_connect) (2023.3)\n", + "Requirement already satisfied: numpy>=1.22.4 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from pandas->vfb_connect) (1.25.2)\n", + "Requirement already satisfied: pytz>=2020.1 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from pandas->vfb_connect) (2023.3.post1)\n", + "Requirement already satisfied: idna<4,>=2.5 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from requests->vfb_connect) (3.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from requests->vfb_connect) (2.0.4)\n", + "Requirement already satisfied: certifi>=2017.4.17 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from requests->vfb_connect) (2023.7.22)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in /Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages (from requests->vfb_connect) (3.2.0)\n", + "Installing collected packages: vfb_connect\n", + "Successfully installed vfb_connect-1.2.20\n", + "\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.2\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" + ] + } + ], + "source": [ + "!pip install vfb_connect" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "07853f0a-4b7d-4e0e-903a-a2daf53ec640", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/do12/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages/urllib3/__init__.py:34: NotOpenSSLWarning: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'LibreSSL 2.8.3'. See: https://github.com/urllib3/urllib3/issues/3020\n", + " warnings.warn(\n" + ] + } + ], + "source": [ + "from vfb_connect.cross_server_tools import VfbConnect\n", + "vc = VfbConnect()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "0f5441cd-f550-4f30-9ed1-be73dd88f6f0", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'label': 'distal medullary amacrine neuron Dm9',\n", + " 'symbol': 'Dm9',\n", + " 'id': 'FBbt_00111271',\n", + " 'tags': 'Entity|Adult|Anatomy|Cell|Class|Glutamatergic|Nervous_system|Neuron|Visual_system|hasScRNAseq',\n", + " 'parents_label': 'Notch OFF hemilineage secondary neuron|adult glutamatergic neuron|distal medullary amacrine neuron',\n", + " 'parents_id': 'FBbt_00049542|FBbt_00058208|FBbt_00003767'}]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "#Cell Type:\n", + "#\t\tIn which datasets can I find this cell type (might start from a synonym)\n", + "#\tWhat is NT for this cell type.\n", + "\n", + "# We can't start from a synonym right now. Need to add a new lookup\n", + "# We can look at term info for an individual neuron\n", + "vc.neo_query_wrapper.get_type_TermInfo([vc.lookup_id('Dm9')], summary=True) \n", + "# Improvements: Make summary True by default. Support dataframe output by default for summary\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "dcf0e55a-fae0-41a3-8f6a-f377e160f4cc", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'Distal medullary wide-field amacrine neuron with arbors that span multiple columns in layers M1 and M6A and columnar processes between these two layers. The processes in M2 and M5 occupy a central column position and are closely associated with R7 and R8 photoreceptor axons, covering around 7 columns. There are around 110 Dm9 neurons per hemisphere. They are glutamatergic (Davis et al., 2020).'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# From this we can see that this type is glutamatergic. For whey we can look at description (although notes \n", + "#- in some cases the infor might be on a superclass)\n", + "vc.neo_query_wrapper.get_type_TermInfo([vc.lookup_id('Dm9')])[0]['term']['description'][0]\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "id": "4753fc75-4801-42b3-bbf4-df5bb614b3d7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[{'core': {'symbol': '',\n", + " 'iri': 'http://flybase.org/reports/FBrf0228639',\n", + " 'types': ['Entity', 'Individual', 'pub'],\n", + " 'short_form': 'FBrf0228639',\n", + " 'unique_facets': ['pub'],\n", + " 'label': 'Nern et al., 2015, Proc. Natl. Acad. Sci. U.S.A. 112(22): E2967--E2976'},\n", + " 'FlyBase': 'FBrf0228639',\n", + " 'PubMed': '25964354',\n", + " 'DOI': '10.1073/pnas.1506763112'},\n", + " {'core': {'symbol': '',\n", + " 'iri': 'http://flybase.org/reports/FBrf0244935',\n", + " 'types': ['Entity', 'Individual', 'pub'],\n", + " 'short_form': 'FBrf0244935',\n", + " 'unique_facets': ['pub'],\n", + " 'label': 'Davis et al., 2020, eLife 9: e50901'},\n", + " 'FlyBase': 'FBrf0244935',\n", + " 'PubMed': '31939737',\n", + " 'DOI': '10.7554/eLife.50901'},\n", + " {'core': {'symbol': '',\n", + " 'iri': 'http://flybase.org/reports/FBrf0222324',\n", + " 'types': ['Entity', 'Individual', 'pub'],\n", + " 'short_form': 'FBrf0222324',\n", + " 'unique_facets': ['pub'],\n", + " 'label': 'Takemura et al., 2013, Nature 500(7461): 175--181'},\n", + " 'FlyBase': 'FBrf0222324',\n", + " 'PubMed': '23925240',\n", + " 'DOI': '10.1038/nature12450'},\n", + " {'core': {'symbol': '',\n", + " 'iri': 'http://flybase.org/reports/FBrf0252485',\n", + " 'types': ['Entity', 'Individual', 'pub'],\n", + " 'short_form': 'FBrf0252485',\n", + " 'unique_facets': ['pub'],\n", + " 'label': 'Kind et al., 2021, eLife 10: e71858'},\n", + " 'FlyBase': 'FBrf0252485',\n", + " 'PubMed': '34913436',\n", + " 'DOI': '10.7554/eLife.71858'}]" + ] + }, + "execution_count": 17, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.neo_query_wrapper.get_type_TermInfo([vc.lookup_id('Dm9')])[0]['def_pubs']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "438cb783-c5ef-4c7d-a061-064176c7624b", + "metadata": {}, + "outputs": [], + "source": [ + "# Supporting ref = label': 'Davis et al., 2020, eLife 9: e50901'" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "3175ccf6-7a1a-49fc-a10e-cc8ea6932d3d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
upstream_neuron_idupstream_neuron_nameweightdownstream_neuron_iddownstream_neuron_nameupstream_classdownstream_classup_data_sourceup_accessiondown_sourcedown_accession
0VFB_001029faDm9#7 (FAFB:11916195)2VFB_001029fcDm2#7 (FAFB:11918130)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm2NoneNoneNoneNone
1VFB_001029c5Dm9#2 (FAFB:11447061)4VFB_001029aiDm8#4 (FAFB:10208775)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm8NoneNoneNoneNone
2VFB_001029crDm9#1 (FAFB:11452427)2VFB_001029aiDm8#4 (FAFB:10208775)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm8NoneNoneNoneNone
3VFB_001029c5Dm9#2 (FAFB:11447061)3VFB_001029aeDm8#1 (FAFB:10109586)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm8NoneNoneNoneNone
4VFB_001029bqDm9#9 (FAFB:10657500)2VFB_001029asDm-DRA2#1 (FAFB:10411788)distal medullary amacrine neuron Dm9distal medullary amacrine neuron Dm-DRA2NoneNoneNoneNone
\n", + "
" + ], + "text/plain": [ + " upstream_neuron_id upstream_neuron_name weight downstream_neuron_id \\\n", + "0 VFB_001029fa Dm9#7 (FAFB:11916195) 2 VFB_001029fc \n", + "1 VFB_001029c5 Dm9#2 (FAFB:11447061) 4 VFB_001029ai \n", + "2 VFB_001029cr Dm9#1 (FAFB:11452427) 2 VFB_001029ai \n", + "3 VFB_001029c5 Dm9#2 (FAFB:11447061) 3 VFB_001029ae \n", + "4 VFB_001029bq Dm9#9 (FAFB:10657500) 2 VFB_001029as \n", + "\n", + " downstream_neuron_name upstream_class \\\n", + "0 Dm2#7 (FAFB:11918130) distal medullary amacrine neuron Dm9 \n", + "1 Dm8#4 (FAFB:10208775) distal medullary amacrine neuron Dm9 \n", + "2 Dm8#4 (FAFB:10208775) distal medullary amacrine neuron Dm9 \n", + "3 Dm8#1 (FAFB:10109586) distal medullary amacrine neuron Dm9 \n", + "4 Dm-DRA2#1 (FAFB:10411788) distal medullary amacrine neuron Dm9 \n", + "\n", + " downstream_class up_data_source up_accession \\\n", + "0 distal medullary amacrine neuron Dm2 None None \n", + "1 distal medullary amacrine neuron Dm8 None None \n", + "2 distal medullary amacrine neuron Dm8 None None \n", + "3 distal medullary amacrine neuron Dm8 None None \n", + "4 distal medullary amacrine neuron Dm-DRA2 None None \n", + "\n", + " down_source down_accession \n", + "0 None None \n", + "1 None None \n", + "2 None None \n", + "3 None None \n", + "4 None None " + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.get_connected_neurons_by_type(upstream_type='Dm9', downstream_type='Dm', weight=1) # Note " + ] + }, + { + "cell_type": "markdown", + "id": "ba843645-d3dc-4e5d-a14f-42322b8874bc", + "metadata": {}, + "source": [ + "# Notes - \n", + "\n", + "* we have a problem with queries running indefinitely when we go above Dm as downstream neuron type.\n", + " * We could deal with this for the most general use-case - Neuron by making all args optional but failing if at least one of upstream or downstream are filled. There's no need to query up to neuron because we know this form the Semantic tag\n", + "* Need to fix typ on in data source return\n", + " ` \"WHERE exists(s1.is_data_source) AND s2.is_data_source = True \" \\`\n", + " -->\n", + " ` \"WHERE exists(s2.is_data_source) AND s2.is_data_source = True \" \\`\n", + "\n", + "With the second fixed we will return datasets - BUT the dataset names are really not easy to understand. THIS NEEDS TO BE FIXED. There has already been some work on this to add SYMBOLS. We need to be returning these in queries!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "28bba6ea-945d-4124-950b-d78f41f36b34", + "metadata": {}, + "outputs": [], + "source": [ + "# \tNTR profiles of downstream neurons corresponding to NT starting neuron \n" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "f98eacb7-c359-4439-b9e7-6169f828b0a9", + "metadata": {}, + "outputs": [], + "source": [ + "# Dm9 downstream types\n", + "dm9_ds_type= set(vc.get_connected_neurons_by_type(upstream_type='Dm9', downstream_type='Dm', weight=1)['downstream_class'])" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "ec1972a4-c388-4901-a61f-4ad91908e42a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'distal medullary amacrine neuron Dm-DRA2',\n", + " 'distal medullary amacrine neuron Dm2',\n", + " 'distal medullary amacrine neuron Dm8'}" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dm9_ds_type" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "8fd4b430-edc9-434d-ab12-999ffc3e5614", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['Acetylcholine_receptor',\n", + " 'Calcium_binding',\n", + " 'Carbohydrate_binding',\n", + " 'Chaperone',\n", + " 'Cytoskeleton_binding',\n", + " 'DNA_binding',\n", + " 'Dopamine_receptor',\n", + " 'Enzyme',\n", + " 'GABA_receptor',\n", + " 'GPCR',\n", + " 'Glutamate_receptor',\n", + " 'Gustatory_receptor',\n", + " 'Histamine_receptor',\n", + " 'Hormone',\n", + " 'Ion_channel',\n", + " 'Ligand',\n", + " 'Lipid_binding',\n", + " 'Mechanosensory_ion_channel',\n", + " 'Metal_ion_binding',\n", + " 'Neuropeptide',\n", + " 'Neurotransmitter_receptor',\n", + " 'Octopamine_receptor',\n", + " 'Odorant_binding',\n", + " 'Olfactory_receptor',\n", + " 'Peptide_or_protein_hormone_receptor',\n", + " 'Photoreceptor',\n", + " 'RNA_binding',\n", + " 'Receptor',\n", + " 'Regulator',\n", + " 'Serotonin_receptor',\n", + " 'Small_molecule_binding',\n", + " 'Structural_molecule',\n", + " 'Thermosensory_ion_channel',\n", + " 'Transcription_factor',\n", + " 'Transporter',\n", + " 'Tyramine_receptor']" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.get_gene_function_filters()" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "49ee182c-29f8-4a5a-b439-47ed1297db34", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "\u001b[0;31mSignature:\u001b[0m\n", + "\u001b[0mvc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_transcriptomic_profile\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mcell_type\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mgene_type\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m \u001b[0mreturn_dataframe\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\n", + "\u001b[0;34m\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mDocstring:\u001b[0m\n", + "Get gene expression data for a given cell_type.\n", + "\n", + "Returns a DataFrame of gene expression data for clusters of cells annotated as cell_type (or subtypes).\n", + "Can optionally restrict to a gene_type - these can be retrieved by running get_gene_function_filters.\n", + "If no data is found, returns False.\n", + "\n", + ":param cell_type: The ID, name or symbol of a class in the Drosophila Anatomy Ontology (FBbt).\n", + ":param gene_type: Optional. A gene function label - these can be retrieved by running get_gene_function_filters().\n", + ":return: DataFrame with gene expression data for clusters of cells annotated as cell_type (or subtypes).\n", + ":rtype: DataFrame\n", + "\u001b[0;31mFile:\u001b[0m ~/Documents/GitHub/VFB_connect/venv/lib/python3.9/site-packages/vfb_connect/cross_server_tools.py\n", + "\u001b[0;31mType:\u001b[0m method" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "vc.get_transcriptomic_profile?\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "074296ba-829c-42e1-9b3f-228f4c75acf5", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "5b81af15-8d97-4400-b666-f2b2c48b00ea", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Getting transcriptomic profile for distal medullary amacrine neuron Dm-DRA2\n", + "Empty DataFrame\n", + "Columns: []\n", + "Index: []\n", + "Getting transcriptomic profile for distal medullary amacrine neuron Dm2\n", + " cell_type cell_type_id sample_sex \\\n", + "0 distal medullary amacrine neuron Dm2 FBbt_00003769 None \n", + "1 distal medullary amacrine neuron Dm2 FBbt_00003769 None \n", + "\n", + " sample_tissue ref gene \\\n", + "0 [adult optic lobe] Özel et al., 2021, Nature 589(7840): 88--95 GluClα \n", + "1 [adult optic lobe] Özel et al., 2021, Nature 589(7840): 88--95 GluRIB \n", + "\n", + " gene_id function extent \\\n", + "0 FBgn0024963 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.451883 \n", + "1 FBgn0264000 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.305439 \n", + "\n", + " level \n", + "0 1098.2018 \n", + "1 1094.0442 \n", + "Getting transcriptomic profile for distal medullary amacrine neuron Dm8\n", + " cell_type cell_type_id sample_sex \\\n", + "0 distal medullary amacrine neuron Dm8 FBbt_00013774 male organism \n", + "1 distal medullary amacrine neuron Dm8 FBbt_00013774 None \n", + "2 distal medullary amacrine neuron Dm8 FBbt_00013774 female organism \n", + "3 distal medullary amacrine neuron Dm8 FBbt_00013774 None \n", + "4 distal medullary amacrine neuron Dm8 FBbt_00013774 male organism \n", + "5 distal medullary amacrine neuron Dm8 FBbt_00013774 None \n", + "6 distal medullary amacrine neuron Dm8 FBbt_00013774 female organism \n", + "7 distal medullary amacrine neuron Dm8 FBbt_00013774 female organism \n", + "8 distal medullary amacrine neuron Dm8 FBbt_00013774 None \n", + "9 distal medullary amacrine neuron Dm8 FBbt_00013774 female organism \n", + "10 distal medullary amacrine neuron Dm8 FBbt_00013774 male organism \n", + "\n", + " sample_tissue \\\n", + "0 [wing, haltere, adult, adult pars intercerebra... \n", + "1 [adult head, proboscis, male reproductive syst... \n", + "2 [adult head, adult corpus cardiacum, antenna, ... \n", + "3 [adult optic lobe] \n", + "4 [wing, haltere, adult, adult pars intercerebra... \n", + "5 [adult head, proboscis, male reproductive syst... \n", + "6 [adult head, adult corpus cardiacum, antenna, ... \n", + "7 [adult head, adult corpus cardiacum, antenna, ... \n", + "8 [adult head, proboscis, male reproductive syst... \n", + "9 [adult head, adult corpus cardiacum, antenna, ... \n", + "10 [wing, haltere, adult, adult pars intercerebra... \n", + "\n", + " ref gene gene_id \\\n", + "0 Li et al., 2022, Science 375(6584): eabk2432 CG11155 FBgn0039927 \n", + "1 Li et al., 2022, Science 375(6584): eabk2432 CG11155 FBgn0039927 \n", + "2 Li et al., 2022, Science 375(6584): eabk2432 CG11155 FBgn0039927 \n", + "3 Özel et al., 2021, Nature 589(7840): 88--95 CG11155 FBgn0039927 \n", + "4 Li et al., 2022, Science 375(6584): eabk2432 GluClα FBgn0024963 \n", + "5 Li et al., 2022, Science 375(6584): eabk2432 GluClα FBgn0024963 \n", + "6 Li et al., 2022, Science 375(6584): eabk2432 GluClα FBgn0024963 \n", + "7 Li et al., 2022, Science 375(6584): eabk2432 GluRIB FBgn0264000 \n", + "8 Li et al., 2022, Science 375(6584): eabk2432 Nmdar2 FBgn0053513 \n", + "9 Li et al., 2022, Science 375(6584): eabk2432 Nmdar2 FBgn0053513 \n", + "10 Li et al., 2022, Science 375(6584): eabk2432 mGluR FBgn0019985 \n", + "\n", + " function extent level \n", + "0 [Receptor, Ion_channel, Transporter, Glutamate... 0.720000 1700.67880 \n", + "1 [Receptor, Ion_channel, Transporter, Glutamate... 0.633803 1543.74290 \n", + "2 [Receptor, Ion_channel, Transporter, Glutamate... 0.482759 1349.29880 \n", + "3 [Receptor, Ion_channel, Transporter, Glutamate... 0.226744 740.19415 \n", + "4 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.720000 1534.37680 \n", + "5 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.492958 1564.11840 \n", + "6 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.517241 1685.25260 \n", + "7 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.241379 848.22955 \n", + "8 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.225352 1295.88900 \n", + "9 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.206897 1154.15540 \n", + "10 [Small_molecule_binding, Receptor, GPCR, Lipid... 0.240000 968.85333 \n" + ] + } + ], + "source": [ + "for t in dm9_ds_type:\n", + " print(\"Getting transcriptomic profile for \" + t)\n", + " print(vc.get_transcriptomic_profile(t, gene_type='Glutamate_receptor'))\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "fdc6c493-7955-4feb-9200-31eeaf42239f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
cell_typecell_type_idsample_sexsample_tissuerefgenegene_idfunctionextentlevel
0distal medullary amacrine neuron Dm2FBbt_00003769None[adult optic lobe]Özel et al., 2021, Nature 589(7840): 88--95GluClαFBgn0024963[Receptor, Neurotransmitter_receptor, Ion_chan...0.4518831098.2018
1distal medullary amacrine neuron Dm2FBbt_00003769None[adult optic lobe]Özel et al., 2021, Nature 589(7840): 88--95GluRIBFBgn0264000[Receptor, Neurotransmitter_receptor, Ion_chan...0.3054391094.0442
\n", + "
" + ], + "text/plain": [ + " cell_type cell_type_id sample_sex \\\n", + "0 distal medullary amacrine neuron Dm2 FBbt_00003769 None \n", + "1 distal medullary amacrine neuron Dm2 FBbt_00003769 None \n", + "\n", + " sample_tissue ref gene \\\n", + "0 [adult optic lobe] Özel et al., 2021, Nature 589(7840): 88--95 GluClα \n", + "1 [adult optic lobe] Özel et al., 2021, Nature 589(7840): 88--95 GluRIB \n", + "\n", + " gene_id function extent \\\n", + "0 FBgn0024963 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.451883 \n", + "1 FBgn0264000 [Receptor, Neurotransmitter_receptor, Ion_chan... 0.305439 \n", + "\n", + " level \n", + "0 1098.2018 \n", + "1 1094.0442 " + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.get_transcriptomic_profile('Dm2', gene_type='Glutamate_receptor')" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "id": "5b08def5-58f1-45ee-ab96-01594e3e705b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
upstream_neuron_idupstream_neuron_nameweightdownstream_neuron_iddownstream_neuron_nameupstream_classdownstream_classup_data_sourceup_accessiondown_sourcedown_accession
0VFB_001029aiDm8#4 (FAFB:10208775)22VFB_001029crDm9#1 (FAFB:11452427)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
1VFB_001029aeDm8#1 (FAFB:10109586)23VFB_001029crDm9#1 (FAFB:11452427)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
2VFB_001029aeDm8#1 (FAFB:10109586)7VFB_001029eeDm9#4 (FAFB:11484679)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
3VFB_001029ahDm8#11 (FAFB:10196189)8VFB_001029eeDm9#4 (FAFB:11484679)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
4VFB_001029ahDm8#11 (FAFB:10196189)3VFB_001029c5Dm9#2 (FAFB:11447061)distal medullary amacrine neuron Dm8distal medullary amacrine neuron Dm9NoneNoneNoneNone
....................................
112VFB_001029ahDm8#11 (FAFB:10196189)2VFB_001029b7Dm#9 (FAFB:10537970)distal medullary amacrine neuron Dm8distal medullary amacrine neuronNoneNoneNoneNone
113VFB_001029clDm11#1 (FAFB:11450453)2VFB_001029b7Dm#9 (FAFB:10537970)distal medullary amacrine neuron Dm11distal medullary amacrine neuronNoneNoneNoneNone
114VFB_001029ceDm2#1 (FAFB:11448822)2VFB_001029b7Dm#9 (FAFB:10537970)distal medullary amacrine neuron Dm2distal medullary amacrine neuronNoneNoneNoneNone
115VFB_001029aeDm8#1 (FAFB:10109586)11VFB_001029cgDm#2 (FAFB:11448962)distal medullary amacrine neuron Dm8distal medullary amacrine neuronNoneNoneNoneNone
116VFB_001029ahDm8#11 (FAFB:10196189)5VFB_001029cgDm#2 (FAFB:11448962)distal medullary amacrine neuron Dm8distal medullary amacrine neuronNoneNoneNoneNone
\n", + "

117 rows × 11 columns

\n", + "
" + ], + "text/plain": [ + " upstream_neuron_id upstream_neuron_name weight downstream_neuron_id \\\n", + "0 VFB_001029ai Dm8#4 (FAFB:10208775) 22 VFB_001029cr \n", + "1 VFB_001029ae Dm8#1 (FAFB:10109586) 23 VFB_001029cr \n", + "2 VFB_001029ae Dm8#1 (FAFB:10109586) 7 VFB_001029ee \n", + "3 VFB_001029ah Dm8#11 (FAFB:10196189) 8 VFB_001029ee \n", + "4 VFB_001029ah Dm8#11 (FAFB:10196189) 3 VFB_001029c5 \n", + ".. ... ... ... ... \n", + "112 VFB_001029ah Dm8#11 (FAFB:10196189) 2 VFB_001029b7 \n", + "113 VFB_001029cl Dm11#1 (FAFB:11450453) 2 VFB_001029b7 \n", + "114 VFB_001029ce Dm2#1 (FAFB:11448822) 2 VFB_001029b7 \n", + "115 VFB_001029ae Dm8#1 (FAFB:10109586) 11 VFB_001029cg \n", + "116 VFB_001029ah Dm8#11 (FAFB:10196189) 5 VFB_001029cg \n", + "\n", + " downstream_neuron_name upstream_class \\\n", + "0 Dm9#1 (FAFB:11452427) distal medullary amacrine neuron Dm8 \n", + "1 Dm9#1 (FAFB:11452427) distal medullary amacrine neuron Dm8 \n", + "2 Dm9#4 (FAFB:11484679) distal medullary amacrine neuron Dm8 \n", + "3 Dm9#4 (FAFB:11484679) distal medullary amacrine neuron Dm8 \n", + "4 Dm9#2 (FAFB:11447061) distal medullary amacrine neuron Dm8 \n", + ".. ... ... \n", + "112 Dm#9 (FAFB:10537970) distal medullary amacrine neuron Dm8 \n", + "113 Dm#9 (FAFB:10537970) distal medullary amacrine neuron Dm11 \n", + "114 Dm#9 (FAFB:10537970) distal medullary amacrine neuron Dm2 \n", + "115 Dm#2 (FAFB:11448962) distal medullary amacrine neuron Dm8 \n", + "116 Dm#2 (FAFB:11448962) distal medullary amacrine neuron Dm8 \n", + "\n", + " downstream_class up_data_source up_accession \\\n", + "0 distal medullary amacrine neuron Dm9 None None \n", + "1 distal medullary amacrine neuron Dm9 None None \n", + "2 distal medullary amacrine neuron Dm9 None None \n", + "3 distal medullary amacrine neuron Dm9 None None \n", + "4 distal medullary amacrine neuron Dm9 None None \n", + ".. ... ... ... \n", + "112 distal medullary amacrine neuron None None \n", + "113 distal medullary amacrine neuron None None \n", + "114 distal medullary amacrine neuron None None \n", + "115 distal medullary amacrine neuron None None \n", + "116 distal medullary amacrine neuron None None \n", + "\n", + " down_source down_accession \n", + "0 None None \n", + "1 None None \n", + "2 None None \n", + "3 None None \n", + "4 None None \n", + ".. ... ... \n", + "112 None None \n", + "113 None None \n", + "114 None None \n", + "115 None None \n", + "116 None None \n", + "\n", + "[117 rows x 11 columns]" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vc.get_connected_neurons_by_type(upstream_type='Dm', downstream_type='Dm', weight=1)" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "5eba1f56-dafd-4dc8-8eea-347457a80482", + "metadata": {}, + "outputs": [], + "source": [ + "# Consider adding query that => detailed MF profile of each Gene returned?\n", + "\n", + "q = vc.nc.commit_list([\"MATCH (c:Class:Neuron)<-[:composed_primarily_of]-(:Individual)-[:expresses]->(g:Gene:Glutamate_receptor)-[]->(go:Class) where go.curie =~ 'GO:.*' return distinct c.label as neuron, g.label as gene, collect(distinct go.label) as molecular_functions order by c.label\"])\n" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "197141cc-30ea-40aa-b05f-01f0b06bb807", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
neurongenemolecular_functions
0CCHamide-1 neuronNmdar2[NMDA glutamate receptor activity, transmitter...
1CCHamide-1 neuronKaiR1D[transmitter-gated monoatomic ion channel acti...
2CCHamide-1 neuronGluClα[Group 3 - Selective Cl- transport, neurotrans...
3CCHamide-1 neuronNmdar1[NMDA glutamate receptor activity, signaling r...
4CCHamide-1 neuronCG11155[Activation of highly calcium permeable postsy...
............
702transmedullary neuron Tm9GluClα[Group 3 - Selective Cl- transport, neurotrans...
703transmedullary neuron Tm9CG11155[Activation of highly calcium permeable postsy...
704transmedullary neuron Tm9GluRIB[transmitter-gated monoatomic ion channel acti...
705transmedullary neuron Tm9GluRIA[transmitter-gated monoatomic ion channel acti...
706transmedullary neuron Tm9mGluR[group II metabotropic glutamate receptor acti...
\n", + "

707 rows × 3 columns

\n", + "
" + ], + "text/plain": [ + " neuron gene \\\n", + "0 CCHamide-1 neuron Nmdar2 \n", + "1 CCHamide-1 neuron KaiR1D \n", + "2 CCHamide-1 neuron GluClα \n", + "3 CCHamide-1 neuron Nmdar1 \n", + "4 CCHamide-1 neuron CG11155 \n", + ".. ... ... \n", + "702 transmedullary neuron Tm9 GluClα \n", + "703 transmedullary neuron Tm9 CG11155 \n", + "704 transmedullary neuron Tm9 GluRIB \n", + "705 transmedullary neuron Tm9 GluRIA \n", + "706 transmedullary neuron Tm9 mGluR \n", + "\n", + " molecular_functions \n", + "0 [NMDA glutamate receptor activity, transmitter... \n", + "1 [transmitter-gated monoatomic ion channel acti... \n", + "2 [Group 3 - Selective Cl- transport, neurotrans... \n", + "3 [NMDA glutamate receptor activity, signaling r... \n", + "4 [Activation of highly calcium permeable postsy... \n", + ".. ... \n", + "702 [Group 3 - Selective Cl- transport, neurotrans... \n", + "703 [Activation of highly calcium permeable postsy... \n", + "704 [transmitter-gated monoatomic ion channel acti... \n", + "705 [transmitter-gated monoatomic ion channel acti... \n", + "706 [group II metabotropic glutamate receptor acti... \n", + "\n", + "[707 rows x 3 columns]" + ] + }, + "execution_count": 40, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "from vfb_connect.neo.neo4j_tools import dict_cursor\n", + "import pandas as pd\n", + "pd.DataFrame.from_records(dict_cursor(q))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1d35e70e-eac5-4ea5-ae48-d602bd86c670", + "metadata": {}, + "outputs": [], + "source": [ + "# Consider adding queries to => broader GO annotation profiles for receptors ==> broader biological story." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}