Switch to unified view

a b/exseek/templates/summarize_cutadapt_pe.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_read_pairs', 'read1_with_adapters', 'read2_with_adapters', 'read_pairs_too_short', 'read_pairs_kept']]\n",
34
    "display(summary_reads.style.set_caption('Read pairs 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_read_pairs'], axis=0)\n",
44
    "percent_reads.drop(columns=['total_read_pairs'], inplace=True)\n",
45
    "display(percent_reads.style.format(gradient_func).set_caption('Read pairs 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', 'total_bp_read1', 'total_bp_read2',\n",
55
    "                             'bp_quality_trimmed', 'bp_quality_trimmed_read1', 'bp_quality_trimmed_read2',\n",
56
    "                             'bp_kept', 'bp_kept_read1', 'bp_kept_read2']]\n",
57
    "display(summary_bp.style.set_caption('Base pairs summary'))"
58
   ]
59
  },
60
  {
61
   "cell_type": "code",
62
   "execution_count": null,
63
   "metadata": {},
64
   "outputs": [],
65
   "source": [
66
    "percent_bp = 100.0*summary_bp.div(summary_bp['total_bp'], axis=0)\n",
67
    "percent_bp.drop(columns=['total_bp'], inplace=True)\n",
68
    "display(percent_bp.style.format(gradient_func).set_caption('Base pairs percentage'))"
69
   ]
70
  }
71
 ],
72
 "metadata": {
73
  "kernelspec": {
74
   "display_name": "Python 3",
75
   "language": "python",
76
   "name": "python3"
77
  },
78
  "language_info": {
79
   "codemirror_mode": {
80
    "name": "ipython",
81
    "version": 3
82
   },
83
   "file_extension": ".py",
84
   "mimetype": "text/x-python",
85
   "name": "python",
86
   "nbconvert_exporter": "python",
87
   "pygments_lexer": "ipython3",
88
   "version": "3.7.6"
89
  },
90
  "toc": {
91
   "base_numbering": 1,
92
   "nav_menu": {},
93
   "number_sections": true,
94
   "sideBar": true,
95
   "skip_h1_title": false,
96
   "title_cell": "Table of Contents",
97
   "title_sidebar": "Contents",
98
   "toc_cell": false,
99
   "toc_position": {},
100
   "toc_section_display": true,
101
   "toc_window_display": false
102
  }
103
 },
104
 "nbformat": 4,
105
 "nbformat_minor": 2
106
}