Switch to unified view

a b/exseek/templates/fastqc.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": null,
6
   "metadata": {},
7
   "outputs": [],
8
   "source": [
9
    "import pandas as pd\n",
10
    "import numpy as np"
11
   ]
12
  },
13
  {
14
   "cell_type": "code",
15
   "execution_count": null,
16
   "metadata": {},
17
   "outputs": [],
18
   "source": [
19
    "summary = pd.read_table('fastqc.txt', sep='\\t')"
20
   ]
21
  },
22
  {
23
   "cell_type": "code",
24
   "execution_count": null,
25
   "metadata": {},
26
   "outputs": [],
27
   "source": [
28
    "summary.set_index('sample_id', inplace=True, drop=False)\n",
29
    "qc_status = summary.iloc[:, 9:].copy()\n",
30
    "qc_status.fillna('NA')\n",
31
    "qc_status = qc_status.astype('str')\n",
32
    "sample_ids = qc_status.index.values\n",
33
    "sections = qc_status.columns.values\n",
34
    "def style_func(val):\n",
35
    "    status, row, col = val.split('|')\n",
36
    "    row, col = int(row), int(col)\n",
37
    "    color = {'pass': 'green', 'fail': 'red', 'warn': 'orange'}.get(status, 'gray')\n",
38
    "    return '<a href=\"../fastqc/{sample_id}_fastqc.html#M{section}\" style=\"color: {color}\">{status}</a>'.format(\n",
39
    "        sample_id=sample_ids[row], color=color, status=status, section=col)\n",
40
    "\n",
41
    "pd.DataFrame(qc_status.values \\\n",
42
    "             + '|' + np.arange(qc_status.shape[0]).astype('str')[:, np.newaxis] \\\n",
43
    "             + '|' + np.arange(qc_status.shape[1]).astype('str')[np.newaxis, :],\n",
44
    "             index=qc_status.index, columns=qc_status.columns) \\\n",
45
    "    .style.format(style_func)"
46
   ]
47
  }
48
 ],
49
 "metadata": {
50
  "kernel_spec": {
51
   "display_name": "Python 3",
52
   "language": "python",
53
   "name": "python3"
54
  },
55
  "laugnage_info": {
56
   "codemirror_mode": {
57
    "name": "ipython",
58
    "version": 3
59
   },
60
   "file_extension": ".py",
61
   "mimetype": "text/x-python",
62
   "name": "python",
63
   "nbconvert_exporter": "python",
64
   "version": "3.6"
65
  }
66
 },
67
 "nbformat": 4,
68
 "nbformat_minor": 2
69
}