1087 lines
34 KiB
Plaintext
1087 lines
34 KiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "f11a76bf",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Exercise: Add experiment information to electrophysiology data"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"id": "b6f2742b",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"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": "2967c84e",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Load electrophysiology data"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"id": "ed626ee3",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"df = pd.read_csv('../../data/QC_passed_2024-07-04_collected.csv')\n",
|
||
|
"info = pd.read_csv('../../data/op_info.csv')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"id": "48d5375f",
|
||
|
"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",
|
||
|
" </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",
|
||
|
" </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",
|
||
|
" </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",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>OP230420</td>\n",
|
||
|
" <td>23420003.abf</td>\n",
|
||
|
" <td>S1</td>\n",
|
||
|
" <td>7</td>\n",
|
||
|
" <td>23420S1c7</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>7.269195</td>\n",
|
||
|
" <td>39.186101</td>\n",
|
||
|
" <td>-69.268799</td>\n",
|
||
|
" <td>24</td>\n",
|
||
|
" <td>300.0</td>\n",
|
||
|
" <td>75.030518</td>\n",
|
||
|
" <td>-29.699707</td>\n",
|
||
|
" <td>242.553711</td>\n",
|
||
|
" <td>-71.411133</td>\n",
|
||
|
" <td>17.15</td>\n",
|
||
|
" <td>478.273362</td>\n",
|
||
|
" <td>4</td>\n",
|
||
|
" <td>598.079936</td>\n",
|
||
|
" <td>0.994396</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.173839</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</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",
|
||
|
" </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 7 23420S1c7 D1 TTX \n",
|
||
|
"4 OP230420 23420003.abf S1 8 23420S1c8 D1 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 7.269195 39.186101 \n",
|
||
|
"4 0.0 yes 10.416389 6.000400 31.599917 \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 -69.268799 24 300.0 75.030518 -29.699707 242.553711 \n",
|
||
|
"4 -70.550537 22 350.0 81.011963 -33.068848 309.448242 \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 -71.411133 17.15 478.273362 4 598.079936 \n",
|
||
|
"4 -61.401367 16.65 575.513924 5 786.927898 \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 0.994396 NaN NaN NaN NaN NaN \n",
|
||
|
"4 1.182830 NaN NaN NaN NaN NaN \n",
|
||
|
"\n",
|
||
|
" high K concentration RMP_from_char \n",
|
||
|
"0 8 mM -61.828554 \n",
|
||
|
"1 8 mM -60.460298 \n",
|
||
|
"2 8 mM -59.615979 \n",
|
||
|
"3 8 mM -61.173839 \n",
|
||
|
"4 8 mM -60.956350 "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"df.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"id": "47191528",
|
||
|
"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>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>OP201027</td>\n",
|
||
|
" <td>Mitte</td>\n",
|
||
|
" <td>temporal</td>\n",
|
||
|
" <td>33</td>\n",
|
||
|
" <td>Rosie</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>OP201029</td>\n",
|
||
|
" <td>Mitte</td>\n",
|
||
|
" <td>temporal</td>\n",
|
||
|
" <td>47</td>\n",
|
||
|
" <td>Rosie</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>OP210323</td>\n",
|
||
|
" <td>Virchow</td>\n",
|
||
|
" <td>temporal</td>\n",
|
||
|
" <td>10</td>\n",
|
||
|
" <td>Rosie</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>OP210615</td>\n",
|
||
|
" <td>Virchow</td>\n",
|
||
|
" <td>temporal</td>\n",
|
||
|
" <td>19</td>\n",
|
||
|
" <td>Rosie</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>OP211123</td>\n",
|
||
|
" <td>Bielefeld</td>\n",
|
||
|
" <td>temporal</td>\n",
|
||
|
" <td>68</td>\n",
|
||
|
" <td>Rosie</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" OP tissue_source area patient_age patcher\n",
|
||
|
"0 OP201027 Mitte temporal 33 Rosie\n",
|
||
|
"1 OP201029 Mitte temporal 47 Rosie\n",
|
||
|
"2 OP210323 Virchow temporal 10 Rosie\n",
|
||
|
"3 OP210615 Virchow temporal 19 Rosie\n",
|
||
|
"4 OP211123 Bielefeld temporal 68 Rosie"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"info.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "2fef4d37",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# 1. Add experiment information to the electrophysiology results\n",
|
||
|
"\n",
|
||
|
"* Is there information for every experiment?\n",
|
||
|
"* How many experiments did each patcher perform? (i.e., individual OPs, or rows in `info`)\n",
|
||
|
"* How many samples did each patcher analyze? (i.e., individual rows in `df`)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"id": "35e19a53",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"df_with_info = df.merge(info, on='OP', how='left')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"id": "eac1244f",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"OP 827\n",
|
||
|
"filename 827\n",
|
||
|
"slice 827\n",
|
||
|
"cell_ch 827\n",
|
||
|
"cell_ID 827\n",
|
||
|
"day 827\n",
|
||
|
"treatment 827\n",
|
||
|
"hrs_incubation 827\n",
|
||
|
"repatch 827\n",
|
||
|
"hrs_after_OP 827\n",
|
||
|
"Rs 827\n",
|
||
|
"Rin 827\n",
|
||
|
"resting_potential 827\n",
|
||
|
"max_spikes 827\n",
|
||
|
"Rheobase 824\n",
|
||
|
"AP_heigth 824\n",
|
||
|
"TH 824\n",
|
||
|
"max_depol 824\n",
|
||
|
"max_repol 824\n",
|
||
|
"membra_time_constant_tau 827\n",
|
||
|
"capacitance 827\n",
|
||
|
"comments 742\n",
|
||
|
"rheo_ramp 120\n",
|
||
|
"AP_halfwidth 820\n",
|
||
|
"Rheobse_ramp 160\n",
|
||
|
"Unnamed: 27 0\n",
|
||
|
"rheos_ramp 32\n",
|
||
|
"comment 5\n",
|
||
|
" 37\n",
|
||
|
"high K concentration 827\n",
|
||
|
"RMP_from_char 827\n",
|
||
|
"tissue_source 800\n",
|
||
|
"area 800\n",
|
||
|
"patient_age 800\n",
|
||
|
"patcher 800\n",
|
||
|
"dtype: int64"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"df_with_info.count()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"id": "2f6724ce",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Verji 35\n",
|
||
|
"Rosie 8\n",
|
||
|
"Anna 2\n",
|
||
|
"Name: patcher, dtype: int64"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"info['patcher'].value_counts()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"id": "8f996049",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"Verji 594\n",
|
||
|
"Rosie 206\n",
|
||
|
"Name: patcher, dtype: int64"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"df_with_info['patcher'].value_counts()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "44031178",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# 2. Remove outliers from the table\n",
|
||
|
"\n",
|
||
|
"1. Load the list of outliers in `outliers.csv`\n",
|
||
|
"2. Use an anti-join to remove the outliers from the table\n",
|
||
|
"3. How many samples (rows) are left in the data?"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"id": "d1d4cc27",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"outliers = pd.read_csv('outliers.csv')"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"id": "fbebbd97",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"(134, 2)"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 10,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"outliers.shape"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"id": "8a3c7943",
|
||
|
"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>cell_ID</th>\n",
|
||
|
" </tr>\n",
|
||
|
" </thead>\n",
|
||
|
" <tbody>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>0</th>\n",
|
||
|
" <td>OP240201</td>\n",
|
||
|
" <td>24201S2c2</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>1</th>\n",
|
||
|
" <td>OP210323</td>\n",
|
||
|
" <td>2021_03_25_0S4_D2c6</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>2</th>\n",
|
||
|
" <td>OP230808</td>\n",
|
||
|
" <td>23808S2c6</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>3</th>\n",
|
||
|
" <td>OP240503</td>\n",
|
||
|
" <td>24503S1c6</td>\n",
|
||
|
" </tr>\n",
|
||
|
" <tr>\n",
|
||
|
" <th>4</th>\n",
|
||
|
" <td>OP230109</td>\n",
|
||
|
" <td>2311S3c2</td>\n",
|
||
|
" </tr>\n",
|
||
|
" </tbody>\n",
|
||
|
"</table>\n",
|
||
|
"</div>"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
" OP cell_ID\n",
|
||
|
"0 OP240201 24201S2c2\n",
|
||
|
"1 OP210323 2021_03_25_0S4_D2c6\n",
|
||
|
"2 OP230808 23808S2c6\n",
|
||
|
"3 OP240503 24503S1c6\n",
|
||
|
"4 OP230109 2311S3c2"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"outliers.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"id": "573687e7",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"temp = df_with_info.merge(outliers, on=['OP', 'cell_ID'], how='outer', indicator=True)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"id": "a4a6574b",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"df_without_outliers = temp[temp['_merge'] == 'left_only'].drop('_merge', axis=1)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"id": "8fd89a40",
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"(659, 35)"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 14,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"df_without_outliers.shape"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"id": "07f4776a",
|
||
|
"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>5</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>6</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",
|
||
|
"5 OP230420 23420003.abf S1 8 23420S1c8 D1 TTX \n",
|
||
|
"6 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",
|
||
|
"5 0.0 yes 10.416389 6.000400 31.599917 \n",
|
||
|
"6 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",
|
||
|
"5 -70.550537 22 350.0 81.011963 -33.068848 309.448242 \n",
|
||
|
"6 -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",
|
||
|
"5 -61.401367 16.65 575.513924 5 786.927898 \n",
|
||
|
"6 -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",
|
||
|
"5 1.182830 NaN NaN NaN NaN NaN \n",
|
||
|
"6 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",
|
||
|
"5 8 mM -60.956350 Bielefeld temporal 13.0 \n",
|
||
|
"6 8 mM -61.283967 Bielefeld temporal 13.0 \n",
|
||
|
"\n",
|
||
|
" patcher \n",
|
||
|
"0 Verji \n",
|
||
|
"1 Verji \n",
|
||
|
"2 Verji \n",
|
||
|
"5 Verji \n",
|
||
|
"6 Verji "
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 15,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"df_without_outliers.head()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"id": "84270332",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# 3. Save final result in `processed_QC_passed_2024-07-04_collected_v1.csv`\n",
|
||
|
"\n",
|
||
|
"1. Using the `.to_csv` method of Pandas DataFrames"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"id": "85902eea",
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"df_without_outliers.to_csv('processed_QC_passed_2024-07-04_collected_v1.csv', index=None)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": null,
|
||
|
"id": "c7bcff45",
|
||
|
"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
|
||
|
}
|