2024-heraklion-data/exercises/tabular_split_apply_combine/split_apply_combine_solution.ipynb

685 lines
37 KiB
Plaintext
Raw Normal View History

2024-08-27 14:27:53 +02:00
{
"cells": [
{
"cell_type": "markdown",
"id": "6f6aa857",
"metadata": {},
"source": [
"# Exercise: Compute summary statistics for the neural data"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "8f9bc8b1",
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"\n",
"# Set some Pandas options: maximum number of rows/columns it's going to display\n",
"pd.set_option('display.max_rows', 1000)\n",
"pd.set_option('display.max_columns', 100)"
]
},
{
"cell_type": "markdown",
"id": "1be11d54",
"metadata": {},
"source": [
"# Load the processed neural data"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d2dfebd3",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('processed_QC_passed_2024-07-04_collected_v1.csv')"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "09554c84",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(659, 35)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.shape"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "df95a10b",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>OP</th>\n",
" <th>filename</th>\n",
" <th>slice</th>\n",
" <th>cell_ch</th>\n",
" <th>cell_ID</th>\n",
" <th>day</th>\n",
" <th>treatment</th>\n",
" <th>hrs_incubation</th>\n",
" <th>repatch</th>\n",
" <th>hrs_after_OP</th>\n",
" <th>Rs</th>\n",
" <th>Rin</th>\n",
" <th>resting_potential</th>\n",
" <th>max_spikes</th>\n",
" <th>Rheobase</th>\n",
" <th>AP_heigth</th>\n",
" <th>TH</th>\n",
" <th>max_depol</th>\n",
" <th>max_repol</th>\n",
" <th>membra_time_constant_tau</th>\n",
" <th>capacitance</th>\n",
" <th>comments</th>\n",
" <th>rheo_ramp</th>\n",
" <th>AP_halfwidth</th>\n",
" <th>Rheobse_ramp</th>\n",
" <th>Unnamed: 27</th>\n",
" <th>rheos_ramp</th>\n",
" <th>comment</th>\n",
" <th></th>\n",
" <th>high K concentration</th>\n",
" <th>RMP_from_char</th>\n",
" <th>tissue_source</th>\n",
" <th>area</th>\n",
" <th>patient_age</th>\n",
" <th>patcher</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>OP230420</td>\n",
" <td>23420003.abf</td>\n",
" <td>S1</td>\n",
" <td>1</td>\n",
" <td>23420S1c1</td>\n",
" <td>D1</td>\n",
" <td>TTX</td>\n",
" <td>0.0</td>\n",
" <td>no</td>\n",
" <td>10.416389</td>\n",
" <td>6.675643</td>\n",
" <td>39.025301</td>\n",
" <td>-74.285889</td>\n",
" <td>24</td>\n",
" <td>200.0</td>\n",
" <td>80.749512</td>\n",
" <td>-35.278320</td>\n",
" <td>336.181641</td>\n",
" <td>-60.791016</td>\n",
" <td>19.40</td>\n",
" <td>510.601767</td>\n",
" <td>0</td>\n",
" <td>753.380113</td>\n",
" <td>1.151009</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>8 mM</td>\n",
" <td>-61.828554</td>\n",
" <td>Bielefeld</td>\n",
" <td>temporal</td>\n",
" <td>13.0</td>\n",
" <td>Verji</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>OP230420</td>\n",
" <td>23420003.abf</td>\n",
" <td>S1</td>\n",
" <td>3</td>\n",
" <td>23420S1c3</td>\n",
" <td>D1</td>\n",
" <td>TTX</td>\n",
" <td>0.0</td>\n",
" <td>no</td>\n",
" <td>10.416389</td>\n",
" <td>7.867174</td>\n",
" <td>48.728367</td>\n",
" <td>-69.573975</td>\n",
" <td>26</td>\n",
" <td>300.0</td>\n",
" <td>78.448486</td>\n",
" <td>-32.043457</td>\n",
" <td>350.097656</td>\n",
" <td>-67.138672</td>\n",
" <td>17.30</td>\n",
" <td>393.397918</td>\n",
" <td>1</td>\n",
" <td>585.102837</td>\n",
" <td>1.006321</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>8 mM</td>\n",
" <td>-60.460298</td>\n",
" <td>Bielefeld</td>\n",
" <td>temporal</td>\n",
" <td>13.0</td>\n",
" <td>Verji</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>OP230420</td>\n",
" <td>23420003.abf</td>\n",
" <td>S1</td>\n",
" <td>6</td>\n",
" <td>23420S1c6</td>\n",
" <td>D1</td>\n",
" <td>TTX</td>\n",
" <td>0.0</td>\n",
" <td>no</td>\n",
" <td>10.416389</td>\n",
" <td>8.820134</td>\n",
" <td>35.971082</td>\n",
" <td>-54.956055</td>\n",
" <td>22</td>\n",
" <td>300.0</td>\n",
" <td>76.660156</td>\n",
" <td>-29.827881</td>\n",
" <td>270.629883</td>\n",
" <td>-52.246094</td>\n",
" <td>14.85</td>\n",
" <td>426.098774</td>\n",
" <td>3</td>\n",
" <td>173.915797</td>\n",
" <td>1.266335</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>8 mM</td>\n",
" <td>-59.615979</td>\n",
" <td>Bielefeld</td>\n",
" <td>temporal</td>\n",
" <td>13.0</td>\n",
" <td>Verji</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>OP230420</td>\n",
" <td>23420003.abf</td>\n",
" <td>S1</td>\n",
" <td>8</td>\n",
" <td>23420S1c8</td>\n",
" <td>D1</td>\n",
" <td>TTX</td>\n",
" <td>0.0</td>\n",
" <td>yes</td>\n",
" <td>10.416389</td>\n",
" <td>6.000400</td>\n",
" <td>31.599917</td>\n",
" <td>-70.550537</td>\n",
" <td>22</td>\n",
" <td>350.0</td>\n",
" <td>81.011963</td>\n",
" <td>-33.068848</td>\n",
" <td>309.448242</td>\n",
" <td>-61.401367</td>\n",
" <td>16.65</td>\n",
" <td>575.513924</td>\n",
" <td>5</td>\n",
" <td>786.927898</td>\n",
" <td>1.182830</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>8 mM</td>\n",
" <td>-60.956350</td>\n",
" <td>Bielefeld</td>\n",
" <td>temporal</td>\n",
" <td>13.0</td>\n",
" <td>Verji</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>OP230420</td>\n",
" <td>23420061.abf</td>\n",
" <td>S1_D2</td>\n",
" <td>8</td>\n",
" <td>23420S1c8</td>\n",
" <td>D2</td>\n",
" <td>TTX</td>\n",
" <td>19.0</td>\n",
" <td>yes</td>\n",
" <td>29.633333</td>\n",
" <td>8.271614</td>\n",
" <td>30.607259</td>\n",
" <td>-70.745850</td>\n",
" <td>1</td>\n",
" <td>1300.0</td>\n",
" <td>48.883057</td>\n",
" <td>-20.855713</td>\n",
" <td>100.952148</td>\n",
" <td>-27.465820</td>\n",
" <td>13.25</td>\n",
" <td>864.892430</td>\n",
" <td>29</td>\n",
" <td>565.938865</td>\n",
" <td>1.504127</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>NaN</td>\n",
" <td>8 mM</td>\n",
" <td>-61.283967</td>\n",
" <td>Bielefeld</td>\n",
" <td>temporal</td>\n",
" <td>13.0</td>\n",
" <td>Verji</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" OP filename slice cell_ch cell_ID day treatment \\\n",
"0 OP230420 23420003.abf S1 1 23420S1c1 D1 TTX \n",
"1 OP230420 23420003.abf S1 3 23420S1c3 D1 TTX \n",
"2 OP230420 23420003.abf S1 6 23420S1c6 D1 TTX \n",
"3 OP230420 23420003.abf S1 8 23420S1c8 D1 TTX \n",
"4 OP230420 23420061.abf S1_D2 8 23420S1c8 D2 TTX \n",
"\n",
" hrs_incubation repatch hrs_after_OP Rs Rin \\\n",
"0 0.0 no 10.416389 6.675643 39.025301 \n",
"1 0.0 no 10.416389 7.867174 48.728367 \n",
"2 0.0 no 10.416389 8.820134 35.971082 \n",
"3 0.0 yes 10.416389 6.000400 31.599917 \n",
"4 19.0 yes 29.633333 8.271614 30.607259 \n",
"\n",
" resting_potential max_spikes Rheobase AP_heigth TH max_depol \\\n",
"0 -74.285889 24 200.0 80.749512 -35.278320 336.181641 \n",
"1 -69.573975 26 300.0 78.448486 -32.043457 350.097656 \n",
"2 -54.956055 22 300.0 76.660156 -29.827881 270.629883 \n",
"3 -70.550537 22 350.0 81.011963 -33.068848 309.448242 \n",
"4 -70.745850 1 1300.0 48.883057 -20.855713 100.952148 \n",
"\n",
" max_repol membra_time_constant_tau capacitance comments rheo_ramp \\\n",
"0 -60.791016 19.40 510.601767 0 753.380113 \n",
"1 -67.138672 17.30 393.397918 1 585.102837 \n",
"2 -52.246094 14.85 426.098774 3 173.915797 \n",
"3 -61.401367 16.65 575.513924 5 786.927898 \n",
"4 -27.465820 13.25 864.892430 29 565.938865 \n",
"\n",
" AP_halfwidth Rheobse_ramp Unnamed: 27 rheos_ramp comment \\\n",
"0 1.151009 NaN NaN NaN NaN NaN \n",
"1 1.006321 NaN NaN NaN NaN NaN \n",
"2 1.266335 NaN NaN NaN NaN NaN \n",
"3 1.182830 NaN NaN NaN NaN NaN \n",
"4 1.504127 NaN NaN NaN NaN NaN \n",
"\n",
" high K concentration RMP_from_char tissue_source area patient_age \\\n",
"0 8 mM -61.828554 Bielefeld temporal 13.0 \n",
"1 8 mM -60.460298 Bielefeld temporal 13.0 \n",
"2 8 mM -59.615979 Bielefeld temporal 13.0 \n",
"3 8 mM -60.956350 Bielefeld temporal 13.0 \n",
"4 8 mM -61.283967 Bielefeld temporal 13.0 \n",
"\n",
" patcher \n",
"0 Verji \n",
"1 Verji \n",
"2 Verji \n",
"3 Verji \n",
"4 Verji "
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.head()"
]
},
{
"cell_type": "markdown",
"id": "0b4f6091",
"metadata": {},
"source": [
"# 1. Does capacitance change with age?\n",
"\n",
"* Compute the capacitance by patient age, and plot it\n",
"* Does it change with age? (eyeballing is enough)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "00bb9eb1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Axes: xlabel='patient_age'>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAioAAAGxCAYAAABMeZ2uAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAwhUlEQVR4nO3dfXBUVYL+8eeSkBhC0pIE0h0NARVUJkEpYCHoyDvIiDjGEhxZB0bG0hWRFLAiuK5xHAnDLKIOu0zJWLzqhqqVOLq+IBQSi6EYQ5QlMC6DChLGzmSjoRMgJpic3x/+uEVDAukQ0qeT76fqVtn3nnSfPrb20+fcc45jjDECAACwUJdwVwAAAKA5BBUAAGAtggoAALAWQQUAAFiLoAIAAKxFUAEAANYiqAAAAGsRVAAAgLWiw12B1mhsbNTXX3+thIQEOY4T7uoAAIAWMMaopqZGa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X5poBQPvjZlp0eP5ArQ5XnlTflPiI+bKfNrS3buvfU0cqT6lPSreIqTcAtDWCCjq0SJ494/PEEVAAdHoM/aDDYvYMAEQ+ggo6LGbPAEDkI6igw2L2DABEPoIKOixmzwBA5ONmWnRozJ4BgMhGUEGHx+wZAIhcDP0AAABrEVQAAIC1CCoAAMBaBBUAAGAtggoAALAWQQUAAFiLoAIAAKxFUAEAANYiqAAAAGsRVAAAgLUIKgAAwFoEFQAAYC2CCgAAsBZBBQAAWIugAgAArEVQAQAA1iKoAAAAaxFUAACAtQgqAADAWgQ
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df.groupby('patient_age')['capacitance'].mean().plot(ls='', marker='.')"
]
},
{
"cell_type": "markdown",
"id": "1940d3fe",
"metadata": {},
"source": [
"# 2. Spiking threshold after potassium incubation\n",
"\n",
"1. Does the spiking threshold (TH) change between Day 1 and Day 2?\n",
"2. Does this result depend on the treatment?"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8175fc1c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"day\n",
"D1 -37.276805\n",
"D2 -33.039838\n",
"Name: TH, dtype: float64"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.groupby('day')['TH'].mean()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "fc34eecb",
"metadata": {},
"outputs": [],
"source": [
"th_per_treatment_and_day = df.pivot_table(index='treatment', columns='day', values='TH', aggfunc='mean')"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "05761273",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th>day</th>\n",
" <th>D1</th>\n",
" <th>D2</th>\n",
" </tr>\n",
" <tr>\n",
" <th>treatment</th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Ctrl</th>\n",
" <td>-37.865372</td>\n",
" <td>-35.751658</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TTX</th>\n",
" <td>-36.852170</td>\n",
" <td>-30.008780</td>\n",
" </tr>\n",
" <tr>\n",
" <th>high K</th>\n",
" <td>-36.926069</td>\n",
" <td>-33.162092</td>\n",
" </tr>\n",
" <tr>\n",
" <th>wash in high K</th>\n",
" <td>NaN</td>\n",
" <td>-35.791016</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"day D1 D2\n",
"treatment \n",
"Ctrl -37.865372 -35.751658\n",
"TTX -36.852170 -30.008780\n",
"high K -36.926069 -33.162092\n",
"wash in high K NaN -35.791016"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"th_per_treatment_and_day"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "95fabcd9",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead tr th {\n",
" text-align: left;\n",
" }\n",
"\n",
" .dataframe thead tr:last-of-type th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr>\n",
" <th></th>\n",
" <th colspan=\"2\" halign=\"left\">mean</th>\n",
" <th colspan=\"2\" halign=\"left\">std</th>\n",
" </tr>\n",
" <tr>\n",
" <th>day</th>\n",
" <th>D1</th>\n",
" <th>D2</th>\n",
" <th>D1</th>\n",
" <th>D2</th>\n",
" </tr>\n",
" <tr>\n",
" <th>treatment</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>Ctrl</th>\n",
" <td>-37.865372</td>\n",
" <td>-35.751658</td>\n",
" <td>4.260140</td>\n",
" <td>5.459102</td>\n",
" </tr>\n",
" <tr>\n",
" <th>TTX</th>\n",
" <td>-36.852170</td>\n",
" <td>-30.008780</td>\n",
" <td>5.406569</td>\n",
" <td>6.577182</td>\n",
" </tr>\n",
" <tr>\n",
" <th>high K</th>\n",
" <td>-36.926069</td>\n",
" <td>-33.162092</td>\n",
" <td>3.966294</td>\n",
" <td>4.479648</td>\n",
" </tr>\n",
" <tr>\n",
" <th>wash in high K</th>\n",
" <td>NaN</td>\n",
" <td>-35.791016</td>\n",
" <td>NaN</td>\n",
" <td>1.009906</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" mean std \n",
"day D1 D2 D1 D2\n",
"treatment \n",
"Ctrl -37.865372 -35.751658 4.260140 5.459102\n",
"TTX -36.852170 -30.008780 5.406569 6.577182\n",
"high K -36.926069 -33.162092 3.966294 4.479648\n",
"wash in high K NaN -35.791016 NaN 1.009906"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"th_per_treatment_and_day = df.pivot_table(index='treatment', columns='day', values='TH', aggfunc=['mean', 'std'])\n",
"th_per_treatment_and_day"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dd5023cd",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}