{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "from matplotlib import pyplot as plt\n", "import seaborn as sns\n", "import glob " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['quantification/SK276-24hr-1.csv',\n", " 'quantification/SK276-6hr-1.csv',\n", " 'quantification/SK276-30min-1.csv',\n", " 'quantification/SK276-0time-1.csv',\n", " 'quantification/SK276-1hr-1.csv',\n", " 'quantification/SK276-3hr-1.csv',\n", " 'quantification/SK276-2hr-1.csv']" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "flist = glob.glob(\"quantification/*.csv\")\n", "flist" ] }, { "cell_type": "code", "execution_count": 3, "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", "
Meansampleorder
174292.400SK276-0time-11
17097.825SK276-0time-11
169112.925SK276-0time-11
168115.513SK276-0time-11
167113.475SK276-0time-11
............
29864.175SK276-24hr-17
28822.550SK276-24hr-17
27949.700SK276-24hr-17
37732.038SK276-24hr-17
01220.050SK276-24hr-17
\n", "

350 rows × 3 columns

\n", "
" ], "text/plain": [ " Mean sample order\n", "174 292.400 SK276-0time-1 1\n", "170 97.825 SK276-0time-1 1\n", "169 112.925 SK276-0time-1 1\n", "168 115.513 SK276-0time-1 1\n", "167 113.475 SK276-0time-1 1\n", ".. ... ... ...\n", "29 864.175 SK276-24hr-1 7\n", "28 822.550 SK276-24hr-1 7\n", "27 949.700 SK276-24hr-1 7\n", "37 732.038 SK276-24hr-1 7\n", "0 1220.050 SK276-24hr-1 7\n", "\n", "[350 rows x 3 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "orders = [7,6,2,1,3,5,4]\n", "flist = glob.glob(\"quantification/*.csv\")\n", "df = pd.DataFrame()\n", "for file, order, in zip(flist, orders):\n", " file_tmp = pd.read_csv(file,index_col=0)\n", " file_tmp[\"sample\"] = file[15:-4]\n", " file_tmp[\"order\"] = order\n", " df = pd.concat([df,file_tmp])\n", "df = df.reset_index(drop = True)\n", "df2 = df.sort_values('order')\n", "df2" ] }, { "cell_type": "code", "execution_count": 12, "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", "
Meansampleordertime
174292.400SK276-0time-110.0
17097.825SK276-0time-110.0
169112.925SK276-0time-110.0
168115.513SK276-0time-110.0
167113.475SK276-0time-110.0
...............
29864.175SK276-24hr-1724.0
28822.550SK276-24hr-1724.0
27949.700SK276-24hr-1724.0
37732.038SK276-24hr-1724.0
01220.050SK276-24hr-1724.0
\n", "

350 rows × 4 columns

\n", "
" ], "text/plain": [ " Mean sample order time\n", "174 292.400 SK276-0time-1 1 0.0\n", "170 97.825 SK276-0time-1 1 0.0\n", "169 112.925 SK276-0time-1 1 0.0\n", "168 115.513 SK276-0time-1 1 0.0\n", "167 113.475 SK276-0time-1 1 0.0\n", ".. ... ... ... ...\n", "29 864.175 SK276-24hr-1 7 24.0\n", "28 822.550 SK276-24hr-1 7 24.0\n", "27 949.700 SK276-24hr-1 7 24.0\n", "37 732.038 SK276-24hr-1 7 24.0\n", "0 1220.050 SK276-24hr-1 7 24.0\n", "\n", "[350 rows x 4 columns]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hours = [0,0.5,1,2,3,6,24]\n", "\n", "time = []\n", "for hour in hours:\n", " time = np.hstack([time, np.full(50, (hour))])\n", "df2['time'] = time\n", "df2\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "ename": "ValueError", "evalue": "Could not interpret input 'time'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0msns\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlineplot\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdf2\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'time'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'Mean'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mci\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'sd'\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mcolor\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'mediumblue'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2\u001b[0m \u001b[0;31m#plt.savefig(\"BV-longtime.pdf\")\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/opt/anaconda3/lib/python3.8/site-packages/seaborn/relational.py\u001b[0m in \u001b[0;36mlineplot\u001b[0;34m(x, y, hue, size, style, data, palette, hue_order, hue_norm, sizes, size_order, size_norm, dashes, markers, style_order, units, estimator, ci, n_boot, seed, sort, err_style, err_kws, legend, ax, **kwargs)\u001b[0m\n\u001b[1;32m 1118\u001b[0m legend=\"brief\", ax=None, **kwargs):\n\u001b[1;32m 1119\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1120\u001b[0;31m p = _LinePlotter(\n\u001b[0m\u001b[1;32m 1121\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhue\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mhue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstyle\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mstyle\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1122\u001b[0m \u001b[0mpalette\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpalette\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhue_order\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mhue_order\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhue_norm\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mhue_norm\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;32m~/opt/anaconda3/lib/python3.8/site-packages/seaborn/relational.py\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, x, y, hue, size, style, data, palette, hue_order, hue_norm, sizes, size_order, size_norm, dashes, markers, style_order, units, estimator, ci, n_boot, seed, sort, err_style, err_kws, legend)\u001b[0m\n\u001b[1;32m 692\u001b[0m sort=True, err_style=None, err_kws=None, legend=None):\n\u001b[1;32m 693\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 694\u001b[0;31m plot_data = self.establish_variables(\n\u001b[0m\u001b[1;32m 695\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0my\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mhue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msize\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstyle\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0munits\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 696\u001b[0m )\n", "\u001b[0;32m~/opt/anaconda3/lib/python3.8/site-packages/seaborn/relational.py\u001b[0m in \u001b[0;36mestablish_variables\u001b[0;34m(self, x, y, hue, size, style, units, data)\u001b[0m\n\u001b[1;32m 135\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvar\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 136\u001b[0m \u001b[0merr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"Could not interpret input '{}'\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvar\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 137\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0merr\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 138\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 139\u001b[0m \u001b[0;31m# Extract variable names\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", "\u001b[0;31mValueError\u001b[0m: Could not interpret input 'time'" ] } ], "source": [ "sns.lineplot(data=df2, x='time', y='Mean', ci='sd',color='mediumblue')\n", "#plt.savefig(\"BV-longtime.pdf\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }