70 lines (69 with data), 1.9 kB
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"summary = pd.read_table('fastqc.txt', sep='\\t')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"summary.set_index('sample_id', inplace=True, drop=False)\n",
"qc_status = summary.iloc[:, 9:].copy()\n",
"qc_status.fillna('NA')\n",
"qc_status = qc_status.astype('str')\n",
"sample_ids = qc_status.index.values\n",
"sections = qc_status.columns.values\n",
"def style_func(val):\n",
" status, row, col = val.split('|')\n",
" row, col = int(row), int(col)\n",
" color = {'pass': 'green', 'fail': 'red', 'warn': 'orange'}.get(status, 'gray')\n",
" return '<a href=\"../fastqc/{sample_id}_fastqc.html#M{section}\" style=\"color: {color}\">{status}</a>'.format(\n",
" sample_id=sample_ids[row], color=color, status=status, section=col)\n",
"\n",
"pd.DataFrame(qc_status.values \\\n",
" + '|' + np.arange(qc_status.shape[0]).astype('str')[:, np.newaxis] \\\n",
" + '|' + np.arange(qc_status.shape[1]).astype('str')[np.newaxis, :],\n",
" index=qc_status.index, columns=qc_status.columns) \\\n",
" .style.format(style_func)"
]
}
],
"metadata": {
"kernel_spec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"laugnage_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"version": "3.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}