-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyze_pacbio_ccs.html
825 lines (744 loc) · 53.4 KB
/
analyze_pacbio_ccs.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />
<title>Analyze PacBio CCSs — Deep mutational scanning (DMS) pipeline for a viral entry protein (VEP) documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script>window.MathJax = {"tex": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true}, "options": {"ignoreHtmlClass": "tex2jax_ignore|mathjax_ignore|document", "processHtmlClass": "tex2jax_process|mathjax_process|math|output_area"}}</script>
<script defer="defer" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Build PacBio consensus sequences" href="build_pacbio_consensus.html" />
<link rel="prev" title="Deep mutational scanning (DMS) pipeline for a viral entry protein (VEP)" href="index.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="body" role="main">
<style>
/* CSS for nbsphinx extension */
/* remove conflicting styling from Sphinx themes */
div.nbinput.container div.prompt *,
div.nboutput.container div.prompt *,
div.nbinput.container div.input_area pre,
div.nboutput.container div.output_area pre,
div.nbinput.container div.input_area .highlight,
div.nboutput.container div.output_area .highlight {
border: none;
padding: 0;
margin: 0;
box-shadow: none;
}
div.nbinput.container > div[class*=highlight],
div.nboutput.container > div[class*=highlight] {
margin: 0;
}
div.nbinput.container div.prompt *,
div.nboutput.container div.prompt * {
background: none;
}
div.nboutput.container div.output_area .highlight,
div.nboutput.container div.output_area pre {
background: unset;
}
div.nboutput.container div.output_area div.highlight {
color: unset; /* override Pygments text color */
}
/* avoid gaps between output lines */
div.nboutput.container div[class*=highlight] pre {
line-height: normal;
}
/* input/output containers */
div.nbinput.container,
div.nboutput.container {
display: -webkit-flex;
display: flex;
align-items: flex-start;
margin: 0;
width: 100%;
}
@media (max-width: 540px) {
div.nbinput.container,
div.nboutput.container {
flex-direction: column;
}
}
/* input container */
div.nbinput.container {
padding-top: 5px;
}
/* last container */
div.nblast.container {
padding-bottom: 5px;
}
/* input prompt */
div.nbinput.container div.prompt pre {
color: #307FC1;
}
/* output prompt */
div.nboutput.container div.prompt pre {
color: #BF5B3D;
}
/* all prompts */
div.nbinput.container div.prompt,
div.nboutput.container div.prompt {
width: 4.5ex;
padding-top: 5px;
position: relative;
user-select: none;
}
div.nbinput.container div.prompt > div,
div.nboutput.container div.prompt > div {
position: absolute;
right: 0;
margin-right: 0.3ex;
}
@media (max-width: 540px) {
div.nbinput.container div.prompt,
div.nboutput.container div.prompt {
width: unset;
text-align: left;
padding: 0.4em;
}
div.nboutput.container div.prompt.empty {
padding: 0;
}
div.nbinput.container div.prompt > div,
div.nboutput.container div.prompt > div {
position: unset;
}
}
/* disable scrollbars and line breaks on prompts */
div.nbinput.container div.prompt pre,
div.nboutput.container div.prompt pre {
overflow: hidden;
white-space: pre;
}
/* input/output area */
div.nbinput.container div.input_area,
div.nboutput.container div.output_area {
-webkit-flex: 1;
flex: 1;
overflow: auto;
}
@media (max-width: 540px) {
div.nbinput.container div.input_area,
div.nboutput.container div.output_area {
width: 100%;
}
}
/* input area */
div.nbinput.container div.input_area {
border: 1px solid #e0e0e0;
border-radius: 2px;
/*background: #f5f5f5;*/
}
/* override MathJax center alignment in output cells */
div.nboutput.container div[class*=MathJax] {
text-align: left !important;
}
/* override sphinx.ext.imgmath center alignment in output cells */
div.nboutput.container div.math p {
text-align: left;
}
/* standard error */
div.nboutput.container div.output_area.stderr {
background: #fdd;
}
/* ANSI colors */
.ansi-black-fg { color: #3E424D; }
.ansi-black-bg { background-color: #3E424D; }
.ansi-black-intense-fg { color: #282C36; }
.ansi-black-intense-bg { background-color: #282C36; }
.ansi-red-fg { color: #E75C58; }
.ansi-red-bg { background-color: #E75C58; }
.ansi-red-intense-fg { color: #B22B31; }
.ansi-red-intense-bg { background-color: #B22B31; }
.ansi-green-fg { color: #00A250; }
.ansi-green-bg { background-color: #00A250; }
.ansi-green-intense-fg { color: #007427; }
.ansi-green-intense-bg { background-color: #007427; }
.ansi-yellow-fg { color: #DDB62B; }
.ansi-yellow-bg { background-color: #DDB62B; }
.ansi-yellow-intense-fg { color: #B27D12; }
.ansi-yellow-intense-bg { background-color: #B27D12; }
.ansi-blue-fg { color: #208FFB; }
.ansi-blue-bg { background-color: #208FFB; }
.ansi-blue-intense-fg { color: #0065CA; }
.ansi-blue-intense-bg { background-color: #0065CA; }
.ansi-magenta-fg { color: #D160C4; }
.ansi-magenta-bg { background-color: #D160C4; }
.ansi-magenta-intense-fg { color: #A03196; }
.ansi-magenta-intense-bg { background-color: #A03196; }
.ansi-cyan-fg { color: #60C6C8; }
.ansi-cyan-bg { background-color: #60C6C8; }
.ansi-cyan-intense-fg { color: #258F8F; }
.ansi-cyan-intense-bg { background-color: #258F8F; }
.ansi-white-fg { color: #C5C1B4; }
.ansi-white-bg { background-color: #C5C1B4; }
.ansi-white-intense-fg { color: #A1A6B2; }
.ansi-white-intense-bg { background-color: #A1A6B2; }
.ansi-default-inverse-fg { color: #FFFFFF; }
.ansi-default-inverse-bg { background-color: #000000; }
.ansi-bold { font-weight: bold; }
.ansi-underline { text-decoration: underline; }
div.nbinput.container div.input_area div[class*=highlight] > pre,
div.nboutput.container div.output_area div[class*=highlight] > pre,
div.nboutput.container div.output_area div[class*=highlight].math,
div.nboutput.container div.output_area.rendered_html,
div.nboutput.container div.output_area > div.output_javascript,
div.nboutput.container div.output_area:not(.rendered_html) > img{
padding: 5px;
margin: 0;
}
/* fix copybtn overflow problem in chromium (needed for 'sphinx_copybutton') */
div.nbinput.container div.input_area > div[class^='highlight'],
div.nboutput.container div.output_area > div[class^='highlight']{
overflow-y: hidden;
}
/* hide copybtn icon on prompts (needed for 'sphinx_copybutton') */
.prompt .copybtn {
display: none;
}
/* Some additional styling taken form the Jupyter notebook CSS */
.jp-RenderedHTMLCommon table,
div.rendered_html table {
border: none;
border-collapse: collapse;
border-spacing: 0;
color: black;
font-size: 12px;
table-layout: fixed;
}
.jp-RenderedHTMLCommon thead,
div.rendered_html thead {
border-bottom: 1px solid black;
vertical-align: bottom;
}
.jp-RenderedHTMLCommon tr,
.jp-RenderedHTMLCommon th,
.jp-RenderedHTMLCommon td,
div.rendered_html tr,
div.rendered_html th,
div.rendered_html td {
text-align: right;
vertical-align: middle;
padding: 0.5em 0.5em;
line-height: normal;
white-space: normal;
max-width: none;
border: none;
}
.jp-RenderedHTMLCommon th,
div.rendered_html th {
font-weight: bold;
}
.jp-RenderedHTMLCommon tbody tr:nth-child(odd),
div.rendered_html tbody tr:nth-child(odd) {
background: #f5f5f5;
}
.jp-RenderedHTMLCommon tbody tr:hover,
div.rendered_html tbody tr:hover {
background: rgba(66, 165, 245, 0.2);
}
</style>
<section id="Analyze-PacBio-CCSs">
<h1>Analyze PacBio CCSs<a class="headerlink" href="#Analyze-PacBio-CCSs" title="Permalink to this heading">¶</a></h1>
<p>This notebook analyzes the PacBio CCSs that have been previously aligned and parsed with <a class="reference external" href="https://jbloomlab.github.io/alignparse/">alignparse</a>.</p>
<p>Import Python modules:</p>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[1]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">alignparse.targets</span>
<span class="kn">import</span> <span class="nn">altair</span> <span class="k">as</span> <span class="nn">alt</span>
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
<span class="kn">import</span> <span class="nn">yaml</span>
</pre></div>
</div>
</div>
<p>Get configuration information:</p>
<div class="nbinput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[2]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># If you are running notebook interactively rather than in pipeline that handles</span>
<span class="c1"># working directories, you may have to first `os.chdir` to appropriate directory.</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"config.yaml"</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">config</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
</pre></div>
</div>
</div>
<p>Read in the PacBio runs:</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">pacbio_runs</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">config</span><span class="p">[</span><span class="s2">"pacbio_runs"</span><span class="p">])</span>
<span class="o">.</span><span class="n">assign</span><span class="p">(</span>
<span class="n">pacbioRun</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="s2">"library"</span><span class="p">]</span> <span class="o">+</span> <span class="s2">"_"</span> <span class="o">+</span> <span class="n">x</span><span class="p">[</span><span class="s2">"run"</span><span class="p">]</span><span class="o">.</span><span class="n">astype</span><span class="p">(</span><span class="nb">str</span><span class="p">),</span>
<span class="n">subdir</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">config</span><span class="p">[</span><span class="s2">"process_ccs_dir"</span><span class="p">]</span> <span class="o">+</span> <span class="s2">"/"</span> <span class="o">+</span> <span class="n">x</span><span class="p">[</span><span class="s2">"pacbioRun"</span><span class="p">],</span>
<span class="p">)</span>
<span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="s2">"fastq"</span><span class="p">)</span>
<span class="p">)</span>
<span class="n">pacbio_runs</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[3]:
</pre></div>
</div>
<div class="output_area rendered_html docutils container">
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>library</th>
<th>run</th>
<th>pacbioRun</th>
<th>subdir</th>
</tr>
</thead>
<tbody>
<tr>
<th>0</th>
<td>LibA</td>
<td>211105</td>
<td>LibA_211105</td>
<td>results/process_ccs/LibA_211105</td>
</tr>
<tr>
<th>1</th>
<td>LibB</td>
<td>211105</td>
<td>LibB_211105</td>
<td>results/process_ccs/LibB_211105</td>
</tr>
<tr>
<th>2</th>
<td>LibA</td>
<td>220124</td>
<td>LibA_220124</td>
<td>results/process_ccs/LibA_220124</td>
</tr>
<tr>
<th>3</th>
<td>LibB</td>
<td>220124</td>
<td>LibB_220124</td>
<td>results/process_ccs/LibB_220124</td>
</tr>
</tbody>
</table>
</div></div>
</div>
<section id="Stats-on-CCS-alignments">
<h2>Stats on CCS alignments<a class="headerlink" href="#Stats-on-CCS-alignments" title="Permalink to this heading">¶</a></h2>
<p>Read and plot the alignment stats from running <code class="docutils literal notranslate"><span class="pre">alignparse</span></code> on the PacBio CCSs:</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">readstats</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">(</span>
<span class="p">[</span>
<span class="p">(</span>
<span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">row</span><span class="o">.</span><span class="n">subdir</span><span class="p">,</span> <span class="s2">"readstats.csv"</span><span class="p">))</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span>
<span class="n">pacbioRun</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">pacbioRun</span><span class="p">,</span> <span class="n">library</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">library</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">pacbio_runs</span><span class="o">.</span><span class="n">itertuples</span><span class="p">()</span>
<span class="p">],</span>
<span class="n">ignore_index</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<span class="n">readstats_chart</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">alt</span><span class="o">.</span><span class="n">Chart</span><span class="p">(</span><span class="n">readstats</span><span class="p">)</span>
<span class="o">.</span><span class="n">encode</span><span class="p">(</span>
<span class="n">x</span><span class="o">=</span><span class="s2">"count:Q"</span><span class="p">,</span>
<span class="n">y</span><span class="o">=</span><span class="n">alt</span><span class="o">.</span><span class="n">Y</span><span class="p">(</span>
<span class="s2">"category:N"</span><span class="p">,</span>
<span class="n">axis</span><span class="o">=</span><span class="n">alt</span><span class="o">.</span><span class="n">Axis</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">),</span>
<span class="p">),</span>
<span class="n">tooltip</span><span class="o">=</span><span class="n">readstats</span><span class="o">.</span><span class="n">columns</span><span class="o">.</span><span class="n">tolist</span><span class="p">(),</span>
<span class="n">facet</span><span class="o">=</span><span class="n">alt</span><span class="o">.</span><span class="n">Facet</span><span class="p">(</span><span class="s2">"pacbioRun:N"</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">),</span>
<span class="p">)</span>
<span class="o">.</span><span class="n">mark_bar</span><span class="p">()</span>
<span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">width</span><span class="o">=</span><span class="mi">250</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mi">75</span><span class="p">)</span>
<span class="o">.</span><span class="n">resolve_scale</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="s2">"independent"</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="s2">"independent"</span><span class="p">)</span>
<span class="p">)</span>
<span class="n">readstats_chart</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[4]:
</pre></div>
</div>
<div class="output_area rendered_html docutils container">
<style>
#altair-viz-c6db807143d6477d963df6d9f1e999ab.vega-embed {
width: 100%;
display: flex;
}
#altair-viz-c6db807143d6477d963df6d9f1e999ab.vega-embed details,
#altair-viz-c6db807143d6477d963df6d9f1e999ab.vega-embed details summary {
position: relative;
}
</style>
<div id="altair-viz-c6db807143d6477d963df6d9f1e999ab"></div>
<script type="text/javascript">
var VEGA_DEBUG = (typeof VEGA_DEBUG == "undefined") ? {} : VEGA_DEBUG;
(function(spec, embedOpt){
let outputDiv = document.currentScript.previousElementSibling;
if (outputDiv.id !== "altair-viz-c6db807143d6477d963df6d9f1e999ab") {
outputDiv = document.getElementById("altair-viz-c6db807143d6477d963df6d9f1e999ab");
}
const paths = {
"vega": "https://cdn.jsdelivr.net/npm/vega@5?noext",
"vega-lib": "https://cdn.jsdelivr.net/npm/vega-lib?noext",
"vega-lite": "https://cdn.jsdelivr.net/npm/[email protected]?noext",
"vega-embed": "https://cdn.jsdelivr.net/npm/vega-embed@6?noext",
};
function maybeLoadScript(lib, version) {
var key = `${lib.replace("-", "")}_version`;
return (VEGA_DEBUG[key] == version) ?
Promise.resolve(paths[lib]) :
new Promise(function(resolve, reject) {
var s = document.createElement('script');
document.getElementsByTagName("head")[0].appendChild(s);
s.async = true;
s.onload = () => {
VEGA_DEBUG[key] = version;
return resolve(paths[lib]);
};
s.onerror = () => reject(`Error loading script: ${paths[lib]}`);
s.src = paths[lib];
});
}
function showError(err) {
outputDiv.innerHTML = `<div class="error" style="color:red;">${err}</div>`;
throw err;
}
function displayChart(vegaEmbed) {
vegaEmbed(outputDiv, spec, embedOpt)
.catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));
}
if(typeof define === "function" && define.amd) {
requirejs.config({paths});
require(["vega-embed"], displayChart, err => showError(`Error loading script: ${err.message}`));
} else {
maybeLoadScript("vega", "5")
.then(() => maybeLoadScript("vega-lite", "5.8.0"))
.then(() => maybeLoadScript("vega-embed", "6"))
.catch(showError)
.then(() => displayChart(vegaEmbed));
}
})({"config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}, "data": {"name": "data-b003f2c0191bd5299e109b939127dda8"}, "mark": {"type": "bar"}, "encoding": {"facet": {"columns": 2, "field": "pacbioRun", "title": null, "type": "nominal"}, "tooltip": [{"field": "category", "type": "nominal"}, {"field": "count", "type": "quantitative"}, {"field": "pacbioRun", "type": "nominal"}, {"field": "library", "type": "nominal"}], "x": {"field": "count", "type": "quantitative"}, "y": {"axis": {"title": null}, "field": "category", "type": "nominal"}}, "height": 75, "resolve": {"scale": {"x": "independent", "y": "independent"}}, "width": 250, "$schema": "https://vega.github.io/schema/vega-lite/v5.8.0.json", "datasets": {"data-b003f2c0191bd5299e109b939127dda8": [{"category": "aligned PacBio_amplicon", "count": 27382, "pacbioRun": "LibA_211105", "library": "LibA"}, {"category": "filtered PacBio_amplicon", "count": 5263, "pacbioRun": "LibA_211105", "library": "LibA"}, {"category": "unmapped", "count": 560, "pacbioRun": "LibA_211105", "library": "LibA"}, {"category": "aligned PacBio_amplicon", "count": 28415, "pacbioRun": "LibB_211105", "library": "LibB"}, {"category": "filtered PacBio_amplicon", "count": 4334, "pacbioRun": "LibB_211105", "library": "LibB"}, {"category": "unmapped", "count": 456, "pacbioRun": "LibB_211105", "library": "LibB"}, {"category": "aligned PacBio_amplicon", "count": 26910, "pacbioRun": "LibA_220124", "library": "LibA"}, {"category": "filtered PacBio_amplicon", "count": 5649, "pacbioRun": "LibA_220124", "library": "LibA"}, {"category": "unmapped", "count": 646, "pacbioRun": "LibA_220124", "library": "LibA"}, {"category": "aligned PacBio_amplicon", "count": 28150, "pacbioRun": "LibB_220124", "library": "LibB"}, {"category": "filtered PacBio_amplicon", "count": 4519, "pacbioRun": "LibB_220124", "library": "LibB"}, {"category": "unmapped", "count": 536, "pacbioRun": "LibB_220124", "library": "LibB"}]}}, {"mode": "vega-lite"});
</script></div>
</div>
</section>
<section id="Visualize-target-to-which-reads-are-being-aligned">
<h2>Visualize target to which reads are being aligned<a class="headerlink" href="#Visualize-target-to-which-reads-are-being-aligned" title="Permalink to this heading">¶</a></h2>
<p>Draw images of the target we’re parsing:</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[5]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">targets</span> <span class="o">=</span> <span class="n">alignparse</span><span class="o">.</span><span class="n">targets</span><span class="o">.</span><span class="n">Targets</span><span class="p">(</span>
<span class="n">seqsfile</span><span class="o">=</span><span class="n">config</span><span class="p">[</span><span class="s2">"pacbio_amplicon"</span><span class="p">],</span>
<span class="n">feature_parse_specs</span><span class="o">=</span><span class="n">config</span><span class="p">[</span><span class="s2">"pacbio_amplicon_specs"</span><span class="p">],</span>
<span class="p">)</span>
<span class="n">fig</span> <span class="o">=</span> <span class="n">targets</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span>
<span class="n">ax_width</span><span class="o">=</span><span class="mi">7</span><span class="p">,</span>
<span class="n">plots_indexing</span><span class="o">=</span><span class="s2">"genbank"</span><span class="p">,</span>
<span class="n">ax_height</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span>
<span class="n">hspace</span><span class="o">=</span><span class="mf">1.2</span><span class="p">,</span>
<span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<img alt="_images/analyze_pacbio_ccs_9_0.png" src="_images/analyze_pacbio_ccs_9_0.png" />
</div>
</div>
</section>
<section id="Why-were-some-CCSs-filtered?">
<h2>Why were some CCSs filtered?<a class="headerlink" href="#Why-were-some-CCSs-filtered?" title="Permalink to this heading">¶</a></h2>
<p>Plot the number of CCSs filtered for each reason:</p>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># CSVs holding filtered reads</span>
<span class="n">filtered_csvs</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">(</span>
<span class="p">[</span>
<span class="p">(</span>
<span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">row</span><span class="o">.</span><span class="n">subdir</span><span class="p">,</span> <span class="s2">"filtered.csv"</span><span class="p">))</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span>
<span class="n">pacbioRun</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">pacbioRun</span><span class="p">,</span> <span class="n">library</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">library</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">pacbio_runs</span><span class="o">.</span><span class="n">itertuples</span><span class="p">()</span>
<span class="p">],</span>
<span class="n">ignore_index</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<span class="c1"># details for all filtered reads</span>
<span class="n">filtered</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">(</span>
<span class="p">[</span>
<span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">row</span><span class="o">.</span><span class="n">csv_file</span><span class="p">)</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span>
<span class="n">target</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">target</span><span class="p">,</span> <span class="n">pacbioRun</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">pacbioRun</span><span class="p">,</span> <span class="n">library</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">library</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">filtered_csvs</span><span class="o">.</span><span class="n">itertuples</span><span class="p">()</span>
<span class="p">],</span>
<span class="n">ignore_index</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<span class="c1"># count reasons for filtering, then add number of non-filtered</span>
<span class="n">filtered_reasons</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">(</span>
<span class="p">[</span>
<span class="n">filtered</span><span class="o">.</span><span class="n">groupby</span><span class="p">([</span><span class="s2">"pacbioRun"</span><span class="p">,</span> <span class="s2">"filter_reason"</span><span class="p">],</span> <span class="n">as_index</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span>
<span class="n">count</span><span class="o">=</span><span class="n">pd</span><span class="o">.</span><span class="n">NamedAgg</span><span class="p">(</span><span class="s2">"query_name"</span><span class="p">,</span> <span class="s2">"count"</span><span class="p">)</span>
<span class="p">),</span>
<span class="n">readstats</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="s1">'category.str.startswith("aligned")'</span><span class="p">,</span> <span class="n">engine</span><span class="o">=</span><span class="s2">"python"</span><span class="p">)</span>
<span class="o">.</span><span class="n">groupby</span><span class="p">(</span><span class="s2">"pacbioRun"</span><span class="p">,</span> <span class="n">as_index</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="o">.</span><span class="n">aggregate</span><span class="p">({</span><span class="s2">"count"</span><span class="p">:</span> <span class="s2">"sum"</span><span class="p">})</span>
<span class="o">.</span><span class="n">assign</span><span class="p">(</span><span class="n">filter_reason</span><span class="o">=</span><span class="s2">"aligned"</span><span class="p">),</span>
<span class="p">]</span>
<span class="p">)</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span>
<span class="n">total_counts</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="o">.</span><span class="n">groupby</span><span class="p">(</span><span class="s2">"pacbioRun"</span><span class="p">)[</span><span class="s2">"count"</span><span class="p">]</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="s2">"sum"</span><span class="p">),</span>
<span class="n">frac_counts</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">[</span><span class="s2">"count"</span><span class="p">]</span> <span class="o">/</span> <span class="n">x</span><span class="p">[</span><span class="s2">"total_counts"</span><span class="p">],</span>
<span class="p">)</span>
<span class="c1"># make chart</span>
<span class="n">filtered_chart</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">alt</span><span class="o">.</span><span class="n">Chart</span><span class="p">(</span><span class="n">filtered_reasons</span><span class="p">)</span>
<span class="o">.</span><span class="n">encode</span><span class="p">(</span>
<span class="n">x</span><span class="o">=</span><span class="s2">"count:Q"</span><span class="p">,</span>
<span class="n">y</span><span class="o">=</span><span class="n">alt</span><span class="o">.</span><span class="n">Y</span><span class="p">(</span>
<span class="s2">"filter_reason:N"</span><span class="p">,</span>
<span class="n">axis</span><span class="o">=</span><span class="n">alt</span><span class="o">.</span><span class="n">Axis</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">),</span>
<span class="p">),</span>
<span class="n">color</span><span class="o">=</span><span class="s2">"is_aligned:N"</span><span class="p">,</span>
<span class="n">tooltip</span><span class="o">=</span><span class="n">filtered_reasons</span><span class="o">.</span><span class="n">columns</span><span class="o">.</span><span class="n">tolist</span><span class="p">(),</span>
<span class="n">facet</span><span class="o">=</span><span class="n">alt</span><span class="o">.</span><span class="n">Facet</span><span class="p">(</span><span class="s2">"pacbioRun:N"</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">title</span><span class="o">=</span><span class="kc">None</span><span class="p">),</span>
<span class="p">)</span>
<span class="o">.</span><span class="n">mark_bar</span><span class="p">()</span>
<span class="o">.</span><span class="n">properties</span><span class="p">(</span><span class="n">width</span><span class="o">=</span><span class="mi">250</span><span class="p">,</span> <span class="n">height</span><span class="o">=</span><span class="mi">75</span><span class="p">)</span>
<span class="o">.</span><span class="n">resolve_scale</span><span class="p">(</span><span class="n">x</span><span class="o">=</span><span class="s2">"independent"</span><span class="p">,</span> <span class="n">y</span><span class="o">=</span><span class="s2">"independent"</span><span class="p">)</span>
<span class="o">.</span><span class="n">transform_filter</span><span class="p">(</span><span class="n">alt</span><span class="o">.</span><span class="n">datum</span><span class="o">.</span><span class="n">frac_counts</span> <span class="o">></span> <span class="mf">0.01</span><span class="p">)</span>
<span class="o">.</span><span class="n">transform_calculate</span><span class="p">(</span><span class="n">is_aligned</span><span class="o">=</span><span class="n">alt</span><span class="o">.</span><span class="n">datum</span><span class="o">.</span><span class="n">filter_reason</span> <span class="o">==</span> <span class="s2">"aligned"</span><span class="p">)</span>
<span class="p">)</span>
<span class="n">filtered_chart</span>
</pre></div>
</div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[6]:
</pre></div>
</div>
<div class="output_area rendered_html docutils container">
<style>
#altair-viz-ba140aa1d7724750addf0e17263b4895.vega-embed {
width: 100%;
display: flex;
}
#altair-viz-ba140aa1d7724750addf0e17263b4895.vega-embed details,
#altair-viz-ba140aa1d7724750addf0e17263b4895.vega-embed details summary {
position: relative;
}
</style>
<div id="altair-viz-ba140aa1d7724750addf0e17263b4895"></div>
<script type="text/javascript">
var VEGA_DEBUG = (typeof VEGA_DEBUG == "undefined") ? {} : VEGA_DEBUG;
(function(spec, embedOpt){
let outputDiv = document.currentScript.previousElementSibling;
if (outputDiv.id !== "altair-viz-ba140aa1d7724750addf0e17263b4895") {
outputDiv = document.getElementById("altair-viz-ba140aa1d7724750addf0e17263b4895");
}
const paths = {
"vega": "https://cdn.jsdelivr.net/npm/vega@5?noext",
"vega-lib": "https://cdn.jsdelivr.net/npm/vega-lib?noext",
"vega-lite": "https://cdn.jsdelivr.net/npm/[email protected]?noext",
"vega-embed": "https://cdn.jsdelivr.net/npm/vega-embed@6?noext",
};
function maybeLoadScript(lib, version) {
var key = `${lib.replace("-", "")}_version`;
return (VEGA_DEBUG[key] == version) ?
Promise.resolve(paths[lib]) :
new Promise(function(resolve, reject) {
var s = document.createElement('script');
document.getElementsByTagName("head")[0].appendChild(s);
s.async = true;
s.onload = () => {
VEGA_DEBUG[key] = version;
return resolve(paths[lib]);
};
s.onerror = () => reject(`Error loading script: ${paths[lib]}`);
s.src = paths[lib];
});
}
function showError(err) {
outputDiv.innerHTML = `<div class="error" style="color:red;">${err}</div>`;
throw err;
}
function displayChart(vegaEmbed) {
vegaEmbed(outputDiv, spec, embedOpt)
.catch(err => showError(`Javascript Error: ${err.message}<br>This usually means there's a typo in your chart specification. See the javascript console for the full traceback.`));
}
if(typeof define === "function" && define.amd) {
requirejs.config({paths});
require(["vega-embed"], displayChart, err => showError(`Error loading script: ${err.message}`));
} else {
maybeLoadScript("vega", "5")
.then(() => maybeLoadScript("vega-lite", "5.8.0"))
.then(() => maybeLoadScript("vega-embed", "6"))
.catch(showError)
.then(() => displayChart(vegaEmbed));
}
})({"config": {"view": {"continuousWidth": 300, "continuousHeight": 300}}, "data": {"name": "data-a963d092880d12a6f6f0af53c23fb0c8"}, "mark": {"type": "bar"}, "encoding": {"color": {"field": "is_aligned", "type": "nominal"}, "facet": {"columns": 2, "field": "pacbioRun", "title": null, "type": "nominal"}, "tooltip": [{"field": "pacbioRun", "type": "nominal"}, {"field": "filter_reason", "type": "nominal"}, {"field": "count", "type": "quantitative"}, {"field": "total_counts", "type": "quantitative"}, {"field": "frac_counts", "type": "quantitative"}], "x": {"field": "count", "type": "quantitative"}, "y": {"axis": {"title": null}, "field": "filter_reason", "type": "nominal"}}, "height": 75, "resolve": {"scale": {"x": "independent", "y": "independent"}}, "transform": [{"filter": "(datum.frac_counts > 0.01)"}, {"calculate": "(datum.filter_reason === 'aligned')", "as": "is_aligned"}], "width": 250, "$schema": "https://vega.github.io/schema/vega-lite/v5.8.0.json", "datasets": {"data-a963d092880d12a6f6f0af53c23fb0c8": [{"pacbioRun": "LibA_211105", "filter_reason": "barcode clip3", "count": 18, "total_counts": 32645, "frac_counts": 0.0005513861234492265}, {"pacbioRun": "LibA_211105", "filter_reason": "barcode mutation_nt_count", "count": 453, "total_counts": 32645, "frac_counts": 0.0138765507734722}, {"pacbioRun": "LibA_211105", "filter_reason": "gene clip3", "count": 392, "total_counts": 32645, "frac_counts": 0.0120079644662276}, {"pacbioRun": "LibA_211105", "filter_reason": "gene mutation_nt_count", "count": 2003, "total_counts": 32645, "frac_counts": 0.06135702251493337}, {"pacbioRun": "LibA_211105", "filter_reason": "query_clip3", "count": 174, "total_counts": 32645, "frac_counts": 0.00533006586000919}, {"pacbioRun": "LibA_211105", "filter_reason": "query_clip5", "count": 598, "total_counts": 32645, "frac_counts": 0.018318272323479858}, {"pacbioRun": "LibA_211105", "filter_reason": "termini3 clip3", "count": 144, "total_counts": 32645, "frac_counts": 0.004411088987593812}, {"pacbioRun": "LibA_211105", "filter_reason": "termini3 mutation_nt_count", "count": 177, "total_counts": 32645, "frac_counts": 0.0054219635472507275}, {"pacbioRun": "LibA_211105", "filter_reason": "termini5 clip5", "count": 965, "total_counts": 32645, "frac_counts": 0.02956042272936131}, {"pacbioRun": "LibA_211105", "filter_reason": "termini5 mutation_nt_count", "count": 187, "total_counts": 32645, "frac_counts": 0.005728289171389187}, {"pacbioRun": "LibA_211105", "filter_reason": "variant_tag3 mutation_nt_count", "count": 103, "total_counts": 32645, "frac_counts": 0.0031551539286261295}, {"pacbioRun": "LibA_211105", "filter_reason": "variant_tag5 mutation_nt_count", "count": 49, "total_counts": 32645, "frac_counts": 0.00150099555827845}, {"pacbioRun": "LibA_220124", "filter_reason": "barcode clip3", "count": 28, "total_counts": 32559, "frac_counts": 0.0008599772720292392}, {"pacbioRun": "LibA_220124", "filter_reason": "barcode mutation_nt_count", "count": 320, "total_counts": 32559, "frac_counts": 0.009828311680334163}, {"pacbioRun": "LibA_220124", "filter_reason": "gene clip3", "count": 491, "total_counts": 32559, "frac_counts": 0.01508031573451273}, {"pacbioRun": "LibA_220124", "filter_reason": "gene mutation_nt_count", "count": 2259, "total_counts": 32559, "frac_counts": 0.06938173776835897}, {"pacbioRun": "LibA_220124", "filter_reason": "query_clip3", "count": 247, "total_counts": 32559, "frac_counts": 0.007586228078257932}, {"pacbioRun": "LibA_220124", "filter_reason": "query_clip5", "count": 660, "total_counts": 32559, "frac_counts": 0.02027089284068921}, {"pacbioRun": "LibA_220124", "filter_reason": "termini3 clip3", "count": 124, "total_counts": 32559, "frac_counts": 0.003808470776129488}, {"pacbioRun": "LibA_220124", "filter_reason": "termini3 mutation_nt_count", "count": 153, "total_counts": 32559, "frac_counts": 0.0046991615221597715}, {"pacbioRun": "LibA_220124", "filter_reason": "termini5 clip5", "count": 1084, "total_counts": 32559, "frac_counts": 0.03329340581713198}, {"pacbioRun": "LibA_220124", "filter_reason": "termini5 mutation_nt_count", "count": 180, "total_counts": 32559, "frac_counts": 0.005528425320187966}, {"pacbioRun": "LibA_220124", "filter_reason": "variant_tag3 mutation_nt_count", "count": 69, "total_counts": 32559, "frac_counts": 0.002119229706072054}, {"pacbioRun": "LibA_220124", "filter_reason": "variant_tag5 mutation_nt_count", "count": 34, "total_counts": 32559, "frac_counts": 0.0010442581160355047}, {"pacbioRun": "LibB_211105", "filter_reason": "barcode clip3", "count": 39, "total_counts": 32749, "frac_counts": 0.001190876057284192}, {"pacbioRun": "LibB_211105", "filter_reason": "barcode mutation_nt_count", "count": 434, "total_counts": 32749, "frac_counts": 0.013252313047726649}, {"pacbioRun": "LibB_211105", "filter_reason": "gene clip3", "count": 394, "total_counts": 32749, "frac_counts": 0.012030901706922349}, {"pacbioRun": "LibB_211105", "filter_reason": "gene mutation_nt_count", "count": 1158, "total_counts": 32749, "frac_counts": 0.035359858316284465}, {"pacbioRun": "LibB_211105", "filter_reason": "query_clip3", "count": 190, "total_counts": 32749, "frac_counts": 0.005801703868820422}, {"pacbioRun": "LibB_211105", "filter_reason": "query_clip5", "count": 492, "total_counts": 32749, "frac_counts": 0.015023359491892882}, {"pacbioRun": "LibB_211105", "filter_reason": "termini3 clip3", "count": 172, "total_counts": 32749, "frac_counts": 0.005252068765458487}, {"pacbioRun": "LibB_211105", "filter_reason": "termini3 mutation_nt_count", "count": 185, "total_counts": 32749, "frac_counts": 0.005649027451219884}, {"pacbioRun": "LibB_211105", "filter_reason": "termini5 clip5", "count": 996, "total_counts": 32749, "frac_counts": 0.030413142386027055}, {"pacbioRun": "LibB_211105", "filter_reason": "termini5 mutation_nt_count", "count": 143, "total_counts": 32749, "frac_counts": 0.00436654554337537}, {"pacbioRun": "LibB_211105", "filter_reason": "variant_tag3 mutation_nt_count", "count": 87, "total_counts": 32749, "frac_counts": 0.002656569666249351}, {"pacbioRun": "LibB_211105", "filter_reason": "variant_tag5 mutation_nt_count", "count": 44, "total_counts": 32749, "frac_counts": 0.0013435524748847292}, {"pacbioRun": "LibB_220124", "filter_reason": "barcode clip3", "count": 30, "total_counts": 32669, "frac_counts": 0.0009183017539563501}, {"pacbioRun": "LibB_220124", "filter_reason": "barcode mutation_nt_count", "count": 355, "total_counts": 32669, "frac_counts": 0.010866570755150143}, {"pacbioRun": "LibB_220124", "filter_reason": "gene clip3", "count": 482, "total_counts": 32669, "frac_counts": 0.014754048180232024}, {"pacbioRun": "LibB_220124", "filter_reason": "gene mutation_nt_count", "count": 1271, "total_counts": 32669, "frac_counts": 0.03890538430928403}, {"pacbioRun": "LibB_220124", "filter_reason": "query_clip3", "count": 201, "total_counts": 32669, "frac_counts": 0.006152621751507545}, {"pacbioRun": "LibB_220124", "filter_reason": "query_clip5", "count": 503, "total_counts": 32669, "frac_counts": 0.01539685940800147}, {"pacbioRun": "LibB_220124", "filter_reason": "termini3 clip3", "count": 153, "total_counts": 32669, "frac_counts": 0.004683338945177386}, {"pacbioRun": "LibB_220124", "filter_reason": "termini3 mutation_nt_count", "count": 170, "total_counts": 32669, "frac_counts": 0.005203709939085983}, {"pacbioRun": "LibB_220124", "filter_reason": "termini5 clip5", "count": 1057, "total_counts": 32669, "frac_counts": 0.03235483179772873}, {"pacbioRun": "LibB_220124", "filter_reason": "termini5 mutation_nt_count", "count": 182, "total_counts": 32669, "frac_counts": 0.005571030640668524}, {"pacbioRun": "LibB_220124", "filter_reason": "variant_tag3 mutation_nt_count", "count": 73, "total_counts": 32669, "frac_counts": 0.002234534267960452}, {"pacbioRun": "LibB_220124", "filter_reason": "variant_tag5 mutation_nt_count", "count": 42, "total_counts": 32669, "frac_counts": 0.0012856224555388902}, {"pacbioRun": "LibA_211105", "filter_reason": "aligned", "count": 27382, "total_counts": 32645, "frac_counts": 0.8387808240159289}, {"pacbioRun": "LibA_220124", "filter_reason": "aligned", "count": 26910, "total_counts": 32559, "frac_counts": 0.826499585368101}, {"pacbioRun": "LibB_211105", "filter_reason": "aligned", "count": 28415, "total_counts": 32749, "frac_counts": 0.8676600812238542}, {"pacbioRun": "LibB_220124", "filter_reason": "aligned", "count": 28150, "total_counts": 32669, "frac_counts": 0.8616731457957084}]}}, {"mode": "vega-lite"});
</script></div>
</div>
</section>
<section id="Get-CCSs-that-align-to-the-amplicon">
<h2>Get CCSs that align to the amplicon<a class="headerlink" href="#Get-CCSs-that-align-to-the-amplicon" title="Permalink to this heading">¶</a></h2>
<div class="nbinput docutils container">
<div class="prompt highlight-none notranslate"><div class="highlight"><pre><span></span>[7]:
</pre></div>
</div>
<div class="input_area highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># CSVs holding aligned reads</span>
<span class="n">aligned_csvs</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">(</span>
<span class="p">[</span>
<span class="p">(</span>
<span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">row</span><span class="o">.</span><span class="n">subdir</span><span class="p">,</span> <span class="s2">"aligned.csv"</span><span class="p">))</span><span class="o">.</span><span class="n">assign</span><span class="p">(</span>
<span class="n">pacbioRun</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">pacbioRun</span><span class="p">,</span> <span class="n">library</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">library</span>
<span class="p">)</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">pacbio_runs</span><span class="o">.</span><span class="n">itertuples</span><span class="p">()</span>
<span class="p">],</span>
<span class="n">ignore_index</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<span class="k">assert</span> <span class="n">aligned_csvs</span><span class="p">[</span><span class="s2">"target"</span><span class="p">]</span><span class="o">.</span><span class="n">nunique</span><span class="p">()</span> <span class="o">==</span> <span class="mi">1</span>
<span class="n">aligned</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">concat</span><span class="p">(</span>
<span class="p">[</span>
<span class="p">(</span>
<span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">row</span><span class="o">.</span><span class="n">csv_file</span><span class="p">)</span>
<span class="o">.</span><span class="n">assign</span><span class="p">(</span><span class="n">pacbioRun</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">pacbioRun</span><span class="p">,</span> <span class="n">library</span><span class="o">=</span><span class="n">row</span><span class="o">.</span><span class="n">library</span><span class="p">)</span>
<span class="o">.</span><span class="n">drop</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="p">[</span><span class="s2">"query_clip5"</span><span class="p">,</span> <span class="s2">"query_clip3"</span><span class="p">])</span>
<span class="o">.</span><span class="n">rename</span><span class="p">(</span><span class="n">columns</span><span class="o">=</span><span class="p">{</span><span class="s2">"barcode_sequence"</span><span class="p">:</span> <span class="s2">"barcode"</span><span class="p">})</span>
<span class="p">)</span>
<span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">aligned_csvs</span><span class="o">.</span><span class="n">itertuples</span><span class="p">()</span>
<span class="p">],</span>
<span class="n">ignore_index</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"</span><span class="se">\n</span><span class="s2">Read </span><span class="si">{</span><span class="nb">len</span><span class="p">(</span><span class="n">aligned</span><span class="p">)</span><span class="si">:</span><span class="s2">.4g</span><span class="si">}</span><span class="s2"> alignable CCSs:"</span><span class="p">)</span>
<span class="n">display</span><span class="p">(</span>
<span class="n">aligned</span><span class="o">.</span><span class="n">groupby</span><span class="p">(</span><span class="s2">"pacbioRun"</span><span class="p">)</span><span class="o">.</span><span class="n">aggregate</span><span class="p">(</span><span class="n">n_CCSs</span><span class="o">=</span><span class="n">pd</span><span class="o">.</span><span class="n">NamedAgg</span><span class="p">(</span><span class="s2">"query_name"</span><span class="p">,</span> <span class="s2">"count"</span><span class="p">))</span>
<span class="p">)</span>
<span class="n">output_csv</span> <span class="o">=</span> <span class="n">config</span><span class="p">[</span><span class="s2">"aligned_ccs_file"</span><span class="p">]</span>
<span class="nb">print</span><span class="p">(</span><span class="sa">f</span><span class="s2">"Writing to </span><span class="si">{</span><span class="n">output_csv</span><span class="si">}</span><span class="s2">"</span><span class="p">)</span>
<span class="n">aligned</span><span class="o">.</span><span class="n">to_csv</span><span class="p">(</span><span class="n">output_csv</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="nboutput docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
Read 1.109e+05 alignable CCSs:
</pre></div></div>
</div>
<div class="nboutput docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area rendered_html docutils container">
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>n_CCSs</th>
</tr>
<tr>
<th>pacbioRun</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th>LibA_211105</th>
<td>27382</td>
</tr>
<tr>
<th>LibA_220124</th>
<td>26910</td>
</tr>
<tr>
<th>LibB_211105</th>
<td>28415</td>
</tr>
<tr>
<th>LibB_220124</th>
<td>28150</td>
</tr>
</tbody>
</table>
</div></div>
</div>
<div class="nboutput nblast docutils container">
<div class="prompt empty docutils container">
</div>
<div class="output_area docutils container">
<div class="highlight"><pre>
Writing to results/process_ccs/CCSs_aligned_to_amplicon.csv
</pre></div></div>
</div>
</section>
</section>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©Jesse Bloom (2023).
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 6.1.3</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a>
|
<a href="_sources/analyze_pacbio_ccs.nblink.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>