{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Obtaining Data for Single Cells " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This section will serve as an introduction to the Allen Cell Types database. We'll work with the AllenSDK to see what information we can gain about our cells.\n", "\n", "First, let's make sure you have an updated version of the Allen Institute Database installed. If you do not have the version below, this cell will install it for you. There is more information on installing the AllenSDK in the install guide. " ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "allensdk already installed.\n" ] } ], "source": [ "# This will ensure that the AllenSDK is installed.\n", "# If not, it will install it for you.\n", "try:\n", " import allensdk\n", " if allensdk.__version__ == '2.11.2':\n", " print('allensdk already installed.')\n", " else: \n", " print('incompatible version of allensdk installed')\n", " !pip install allensdk==2.11.2\n", "except ImportError as e:\n", " !pip install allensdk==2.11.2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, we'll `import` the CellTypesCache module. This module provides tools to allow us to access information from the Allen Cell Types database. We're passing it a **manifest** filename as well. CellTypesCache will store the data in the path specified by the manifest filename. You can look under cell_types in your directory, and take a look at the file.\n", "\n", "If you're curious, you can see the full source documentation for the core package on the Allen Brain Atlas website" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Packages were successfully imported.\n" ] } ], "source": [ "# Import the \"Cell Types Cache\" from the AllenSDK core package\n", "from allensdk.core.cell_types_cache import CellTypesCache\n", "\n", "# Import CellTypesApi, which will allow us to query the database.\n", "from allensdk.api.queries.cell_types_api import CellTypesApi\n", "\n", "# Import packages \n", "import pandas as pd\n", "import numpy as np\n", "import matplotlib.pyplot as plt \n", "%matplotlib inline \n", "import warnings\n", "warnings.filterwarnings('ignore')\n", "\n", "# We'll then initialize the cache as 'ctc' (cell types cache)\n", "ctc = CellTypesCache(manifest_file='cell_types/manifest.json')\n", "\n", "print('Packages were successfully imported.')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get Available Cells" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `get_cells()` method downloads metadata for cells in the database. The database contains human cells and mouse cells. By default, `get_cells()` downloads metadata for *all* cells in the database. Alternatively, you can filter the database to only include cells collected from a certain species.\n", "Look through the documentation for the CellTypesCache for more information on the `get_cells` method." ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of cells: 2333\n" ] }, { "data": { "text/html": [ "
\n", " | reporter_status | \n", "cell_soma_location | \n", "species | \n", "name | \n", "structure_layer_name | \n", "structure_area_id | \n", "structure_area_abbrev | \n", "transgenic_line | \n", "dendrite_type | \n", "apical | \n", "reconstruction_type | \n", "disease_state | \n", "donor_id | \n", "structure_hemisphere | \n", "normalized_depth | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
525011903 | \n", "None | \n", "[273.0, 354.0, 216.0] | \n", "Homo Sapiens | \n", "H16.03.003.01.14.02 | \n", "3 | \n", "12113 | \n", "FroL | \n", "\n", " | spiny | \n", "intact | \n", "None | \n", "epilepsy | \n", "524848408 | \n", "right | \n", "NaN | \n", "
565871768 | \n", "positive | \n", "[8966.56330957526, 1429.52689052075, 8567.3896... | \n", "Mus musculus | \n", "Oxtr-2A-Cre;Ai14-293837.03.01.02 | \n", "5 | \n", "385 | \n", "VISp | \n", "Oxtr-T2A-Cre | \n", "aspiny | \n", "NA | \n", "None | \n", "\n", " | 563340157 | \n", "left | \n", "0.582057 | \n", "
469801138 | \n", "positive | \n", "[7872.53138541818, 993.212032389272, 3127.1530... | \n", "Mus musculus | \n", "Pvalb-IRES-Cre;Ai14-170927.05.02.01 | \n", "4 | \n", "385 | \n", "VISp | \n", "Pvalb-IRES-Cre | \n", "aspiny | \n", "NA | \n", "None | \n", "\n", " | 319194354 | \n", "right | \n", "0.469578 | \n", "
528642047 | \n", "None | \n", "[69.0, 254.0, 96.0] | \n", "Homo Sapiens | \n", "H16.06.009.01.02.06.05 | \n", "5 | \n", "12141 | \n", "MTG | \n", "\n", " | aspiny | \n", "NA | \n", "None | \n", "epilepsy | \n", "528574320 | \n", "left | \n", "NaN | \n", "
605889373 | \n", "positive | \n", "[9400.0, 1520.74232706376, 2188.13845194139] | \n", "Mus musculus | \n", "Vipr2-IRES2-Cre;Slc32a1-T2A-FlpO;Ai65-337419.0... | \n", "2/3 | \n", "385 | \n", "VISp | \n", "Slc32a1-T2A-FlpO|Vipr2-IRES2-Cre | \n", "aspiny | \n", "NA | \n", "None | \n", "\n", " | 605622695 | \n", "right | \n", "NaN | \n", "
\n", " | average_bifurcation_angle_local | \n", "average_bifurcation_angle_remote | \n", "average_contraction | \n", "average_diameter | \n", "average_fragmentation | \n", "average_parent_daughter_ratio | \n", "hausdorff_dimension | \n", "id | \n", "max_branch_order | \n", "max_euclidean_distance | \n", "... | \n", "overall_width | \n", "scale_factor_x | \n", "scale_factor_y | \n", "scale_factor_z | \n", "soma_surface | \n", "superseded | \n", "tags | \n", "total_length | \n", "total_surface | \n", "total_volume | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
specimen_id | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
478107198 | \n", "82.727781 | \n", "NaN | \n", "0.864267 | \n", "0.345092 | \n", "20.723077 | \n", "0.964510 | \n", "NaN | \n", "491119743 | \n", "6.0 | \n", "99.779724 | \n", "... | \n", "136.267522 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "435.740270 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "1666.082926 | \n", "1803.875644 | \n", "167.343086 | \n", "
502367941 | \n", "82.506680 | \n", "NaN | \n", "0.903890 | \n", "0.634047 | \n", "105.277778 | \n", "0.862183 | \n", "NaN | \n", "546781359 | \n", "3.0 | \n", "432.383110 | \n", "... | \n", "370.170045 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "1446.587725 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "2277.259374 | \n", "4543.139073 | \n", "921.571895 | \n", "
515771244 | \n", "77.536678 | \n", "NaN | \n", "0.863104 | \n", "0.417929 | \n", "73.666667 | \n", "0.926633 | \n", "NaN | \n", "537042261 | \n", "6.0 | \n", "373.630444 | \n", "... | \n", "381.015114 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "287.118123 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "3589.339062 | \n", "4704.910407 | \n", "582.285423 | \n", "
561435279 | \n", "76.583222 | \n", "NaN | \n", "0.900537 | \n", "0.400396 | \n", "95.979167 | \n", "0.942049 | \n", "NaN | \n", "689123605 | \n", "11.0 | \n", "943.382549 | \n", "... | \n", "524.550156 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "180.994813 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "5416.228778 | \n", "6814.933290 | \n", "740.722806 | \n", "
591268268 | \n", "72.019250 | \n", "NaN | \n", "0.873518 | \n", "0.227626 | \n", "47.535714 | \n", "1.000000 | \n", "NaN | \n", "657879305 | \n", "5.0 | \n", "186.218009 | \n", "... | \n", "261.459057 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "55.055236 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "1659.465869 | \n", "1185.773462 | \n", "69.144146 | \n", "
5 rows × 29 columns
\n", "\n", " | reporter_status | \n", "cell_soma_location | \n", "species | \n", "name | \n", "structure_layer_name | \n", "structure_area_id | \n", "structure_area_abbrev | \n", "transgenic_line | \n", "dendrite_type | \n", "apical | \n", "... | \n", "overall_width | \n", "scale_factor_x | \n", "scale_factor_y | \n", "scale_factor_z | \n", "soma_surface | \n", "superseded | \n", "tags | \n", "total_length | \n", "total_surface | \n", "total_volume | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
313861608 | \n", "positive | \n", "[9349.44051500564, 1314.78991021449, 3245.6530... | \n", "Mus musculus | \n", "Pvalb-IRES-Cre;Ai14-165874.04.02.01 | \n", "5 | \n", "385 | \n", "VISp | \n", "Pvalb-IRES-Cre | \n", "aspiny | \n", "NA | \n", "... | \n", "358.994232 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "514.500853 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "3538.876780 | \n", "6041.095769 | \n", "945.093080 | \n", "
313862022 | \n", "positive | \n", "[9489.24257509068, 1423.65239028148, 2785.4430... | \n", "Mus musculus | \n", "Scnn1a-Tg2-Cre;Ai14-167081.03.02.01 | \n", "4 | \n", "385 | \n", "VISp | \n", "Scnn1a-Tg2-Cre | \n", "spiny | \n", "intact | \n", "... | \n", "287.122628 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "268.777679 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "3498.090031 | \n", "3523.606841 | \n", "306.290931 | \n", "
313862167 | \n", "positive | \n", "[9279.53948496313, 1831.03502009105, 2151.2443... | \n", "Mus musculus | \n", "Sst-IRES-Cre;Ai14-167638.05.02.01 | \n", "4 | \n", "409 | \n", "VISl | \n", "Sst-IRES-Cre | \n", "aspiny | \n", "NA | \n", "... | \n", "327.150383 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "361.118559 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "2644.878298 | \n", "3883.698604 | \n", "512.836253 | \n", "
313862167 | \n", "positive | \n", "[9279.53948496313, 1831.03502009105, 2151.2443... | \n", "Mus musculus | \n", "Sst-IRES-Cre;Ai14-167638.05.02.01 | \n", "4 | \n", "409 | \n", "VISl | \n", "Sst-IRES-Cre | \n", "aspiny | \n", "NA | \n", "... | \n", "327.150383 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "361.118559 | \n", "True | \n", "3D Neuron Reconstruction morphology | \n", "2644.878347 | \n", "3883.699514 | \n", "512.835043 | \n", "
313862306 | \n", "positive | \n", "[8976.63502144556, 1878.14058922573, 8881.4968... | \n", "Mus musculus | \n", "Sst-IRES-Cre;Ai14-167636.04.01.01 | \n", "6a | \n", "385 | \n", "VISp | \n", "Sst-IRES-Cre | \n", "aspiny | \n", "NA | \n", "... | \n", "242.781213 | \n", "0.1144 | \n", "0.1144 | \n", "0.28 | \n", "94.306278 | \n", "False | \n", "3D Neuron Reconstruction morphology | \n", "2502.160541 | \n", "1994.902243 | \n", "141.878464 | \n", "
5 rows × 44 columns
\n", "