| 1 |
{ |
| 2 |
"cells": [ |
| 3 |
{ |
| 4 |
"cell_type": "markdown", |
| 5 |
"metadata": {}, |
| 6 |
"source": [ |
| 7 |
"# Barcode_split API Usage" |
| 8 |
] |
| 9 |
}, |
| 10 |
{ |
| 11 |
"cell_type": "markdown", |
| 12 |
"metadata": {}, |
| 13 |
"source": [ |
| 14 |
"## Running Jupyter notebook" |
| 15 |
] |
| 16 |
}, |
| 17 |
{ |
| 18 |
"cell_type": "markdown", |
| 19 |
"metadata": {}, |
| 20 |
"source": [ |
| 21 |
"If you want to run pycoQC interactively in Jupyter you need to install Jupyter manually. If you installed pycoQC in a virtual environment then install Jupyter in the same virtual environment.\n", |
| 22 |
"\n", |
| 23 |
"```bash\n", |
| 24 |
"pip3 install notebook\n", |
| 25 |
"```\n", |
| 26 |
"\n", |
| 27 |
"Launch the notebook in a shell terminal\n", |
| 28 |
"\n", |
| 29 |
"```bash\n", |
| 30 |
"jupyter notebook\n", |
| 31 |
"```\n", |
| 32 |
"\n", |
| 33 |
"If it does not auto-start, open the following URL in you favorite web browser http://localhost:8888/tree\n", |
| 34 |
"\n", |
| 35 |
"From Jupyter homepage you can navigate to the directory you want to work in and create a new Python3 Notebook." |
| 36 |
] |
| 37 |
}, |
| 38 |
{ |
| 39 |
"cell_type": "markdown", |
| 40 |
"metadata": {}, |
| 41 |
"source": [ |
| 42 |
"## Imports" |
| 43 |
] |
| 44 |
}, |
| 45 |
{ |
| 46 |
"cell_type": "code", |
| 47 |
"execution_count": 3, |
| 48 |
"metadata": { |
| 49 |
"ExecuteTime": { |
| 50 |
"end_time": "2020-01-09T16:56:53.746078Z", |
| 51 |
"start_time": "2020-01-09T16:56:53.736022Z" |
| 52 |
}, |
| 53 |
"init_cell": true |
| 54 |
}, |
| 55 |
"outputs": [], |
| 56 |
"source": [ |
| 57 |
"# Run cell with Ctrl + Enter\n", |
| 58 |
"\n", |
| 59 |
"# Import main pycoQC module\n", |
| 60 |
"from pycoQC.Barcode_split import Barcode_split\n", |
| 61 |
"\n", |
| 62 |
"# Import helper functions from pycoQC\n", |
| 63 |
"from pycoQC.common import jhelp, head, ls" |
| 64 |
] |
| 65 |
}, |
| 66 |
{ |
| 67 |
"cell_type": "markdown", |
| 68 |
"metadata": {}, |
| 69 |
"source": [ |
| 70 |
"## Running Barcode_split" |
| 71 |
] |
| 72 |
}, |
| 73 |
{ |
| 74 |
"cell_type": "code", |
| 75 |
"execution_count": 2, |
| 76 |
"metadata": { |
| 77 |
"ExecuteTime": { |
| 78 |
"end_time": "2020-01-09T16:56:52.484368Z", |
| 79 |
"start_time": "2020-01-09T16:56:52.470584Z" |
| 80 |
}, |
| 81 |
"init_cell": true |
| 82 |
}, |
| 83 |
"outputs": [ |
| 84 |
{ |
| 85 |
"data": { |
| 86 |
"text/markdown": [ |
| 87 |
"**Barcode_split** (summary_file, barcode_file, output_dir, output_unclassified, min_barcode_percent, verbose, quiet)\n", |
| 88 |
"\n", |
| 89 |
"Parse Albacore sequencing_summary.txt file and split per barcode By default, data for low frequency barcodes and unclassified reads are not written in the output directory\n", |
| 90 |
"\n", |
| 91 |
"---\n", |
| 92 |
"\n", |
| 93 |
"* **summary_file** (required) [str]\n", |
| 94 |
"\n", |
| 95 |
"Path to a sequencing_summary generated by Albacore 1.0.0 + (read_fast5_basecaller.py) / Guppy 2.1.3+ (guppy_basecaller). One can also pass multiple space separated file paths or a UNIX style regex matching multiple files\n", |
| 96 |
"\n", |
| 97 |
"* **barcode_file** (default: \"\") [str]\n", |
| 98 |
"\n", |
| 99 |
"Path to the barcode_file generated by Guppy 2.1.3+ (guppy_barcoder) or Deepbinner 0.2.0+. This is not a required file. One can also pass multiple space separated file paths or a UNIX style regex matching multiple files\n", |
| 100 |
"\n", |
| 101 |
"* **output_dir** (default: \"\") [str]\n", |
| 102 |
"\n", |
| 103 |
"Folder where to output split barcode data\n", |
| 104 |
"\n", |
| 105 |
"* **output_unclassified** (default: False) [bool]\n", |
| 106 |
"\n", |
| 107 |
"If True unclassified barcodes are also written in a file. By default they are skiped\n", |
| 108 |
"\n", |
| 109 |
"* **min_barcode_percent** (default: 0.1) [float]\n", |
| 110 |
"\n", |
| 111 |
"Minimal percent of total reads to write barcode reads in file.\n", |
| 112 |
"\n", |
| 113 |
"* **verbose** (default: False) [bool]\n", |
| 114 |
"\n", |
| 115 |
"Increase verbosity\n", |
| 116 |
"\n", |
| 117 |
"* **quiet** (default: False) [bool]\n", |
| 118 |
"\n", |
| 119 |
"Reduce verbosity\n", |
| 120 |
"\n" |
| 121 |
], |
| 122 |
"text/plain": [ |
| 123 |
"<IPython.core.display.Markdown object>" |
| 124 |
] |
| 125 |
}, |
| 126 |
"metadata": {}, |
| 127 |
"output_type": "display_data" |
| 128 |
} |
| 129 |
], |
| 130 |
"source": [ |
| 131 |
"jhelp(Barcode_split)" |
| 132 |
] |
| 133 |
}, |
| 134 |
{ |
| 135 |
"cell_type": "markdown", |
| 136 |
"metadata": {}, |
| 137 |
"source": [ |
| 138 |
"### Basic usage" |
| 139 |
] |
| 140 |
}, |
| 141 |
{ |
| 142 |
"cell_type": "code", |
| 143 |
"execution_count": 4, |
| 144 |
"metadata": { |
| 145 |
"ExecuteTime": { |
| 146 |
"end_time": "2020-01-09T16:57:00.123417Z", |
| 147 |
"start_time": "2020-01-09T16:56:57.339181Z" |
| 148 |
}, |
| 149 |
"scrolled": false |
| 150 |
}, |
| 151 |
"outputs": [ |
| 152 |
{ |
| 153 |
"name": "stderr", |
| 154 |
"output_type": "stream", |
| 155 |
"text": [ |
| 156 |
"Import data from sequencing summary file(s) and cleanup\n", |
| 157 |
"\tRead files and import in a dataframe\n", |
| 158 |
"Check input data files\n", |
| 159 |
"Parse data files\n", |
| 160 |
"Merge data\n", |
| 161 |
"\tCleanup missing barcodes values\n", |
| 162 |
"\tCleaning up low frequency barcodes\n", |
| 163 |
"Split data per barcode\n", |
| 164 |
"\tProcessing data for Barcode barcode02\n", |
| 165 |
"\tProcessing data for Barcode barcode07\n", |
| 166 |
"\tProcessing data for Barcode barcode08\n", |
| 167 |
"\tProcessing data for Barcode barcode09\n", |
| 168 |
"\tProcessing data for Barcode barcode10\n", |
| 169 |
"\tProcessing data for Barcode barcode11\n", |
| 170 |
"\tProcessing data for Barcode barcode12\n", |
| 171 |
"\tProcessing data for Barcode unclassified\n", |
| 172 |
"Barcode Counts\n", |
| 173 |
" Counts Write\n", |
| 174 |
"barcode02 2 False\n", |
| 175 |
"barcode07 1 False\n", |
| 176 |
"barcode08 30 False\n", |
| 177 |
"barcode09 9945 True\n", |
| 178 |
"barcode10 12644 True\n", |
| 179 |
"barcode11 13594 True\n", |
| 180 |
"barcode12 9813 True\n", |
| 181 |
"unclassified 3971 True\n" |
| 182 |
] |
| 183 |
} |
| 184 |
], |
| 185 |
"source": [ |
| 186 |
"Barcode_split (\n", |
| 187 |
" summary_file=\"./data/Guppy-2.2.4-basecall-1D-DNA_sequencing_summary+barcode.txt.gz\",\n", |
| 188 |
" output_unclassified=True,\n", |
| 189 |
" output_dir=\"./results/\")" |
| 190 |
] |
| 191 |
}, |
| 192 |
{ |
| 193 |
"cell_type": "markdown", |
| 194 |
"metadata": {}, |
| 195 |
"source": [ |
| 196 |
"### With externaly provided barcodes" |
| 197 |
] |
| 198 |
}, |
| 199 |
{ |
| 200 |
"cell_type": "code", |
| 201 |
"execution_count": 5, |
| 202 |
"metadata": { |
| 203 |
"ExecuteTime": { |
| 204 |
"end_time": "2020-01-09T16:57:00.990564Z", |
| 205 |
"start_time": "2020-01-09T16:57:00.703388Z" |
| 206 |
}, |
| 207 |
"scrolled": false |
| 208 |
}, |
| 209 |
"outputs": [ |
| 210 |
{ |
| 211 |
"name": "stderr", |
| 212 |
"output_type": "stream", |
| 213 |
"text": [ |
| 214 |
"Import data from sequencing summary file(s) and cleanup\n", |
| 215 |
"\tRead files and import in a dataframe\n", |
| 216 |
"Check input data files\n", |
| 217 |
"Parse data files\n", |
| 218 |
"Merge data\n", |
| 219 |
"\tCleanup missing barcodes values\n", |
| 220 |
"\tCleaning up low frequency barcodes\n", |
| 221 |
"Split data per barcode\n", |
| 222 |
"\tProcessing data for Barcode 1\n", |
| 223 |
"\tProcessing data for Barcode 2\n", |
| 224 |
"\tProcessing data for Barcode 3\n", |
| 225 |
"\tProcessing data for Barcode 4\n", |
| 226 |
"\tProcessing data for Barcode 5\n", |
| 227 |
"\tProcessing data for Barcode 6\n", |
| 228 |
"\tProcessing data for Barcode 7\n", |
| 229 |
"\tProcessing data for Barcode 8\n", |
| 230 |
"\tProcessing data for Barcode unclassified\n", |
| 231 |
"Barcode Counts\n", |
| 232 |
" Counts Write\n", |
| 233 |
"1 534 True\n", |
| 234 |
"2 206 True\n", |
| 235 |
"3 562 True\n", |
| 236 |
"4 579 True\n", |
| 237 |
"5 590 True\n", |
| 238 |
"6 655 True\n", |
| 239 |
"7 271 True\n", |
| 240 |
"8 378 True\n", |
| 241 |
"unclassified 224 False\n" |
| 242 |
] |
| 243 |
} |
| 244 |
], |
| 245 |
"source": [ |
| 246 |
"Barcode_split (\n", |
| 247 |
" summary_file=\"./data/Guppy-basecall-1D-DNA_sequencing_summary.txt.gz\",\n", |
| 248 |
" barcode_file=\"./data/Guppy-basecall-1D-DNA_deepbinner_barcoding_summary.txt.gz\",\n", |
| 249 |
" output_dir=\"./results/\")" |
| 250 |
] |
| 251 |
}, |
| 252 |
{ |
| 253 |
"cell_type": "markdown", |
| 254 |
"metadata": {}, |
| 255 |
"source": [ |
| 256 |
"### If no barcode an error is raised" |
| 257 |
] |
| 258 |
}, |
| 259 |
{ |
| 260 |
"cell_type": "code", |
| 261 |
"execution_count": 6, |
| 262 |
"metadata": { |
| 263 |
"ExecuteTime": { |
| 264 |
"end_time": "2020-01-09T16:57:06.448474Z", |
| 265 |
"start_time": "2020-01-09T16:57:06.276306Z" |
| 266 |
} |
| 267 |
}, |
| 268 |
"outputs": [ |
| 269 |
{ |
| 270 |
"name": "stderr", |
| 271 |
"output_type": "stream", |
| 272 |
"text": [ |
| 273 |
"Import data from sequencing summary file(s) and cleanup\n", |
| 274 |
"\tRead files and import in a dataframe\n", |
| 275 |
"Check input data files\n", |
| 276 |
"Parse data files\n", |
| 277 |
"Merge data\n" |
| 278 |
] |
| 279 |
}, |
| 280 |
{ |
| 281 |
"ename": "pycoQCError", |
| 282 |
"evalue": "No barcode information found in provided file(s)", |
| 283 |
"output_type": "error", |
| 284 |
"traceback": [ |
| 285 |
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
| 286 |
"\u001b[0;31mpycoQCError\u001b[0m Traceback (most recent call last)", |
| 287 |
"\u001b[0;32m<ipython-input-6-2f136ce0e4dc>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m Barcode_split (\n\u001b[1;32m 2\u001b[0m \u001b[0msummary_file\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"./data/Guppy-basecall-1D-DNA_sequencing_summary.txt.gz\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m output_dir=\"./results/\")\n\u001b[0m", |
| 288 |
"\u001b[0;32m~/Programming/Packages/pycoQC/pycoQC/Barcode_split.py\u001b[0m in \u001b[0;36mBarcode_split\u001b[0;34m(summary_file, barcode_file, output_dir, output_unclassified, min_barcode_percent, verbose, quiet)\u001b[0m\n\u001b[1;32m 75\u001b[0m \u001b[0mdf\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrename\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0;34m\"barcode_arrangement\"\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\"barcode\"\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 76\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;34m\"barcode\"\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdf\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 77\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mpycoQCError\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m\"No barcode information found in provided file(s)\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 78\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 79\u001b[0m \u001b[0;31m# Quick data cleanup\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
| 289 |
"\u001b[0;31mpycoQCError\u001b[0m: No barcode information found in provided file(s)" |
| 290 |
] |
| 291 |
} |
| 292 |
], |
| 293 |
"source": [ |
| 294 |
"Barcode_split (\n", |
| 295 |
" summary_file=\"./data/Guppy-basecall-1D-DNA_sequencing_summary.txt.gz\",\n", |
| 296 |
" output_dir=\"./results/\")" |
| 297 |
] |
| 298 |
} |
| 299 |
], |
| 300 |
"metadata": { |
| 301 |
"celltoolbar": "Initialization Cell", |
| 302 |
"hide_input": false, |
| 303 |
"kernelspec": { |
| 304 |
"display_name": "pycoQC", |
| 305 |
"language": "python", |
| 306 |
"name": "pycoqc" |
| 307 |
}, |
| 308 |
"language_info": { |
| 309 |
"codemirror_mode": { |
| 310 |
"name": "ipython", |
| 311 |
"version": 3 |
| 312 |
}, |
| 313 |
"file_extension": ".py", |
| 314 |
"mimetype": "text/x-python", |
| 315 |
"name": "python", |
| 316 |
"nbconvert_exporter": "python", |
| 317 |
"pygments_lexer": "ipython3", |
| 318 |
"version": "3.6.6" |
| 319 |
}, |
| 320 |
"widgets": { |
| 321 |
"state": {}, |
| 322 |
"version": "1.1.1" |
| 323 |
} |
| 324 |
}, |
| 325 |
"nbformat": 4, |
| 326 |
"nbformat_minor": 1 |
| 327 |
} |