Switch to unified view

a b/exseek/templates/summarize_cutadapt_se.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": null,
6
   "metadata": {},
7
   "outputs": [],
8
   "source": [
9
    "%pylab inline"
10
   ]
11
  },
12
  {
13
   "cell_type": "code",
14
   "execution_count": null,
15
   "metadata": {},
16
   "outputs": [],
17
   "source": [
18
    "import numpy as np\n",
19
    "import pandas as pd\n",
20
    "from IPython.display import display\n",
21
    "\n",
22
    "def gradient_func(val):\n",
23
    "    return '<span style=\"background: linear-gradient(90deg, #d65f5f {0}%, transparent 0%)\">{0:.3f}</span>'.format(val)"
24
   ]
25
  },
26
  {
27
   "cell_type": "code",
28
   "execution_count": null,
29
   "metadata": {},
30
   "outputs": [],
31
   "source": [
32
    "summary = pd.read_table('cutadapt.txt', sep='\\t', index_col=0)\n",
33
    "summary_reads = summary.loc[:, ['total_reads', 'reads_with_adapters', 'reads_too_short', 'reads_kept']]\n",
34
    "display(summary_reads.style.set_caption('Reads summary'))"
35
   ]
36
  },
37
  {
38
   "cell_type": "code",
39
   "execution_count": null,
40
   "metadata": {},
41
   "outputs": [],
42
   "source": [
43
    "percent_reads = 100.0*summary_reads.div(summary_reads['total_reads'], axis=0)\n",
44
    "percent_reads.drop(columns=['total_reads'], inplace=True)\n",
45
    "display(percent_reads.style.format(gradient_func).set_caption('Reads percentage'))"
46
   ]
47
  },
48
  {
49
   "cell_type": "code",
50
   "execution_count": null,
51
   "metadata": {},
52
   "outputs": [],
53
   "source": [
54
    "summary_bp = summary.loc[:, ['total_bp', 'bp_quality_trimmed', 'bp_kept']]\n",
55
    "display(summary_bp.style.set_caption('Base pairs summary'))"
56
   ]
57
  },
58
  {
59
   "cell_type": "code",
60
   "execution_count": null,
61
   "metadata": {},
62
   "outputs": [],
63
   "source": [
64
    "percent_bp = 100.0*summary_bp.div(summary_bp['total_bp'], axis=0)\n",
65
    "percent_bp.drop(columns=['total_bp'], inplace=True)\n",
66
    "display(percent_bp.style.format(gradient_func).set_caption('Base pairs percentage'))"
67
   ]
68
  }
69
 ],
70
 "metadata": {
71
  "kernelspec": {
72
   "display_name": "Python 3",
73
   "language": "python",
74
   "name": "python3"
75
  },
76
  "language_info": {
77
   "codemirror_mode": {
78
    "name": "ipython",
79
    "version": 3
80
   },
81
   "file_extension": ".py",
82
   "mimetype": "text/x-python",
83
   "name": "python",
84
   "nbconvert_exporter": "python",
85
   "pygments_lexer": "ipython3",
86
   "version": "3.6.6"
87
  },
88
  "toc": {
89
   "base_numbering": 1,
90
   "nav_menu": {},
91
   "number_sections": true,
92
   "sideBar": true,
93
   "skip_h1_title": false,
94
   "title_cell": "Table of Contents",
95
   "title_sidebar": "Contents",
96
   "toc_cell": false,
97
   "toc_position": {},
98
   "toc_section_display": true,
99
   "toc_window_display": false
100
  }
101
 },
102
 "nbformat": 4,
103
 "nbformat_minor": 2
104
}