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

447 lines
14 KiB
Plaintext
Raw Permalink Normal View History

2024-08-27 14:27:53 +02:00
{
"cells": [
{
"cell_type": "markdown",
"id": "6f634238",
"metadata": {},
"source": [
"# Exercise: Compute summary statistics for the neural data"
]
},
{
"cell_type": "code",
"execution_count": 2,
"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": "141ca000",
"metadata": {},
"source": [
"# Load the processed neural data"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d2dfebd3",
"metadata": {},
"outputs": [],
"source": [
"df = pd.read_csv('processed_QC_passed_2024-07-04_collected_v1.csv')"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "09554c84",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(659, 35)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.shape"
]
},
{
"cell_type": "code",
"execution_count": 5,
"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": 5,
"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": null,
"id": "bb796266",
"metadata": {},
"outputs": [],
"source": []
},
{
"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": 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
}