-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
3746 lines (3700 loc) · 683 KB
/
index.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
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="author" content="Tao Wu" />
<meta name="author" content="Xue-Song Liu (Corresponding author)" />
<meta name="date" content="2022-05-04" />
<title>Pan-cancer quantification of neoantigen-mediated immunoediting in cancer evolution</title>
<script src="report_main_files/header-attrs-2.9/header-attrs.js"></script>
<script src="report_main_files/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="report_main_files/bootstrap-3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="report_main_files/bootstrap-3.3.7/js/bootstrap.min.js"></script>
<script src="report_main_files/jqueryui-1.11.4/jquery-ui.min.js"></script>
<script src="report_main_files/navigation-1.1/tabsets.js"></script>
<link href="report_main_files/magnific-popup-1.1.0/magnific-popup.css" rel="stylesheet" />
<script src="report_main_files/magnific-popup-1.1.0/jquery.magnific-popup.min.js"></script>
<link href="report_main_files/readthedown-0.1/readthedown.css" rel="stylesheet" />
<link href="report_main_files/readthedown-0.1/readthedown_fonts_embed.css" rel="stylesheet" />
<script src="report_main_files/readthedown-0.1/readthedown.js"></script>
<script src="report_main_files/htmlwidgets-1.5.4/htmlwidgets.js"></script>
<link href="report_main_files/datatables-css-0.0.0/datatables-crosstalk.css" rel="stylesheet" />
<script src="report_main_files/datatables-binding-0.19/datatables.js"></script>
<link href="report_main_files/dt-core-1.10.20/css/jquery.dataTables.min.css" rel="stylesheet" />
<link href="report_main_files/dt-core-1.10.20/css/jquery.dataTables.extra.css" rel="stylesheet" />
<script src="report_main_files/dt-core-1.10.20/js/jquery.dataTables.min.js"></script>
<link href="report_main_files/crosstalk-1.1.1/css/crosstalk.css" rel="stylesheet" />
<script src="report_main_files/crosstalk-1.1.1/js/crosstalk.min.js"></script>
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
background-color: #ffffff;
color: #a0a0a0;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #a0a0a0; padding-left: 4px; }
div.sourceCode
{ color: #1f1c1b; background-color: #ffffff; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span { color: #1f1c1b; } /* Normal */
code span.al { color: #bf0303; background-color: #f7e6e6; font-weight: bold; } /* Alert */
code span.an { color: #ca60ca; } /* Annotation */
code span.at { color: #0057ae; } /* Attribute */
code span.bn { color: #b08000; } /* BaseN */
code span.bu { color: #644a9b; font-weight: bold; } /* BuiltIn */
code span.cf { color: #1f1c1b; font-weight: bold; } /* ControlFlow */
code span.ch { color: #924c9d; } /* Char */
code span.cn { color: #aa5500; } /* Constant */
code span.co { color: #898887; } /* Comment */
code span.cv { color: #0095ff; } /* CommentVar */
code span.do { color: #607880; } /* Documentation */
code span.dt { color: #0057ae; } /* DataType */
code span.dv { color: #b08000; } /* DecVal */
code span.er { color: #bf0303; text-decoration: underline; } /* Error */
code span.ex { color: #0095ff; font-weight: bold; } /* Extension */
code span.fl { color: #b08000; } /* Float */
code span.fu { color: #644a9b; } /* Function */
code span.im { color: #ff5500; } /* Import */
code span.in { color: #b08000; } /* Information */
code span.kw { color: #1f1c1b; font-weight: bold; } /* Keyword */
code span.op { color: #1f1c1b; } /* Operator */
code span.ot { color: #006e28; } /* Other */
code span.pp { color: #006e28; } /* Preprocessor */
code span.re { color: #0057ae; background-color: #e0e9f8; } /* RegionMarker */
code span.sc { color: #3daee9; } /* SpecialChar */
code span.ss { color: #ff5500; } /* SpecialString */
code span.st { color: #bf0303; } /* String */
code span.va { color: #0057ae; } /* Variable */
code span.vs { color: #bf0303; } /* VerbatimString */
code span.wa { color: #bf0303; } /* Warning */
</style>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("toc");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open')
});
});
</script>
<!-- code folding -->
<!-- code download -->
<!-- tabsets dropdown -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
background: white;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li.active a {
padding: 0 15px !important;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
margin-left: 0 !important;
}
</style>
</head>
<body class="preload">
<!-- readthedown start -->
<div id="content" data-toggle="wy-nav-shift">
<nav id="nav-top" role="navigation" aria-label="top navigation">
<a role="button" href="#" data-toggle="wy-nav-top"><span class="glyphicon glyphicon-menu-hamburger"></span></a>
</nav>
<h1 class="title">Pan-cancer quantification of neoantigen-mediated immunoediting in cancer evolution</h1>
<!-- readthedown authors -->
<div id="sidebar">
<h2><a href="#content">Pan-cancer quantification of neoantigen-mediated immunoediting in cancer evolution</a></h2>
<div id="toc">
<ul>
<li><a href="#dependencies">Dependencies</a></li>
<li><a href="#data-download-and-preprocessing">Data download and preprocessing</a>
<ul>
<li><a href="#tcga-pancancer-data-download-and-clean">TCGA pancancer data download and clean</a>
<ul>
<li><a href="#mutation-data">Mutation data</a></li>
<li><a href="#expression-data">Expression data</a></li>
<li><a href="#hla-typing-and-immune-cell-infiltration-data">HLA typing and immune cell infiltration data</a></li>
</ul></li>
<li><a href="#tcga-pancancer-data-processing">TCGA pancancer data processing</a>
<ul>
<li><a href="#hla-typing">HLA typing</a></li>
<li><a href="#neoantigen-prediction">Neoantigen prediction</a></li>
</ul></li>
<li><a href="#immunotherapy-data-download-and-clean">Immunotherapy data download and clean</a></li>
</ul></li>
<li><a href="#tcga-pancancer-analysis">TCGA pancancer analysis</a>
<ul>
<li><a href="#the-existence-of-significant-immunoediting-signal">The existence of significant immunoediting signal</a></li>
<li><a href="#neoantigen-enrichment-score-and-immune-negative-selection-strength-quantification">Neoantigen enrichment score and immune negative selection strength quantification</a></li>
<li><a href="#pan-cancer-features-and-correlations-of-immunoediting-signal">Pan-cancer features and correlations of immunoediting signal</a></li>
</ul></li>
<li><a href="#immunotherapy-dataset-analysis">Immunotherapy dataset analysis</a>
<ul>
<li><a href="#quantified-immunoediting-elimination-signal-predicts-the-clinical-response-of-cancer-immunotherapy">Quantified immunoediting-elimination signal predicts the clinical response of cancer immunotherapy</a></li>
</ul></li>
<li><a href="#supplementary-analyses">Supplementary analyses</a>
<ul>
<li><a href="#sample-statistics-and-clinical-features">Sample statistics and clinical features</a></li>
<li><a href="#robust-of-method">Robust of method</a>
<ul>
<li><a href="#minimum-number-of-non-neoantigenic-mutations-to-calculate-significant-p">Minimum number of non-neoantigenic mutations to calculate significant P</a></li>
<li><a href="#threshold-for-neoantigen-prediction">Threshold for neoantigen prediction</a></li>
<li><a href="#another-method-for-neoantigen-prediction">Another method for neoantigen prediction</a></li>
</ul></li>
<li><a href="#immune-escape-analysis">Immune escape analysis</a></li>
<li><a href="#ccf-distribution-analysis">CCF distribution analysis</a></li>
<li><a href="#other-immune-cell-infiltration-quantification-methods">Other immune cell infiltration quantification methods</a></li>
<li><a href="#comparison-with-other-biomarkers-of-ici">Comparison with other biomarkers of ICI</a></li>
</ul></li>
</ul>
</div>
<div id="postamble" data-toggle="wy-nav-shift" class="status">
<p class="author"><span class="glyphicon glyphicon-user"></span> Tao Wu</p>
<p class="author"><span class="glyphicon glyphicon-user"></span> Xue-Song Liu (Corresponding author)</p>
<p class="date"><span class="glyphicon glyphicon-calendar"></span> 2022-05-04</p>
</div>
</div>
<!-- Don't indent these lines or it will mess pre blocks indentation -->
<div id="main">
<div id="dependencies" class="section level1">
<h1>Dependencies</h1>
<p>This project is depended on R software, R packages, shell bash, Julia software and some Julia packages :</p>
<ul>
<li><a href="https://github.com/wt12318/NeoEnrichment">NeoEnrichment</a> - do neoantigen enrichment for this project.</li>
<li><a href="https://www.tidyverse.org/">tidyverse</a> - tidy data</li>
<li><a href="https://github.com/Rdatatable/data.table">data.table</a> - read and tidy data</li>
<li><a href="https://github.com/therneau/survival">survival</a> - survival analysis</li>
<li><a href="https://github.com/kassambara/survminer">survminer</a> - plot survival fit</li>
<li><a href="https://cran.r-project.org/web/packages/DT/index.html">DT</a> - show data table as a table in html</li>
<li><a href="https://github.com/thomasp85/patchwork">patchwork</a> - arrange figures into complex compound figures</li>
<li><a href="https://github.com/PoisonAlien/maftools">maftools</a> - summarize, Analyze and Visualize MAF files</li>
<li><a href="https://github.com/jokergoo/ComplexHeatmap">ComplexHeatmap</a> - make heatmap</li>
<li><a href="https://github.com/ShixiangWang/ezcox">ezcox</a> - operate a batch of univariate or multivariate Cox models and return tidy result</li>
<li><a href="https://github.com/thomas-neitmann/ggcharts">ggcharts</a> - plot pyramid bar plot</li>
<li>parallel - Parallel Computing</li>
<li><a href="https://julialang.org/">Julia</a> - do simulation</li>
<li>knitr, rmdformats - used to compile this file</li>
</ul>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyverse)</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggpubr)</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(cowplot)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(NeoEnrichment)</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(parallel)</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(survminer)</span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(survival)</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(data.table)</span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(patchwork)</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ComplexHeatmap)</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(maftools)</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ezcox)</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(ggcharts)</span></code></pre></div>
</div>
<div id="data-download-and-preprocessing" class="section level1">
<h1>Data download and preprocessing</h1>
<p>This part will describe how and where the data that this project used is downloaded and pre-processed.</p>
<div id="tcga-pancancer-data-download-and-clean" class="section level2">
<h2>TCGA pancancer data download and clean</h2>
<div id="mutation-data" class="section level3">
<h3>Mutation data</h3>
<p>Pre-compiled curated somatic mutations (called by MuTect2) for TCGA cohorts were downloaded from <a href="https://xenabrowser.net/datapages/?dataset=GDC-PANCAN.mutect2_snv.tsv&host=https%3A%2F%2Fgdc.xenahubs.net&removeHub=https%3A%2F%2Fxena.treehouse.gi.ucsc.edu%3A443">Xena</a> and only keep missense variants for following analysis</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>mutect2 <span class="ot"><-</span> data.table<span class="sc">::</span><span class="fu">fread</span>(<span class="st">"~/useful_data/GDC-PANCAN.mutect2_snv.tsv"</span>) <span class="sc">%>%</span> </span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">filter</span>(effect<span class="sc">==</span><span class="st">"missense_variant"</span> <span class="sc">&</span> filter<span class="sc">==</span><span class="st">"PASS"</span>)</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(mutect2,<span class="at">file =</span> <span class="st">"../data/pancancer_mutation.rds"</span>)</span></code></pre></div>
<p>view this file:</p>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>pancancer_mutation <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/pancancer_mutation.rds"</span>)</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>DT<span class="sc">::</span><span class="fu">datatable</span>(<span class="fu">head</span>(pancancer_mutation),</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="at">options =</span> <span class="fu">list</span>(<span class="at">scrollX =</span> <span class="cn">TRUE</span>, <span class="at">keys =</span> <span class="cn">TRUE</span>,</span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="at">columnDefs =</span> <span class="fu">list</span>(<span class="fu">list</span>(<span class="at">className =</span> <span class="st">'dt-center'</span>, <span class="at">targets =</span> <span class="dv">2</span>))), <span class="at">rownames =</span> <span class="cn">FALSE</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a>)</span></code></pre></div>
<div id="htmlwidget-d58e2ef959ae289ee3dc" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-d58e2ef959ae289ee3dc">{"x":{"filter":"none","vertical":false,"data":[["TCGA-P6-A5OH-01A","TCGA-P6-A5OH-01A","TCGA-P6-A5OH-01A","TCGA-P6-A5OH-01A","TCGA-P6-A5OH-01A","TCGA-P6-A5OH-01A"],["WASF2","MACF1","NFIA","CADM3","DUSP27","RGSL1"],["chr1","chr1","chr1","chr1","chr1","chr1"],[27410171,39455094,61088434,159200836,167126702,182556049],[27410171,39455094,61088434,159200836,167126702,182556049],["G","T","C","G","G","G"],["A","A","T","A","C","C"],["p.A287V","p.H6923Q","p.L105F","p.D371N","p.G524A","p.E1075Q"],["missense_variant","missense_variant","missense_variant","missense_variant","missense_variant","missense_variant"],["PASS","PASS","PASS","PASS","PASS","PASS"],[0.25531914893617,0.0720720720720721,0.152671755725191,0.299479166666667,0.0555555555555556,0.2734375]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th>Sample_ID<\/th>\n <th>gene<\/th>\n <th>chrom<\/th>\n <th>start<\/th>\n <th>end<\/th>\n <th>ref<\/th>\n <th>alt<\/th>\n <th>Amino_Acid_Change<\/th>\n <th>effect<\/th>\n <th>filter<\/th>\n <th>dna_vaf<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"scrollX":true,"keys":true,"columnDefs":[{"className":"dt-center","targets":2},{"className":"dt-right","targets":[3,4,10]}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
<p>To predict neoantigen, mutation files were first transformed into single sample VCF format by maf2vcf tools (This Code can be found in <code>code/shell/TCGA_neoantigen</code> folder).</p>
<p>ABSOLUTE-annotated MAF file which contains cancer cell fraction (CCF) information of mutations was downloaded from GDC PanCanAtlas publications (<a href="https://gdc.cancer.gov/node/905/">TCGA_consolidated.abs_mafs_truncated.fixed.txt.gz</a>), and then we used liftover function from R package “rtracklayer” to convert the this hg37 genome coordinates file to hg38 coordinates:</p>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>absolute_maf <span class="ot"><-</span> data.table<span class="sc">::</span><span class="fu">fread</span>(<span class="st">"~/useful_data/TCGA_consolidated.abs_mafs_truncated.fixed.txt"</span>)</span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>absolute_maf <span class="ot"><-</span> absolute_maf <span class="sc">%>%</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">select</span>(Hugo_Symbol,Chromosome,Start_position,End_position,ccf_hat,sample,</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> Protein_Change,Variant_Classification,Variant_Type,Reference_Allele,</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> Tumor_Seq_Allele2,ref,alt,purity)</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(GenomicRanges)</span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a>absolute_maf<span class="sc">$</span>Chromosome <span class="ot"><-</span> <span class="fu">paste0</span>(<span class="st">"chr"</span>,absolute_maf<span class="sc">$</span>Chromosome)</span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a>absolute_granges <span class="ot"><-</span> <span class="fu">makeGRangesFromDataFrame</span>(absolute_maf,</span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a> <span class="at">keep.extra.columns=</span><span class="cn">TRUE</span>,</span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a> <span class="at">ignore.strand=</span><span class="cn">TRUE</span>,</span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a> <span class="at">seqinfo=</span><span class="cn">NULL</span>,</span>
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a> <span class="at">seqnames.field=</span><span class="st">"Chromosome"</span>,</span>
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a> <span class="at">start.field=</span><span class="st">"Start_position"</span>,</span>
<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a> <span class="at">end.field=</span><span class="st">"End_position"</span>,</span>
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a> <span class="at">starts.in.df.are.0based=</span><span class="cn">FALSE</span>)</span>
<span id="cb4-19"><a href="#cb4-19" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(rtracklayer)</span>
<span id="cb4-20"><a href="#cb4-20" aria-hidden="true" tabindex="-1"></a>chainObject <span class="ot"><-</span> <span class="fu">import.chain</span>(<span class="st">"~/useful_data/hg19ToHg38.over.chain"</span>)</span>
<span id="cb4-21"><a href="#cb4-21" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-22"><a href="#cb4-22" aria-hidden="true" tabindex="-1"></a>results <span class="ot"><-</span> <span class="fu">as.data.frame</span>(<span class="fu">liftOver</span>(absolute_granges, chainObject))</span>
<span id="cb4-23"><a href="#cb4-23" aria-hidden="true" tabindex="-1"></a>results <span class="ot"><-</span> results <span class="sc">%>%</span></span>
<span id="cb4-24"><a href="#cb4-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(width<span class="sc">==</span><span class="dv">1</span>)</span>
<span id="cb4-25"><a href="#cb4-25" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-26"><a href="#cb4-26" aria-hidden="true" tabindex="-1"></a>results <span class="ot"><-</span> results <span class="sc">%>%</span></span>
<span id="cb4-27"><a href="#cb4-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(Variant_Classification<span class="sc">==</span><span class="st">"Missense_Mutation"</span>) <span class="sc">%>%</span></span>
<span id="cb4-28"><a href="#cb4-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">index=</span><span class="fu">paste</span>(<span class="fu">substr</span>(sample,<span class="dv">1</span>,<span class="dv">16</span>),seqnames,start,Reference_Allele,Tumor_Seq_Allele2,<span class="at">sep =</span> <span class="st">":"</span>)) <span class="sc">%>%</span></span>
<span id="cb4-29"><a href="#cb4-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,index,Hugo_Symbol,Protein_Change,Reference_Allele,Tumor_Seq_Allele2,purity,ccf_hat)</span>
<span id="cb4-30"><a href="#cb4-30" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(results,<span class="at">file =</span> <span class="st">"../data/all_mut_mis_ccf.rds"</span>)</span></code></pre></div>
<p>Driver mutation data was downloaded from Bailey M H et.al study (<a href="https://gdc.cancer.gov/about-data/publications/pancan-driver">Mutation.CTAT.3D.Scores.txt</a>). This study used three different categories of tools to find driver mutations:</p>
<ol style="list-style-type: decimal">
<li>tools distinguishing benign versus pathogenic mutations using sequence (CTAT population);</li>
<li>tools distinguishing driver versus passenger mutations using sequence (CTAT cancer);</li>
<li>tools discovering statistically significant three-dimensional clusters of missense mutations (structure based).</li>
</ol>
<p>We keep mutations identified by ≥2 approaches as finial high confident driver mutations, including 3437 unique mutations:</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>driver <span class="ot"><-</span> data.table<span class="sc">::</span><span class="fu">fread</span>(<span class="st">"~/data/Mutation.CTAT.3D.Scores.txt"</span>)</span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a>driver_mutations <span class="ot"><-</span> driver <span class="sc">%>%</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">nmethod=</span><span class="st">`</span><span class="at">New_Linear (functional) flag</span><span class="st">`</span><span class="sc">+</span><span class="st">`</span><span class="at">New_Linear (cancer-focused) flag</span><span class="st">`</span><span class="sc">+</span><span class="st">`</span><span class="at">New_3D mutational hotspot flag</span><span class="st">`</span>) <span class="sc">%>%</span> </span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(nmethod<span class="sc">>=</span><span class="dv">2</span>)</span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(driver_mutations,<span class="at">file =</span> <span class="st">"../data/driver_mutations.rds"</span>)</span></code></pre></div>
</div>
<div id="expression-data" class="section level3">
<h3>Expression data</h3>
<p>The normalized gene-level RNA-seq data (TPM, transcripts per million) for 31 TCGA cohorts were downloaded from Xena (<a href="https://xenabrowser.net/datapages/?dataset=tcga_RSEM_gene_tpm&host=https%3A%2F%2Ftoil.xenahubs.net&removeHub=https%3A%2F%2Fxena.treehouse.gi.ucsc.edu%3A443">tcga_RSEM_gene_tpm</a>) and transformed from log-form to non-log form (This file is too large to store in Github):</p>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>TPM_log2 <span class="ot"><-</span> data.table<span class="sc">::</span><span class="fu">fread</span>(<span class="st">"~/useful_data/xena_RSEM_TPM/tcga_RSEM_gene_tpm.gz"</span>)</span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>mapping <span class="ot"><-</span> data.table<span class="sc">::</span><span class="fu">fread</span>(<span class="st">"~/useful_data/xena_RSEM_TPM/mapping_probe"</span>)</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a>mapping <span class="ot"><-</span> mapping[,<span class="dv">1</span><span class="sc">:</span><span class="dv">2</span>]</span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>TPM_log2_mapping <span class="ot"><-</span> <span class="fu">left_join</span>(TPM_log2 <span class="sc">%>%</span> <span class="fu">rename</span>(<span class="at">id=</span>sample),mapping) <span class="sc">%>%</span></span>
<span id="cb6-5"><a href="#cb6-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(id,gene,<span class="fu">everything</span>())<span class="do">###log2(tpm+0.001)</span></span>
<span id="cb6-6"><a href="#cb6-6" aria-hidden="true" tabindex="-1"></a>TPM_log2_mapping <span class="ot"><-</span> <span class="fu">as.data.frame</span>(TPM_log2_mapping)</span>
<span id="cb6-7"><a href="#cb6-7" aria-hidden="true" tabindex="-1"></a>tpm_trans <span class="ot"><-</span> TPM_log2_mapping</span>
<span id="cb6-8"><a href="#cb6-8" aria-hidden="true" tabindex="-1"></a>tpm_trans[,<span class="dv">3</span><span class="sc">:</span><span class="fu">ncol</span>(tpm_trans)] <span class="ot"><-</span> <span class="fu">apply</span>(TPM_log2_mapping[,<span class="dv">3</span><span class="sc">:</span><span class="fu">ncol</span>(TPM_log2_mapping)],<span class="dv">2</span>,</span>
<span id="cb6-9"><a href="#cb6-9" aria-hidden="true" tabindex="-1"></a> <span class="cf">function</span>(x){(<span class="dv">2</span><span class="sc">^</span>x) <span class="sc">-</span> <span class="fl">0.001</span>})</span>
<span id="cb6-10"><a href="#cb6-10" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(tpm_trans,<span class="at">file =</span> <span class="st">"~/useful_data/xena_RSEM_TPM/tpm_trans.rds"</span>)</span></code></pre></div>
</div>
<div id="hla-typing-and-immune-cell-infiltration-data" class="section level3">
<h3>HLA typing and immune cell infiltration data</h3>
<p>HLA typing data was downloaded from Thorsson et.al study and transformed to the format required by the neoantigen prediction tools:</p>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>hla <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="st">"~/useful_data/panCancer_hla.tsv"</span>,<span class="at">sep =</span> <span class="st">"</span><span class="sc">\t</span><span class="st">"</span>)</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>hla <span class="ot"><-</span> hla <span class="sc">%>%</span></span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">separate</span>(<span class="at">col =</span> V2,<span class="at">into =</span> <span class="fu">c</span>(<span class="st">"HLA-A_1"</span>,<span class="st">"HLA-A_2"</span>,</span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a> <span class="st">"HLA-B_1"</span>,<span class="st">"HLA-B_2"</span>,</span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="st">"HLA-C_1"</span>,<span class="st">"HLA-C_2"</span>),<span class="at">sep =</span> <span class="st">","</span>)</span>
<span id="cb7-6"><a href="#cb7-6" aria-hidden="true" tabindex="-1"></a><span class="do">###no stars</span></span>
<span id="cb7-7"><a href="#cb7-7" aria-hidden="true" tabindex="-1"></a>hla <span class="ot"><-</span> <span class="fu">t</span>(base<span class="sc">::</span><span class="fu">apply</span>(hla,<span class="dv">1</span>,<span class="cf">function</span>(x){</span>
<span id="cb7-8"><a href="#cb7-8" aria-hidden="true" tabindex="-1"></a> x[<span class="fu">which</span>(<span class="fu">duplicated</span>(x))] <span class="ot"><-</span> <span class="cn">NA</span></span>
<span id="cb7-9"><a href="#cb7-9" aria-hidden="true" tabindex="-1"></a> x <span class="ot"><-</span> <span class="fu">gsub</span>(<span class="st">"</span><span class="sc">\\</span><span class="st">*"</span>,<span class="st">""</span>,x)</span>
<span id="cb7-10"><a href="#cb7-10" aria-hidden="true" tabindex="-1"></a> x</span>
<span id="cb7-11"><a href="#cb7-11" aria-hidden="true" tabindex="-1"></a>})) <span class="sc">%>%</span> <span class="fu">as.data.frame</span>()</span>
<span id="cb7-12"><a href="#cb7-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-13"><a href="#cb7-13" aria-hidden="true" tabindex="-1"></a><span class="fu">colnames</span>(hla)[<span class="dv">1</span>] <span class="ot"><-</span> <span class="st">"Patient"</span></span>
<span id="cb7-14"><a href="#cb7-14" aria-hidden="true" tabindex="-1"></a><span class="fu">write.table</span>(hla,<span class="at">file =</span> <span class="st">"~/useful_data/TCGA_HLA_typing.txt"</span>,<span class="at">sep =</span> <span class="st">"</span><span class="sc">\t</span><span class="st">"</span>,<span class="at">quote =</span> F,<span class="at">col.names =</span> T,<span class="at">row.names =</span> F)</span></code></pre></div>
<p>Immune cell infiltration data for all TCGA tumors was downloaded from ImmuneCellAI study (Miao et al., 2020), which estimates the abundance of 24 immune cells comprised of 18 T-cell subtypes and 6 other immune cells. We can only download indivial cancer type data from the web server, so we need combine them all:</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>files <span class="ot"><-</span> <span class="fu">list.files</span>(<span class="st">"~/test/immune_score/immuneCellAI/"</span>)</span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a>re <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="fu">length</span>(files))</span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span>(i <span class="cf">in</span> <span class="fu">seq_along</span>(re)){</span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> dt <span class="ot"><-</span> data.table<span class="sc">::</span><span class="fu">fread</span>(<span class="fu">paste0</span>(<span class="st">"~/test/immune_score/immuneCellAI/"</span>,files[i]),<span class="at">data.table =</span> F) <span class="sc">%>%</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">rename</span>(<span class="at">sample=</span>V1) <span class="sc">%>%</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">sample=</span><span class="fu">substr</span>(sample,<span class="dv">1</span>,<span class="dv">16</span>)) <span class="sc">%>%</span></span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">sample=</span><span class="fu">gsub</span>(<span class="st">"</span><span class="sc">\\</span><span class="st">."</span>,<span class="st">"-"</span>,sample))</span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> re[[i]] <span class="ot"><-</span> dt</span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a>results <span class="ot"><-</span> <span class="fu">bind_rows</span>(re)</span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(results,<span class="at">file =</span> <span class="st">"../data/pancancer_subtcells.rds"</span>)</span></code></pre></div>
<p>We can view this file:</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>pancancer_immune <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/pancancer_subtcells.rds"</span>)</span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a>DT<span class="sc">::</span><span class="fu">datatable</span>(<span class="fu">head</span>(pancancer_immune),</span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="at">options =</span> <span class="fu">list</span>(<span class="at">scrollX =</span> <span class="cn">TRUE</span>, <span class="at">keys =</span> <span class="cn">TRUE</span>), <span class="at">rownames =</span> <span class="cn">FALSE</span></span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a>)</span></code></pre></div>
<div id="htmlwidget-3a1eac91ebb9e3ebf93f" style="width:100%;height:auto;" class="datatables html-widget"></div>
<script type="application/json" data-for="htmlwidget-3a1eac91ebb9e3ebf93f">{"x":{"filter":"none","vertical":false,"data":[["TCGA-OR-A5J1-01A","TCGA-OR-A5J2-01A","TCGA-OR-A5J3-01A","TCGA-OR-A5J5-01A","TCGA-OR-A5J6-01A","TCGA-OR-A5J7-01A"],[0,0,0.089,0.014,0,0.042],[0.115,0.114,0.087,0.218,0,0.069],[0.436,0.427,0.192,0.406,0.537,0.218],[0.035,0.08,0,0.003,0.105,0.02],[0.04,0.104,0.033,0.079,0.123,0.174],[0.048,0.025,0,0,0.11,0.013],[0.065,0.245,0,0,0.156,0.003],[0.158,0.152,0.069,0.004,0.148,0.025],[0.334,0.219,0,0.082,0.325,0],[0.057,0.044,0.253,0.114,0.203,0.112],[0.075,0.115,0,0.055,0.03,0.043],[0,0.087,0.061,0,0,0.041],[0.027,0.012,0,0,0.031,0],[0,0.143,0.07,0.105,0,0.043],[0.278,0.163,0.045,0.173,0.17,0.051],[0.15,0.207,0.149,0.088,0.224,0.13],[0.026,0.068,0.067,0.114,0.038,0.14],[0.104,0.095,0.076,0.148,0.172,0.086],[0.182,0.102,0.085,0.085,0.275,0.112],[0.162,0.003,0.146,0.254,0.377,0.179],[0.115,0.106,0.162,0.122,0.115,0.157],[0.089,0.07,0.13,0.151,0.09,0.06],[0.102,0.084,0.123,0.087,0.058,0.094],[0.201,0.211,0.046,0.156,0.206,0.048],[0.606,0.508,0.496,0.613,0.851,0.549]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th>sample<\/th>\n <th>CD4_naive<\/th>\n <th>CD8_naive<\/th>\n <th>Tc<\/th>\n <th>Tex<\/th>\n <th>Tr1<\/th>\n <th>nTreg<\/th>\n <th>iTreg<\/th>\n <th>Th1<\/th>\n <th>Th2<\/th>\n <th>Th17<\/th>\n <th>Tfh<\/th>\n <th>Tcm<\/th>\n <th>Tem<\/th>\n <th>NKT<\/th>\n <th>MAIT<\/th>\n <th>DC<\/th>\n <th>B_cell<\/th>\n <th>Monocyte<\/th>\n <th>Macrophage<\/th>\n <th>NK<\/th>\n <th>Neutrophil<\/th>\n <th>Tgd<\/th>\n <th>CD4_T<\/th>\n <th>CD8_T<\/th>\n <th>InfiltrationScore<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"scrollX":true,"keys":true,"columnDefs":[{"className":"dt-right","targets":[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]}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
<p>Other Immune cell infiltration data including CIBERSORT (abs mode), Quantiseq were downloaded from the <a href="http://timer.comp-genomics.org/">TIMER2.0</a> study.</p>
</div>
</div>
<div id="tcga-pancancer-data-processing" class="section level2">
<h2>TCGA pancancer data processing</h2>
<p>This part describes HLA typing and neoantigen prediction of TCGA data.</p>
<div id="hla-typing" class="section level3">
<h3>HLA typing</h3>
<p>For samples which don’t have corresponding HLA infromation data in Thorsson et.al study, HLA genotyping was performed with Optitype (Szolek et al., 2014), using default parameters. This corresponding code can be found in <code>code/python/HLA_typing</code> (using snakemake pipeline tools).</p>
</div>
<div id="neoantigen-prediction" class="section level3">
<h3>Neoantigen prediction</h3>
<p>Mutect2 mutation files were first transformed into VCF format by maf2vcf tools, and we used NeoPredPipe to predict neoantigen (Schenck et al., 2019). Single-nucleotide variants leading to a single amino acid change are the focus of this study. From the output results, if the IC50 of a novel peptide is less than 50, the bind level is SB (strong binder, rank is less than 0.5%), and the expression level (TPM) is greater than 1, then this peptide is labeled as neoantigen. A mutation is considered neoantigenic if there is at least one peptide derived from the mutated site is predicted as neoantigen. The neoantigen prediction code using NeoPrePipe can be found in <code>code/shell/TCGA_neoantigen</code>. Then we add CCF and mRNA expression information to neoantigen prediction data:</p>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(dplyr)</span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="fu">setwd</span>(<span class="st">"/public/slst/home/wutao2/TCGA_neopredpipe/batch_results"</span>)</span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a>files <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="st">"files"</span>)</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">100</span>){</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> data.table<span class="sc">::</span><span class="fu">fread</span>(<span class="fu">paste</span>(files<span class="sc">$</span>V1[i],<span class="st">"/batch_"</span>,files<span class="sc">$</span>V1[i],<span class="st">".neoantigens.unfiltered.txt"</span>,<span class="at">sep =</span> <span class="st">""</span>),<span class="at">fill=</span><span class="cn">TRUE</span>)</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> mut <span class="sc">%>%</span></span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(<span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">4</span><span class="sc">:</span><span class="dv">11</span>,<span class="dv">21</span><span class="sc">:</span><span class="dv">28</span>))</span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">colnames</span>(mut) <span class="ot"><-</span> <span class="fu">c</span>(<span class="st">"sample"</span>,<span class="st">"chr"</span>,<span class="st">"position"</span>,</span>
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a> <span class="st">"ref"</span>,<span class="st">"alt"</span>,<span class="st">"gene"</span>,<span class="st">"exp"</span>,<span class="st">"res_pos"</span>,</span>
<span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a> <span class="st">"hla"</span>,<span class="st">"score_el"</span>,<span class="st">"rank_el"</span>,<span class="st">"score_ba"</span>,</span>
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a> <span class="st">"rank_ba"</span>,<span class="st">"IC50"</span>,<span class="st">"candidate"</span>,<span class="st">"bindlevel"</span>,</span>
<span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a> <span class="st">"novelty"</span>)</span>
<span id="cb10-14"><a href="#cb10-14" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> mut <span class="sc">%>%</span></span>
<span id="cb10-15"><a href="#cb10-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">novelty=</span><span class="fu">ifelse</span>(<span class="fu">is.na</span>(novelty),<span class="dv">0</span>,novelty)) <span class="sc">%>%</span></span>
<span id="cb10-16"><a href="#cb10-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">index=</span><span class="fu">paste</span>(sample,chr,position,ref,alt,<span class="at">sep =</span> <span class="st">":"</span>))</span>
<span id="cb10-17"><a href="#cb10-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">saveRDS</span>(mut,<span class="at">file =</span> <span class="fu">paste</span>(files<span class="sc">$</span>V1[i],<span class="st">".rds"</span>,<span class="at">sep =</span> <span class="st">""</span>))</span>
<span id="cb10-18"><a href="#cb10-18" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb10-19"><a href="#cb10-19" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-20"><a href="#cb10-20" aria-hidden="true" tabindex="-1"></a>files <span class="ot"><-</span> <span class="fu">list.files</span>(<span class="st">"~/test/data/2021_03_31/"</span>)</span>
<span id="cb10-21"><a href="#cb10-21" aria-hidden="true" tabindex="-1"></a>re <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="dv">100</span>)</span>
<span id="cb10-22"><a href="#cb10-22" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-23"><a href="#cb10-23" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">100</span>){</span>
<span id="cb10-24"><a href="#cb10-24" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="fu">paste</span>(<span class="st">"~/test/data/2021_03_31/"</span>,files[i],<span class="at">sep =</span> <span class="st">""</span>))</span>
<span id="cb10-25"><a href="#cb10-25" aria-hidden="true" tabindex="-1"></a> neo <span class="ot"><-</span> mut <span class="sc">%>%</span></span>
<span id="cb10-26"><a href="#cb10-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(novelty <span class="sc">==</span> <span class="dv">1</span>) <span class="sc">%>%</span></span>
<span id="cb10-27"><a href="#cb10-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(IC50<span class="sc"><</span><span class="dv">50</span> <span class="sc">&</span> bindlevel<span class="sc">==</span><span class="st">"SB"</span> <span class="sc">&</span> novelty<span class="sc">==</span><span class="dv">1</span> ) <span class="sc">%>%</span></span>
<span id="cb10-28"><a href="#cb10-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">distinct</span>(index,<span class="at">.keep_all =</span> T)</span>
<span id="cb10-29"><a href="#cb10-29" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-30"><a href="#cb10-30" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> mut <span class="sc">%>%</span></span>
<span id="cb10-31"><a href="#cb10-31" aria-hidden="true" tabindex="-1"></a> <span class="fu">distinct</span>(index,<span class="at">.keep_all =</span> T) <span class="sc">%>%</span></span>
<span id="cb10-32"><a href="#cb10-32" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">neo =</span> <span class="fu">ifelse</span>(index <span class="sc">%in%</span> neo<span class="sc">$</span>index , <span class="st">"neo"</span>,<span class="st">"not_neo"</span>))</span>
<span id="cb10-33"><a href="#cb10-33" aria-hidden="true" tabindex="-1"></a> re[[i]] <span class="ot"><-</span> mut</span>
<span id="cb10-34"><a href="#cb10-34" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb10-35"><a href="#cb10-35" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-36"><a href="#cb10-36" aria-hidden="true" tabindex="-1"></a>all_mut <span class="ot"><-</span> <span class="fu">bind_rows</span>(re)</span>
<span id="cb10-37"><a href="#cb10-37" aria-hidden="true" tabindex="-1"></a>all_mut <span class="ot"><-</span> all_mut <span class="sc">%>%</span></span>
<span id="cb10-38"><a href="#cb10-38" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,chr,position,ref,alt,neo,gene,exp)</span>
<span id="cb10-39"><a href="#cb10-39" aria-hidden="true" tabindex="-1"></a>all_mut <span class="ot"><-</span> all_mut <span class="sc">%>%</span></span>
<span id="cb10-40"><a href="#cb10-40" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">gene=</span><span class="fu">gsub</span>(<span class="st">"</span><span class="sc">\\</span><span class="st">:.+"</span>,<span class="st">""</span>,gene))</span>
<span id="cb10-41"><a href="#cb10-41" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(all_mut,<span class="at">file =</span> <span class="st">"~/test/data/2021_04_17/all_mut.rds"</span>)</span>
<span id="cb10-42"><a href="#cb10-42" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-43"><a href="#cb10-43" aria-hidden="true" tabindex="-1"></a>tpm <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"~/useful_data/xena_RSEM_TPM/tpm_trans.rds"</span>)</span>
<span id="cb10-44"><a href="#cb10-44" aria-hidden="true" tabindex="-1"></a>tpm <span class="ot"><-</span> tpm[<span class="sc">!</span><span class="fu">duplicated</span>(tpm<span class="sc">$</span>gene),]</span>
<span id="cb10-45"><a href="#cb10-45" aria-hidden="true" tabindex="-1"></a>all_mut<span class="sc">$</span>tpm_exp <span class="ot"><-</span> <span class="fu">mapply</span>(<span class="cf">function</span>(sample,gene){</span>
<span id="cb10-46"><a href="#cb10-46" aria-hidden="true" tabindex="-1"></a> tpm[tpm<span class="sc">$</span>gene<span class="sc">==</span>gene,<span class="fu">substr</span>(sample,<span class="dv">1</span>,<span class="dv">15</span>)]</span>
<span id="cb10-47"><a href="#cb10-47" aria-hidden="true" tabindex="-1"></a>},all_mut<span class="sc">$</span>sample,all_mut<span class="sc">$</span>gene)</span>
<span id="cb10-48"><a href="#cb10-48" aria-hidden="true" tabindex="-1"></a>all_mut1 <span class="ot"><-</span> all_mut <span class="sc">%>%</span></span>
<span id="cb10-49"><a href="#cb10-49" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="fu">lengths</span>(tpm_exp)<span class="sc">!=</span><span class="dv">0</span>)</span>
<span id="cb10-50"><a href="#cb10-50" aria-hidden="true" tabindex="-1"></a>all_mut1<span class="sc">$</span>tpm_exp <span class="ot"><-</span> <span class="fu">as.numeric</span>(all_mut1<span class="sc">$</span>tpm_exp)</span>
<span id="cb10-51"><a href="#cb10-51" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(all_mut1,<span class="at">file =</span> <span class="st">"../data/all_mut_tpm_not_filter.rds"</span>)<span class="do">##this file is used to calculte EXP-ES</span></span>
<span id="cb10-52"><a href="#cb10-52" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-53"><a href="#cb10-53" aria-hidden="true" tabindex="-1"></a>all_mut1 <span class="ot"><-</span> all_mut1 <span class="sc">%>%</span></span>
<span id="cb10-54"><a href="#cb10-54" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">neo2=</span><span class="fu">ifelse</span>(neo<span class="sc">==</span><span class="st">"neo"</span> <span class="sc">&</span> tpm_exp<span class="sc">></span><span class="dv">1</span>,<span class="st">"neo"</span>,<span class="st">"not_neo"</span>))</span>
<span id="cb10-55"><a href="#cb10-55" aria-hidden="true" tabindex="-1"></a>all_mut1 <span class="ot"><-</span> all_mut1 <span class="sc">%>%</span></span>
<span id="cb10-56"><a href="#cb10-56" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(<span class="sc">-</span>neo,<span class="sc">-</span>exp) <span class="sc">%>%</span></span>
<span id="cb10-57"><a href="#cb10-57" aria-hidden="true" tabindex="-1"></a> <span class="fu">rename</span>(<span class="at">neo=</span>neo2)</span>
<span id="cb10-58"><a href="#cb10-58" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(all_mut1,<span class="at">file =</span> <span class="st">"~/test/all_mut_tpm.rds"</span>)</span>
<span id="cb10-59"><a href="#cb10-59" aria-hidden="true" tabindex="-1"></a><span class="do">##add ccf</span></span>
<span id="cb10-60"><a href="#cb10-60" aria-hidden="true" tabindex="-1"></a>results <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"~/test/data/2021_04_05/all_mut_mis_ccf.rds"</span>)</span>
<span id="cb10-61"><a href="#cb10-61" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-62"><a href="#cb10-62" aria-hidden="true" tabindex="-1"></a>all_mut_tpm <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"~/test/all_mut_tpm.rds"</span>)</span>
<span id="cb10-63"><a href="#cb10-63" aria-hidden="true" tabindex="-1"></a><span class="co">#all_mut_tpm <- readRDS("~/test/all_mut_tpm_not_filter.rds")</span></span>
<span id="cb10-64"><a href="#cb10-64" aria-hidden="true" tabindex="-1"></a>all_mut <span class="ot"><-</span> all_mut_tpm <span class="sc">%>%</span></span>
<span id="cb10-65"><a href="#cb10-65" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">index=</span><span class="fu">paste</span>(sample,chr,position,ref,alt,<span class="at">sep =</span> <span class="st">":"</span>)) <span class="sc">%>%</span></span>
<span id="cb10-66"><a href="#cb10-66" aria-hidden="true" tabindex="-1"></a> dplyr<span class="sc">::</span><span class="fu">rename</span>(<span class="at">ref_allele=</span>ref,<span class="at">alt_allele=</span>alt)</span>
<span id="cb10-67"><a href="#cb10-67" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-68"><a href="#cb10-68" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> <span class="fu">inner_join</span>(</span>
<span id="cb10-69"><a href="#cb10-69" aria-hidden="true" tabindex="-1"></a> all_mut,</span>
<span id="cb10-70"><a href="#cb10-70" aria-hidden="true" tabindex="-1"></a> results <span class="sc">%>%</span> <span class="fu">select</span>(<span class="sc">-</span>sample),</span>
<span id="cb10-71"><a href="#cb10-71" aria-hidden="true" tabindex="-1"></a> <span class="at">by=</span><span class="st">"index"</span></span>
<span id="cb10-72"><a href="#cb10-72" aria-hidden="true" tabindex="-1"></a>)</span>
<span id="cb10-73"><a href="#cb10-73" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> all_mut_ccf[<span class="sc">!</span><span class="fu">duplicated</span>(all_mut_ccf<span class="sc">$</span>index),]</span>
<span id="cb10-74"><a href="#cb10-74" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(all_mut_ccf,<span class="at">file =</span> <span class="st">"../data/all_mut_ccf_tpm.rds"</span>)<span class="do">##This file is used to calculate CCF-ES</span></span></code></pre></div>
</div>
</div>
<div id="immunotherapy-data-download-and-clean" class="section level2">
<h2>Immunotherapy data download and clean</h2>
<p>We collected three cohorts of immunotherapy datasets for our analysis. <code>The Hugo et al. (2016) dataset</code> was related to anti-PD-1 therapy in metastatic melanoma. This dataset has 37 samples with WES data, 26 were also analyzed by RNA sequencing (RNA-seq). <code>The Riaz et al. (2017) dataset</code> was related to anti-PD-1 therapy in metastatic melanoma. This dataset has 56 samples with WES data, 40 with RNA-seq. <code>The David Liu et.al (2019) cohort</code> has patients with melanoma treated with anti-PD1 ICB, which 119 samples has WES data, 112 with RNA-seq.</p>
<p>Immune therapy response for patients was defined by RECIST v1.1(CR/PR/SD/PD), responding tumors were derived from patients who have complete or partial responses (CR/PR) in response to anti-PD-1 therapy; non-responding tumors were derived from patients who had progressive disease or stable disease (PD/SD).</p>
<p>The details of mutation calling, producing copy number segment file (using GATK4) and RNA_seq process can be found in Methods. Code can be found in <code>code/shell/ICI</code>. The HLA typing and neoantigen prediction was the same as the process in TCGA data as previously described. The code for caculating CCF by ABSOLUTE can be found in <code>code/R/ICI_ABSOLUTE.R</code></p>
<p>After got neoantiogen prediction and ABSOLUTE CCF information, we can combine these data for downstream analysis:</p>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="do">####combine neoantigen prediction data</span></span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(dplyr)</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(readr)</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a>files <span class="ot"><-</span> <span class="fu">list.files</span>(<span class="st">"immunetherapy/"</span>)</span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a>files <span class="ot"><-</span> files[<span class="fu">grepl</span>(<span class="st">"neoantigens.unfiltered.txt"</span>,files)]</span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a>re <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="dv">25</span>)</span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">25</span>){</span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> <span class="fu">read_table2</span>(<span class="fu">paste</span>(<span class="st">"immunetherapy/"</span>,files[i],<span class="at">sep =</span> <span class="st">""</span>),<span class="at">col_names =</span> <span class="fu">paste0</span>(<span class="fu">rep</span>(<span class="st">"V"</span>,<span class="dv">27</span>),<span class="fu">c</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">27</span>)))</span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> mut <span class="sc">%>%</span></span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(<span class="fu">c</span>(<span class="dv">1</span>,<span class="dv">3</span><span class="sc">:</span><span class="dv">10</span>,<span class="dv">20</span><span class="sc">:</span><span class="dv">27</span>))</span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">colnames</span>(mut) <span class="ot"><-</span> <span class="fu">c</span>(<span class="st">"sample"</span>,<span class="st">"chr"</span>,<span class="st">"position"</span>,</span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a> <span class="st">"ref"</span>,<span class="st">"alt"</span>,<span class="st">"gene"</span>,<span class="st">"exp"</span>,<span class="st">"res_pos"</span>,</span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a> <span class="st">"hla"</span>,<span class="st">"score_el"</span>,<span class="st">"rank_el"</span>,<span class="st">"score_ba"</span>,</span>
<span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a> <span class="st">"rank_ba"</span>,<span class="st">"IC50"</span>,<span class="st">"candidate"</span>,<span class="st">"bindlevel"</span>,</span>
<span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a> <span class="st">"novelty"</span>)</span>
<span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> mut <span class="sc">%>%</span></span>
<span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">novelty=</span><span class="fu">ifelse</span>(<span class="fu">is.na</span>(novelty),<span class="dv">0</span>,novelty)) <span class="sc">%>%</span></span>
<span id="cb11-19"><a href="#cb11-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">index=</span><span class="fu">paste</span>(sample,chr,position,ref,alt,<span class="at">sep =</span> <span class="st">":"</span>))</span>
<span id="cb11-20"><a href="#cb11-20" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb11-21"><a href="#cb11-21" aria-hidden="true" tabindex="-1"></a> neo <span class="ot"><-</span> mut <span class="sc">%>%</span></span>
<span id="cb11-22"><a href="#cb11-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(IC50<span class="sc"><</span><span class="dv">50</span> <span class="sc">&</span> bindlevel<span class="sc">==</span><span class="st">"SB"</span> <span class="sc">&</span> novelty<span class="sc">==</span><span class="dv">1</span> <span class="sc">&</span> exp<span class="sc">></span><span class="dv">1</span>) <span class="sc">%>%</span></span>
<span id="cb11-23"><a href="#cb11-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">distinct</span>(index,<span class="at">.keep_all =</span> T)</span>
<span id="cb11-24"><a href="#cb11-24" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb11-25"><a href="#cb11-25" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> mut <span class="sc">%>%</span></span>
<span id="cb11-26"><a href="#cb11-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">distinct</span>(index,<span class="at">.keep_all =</span> T) <span class="sc">%>%</span></span>
<span id="cb11-27"><a href="#cb11-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">neo =</span> <span class="fu">ifelse</span>(index <span class="sc">%in%</span> neo<span class="sc">$</span>index , <span class="st">"neo"</span>,<span class="st">"not_neo"</span>))</span>
<span id="cb11-28"><a href="#cb11-28" aria-hidden="true" tabindex="-1"></a> mut <span class="ot"><-</span> mut <span class="sc">%>%</span> </span>
<span id="cb11-29"><a href="#cb11-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,chr,position,gene,exp,neo) <span class="sc">%>%</span> </span>
<span id="cb11-30"><a href="#cb11-30" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">gene=</span><span class="fu">gsub</span>(<span class="st">"</span><span class="sc">\\</span><span class="st">:.+"</span>,<span class="st">""</span>,gene))</span>
<span id="cb11-31"><a href="#cb11-31" aria-hidden="true" tabindex="-1"></a> mut<span class="sc">$</span>sample <span class="ot"><-</span> <span class="fu">paste</span>(<span class="fu">gsub</span>(<span class="st">"_.+"</span>,<span class="st">""</span>,files[i]),mut<span class="sc">$</span>sample,<span class="at">sep =</span> <span class="st">"_"</span>)</span>
<span id="cb11-32"><a href="#cb11-32" aria-hidden="true" tabindex="-1"></a> re[[i]] <span class="ot"><-</span> mut</span>
<span id="cb11-33"><a href="#cb11-33" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb11-34"><a href="#cb11-34" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-35"><a href="#cb11-35" aria-hidden="true" tabindex="-1"></a>all_mut <span class="ot"><-</span> <span class="fu">bind_rows</span>(re)</span>
<span id="cb11-36"><a href="#cb11-36" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(all_mut,<span class="at">file =</span> <span class="st">"../data/Immunotherapy/all_mut_ici.rds"</span>)</span>
<span id="cb11-37"><a href="#cb11-37" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-38"><a href="#cb11-38" aria-hidden="true" tabindex="-1"></a><span class="do">###ccf in maf files of ABSOLUTE output</span></span>
<span id="cb11-39"><a href="#cb11-39" aria-hidden="true" tabindex="-1"></a><span class="do">##nadeem</span></span>
<span id="cb11-40"><a href="#cb11-40" aria-hidden="true" tabindex="-1"></a>sample_run <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="st">"immunetherapy/nadeem_absolute/Nad_sample_run"</span>,<span class="at">sep =</span> <span class="st">","</span>,<span class="at">stringsAsFactors =</span> F)</span>
<span id="cb11-41"><a href="#cb11-41" aria-hidden="true" tabindex="-1"></a>files <span class="ot"><-</span> <span class="fu">list.files</span>(<span class="st">"immunetherapy/nadeem_absolute/"</span>)[<span class="sc">-</span><span class="dv">1</span>]</span>
<span id="cb11-42"><a href="#cb11-42" aria-hidden="true" tabindex="-1"></a>re <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="dv">57</span>)</span>
<span id="cb11-43"><a href="#cb11-43" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-44"><a href="#cb11-44" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">57</span>){</span>
<span id="cb11-45"><a href="#cb11-45" aria-hidden="true" tabindex="-1"></a> test <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="fu">paste0</span>(<span class="st">"immunetherapy/nadeem_absolute/"</span>,files[i]),<span class="at">sep =</span> <span class="st">"</span><span class="sc">\t</span><span class="st">"</span>,<span class="at">header =</span> T) <span class="sc">%>%</span> </span>
<span id="cb11-46"><a href="#cb11-46" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,Hugo_Symbol,Chromosome,Start_position,cancer_cell_frac,purity)</span>
<span id="cb11-47"><a href="#cb11-47" aria-hidden="true" tabindex="-1"></a> test<span class="sc">$</span>sample <span class="ot"><-</span> <span class="fu">paste</span>(<span class="st">"nadeem"</span>,<span class="fu">as.character</span>(sample_run[<span class="fu">which</span>(sample_run<span class="sc">$</span>V2<span class="sc">==</span><span class="fu">unique</span>(test<span class="sc">$</span>sample)),<span class="st">"V1"</span>]),</span>
<span id="cb11-48"><a href="#cb11-48" aria-hidden="true" tabindex="-1"></a> <span class="at">sep =</span> <span class="st">"_"</span>)</span>
<span id="cb11-49"><a href="#cb11-49" aria-hidden="true" tabindex="-1"></a> re[[i]] <span class="ot"><-</span> test</span>
<span id="cb11-50"><a href="#cb11-50" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb11-51"><a href="#cb11-51" aria-hidden="true" tabindex="-1"></a>nadeem_ccf <span class="ot"><-</span> <span class="fu">bind_rows</span>(re)</span>
<span id="cb11-52"><a href="#cb11-52" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-53"><a href="#cb11-53" aria-hidden="true" tabindex="-1"></a><span class="do">##willy</span></span>
<span id="cb11-54"><a href="#cb11-54" aria-hidden="true" tabindex="-1"></a>sample_run <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="st">"immunetherapy/willy_absolute/clinical.txt"</span>,<span class="at">sep =</span> <span class="st">","</span>,<span class="at">stringsAsFactors =</span> F)</span>
<span id="cb11-55"><a href="#cb11-55" aria-hidden="true" tabindex="-1"></a>files <span class="ot"><-</span> <span class="fu">list.files</span>(<span class="st">"immunetherapy/willy_absolute/"</span>)[<span class="sc">-</span><span class="dv">1</span>]</span>
<span id="cb11-56"><a href="#cb11-56" aria-hidden="true" tabindex="-1"></a>re <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="dv">38</span>)</span>
<span id="cb11-57"><a href="#cb11-57" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-58"><a href="#cb11-58" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">38</span>){</span>
<span id="cb11-59"><a href="#cb11-59" aria-hidden="true" tabindex="-1"></a> test <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="fu">paste0</span>(<span class="st">"immunetherapy/willy_absolute/"</span>,files[i]),<span class="at">sep =</span> <span class="st">"</span><span class="sc">\t</span><span class="st">"</span>,<span class="at">header =</span> T) <span class="sc">%>%</span> </span>
<span id="cb11-60"><a href="#cb11-60" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,Hugo_Symbol,Chromosome,Start_position,cancer_cell_frac,purity)</span>
<span id="cb11-61"><a href="#cb11-61" aria-hidden="true" tabindex="-1"></a> test<span class="sc">$</span>sample <span class="ot"><-</span> <span class="fu">paste</span>(<span class="st">"willy"</span>,<span class="fu">as.character</span>(sample_run[<span class="fu">which</span>(sample_run<span class="sc">$</span>V2<span class="sc">==</span><span class="fu">unique</span>(test<span class="sc">$</span>sample)),<span class="st">"V1"</span>]),</span>
<span id="cb11-62"><a href="#cb11-62" aria-hidden="true" tabindex="-1"></a> <span class="at">sep =</span> <span class="st">"_"</span>)</span>
<span id="cb11-63"><a href="#cb11-63" aria-hidden="true" tabindex="-1"></a> re[[i]] <span class="ot"><-</span> test</span>
<span id="cb11-64"><a href="#cb11-64" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb11-65"><a href="#cb11-65" aria-hidden="true" tabindex="-1"></a>willy_ccf <span class="ot"><-</span> <span class="fu">bind_rows</span>(re)</span>
<span id="cb11-66"><a href="#cb11-66" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-67"><a href="#cb11-67" aria-hidden="true" tabindex="-1"></a><span class="do">###liu</span></span>
<span id="cb11-68"><a href="#cb11-68" aria-hidden="true" tabindex="-1"></a>sample_run <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="st">"immunetherapy/liu_absolute/liu_sample_run"</span>,<span class="at">sep =</span> <span class="st">","</span>,<span class="at">stringsAsFactors =</span> F)</span>
<span id="cb11-69"><a href="#cb11-69" aria-hidden="true" tabindex="-1"></a>files <span class="ot"><-</span> <span class="fu">list.files</span>(<span class="st">"immunetherapy/liu_absolute/"</span>)[<span class="sc">-</span><span class="dv">1</span>]</span>
<span id="cb11-70"><a href="#cb11-70" aria-hidden="true" tabindex="-1"></a>re <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="dv">121</span>)</span>
<span id="cb11-71"><a href="#cb11-71" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-72"><a href="#cb11-72" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">121</span>){</span>
<span id="cb11-73"><a href="#cb11-73" aria-hidden="true" tabindex="-1"></a> test <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="fu">paste0</span>(<span class="st">"immunetherapy/liu_absolute/"</span>,files[i]),<span class="at">sep =</span> <span class="st">"</span><span class="sc">\t</span><span class="st">"</span>,<span class="at">header =</span> T) <span class="sc">%>%</span> </span>
<span id="cb11-74"><a href="#cb11-74" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,Hugo_Symbol,Chromosome,Start_position,cancer_cell_frac,purity)</span>
<span id="cb11-75"><a href="#cb11-75" aria-hidden="true" tabindex="-1"></a> test<span class="sc">$</span>sample <span class="ot"><-</span> <span class="fu">paste</span>(<span class="st">"liu"</span>,<span class="fu">as.character</span>(sample_run[<span class="fu">which</span>(sample_run<span class="sc">$</span>V2<span class="sc">==</span><span class="fu">unique</span>(test<span class="sc">$</span>sample)),<span class="st">"V1"</span>]),</span>
<span id="cb11-76"><a href="#cb11-76" aria-hidden="true" tabindex="-1"></a> <span class="at">sep =</span> <span class="st">"_"</span>)</span>
<span id="cb11-77"><a href="#cb11-77" aria-hidden="true" tabindex="-1"></a> re[[i]] <span class="ot"><-</span> test</span>
<span id="cb11-78"><a href="#cb11-78" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb11-79"><a href="#cb11-79" aria-hidden="true" tabindex="-1"></a>liu_ccf <span class="ot"><-</span> <span class="fu">bind_rows</span>(re)</span>
<span id="cb11-80"><a href="#cb11-80" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-81"><a href="#cb11-81" aria-hidden="true" tabindex="-1"></a>all_ccf <span class="ot"><-</span> <span class="fu">bind_rows</span>(liu_ccf,nadeem_ccf,willy_ccf)</span>
<span id="cb11-82"><a href="#cb11-82" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(all_ccf,<span class="at">file =</span> <span class="st">"../data/Immunotherapy/all_ccf.rds"</span>)</span>
<span id="cb11-83"><a href="#cb11-83" aria-hidden="true" tabindex="-1"></a><span class="do">###merge ccf and neoantigen data</span></span>
<span id="cb11-84"><a href="#cb11-84" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> <span class="fu">left_join</span>(</span>
<span id="cb11-85"><a href="#cb11-85" aria-hidden="true" tabindex="-1"></a> all_mut_ici <span class="sc">%>%</span> </span>
<span id="cb11-86"><a href="#cb11-86" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">index=</span><span class="fu">paste</span>(sample,chr,position,<span class="at">sep =</span> <span class="st">":"</span>)),</span>
<span id="cb11-87"><a href="#cb11-87" aria-hidden="true" tabindex="-1"></a> all_ccf <span class="sc">%>%</span> </span>
<span id="cb11-88"><a href="#cb11-88" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">Chromosome=</span><span class="fu">paste0</span>(<span class="st">"chr"</span>,Chromosome)) <span class="sc">%>%</span> </span>
<span id="cb11-89"><a href="#cb11-89" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">index=</span><span class="fu">paste</span>(sample,Chromosome,Start_position,<span class="at">sep =</span> <span class="st">":"</span>)) <span class="sc">%>%</span> </span>
<span id="cb11-90"><a href="#cb11-90" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(index,cancer_cell_frac,purity),</span>
<span id="cb11-91"><a href="#cb11-91" aria-hidden="true" tabindex="-1"></a> <span class="at">by=</span><span class="st">"index"</span></span>
<span id="cb11-92"><a href="#cb11-92" aria-hidden="true" tabindex="-1"></a>)</span>
<span id="cb11-93"><a href="#cb11-93" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-94"><a href="#cb11-94" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(cancer_cell_frac))</span>
<span id="cb11-95"><a href="#cb11-95" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(all_mut_ccf,<span class="at">file =</span> <span class="st">"../data/Immunotherapy/all_mut_ccf_ici.rds"</span>)</span></code></pre></div>
</div>
</div>
<div id="tcga-pancancer-analysis" class="section level1">
<h1>TCGA pancancer analysis</h1>
<div id="the-existence-of-significant-immunoediting-signal" class="section level2">
<h2>The existence of significant immunoediting signal</h2>
<p>We investigate the status of this immunoediting signal with the new method developed in this study using TCGA pan-cancer dataset. The method detail showed in Method part of manuscript, and implemented in the package <code>NeoEnrichment</code> which can be found in <a href="https://github.com/wt12318/NeoEnrichment">Github</a></p>
<p>We filterd samples with at least 1 neoantigenic and 1 subclonal mutation (CCF<0.6) and calculated CCF-NES value:</p>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/all_mut_ccf_tpm.rds"</span>)</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span></span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">rename</span>(<span class="at">ccf=</span>ccf_hat) <span class="sc">%>%</span></span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">neo=</span><span class="fu">ifelse</span>(neo<span class="sc">==</span><span class="st">"neo"</span>,<span class="st">"yes"</span>,<span class="st">"no"</span>))</span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>samples_has_subclonal <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span> </span>
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(ccf<span class="sc"><</span><span class="fl">0.6</span>) <span class="sc">%>%</span> </span>
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample) <span class="sc">%>%</span></span>
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">distinct</span>(sample)</span>
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="sc">%>%</span> </span>
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(sample <span class="sc">%in%</span> samples_has_subclonal<span class="sc">$</span>sample) <span class="sc">%>%</span></span>
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(sample) <span class="sc">%>%</span></span>
<span id="cb12-12"><a href="#cb12-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">c_n=</span><span class="fu">sum</span>(neo<span class="sc">==</span><span class="st">"yes"</span>),<span class="at">c_m=</span><span class="fu">sum</span>(neo<span class="sc">==</span><span class="st">"no"</span>)) <span class="sc">%>%</span> <span class="fu">filter</span>(c_n<span class="sc">>=</span><span class="dv">1</span> <span class="sc">&</span> c_m <span class="sc">>=</span><span class="dv">1</span>) <span class="ot">-></span> summ</span>
<span id="cb12-13"><a href="#cb12-13" aria-hidden="true" tabindex="-1"></a>neo_missense <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span> </span>
<span id="cb12-14"><a href="#cb12-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(sample <span class="sc">%in%</span> summ<span class="sc">$</span>sample)</span>
<span id="cb12-15"><a href="#cb12-15" aria-hidden="true" tabindex="-1"></a>cal_nes_warp <span class="ot"><-</span> <span class="cf">function</span>(dt){</span>
<span id="cb12-16"><a href="#cb12-16" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="at">length =</span> <span class="fu">length</span>(<span class="fu">unique</span>(dt<span class="sc">$</span>sample)))</span>
<span id="cb12-17"><a href="#cb12-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">names</span>(results_ccf) <span class="ot"><-</span> <span class="fu">unique</span>(dt<span class="sc">$</span>sample)</span>
<span id="cb12-18"><a href="#cb12-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-19"><a href="#cb12-19" aria-hidden="true" tabindex="-1"></a> cl <span class="ot"><-</span> <span class="fu">makeCluster</span>(<span class="fu">getOption</span>(<span class="st">"cl.cores"</span>, <span class="dv">16</span>),<span class="at">type=</span><span class="st">"FORK"</span>)</span>
<span id="cb12-20"><a href="#cb12-20" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">parSapply</span>(<span class="at">cl=</span>cl,<span class="fu">names</span>(results_ccf),</span>
<span id="cb12-21"><a href="#cb12-21" aria-hidden="true" tabindex="-1"></a> <span class="cf">function</span>(x){</span>
<span id="cb12-22"><a href="#cb12-22" aria-hidden="true" tabindex="-1"></a> data <span class="ot"><-</span> dt <span class="sc">%>%</span> <span class="fu">filter</span>(sample <span class="sc">==</span> x)</span>
<span id="cb12-23"><a href="#cb12-23" aria-hidden="true" tabindex="-1"></a> a <span class="ot"><-</span> NeoEnrichment<span class="sc">::</span><span class="fu">cal_nes_new_test</span>(<span class="at">dt =</span> data,</span>
<span id="cb12-24"><a href="#cb12-24" aria-hidden="true" tabindex="-1"></a> <span class="at">sample_counts =</span> <span class="dv">1000</span>,</span>
<span id="cb12-25"><a href="#cb12-25" aria-hidden="true" tabindex="-1"></a> <span class="at">need_p =</span> <span class="cn">FALSE</span>)</span>
<span id="cb12-26"><a href="#cb12-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(a)</span>
<span id="cb12-27"><a href="#cb12-27" aria-hidden="true" tabindex="-1"></a> },<span class="at">simplify =</span> <span class="cn">FALSE</span>)</span>
<span id="cb12-28"><a href="#cb12-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">stopCluster</span>(cl)</span>
<span id="cb12-29"><a href="#cb12-29" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">Filter</span>(<span class="cf">function</span>(x){<span class="fu">length</span>(x)<span class="sc">></span><span class="dv">1</span>},results_ccf)</span>
<span id="cb12-30"><a href="#cb12-30" aria-hidden="true" tabindex="-1"></a> pancancer_nes_ccf <span class="ot"><-</span> <span class="fu">bind_rows</span>(results_ccf)</span>
<span id="cb12-31"><a href="#cb12-31" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(pancancer_nes_ccf)</span>
<span id="cb12-32"><a href="#cb12-32" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb12-33"><a href="#cb12-33" aria-hidden="true" tabindex="-1"></a>neo_missense <span class="ot"><-</span> neo_missense <span class="sc">%>%</span> <span class="fu">select</span>(sample,neo,ccf) <span class="sc">%>%</span> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(ccf))</span>
<span id="cb12-34"><a href="#cb12-34" aria-hidden="true" tabindex="-1"></a>neo_nes <span class="ot"><-</span> <span class="fu">cal_nes_warp</span>(neo_missense)</span>
<span id="cb12-35"><a href="#cb12-35" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(neo_nes,<span class="at">file =</span> <span class="st">"../data/neo_nes_ccf06_1.rds"</span>)</span></code></pre></div>
<p>For each sample, we permutate the neoantigen labeling (ie. randomly select the same number of mutations as the actual neoantigen number in the selected sample and label them as neoantigenic mutations) and calculate ES value. For pan-cancer or cancer type dataset, we can obtain the same number of simulated samples and corresponding ES values, then calculate the median ES of these simulated samples. This process was repeated many times (usually 2000 times) to get the simulated distribution of median ES. The actual pan-cancer or cancer type median ES values are compared with this simulated ES distribution, and p values are then reported:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>neo_nes <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"/public/slst/home/wutao2/cal_nes/ccf/neo_nes_ccf06_1.rds"</span>)</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"/public/slst/home/wutao2/cal_nes/ccf/all_mut_ccf_tpm.rds"</span>)</span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">rename</span>(<span class="at">ccf=</span>ccf_hat) <span class="sc">%>%</span></span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">neo=</span><span class="fu">ifelse</span>(neo<span class="sc">==</span><span class="st">"neo"</span>,<span class="st">"yes"</span>,<span class="st">"no"</span>))</span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a>neo_missense <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span> </span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(sample <span class="sc">%in%</span> neo_nes<span class="sc">$</span>sample)</span>
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a>neo_missense <span class="ot"><-</span> neo_missense <span class="sc">%>%</span> </span>
<span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,neo,ccf) <span class="sc">%>%</span> </span>
<span id="cb13-10"><a href="#cb13-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(ccf))</span>
<span id="cb13-11"><a href="#cb13-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-12"><a href="#cb13-12" aria-hidden="true" tabindex="-1"></a>cal_nes_warp <span class="ot"><-</span> <span class="cf">function</span>(dt){</span>
<span id="cb13-13"><a href="#cb13-13" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="at">length =</span> <span class="fu">length</span>(<span class="fu">unique</span>(dt<span class="sc">$</span>sample)))</span>
<span id="cb13-14"><a href="#cb13-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">names</span>(results_ccf) <span class="ot"><-</span> <span class="fu">unique</span>(dt<span class="sc">$</span>sample)</span>
<span id="cb13-15"><a href="#cb13-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-16"><a href="#cb13-16" aria-hidden="true" tabindex="-1"></a> cl <span class="ot"><-</span> <span class="fu">makeCluster</span>(<span class="fu">getOption</span>(<span class="st">"cl.cores"</span>, <span class="dv">30</span>),<span class="at">type=</span><span class="st">"FORK"</span>)</span>
<span id="cb13-17"><a href="#cb13-17" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">parSapply</span>(<span class="at">cl=</span>cl,<span class="fu">names</span>(results_ccf),</span>
<span id="cb13-18"><a href="#cb13-18" aria-hidden="true" tabindex="-1"></a> <span class="cf">function</span>(x){</span>
<span id="cb13-19"><a href="#cb13-19" aria-hidden="true" tabindex="-1"></a> data <span class="ot"><-</span> dt <span class="sc">%>%</span> <span class="fu">filter</span>(sample <span class="sc">==</span> x)</span>
<span id="cb13-20"><a href="#cb13-20" aria-hidden="true" tabindex="-1"></a> a <span class="ot"><-</span> NeoEnrichment<span class="sc">::</span><span class="fu">cal_nes_new_test</span>(<span class="at">dt =</span> data,</span>
<span id="cb13-21"><a href="#cb13-21" aria-hidden="true" tabindex="-1"></a> <span class="at">sample_counts =</span> <span class="dv">1000</span>,</span>
<span id="cb13-22"><a href="#cb13-22" aria-hidden="true" tabindex="-1"></a> <span class="at">need_p =</span> <span class="cn">FALSE</span>)</span>
<span id="cb13-23"><a href="#cb13-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(a)</span>
<span id="cb13-24"><a href="#cb13-24" aria-hidden="true" tabindex="-1"></a> },<span class="at">simplify =</span> <span class="cn">FALSE</span>)</span>
<span id="cb13-25"><a href="#cb13-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">stopCluster</span>(cl)</span>
<span id="cb13-26"><a href="#cb13-26" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">Filter</span>(<span class="cf">function</span>(x){<span class="fu">length</span>(x)<span class="sc">></span><span class="dv">1</span>},results_ccf)</span>
<span id="cb13-27"><a href="#cb13-27" aria-hidden="true" tabindex="-1"></a> pancancer_nes_ccf <span class="ot"><-</span> <span class="fu">bind_rows</span>(results_ccf)</span>
<span id="cb13-28"><a href="#cb13-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(pancancer_nes_ccf)</span>
<span id="cb13-29"><a href="#cb13-29" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb13-30"><a href="#cb13-30" aria-hidden="true" tabindex="-1"></a>res <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="dv">2000</span>)</span>
<span id="cb13-31"><a href="#cb13-31" aria-hidden="true" tabindex="-1"></a><span class="cf">for</span> (i <span class="cf">in</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">2000</span>){</span>
<span id="cb13-32"><a href="#cb13-32" aria-hidden="true" tabindex="-1"></a> neo_missense_sim <span class="ot"><-</span> neo_missense <span class="sc">%>%</span></span>
<span id="cb13-33"><a href="#cb13-33" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(sample) <span class="sc">%>%</span></span>
<span id="cb13-34"><a href="#cb13-34" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">neo_sim=</span><span class="fu">sample</span>(neo,<span class="fu">length</span>(neo)))</span>
<span id="cb13-35"><a href="#cb13-35" aria-hidden="true" tabindex="-1"></a> neo_missense_sim <span class="ot"><-</span> neo_missense_sim <span class="sc">%>%</span></span>
<span id="cb13-36"><a href="#cb13-36" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(<span class="sc">-</span>neo) <span class="sc">%>%</span></span>
<span id="cb13-37"><a href="#cb13-37" aria-hidden="true" tabindex="-1"></a> <span class="fu">rename</span>(<span class="at">neo=</span>neo_sim)</span>
<span id="cb13-38"><a href="#cb13-38" aria-hidden="true" tabindex="-1"></a> neo_nes_sim <span class="ot"><-</span> <span class="fu">cal_nes_warp</span>(neo_missense_sim)</span>
<span id="cb13-39"><a href="#cb13-39" aria-hidden="true" tabindex="-1"></a> neo_nes_sim<span class="sc">$</span>sim_num <span class="ot"><-</span> i</span>
<span id="cb13-40"><a href="#cb13-40" aria-hidden="true" tabindex="-1"></a> res[[i]] <span class="ot"><-</span> neo_nes_sim</span>
<span id="cb13-41"><a href="#cb13-41" aria-hidden="true" tabindex="-1"></a> <span class="fu">print</span>(<span class="fu">paste0</span>(<span class="st">"Complete "</span>,i,<span class="st">" sim. "</span>))</span>
<span id="cb13-42"><a href="#cb13-42" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb13-43"><a href="#cb13-43" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(res,<span class="at">file =</span> <span class="st">"/public/slst/home/wutao2/cal_nes/ccf/sim_2000_not_filter_driver.rds"</span>)</span>
<span id="cb13-44"><a href="#cb13-44" aria-hidden="true" tabindex="-1"></a>sim_2000_not_filter <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"~/test/data/2021_09_26/sim_2000_not_filter.rds"</span>)</span>
<span id="cb13-45"><a href="#cb13-45" aria-hidden="true" tabindex="-1"></a>sim_2000_not_filter <span class="ot"><-</span> <span class="fu">bind_rows</span>(sim_2000_not_filter)</span>
<span id="cb13-46"><a href="#cb13-46" aria-hidden="true" tabindex="-1"></a>sim_2000_not_filter<span class="sc">$</span>cancer <span class="ot"><-</span> <span class="fu">get_cancer_type</span>(sim_2000_not_filter<span class="sc">$</span>sample,</span>
<span id="cb13-47"><a href="#cb13-47" aria-hidden="true" tabindex="-1"></a> <span class="at">parallel =</span> T,<span class="at">cores =</span> <span class="dv">20</span>)</span>
<span id="cb13-48"><a href="#cb13-48" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(sim_2000_not_filter,<span class="at">file =</span> <span class="st">"../../tmp/sim_2000_not_filter_all_ccf.rds"</span>)<span class="do">##this file is too large to push to Github</span></span></code></pre></div>
<p>We can visualize the simulation using <code>WVPlots</code> package :</p>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>neo_nes <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/neo_nes_ccf06_1.rds"</span>)</span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a>sim_all <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../../tmp/sim_2000_not_filter_all_ccf.rds"</span>)</span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a>sim_all <span class="sc">%>%</span></span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(cancer,sim_num) <span class="sc">%>%</span></span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">median_es=</span><span class="fu">median</span>(es)) <span class="ot">-></span> summ2</span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a><span class="co">#> `summarise()` has grouped output by 'cancer'. You can override using the</span></span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="co">#> `.groups` argument.</span></span>
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a>neo_nes<span class="sc">$</span>cancer <span class="ot"><-</span> <span class="fu">get_cancer_type</span>(neo_nes<span class="sc">$</span>sample)</span>
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a>neo_nes_summ <span class="ot"><-</span> neo_nes <span class="sc">%>%</span> </span>
<span id="cb14-10"><a href="#cb14-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(cancer) <span class="sc">%>%</span> <span class="fu">summarise</span>(<span class="at">median_es=</span><span class="fu">median</span>(es))</span>
<span id="cb14-11"><a href="#cb14-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-12"><a href="#cb14-12" aria-hidden="true" tabindex="-1"></a><span class="co">#The following code can be used to plot cancer type simulation which showd in FigS4</span></span>
<span id="cb14-13"><a href="#cb14-13" aria-hidden="true" tabindex="-1"></a><span class="co">#res <- vector("list",30)</span></span>
<span id="cb14-14"><a href="#cb14-14" aria-hidden="true" tabindex="-1"></a><span class="co"># for (i in 1:30){</span></span>
<span id="cb14-15"><a href="#cb14-15" aria-hidden="true" tabindex="-1"></a><span class="co"># dt <- sim_all %>% filter(cancer==neo_nes_summ$cancer[i])</span></span>
<span id="cb14-16"><a href="#cb14-16" aria-hidden="true" tabindex="-1"></a><span class="co"># dt_summ <- dt %>% </span></span>
<span id="cb14-17"><a href="#cb14-17" aria-hidden="true" tabindex="-1"></a><span class="co"># group_by(sim_num) %>%</span></span>
<span id="cb14-18"><a href="#cb14-18" aria-hidden="true" tabindex="-1"></a><span class="co"># summarise(median_es=median(es))</span></span>
<span id="cb14-19"><a href="#cb14-19" aria-hidden="true" tabindex="-1"></a><span class="co"># p <- WVPlots::ShadedDensity(frame = dt_summ, </span></span>
<span id="cb14-20"><a href="#cb14-20" aria-hidden="true" tabindex="-1"></a><span class="co"># xvar = "median_es",</span></span>
<span id="cb14-21"><a href="#cb14-21" aria-hidden="true" tabindex="-1"></a><span class="co"># threshold = neo_nes_summ$median_es[i],</span></span>
<span id="cb14-22"><a href="#cb14-22" aria-hidden="true" tabindex="-1"></a><span class="co"># title = neo_nes_summ$cancer[i],</span></span>
<span id="cb14-23"><a href="#cb14-23" aria-hidden="true" tabindex="-1"></a><span class="co"># tail = "left")</span></span>
<span id="cb14-24"><a href="#cb14-24" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[1]]$aes_params$colour <- "red"</span></span>
<span id="cb14-25"><a href="#cb14-25" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[1]]$aes_params$size <- 1</span></span>
<span id="cb14-26"><a href="#cb14-26" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[2]]$aes_params$fill <- "blue" #geom_ribbon</span></span>
<span id="cb14-27"><a href="#cb14-27" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[3]]$aes_params$colour <- "black" </span></span>
<span id="cb14-28"><a href="#cb14-28" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[3]]$aes_params$size <- 1</span></span>
<span id="cb14-29"><a href="#cb14-29" aria-hidden="true" tabindex="-1"></a><span class="co"># p1 <- p + labs(x="Simulation median es")+</span></span>
<span id="cb14-30"><a href="#cb14-30" aria-hidden="true" tabindex="-1"></a><span class="co"># theme_prism()</span></span>
<span id="cb14-31"><a href="#cb14-31" aria-hidden="true" tabindex="-1"></a><span class="co"># res[[i]] <- p1</span></span>
<span id="cb14-32"><a href="#cb14-32" aria-hidden="true" tabindex="-1"></a><span class="co"># }</span></span>
<span id="cb14-33"><a href="#cb14-33" aria-hidden="true" tabindex="-1"></a><span class="co"># </span></span>
<span id="cb14-34"><a href="#cb14-34" aria-hidden="true" tabindex="-1"></a><span class="co"># plot_grid(plotlist = res)</span></span>
<span id="cb14-35"><a href="#cb14-35" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-36"><a href="#cb14-36" aria-hidden="true" tabindex="-1"></a>sim_all <span class="sc">%>%</span></span>
<span id="cb14-37"><a href="#cb14-37" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(sim_num) <span class="sc">%>%</span></span>
<span id="cb14-38"><a href="#cb14-38" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">median_es=</span><span class="fu">median</span>(es)) <span class="ot">-></span> summ</span>
<span id="cb14-39"><a href="#cb14-39" aria-hidden="true" tabindex="-1"></a>p <span class="ot"><-</span> WVPlots<span class="sc">::</span><span class="fu">ShadedDensity</span>(<span class="at">frame =</span> summ, </span>
<span id="cb14-40"><a href="#cb14-40" aria-hidden="true" tabindex="-1"></a> <span class="at">xvar =</span> <span class="st">"median_es"</span>,</span>
<span id="cb14-41"><a href="#cb14-41" aria-hidden="true" tabindex="-1"></a> <span class="at">threshold =</span> <span class="fu">median</span>(neo_nes<span class="sc">$</span>es),</span>
<span id="cb14-42"><a href="#cb14-42" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">""</span>,</span>
<span id="cb14-43"><a href="#cb14-43" aria-hidden="true" tabindex="-1"></a> <span class="at">tail =</span> <span class="st">"left"</span>)</span>
<span id="cb14-44"><a href="#cb14-44" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-45"><a href="#cb14-45" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">1</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>colour <span class="ot"><-</span> <span class="st">"red"</span></span>
<span id="cb14-46"><a href="#cb14-46" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">1</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>size <span class="ot"><-</span> <span class="dv">1</span></span>
<span id="cb14-47"><a href="#cb14-47" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">2</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>fill <span class="ot"><-</span> <span class="st">"blue"</span> <span class="co">#geom_ribbon</span></span>
<span id="cb14-48"><a href="#cb14-48" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">3</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>colour <span class="ot"><-</span> <span class="st">"black"</span> </span>
<span id="cb14-49"><a href="#cb14-49" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">3</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>size <span class="ot"><-</span> <span class="dv">1</span></span>
<span id="cb14-50"><a href="#cb14-50" aria-hidden="true" tabindex="-1"></a><span class="co">#p$layers[[4]]$aes_params$label <- "Actual median ES" #geom_text</span></span>
<span id="cb14-51"><a href="#cb14-51" aria-hidden="true" tabindex="-1"></a>p1 <span class="ot"><-</span> p <span class="sc">+</span> <span class="fu">labs</span>(<span class="at">x=</span><span class="st">"Simulation median es"</span>)<span class="sc">+</span></span>
<span id="cb14-52"><a href="#cb14-52" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_prism</span>()</span>
<span id="cb14-53"><a href="#cb14-53" aria-hidden="true" tabindex="-1"></a>p1</span></code></pre></div>
<p><img src="report_main_files/figure-html/via1-1.png" width="2400" /></p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="do">##save</span></span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="co"># neo_nes_summ <- neo_nes_summ %>% </span></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="co"># rowwise() %>% </span></span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a><span class="co"># mutate(p=mean(summ2$median_es[summ2$cancer==cancer] <= median_es))</span></span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a><span class="co"># saveRDS(neo_nes_summ,file = "neo_nes_summ_ccf_061_not_filter.rds")</span></span></code></pre></div>
<p>Then we can compare the median actual CCF-ES with median simulation CCF-ES in pan-cancer and cancer-type:</p>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a>get_f1 <span class="ot"><-</span> <span class="cf">function</span>(dt,pancancer_p,dt2,median_es){</span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a> p1 <span class="ot"><-</span> <span class="fu">ggplot</span>(<span class="at">data=</span>dt,<span class="fu">aes</span>(<span class="at">x=</span><span class="dv">1</span>,<span class="at">y=</span>es))<span class="sc">+</span></span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_violin</span>(<span class="at">alpha=</span><span class="fl">0.7</span>,<span class="at">width=</span><span class="fl">0.5</span>)<span class="sc">+</span></span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_boxplot</span>(<span class="at">width=</span><span class="fl">0.2</span>)<span class="sc">+</span></span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_prism</span>()<span class="sc">+</span></span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">labs</span>(<span class="at">x=</span><span class="fu">paste0</span>(<span class="st">"median es = "</span>,<span class="fu">round</span>(median_es,<span class="at">digits =</span> <span class="dv">3</span>),<span class="st">"</span><span class="sc">\n</span><span class="st"> n = "</span>,<span class="fu">nrow</span>(dt)),<span class="at">size=</span><span class="dv">1</span>)<span class="sc">+</span></span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.ticks.x =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.text.x =</span> <span class="fu">element_blank</span>())<span class="sc">+</span></span>
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">text =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">7</span>))<span class="sc">+</span></span>
<span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">annotate</span>(<span class="at">geom=</span><span class="st">"text"</span>, <span class="at">x=</span><span class="dv">1</span>, <span class="at">y=</span><span class="fl">1.1</span>, <span class="at">label=</span><span class="fu">paste0</span>(<span class="st">"p = "</span>,pancancer_p),</span>
<span id="cb16-11"><a href="#cb16-11" aria-hidden="true" tabindex="-1"></a> <span class="at">color=</span><span class="st">"red"</span>,<span class="at">size=</span><span class="dv">4</span>)</span>
<span id="cb16-12"><a href="#cb16-12" aria-hidden="true" tabindex="-1"></a> dt<span class="sc">$</span>cancer <span class="ot"><-</span> <span class="fu">get_cancer_type</span>(dt<span class="sc">$</span>sample)</span>
<span id="cb16-13"><a href="#cb16-13" aria-hidden="true" tabindex="-1"></a> dt <span class="sc">%>%</span> <span class="fu">group_by</span>(cancer) <span class="sc">%>%</span></span>
<span id="cb16-14"><a href="#cb16-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">median_est=</span><span class="fu">median</span>(es),<span class="at">c=</span><span class="fu">n</span>()) <span class="sc">%>%</span></span>
<span id="cb16-15"><a href="#cb16-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">arrange</span>(median_est) <span class="sc">%>%</span></span>
<span id="cb16-16"><a href="#cb16-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">label=</span><span class="fu">paste0</span>(cancer,<span class="st">"</span><span class="sc">\n</span><span class="st">(n="</span>,c,<span class="st">")"</span>))<span class="ot">-></span> summ1</span>
<span id="cb16-17"><a href="#cb16-17" aria-hidden="true" tabindex="-1"></a> summ1 <span class="ot"><-</span> <span class="fu">left_join</span>(summ1,dt2 <span class="sc">%>%</span> <span class="fu">select</span>(cancer,p))</span>
<span id="cb16-18"><a href="#cb16-18" aria-hidden="true" tabindex="-1"></a> summ1<span class="sc">$</span>p <span class="ot"><-</span> <span class="fu">signif</span>(summ1<span class="sc">$</span>p,<span class="at">digits =</span> <span class="dv">1</span>)</span>
<span id="cb16-19"><a href="#cb16-19" aria-hidden="true" tabindex="-1"></a> summ1 <span class="ot"><-</span> summ1 <span class="sc">%>%</span></span>
<span id="cb16-20"><a href="#cb16-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">sig=</span><span class="fu">case_when</span>(</span>
<span id="cb16-21"><a href="#cb16-21" aria-hidden="true" tabindex="-1"></a> p <span class="sc"><=</span> <span class="fl">0.05</span> <span class="sc">&</span> p <span class="sc">></span> <span class="fl">0.01</span> <span class="sc">~</span> <span class="st">"*"</span>,</span>
<span id="cb16-22"><a href="#cb16-22" aria-hidden="true" tabindex="-1"></a> p <span class="sc"><</span> <span class="fl">0.01</span> <span class="sc">~</span> <span class="st">"**"</span>,</span>
<span id="cb16-23"><a href="#cb16-23" aria-hidden="true" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> <span class="st">"ns"</span></span>
<span id="cb16-24"><a href="#cb16-24" aria-hidden="true" tabindex="-1"></a> ))</span>
<span id="cb16-25"><a href="#cb16-25" aria-hidden="true" tabindex="-1"></a> dt <span class="ot"><-</span> <span class="fu">left_join</span>(dt,summ1)</span>
<span id="cb16-26"><a href="#cb16-26" aria-hidden="true" tabindex="-1"></a> dt<span class="sc">$</span>label <span class="ot"><-</span> <span class="fu">factor</span>(dt<span class="sc">$</span>label,<span class="at">levels =</span> summ1<span class="sc">$</span>label)</span>
<span id="cb16-27"><a href="#cb16-27" aria-hidden="true" tabindex="-1"></a> df2 <span class="ot"><-</span> <span class="fu">data.frame</span>(<span class="at">x =</span> <span class="dv">1</span><span class="sc">:</span><span class="fu">nrow</span>(summ1), <span class="at">y =</span> <span class="fl">1.1</span>, <span class="at">family =</span> summ1<span class="sc">$</span>sig)</span>
<span id="cb16-28"><a href="#cb16-28" aria-hidden="true" tabindex="-1"></a> p2 <span class="ot"><-</span> <span class="fu">ggplot</span>(<span class="at">data=</span>dt,<span class="fu">aes</span>(<span class="at">x=</span>label,<span class="at">y=</span>es))<span class="sc">+</span></span>
<span id="cb16-29"><a href="#cb16-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_boxplot</span>()<span class="sc">+</span></span>
<span id="cb16-30"><a href="#cb16-30" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_prism</span>()<span class="sc">+</span></span>
<span id="cb16-31"><a href="#cb16-31" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.title.x =</span> <span class="fu">element_blank</span>())<span class="sc">+</span></span>
<span id="cb16-32"><a href="#cb16-32" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.text.x =</span> <span class="fu">element_text</span>(<span class="at">angle =</span> <span class="dv">45</span>,<span class="at">vjust =</span> <span class="dv">1</span>, <span class="at">hjust =</span> <span class="dv">1</span>))<span class="sc">+</span></span>
<span id="cb16-33"><a href="#cb16-33" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">text =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">6</span>))<span class="sc">+</span></span>
<span id="cb16-34"><a href="#cb16-34" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_text</span>(<span class="at">data=</span>df2,<span class="fu">aes</span>(<span class="at">x=</span>x,<span class="at">y=</span>y,<span class="at">label =</span> family))<span class="sc">+</span></span>
<span id="cb16-35"><a href="#cb16-35" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_hline</span>(<span class="at">yintercept=</span><span class="dv">0</span>,</span>
<span id="cb16-36"><a href="#cb16-36" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">"red"</span>, <span class="at">size=</span><span class="dv">1</span>)</span>
<span id="cb16-37"><a href="#cb16-37" aria-hidden="true" tabindex="-1"></a> p3 <span class="ot"><-</span> p1 <span class="sc">+</span> p2 <span class="sc">+</span> <span class="fu">plot_layout</span>(<span class="at">widths =</span> <span class="fu">c</span>(<span class="dv">1</span>, <span class="dv">8</span>))</span>
<span id="cb16-38"><a href="#cb16-38" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb16-39"><a href="#cb16-39" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-40"><a href="#cb16-40" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb16-41"><a href="#cb16-41" aria-hidden="true" tabindex="-1"></a>neo_nes4 <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/neo_nes_ccf06_1.rds"</span>)</span>
<span id="cb16-42"><a href="#cb16-42" aria-hidden="true" tabindex="-1"></a>neo_nes_summ <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/neo_nes_summ_ccf_061_not_filter.rds"</span>)</span>
<span id="cb16-43"><a href="#cb16-43" aria-hidden="true" tabindex="-1"></a>p3 <span class="ot"><-</span> <span class="fu">get_f1</span>(neo_nes4,<span class="at">pancancer_p =</span> <span class="fl">0.051</span>,<span class="at">dt2 =</span> neo_nes_summ,<span class="at">median_es =</span> <span class="fu">median</span>(neo_nes4<span class="sc">$</span>es))</span>
<span id="cb16-44"><a href="#cb16-44" aria-hidden="true" tabindex="-1"></a><span class="co">#> Joining, by = "cancer"Joining, by = "cancer"</span></span>
<span id="cb16-45"><a href="#cb16-45" aria-hidden="true" tabindex="-1"></a>p3</span></code></pre></div>
<p><img src="report_main_files/figure-html/unnamed-chunk-6-1.png" width="2400" /></p>
<p>The observed ESCCF is -0.017 (p=0.051). In PAAD and LUAD, the observed ESCCF values are significant lower compared with the random simulations, suggesting the existence of immunoediting-elimination signal. Since some neoantigenic mutations can be cancer drivers, which are known to undergo positive selection during the evolution of cancer. Neoantigens that happens to be cancer drivers are not undergoing immune based negative selection, probably because the driving force could override the negative selection, so we compared ES between the samples which neoantigenic and driver lie in the same gene with other samples:</p>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span></span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">gene_protein_change=</span><span class="fu">paste</span>(Hugo_Symbol,Protein_Change,<span class="at">sep =</span> <span class="st">"-"</span>))</span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a>driver_mutations <span class="ot"><-</span> driver_mutations <span class="sc">%>%</span></span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">gene_protein_change=</span><span class="fu">paste</span>(gene,protein_change,<span class="at">sep =</span> <span class="st">"-"</span>))</span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span></span>
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">is_driver=</span><span class="fu">ifelse</span>(gene_protein_change <span class="sc">%in%</span> driver_mutations<span class="sc">$</span>gene_protein_change,<span class="st">"yes"</span>,<span class="st">"no"</span>))</span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a><span class="fu">sum</span>(all_mut_ccf<span class="sc">$</span>is_driver<span class="sc">==</span><span class="st">"yes"</span> <span class="sc">&</span> all_mut_ccf<span class="sc">$</span>neo<span class="sc">==</span><span class="st">"yes"</span>) <span class="sc">/</span> <span class="fu">sum</span>(all_mut_ccf<span class="sc">$</span>neo<span class="sc">==</span><span class="st">"yes"</span>)<span class="do">##0.01029878</span></span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="sc">%>%</span> <span class="fu">group_by</span>(sample) <span class="sc">%>%</span></span>
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">inter_gene=</span><span class="fu">intersect</span>(Hugo_Symbol[neo<span class="sc">==</span><span class="st">"yes"</span>],</span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a> Hugo_Symbol[is_driver<span class="sc">==</span><span class="st">"yes"</span>])) <span class="ot">-></span> aaa<span class="do">##701 samples</span></span>
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span></span>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">sample_neo_index=</span><span class="fu">paste</span>(sample,neo,Hugo_Symbol,<span class="at">sep =</span> <span class="st">","</span>))</span>
<span id="cb17-14"><a href="#cb17-14" aria-hidden="true" tabindex="-1"></a>aaa <span class="ot"><-</span> aaa <span class="sc">%>%</span> <span class="fu">mutate</span>(<span class="at">sample_neo_index=</span><span class="fu">paste</span>(sample,<span class="st">"yes"</span>,inter_gene,<span class="at">sep =</span> <span class="st">","</span>))</span>
<span id="cb17-15"><a href="#cb17-15" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-16"><a href="#cb17-16" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="sc">%>%</span></span>
<span id="cb17-17"><a href="#cb17-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">in_aaa =</span> <span class="fu">ifelse</span>(sample_neo_index <span class="sc">%in%</span> aaa<span class="sc">$</span>sample_neo_index,<span class="st">"yes"</span>,<span class="st">"no"</span>)) <span class="sc">%>%</span></span>
<span id="cb17-18"><a href="#cb17-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(sample) <span class="sc">%>%</span></span>
<span id="cb17-19"><a href="#cb17-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">need_sample=</span><span class="fu">ifelse</span>(<span class="fu">any</span>(in_aaa<span class="sc">==</span><span class="st">"yes"</span>),<span class="st">"no"</span>,<span class="st">"yes"</span>)) <span class="sc">%>%</span></span>
<span id="cb17-20"><a href="#cb17-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(need_sample<span class="sc">==</span><span class="st">"yes"</span>) <span class="ot">-></span> summ2</span>
<span id="cb17-21"><a href="#cb17-21" aria-hidden="true" tabindex="-1"></a>need_samples <span class="ot"><-</span> <span class="fu">intersect</span>(samples_has_subclonal<span class="sc">$</span>sample,summ2<span class="sc">$</span>sample)</span>
<span id="cb17-22"><a href="#cb17-22" aria-hidden="true" tabindex="-1"></a>all_mut_ccf <span class="sc">%>%</span></span>
<span id="cb17-23"><a href="#cb17-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(sample <span class="sc">%in%</span> need_samples) <span class="sc">%>%</span></span>
<span id="cb17-24"><a href="#cb17-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(sample) <span class="sc">%>%</span></span>
<span id="cb17-25"><a href="#cb17-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">c_n=</span><span class="fu">sum</span>(neo<span class="sc">==</span><span class="st">"yes"</span>),<span class="at">c_m=</span><span class="fu">sum</span>(neo<span class="sc">==</span><span class="st">"no"</span>)) <span class="sc">%>%</span> <span class="fu">filter</span>(c_n<span class="sc">>=</span><span class="dv">1</span> <span class="sc">&</span> c_m <span class="sc">>=</span><span class="dv">1</span>) <span class="ot">-></span> summ</span>
<span id="cb17-26"><a href="#cb17-26" aria-hidden="true" tabindex="-1"></a>neo_missense <span class="ot"><-</span> all_mut_ccf <span class="sc">%>%</span> <span class="fu">filter</span>(sample <span class="sc">%in%</span> summ<span class="sc">$</span>sample)</span>
<span id="cb17-27"><a href="#cb17-27" aria-hidden="true" tabindex="-1"></a>neo_missense <span class="ot"><-</span> neo_missense <span class="sc">%>%</span> <span class="fu">select</span>(sample,neo,ccf) <span class="sc">%>%</span> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(ccf))</span>
<span id="cb17-28"><a href="#cb17-28" aria-hidden="true" tabindex="-1"></a>neo_nes <span class="ot"><-</span> <span class="fu">cal_nes_warp</span>(neo_missense)<span class="do">##addp</span></span>
<span id="cb17-29"><a href="#cb17-29" aria-hidden="true" tabindex="-1"></a><span class="fu">median</span>(neo_nes<span class="sc">$</span>es)</span>
<span id="cb17-30"><a href="#cb17-30" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(neo_nes,<span class="at">file =</span> <span class="st">"../data/neo_nes_ccf06_1_remove_driver_samples_addp.rds"</span>)</span></code></pre></div>
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>neo_nes <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/neo_nes_ccf06_1.rds"</span>)</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a>neo_nes_remove_drivers <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/neo_nes_ccf06_1_remove_driver_samples_addp.rds"</span>)</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a>neo_nes2 <span class="ot"><-</span> neo_nes <span class="sc">%>%</span></span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span>(sample <span class="sc">%in%</span> neo_nes_remove_drivers<span class="sc">$</span>sample))</span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a>dt <span class="ot"><-</span> <span class="fu">data.frame</span>(<span class="at">es=</span><span class="fu">c</span>(neo_nes_remove_drivers<span class="sc">$</span>es,neo_nes2<span class="sc">$</span>es),</span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a> <span class="at">type=</span><span class="fu">c</span>(<span class="fu">rep</span>(<span class="st">"neo not in driver"</span>,<span class="fu">nrow</span>(neo_nes_remove_drivers)),</span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">rep</span>(<span class="st">"neo in driver"</span>,<span class="fu">nrow</span>(neo_nes2))))</span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a>dt<span class="sc">$</span>type <span class="ot"><-</span> <span class="fu">factor</span>(dt<span class="sc">$</span>type,<span class="at">levels =</span> <span class="fu">c</span>(<span class="st">"neo not in driver"</span>,<span class="st">"neo in driver"</span>))</span>
<span id="cb18-9"><a href="#cb18-9" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(<span class="at">data =</span> dt,<span class="fu">aes</span>(<span class="at">x=</span>type,<span class="at">y=</span>es))<span class="sc">+</span></span>
<span id="cb18-10"><a href="#cb18-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_boxplot</span>()<span class="sc">+</span></span>
<span id="cb18-11"><a href="#cb18-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">stat_compare_means</span>()<span class="sc">+</span></span>
<span id="cb18-12"><a href="#cb18-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_prism</span>()<span class="sc">+</span></span>
<span id="cb18-13"><a href="#cb18-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.title.x =</span> <span class="fu">element_blank</span>())</span></code></pre></div>
<p><img src="report_main_files/figure-html/unnamed-chunk-8-1.png" width="2400" /></p>
<p>We can see that samples which neoantigenic and driver mutation lie in the same gene have the higher ES than other samples. So we filtered these sample to remove the effect that driver mutation cound couse.</p>
<p>When samples with neoantigenic and driver mutations lied on same genes are not included, the observed median ESCCF is -0.023 (n=5295, P=0.0055) (the simulation procedure is the same as above):</p>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a>sim_all <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../../tmp/sim_2000_not_filter_all_ccf.rds"</span>)<span class="do">##this file is too large to push to Github</span></span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a>sim_filter_driver <span class="ot"><-</span> sim_all <span class="sc">%>%</span> </span>
<span id="cb19-3"><a href="#cb19-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(sample <span class="sc">%in%</span> neo_nes_remove_drivers<span class="sc">$</span>sample)</span>
<span id="cb19-4"><a href="#cb19-4" aria-hidden="true" tabindex="-1"></a>sim_filter_driver <span class="sc">%>%</span></span>
<span id="cb19-5"><a href="#cb19-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(cancer,sim_num) <span class="sc">%>%</span></span>
<span id="cb19-6"><a href="#cb19-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">median_es=</span><span class="fu">median</span>(es)) <span class="ot">-></span> summ2</span>
<span id="cb19-7"><a href="#cb19-7" aria-hidden="true" tabindex="-1"></a><span class="co">#> `summarise()` has grouped output by 'cancer'. You can override using the</span></span>
<span id="cb19-8"><a href="#cb19-8" aria-hidden="true" tabindex="-1"></a><span class="co">#> `.groups` argument.</span></span>
<span id="cb19-9"><a href="#cb19-9" aria-hidden="true" tabindex="-1"></a>neo_nes_remove_drivers<span class="sc">$</span>cancer <span class="ot"><-</span> <span class="fu">get_cancer_type</span>(neo_nes_remove_drivers<span class="sc">$</span>sample)</span>
<span id="cb19-10"><a href="#cb19-10" aria-hidden="true" tabindex="-1"></a>neo_nes_summ <span class="ot"><-</span> neo_nes_remove_drivers <span class="sc">%>%</span> </span>
<span id="cb19-11"><a href="#cb19-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(cancer) <span class="sc">%>%</span> <span class="fu">summarise</span>(<span class="at">median_es=</span><span class="fu">median</span>(es))</span>
<span id="cb19-12"><a href="#cb19-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-13"><a href="#cb19-13" aria-hidden="true" tabindex="-1"></a><span class="co">#The following code can be used to plot cancer type simulation which showd in FigS6</span></span>
<span id="cb19-14"><a href="#cb19-14" aria-hidden="true" tabindex="-1"></a><span class="co">#res <- vector("list",30)</span></span>
<span id="cb19-15"><a href="#cb19-15" aria-hidden="true" tabindex="-1"></a><span class="co"># for (i in 1:30){</span></span>
<span id="cb19-16"><a href="#cb19-16" aria-hidden="true" tabindex="-1"></a><span class="co"># dt <- sim_filter_driver %>% filter(cancer==neo_nes_summ$cancer[i])</span></span>
<span id="cb19-17"><a href="#cb19-17" aria-hidden="true" tabindex="-1"></a><span class="co"># dt_summ <- dt %>% </span></span>
<span id="cb19-18"><a href="#cb19-18" aria-hidden="true" tabindex="-1"></a><span class="co"># group_by(sim_num) %>%</span></span>
<span id="cb19-19"><a href="#cb19-19" aria-hidden="true" tabindex="-1"></a><span class="co"># summarise(median_es=median(es))</span></span>
<span id="cb19-20"><a href="#cb19-20" aria-hidden="true" tabindex="-1"></a><span class="co"># p <- WVPlots::ShadedDensity(frame = dt_summ, </span></span>
<span id="cb19-21"><a href="#cb19-21" aria-hidden="true" tabindex="-1"></a><span class="co"># xvar = "median_es",</span></span>
<span id="cb19-22"><a href="#cb19-22" aria-hidden="true" tabindex="-1"></a><span class="co"># threshold = neo_nes_summ$median_es[i],</span></span>
<span id="cb19-23"><a href="#cb19-23" aria-hidden="true" tabindex="-1"></a><span class="co"># title = neo_nes_summ$cancer[i],</span></span>
<span id="cb19-24"><a href="#cb19-24" aria-hidden="true" tabindex="-1"></a><span class="co"># tail = "left")</span></span>
<span id="cb19-25"><a href="#cb19-25" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[1]]$aes_params$colour <- "red"</span></span>
<span id="cb19-26"><a href="#cb19-26" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[1]]$aes_params$size <- 1</span></span>
<span id="cb19-27"><a href="#cb19-27" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[2]]$aes_params$fill <- "blue" #geom_ribbon</span></span>
<span id="cb19-28"><a href="#cb19-28" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[3]]$aes_params$colour <- "black" </span></span>
<span id="cb19-29"><a href="#cb19-29" aria-hidden="true" tabindex="-1"></a><span class="co"># p$layers[[3]]$aes_params$size <- 1</span></span>
<span id="cb19-30"><a href="#cb19-30" aria-hidden="true" tabindex="-1"></a><span class="co"># p1 <- p + labs(x="Simulation median es")+</span></span>
<span id="cb19-31"><a href="#cb19-31" aria-hidden="true" tabindex="-1"></a><span class="co"># theme_prism()</span></span>
<span id="cb19-32"><a href="#cb19-32" aria-hidden="true" tabindex="-1"></a><span class="co"># res[[i]] <- p1</span></span>
<span id="cb19-33"><a href="#cb19-33" aria-hidden="true" tabindex="-1"></a><span class="co"># }</span></span>
<span id="cb19-34"><a href="#cb19-34" aria-hidden="true" tabindex="-1"></a><span class="co"># </span></span>
<span id="cb19-35"><a href="#cb19-35" aria-hidden="true" tabindex="-1"></a><span class="co"># plot_grid(plotlist = res)</span></span>
<span id="cb19-36"><a href="#cb19-36" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-37"><a href="#cb19-37" aria-hidden="true" tabindex="-1"></a>sim_filter_driver <span class="sc">%>%</span></span>
<span id="cb19-38"><a href="#cb19-38" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(sim_num) <span class="sc">%>%</span></span>
<span id="cb19-39"><a href="#cb19-39" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">median_es=</span><span class="fu">median</span>(es)) <span class="ot">-></span> summ</span>
<span id="cb19-40"><a href="#cb19-40" aria-hidden="true" tabindex="-1"></a>p <span class="ot"><-</span> WVPlots<span class="sc">::</span><span class="fu">ShadedDensity</span>(<span class="at">frame =</span> summ, </span>
<span id="cb19-41"><a href="#cb19-41" aria-hidden="true" tabindex="-1"></a> <span class="at">xvar =</span> <span class="st">"median_es"</span>,</span>
<span id="cb19-42"><a href="#cb19-42" aria-hidden="true" tabindex="-1"></a> <span class="at">threshold =</span> <span class="fu">median</span>(neo_nes_remove_drivers<span class="sc">$</span>es),</span>
<span id="cb19-43"><a href="#cb19-43" aria-hidden="true" tabindex="-1"></a> <span class="at">title =</span> <span class="st">""</span>,</span>
<span id="cb19-44"><a href="#cb19-44" aria-hidden="true" tabindex="-1"></a> <span class="at">tail =</span> <span class="st">"left"</span>)</span>
<span id="cb19-45"><a href="#cb19-45" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb19-46"><a href="#cb19-46" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">1</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>colour <span class="ot"><-</span> <span class="st">"red"</span></span>
<span id="cb19-47"><a href="#cb19-47" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">1</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>size <span class="ot"><-</span> <span class="dv">1</span></span>
<span id="cb19-48"><a href="#cb19-48" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">2</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>fill <span class="ot"><-</span> <span class="st">"blue"</span> <span class="co">#geom_ribbon</span></span>
<span id="cb19-49"><a href="#cb19-49" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">3</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>colour <span class="ot"><-</span> <span class="st">"black"</span> </span>
<span id="cb19-50"><a href="#cb19-50" aria-hidden="true" tabindex="-1"></a>p<span class="sc">$</span>layers[[<span class="dv">3</span>]]<span class="sc">$</span>aes_params<span class="sc">$</span>size <span class="ot"><-</span> <span class="dv">1</span></span>
<span id="cb19-51"><a href="#cb19-51" aria-hidden="true" tabindex="-1"></a><span class="co">#p$layers[[4]]$aes_params$label <- "Actual median ES" #geom_text</span></span>
<span id="cb19-52"><a href="#cb19-52" aria-hidden="true" tabindex="-1"></a>p1 <span class="ot"><-</span> p <span class="sc">+</span> <span class="fu">labs</span>(<span class="at">x=</span><span class="st">"Simulation median es"</span>)<span class="sc">+</span></span>
<span id="cb19-53"><a href="#cb19-53" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_prism</span>()</span>
<span id="cb19-54"><a href="#cb19-54" aria-hidden="true" tabindex="-1"></a>p1</span></code></pre></div>
<p><img src="report_main_files/figure-html/unnamed-chunk-9-1.png" width="2400" /></p>
<div class="sourceCode" id="cb20"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a><span class="do">##save</span></span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a><span class="co"># neo_nes_summ <- neo_nes_summ %>% </span></span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="co"># rowwise() %>% </span></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="co"># mutate(p=mean(summ2$median_es[summ2$cancer==cancer] <= median_es))</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="co"># saveRDS(neo_nes_summ,file = "neo_nes_summ_ccf_061.rds")</span></span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a>neo_nes3 <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/neo_nes_ccf06_1_remove_driver_samples_addp.rds"</span>) <span class="sc">%>%</span> </span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(<span class="sc">-</span>p)</span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a>neo_nes_summ <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/neo_nes_summ_ccf_061.rds"</span>)</span>
<span id="cb20-10"><a href="#cb20-10" aria-hidden="true" tabindex="-1"></a>p3 <span class="ot"><-</span> <span class="fu">get_f1</span>(neo_nes3,<span class="at">pancancer_p =</span> <span class="fl">0.0055</span>,<span class="at">dt2 =</span> neo_nes_summ,<span class="at">median_es =</span> <span class="fu">median</span>(neo_nes3<span class="sc">$</span>es))</span>
<span id="cb20-11"><a href="#cb20-11" aria-hidden="true" tabindex="-1"></a><span class="co">#> Joining, by = "cancer"Joining, by = "cancer"</span></span>
<span id="cb20-12"><a href="#cb20-12" aria-hidden="true" tabindex="-1"></a>p3</span></code></pre></div>
<p><img src="report_main_files/figure-html/unnamed-chunk-9-2.png" width="2400" /></p>
<p>Several cancer types including ACC, PAAD, UCEC, LUAD show significant low ESCCF values. This data demonstrates the existence of immunoediting-elimination signal in TCGA dataset.</p>
<p>We then calculated the EXP-ES and corresponding simulation median ES distribution:</p>
<div class="sourceCode" id="cb21"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/all_mut_tpm_not_filter.rds"</span>)</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="ot"><-</span> all_mut_exp <span class="sc">%>%</span> </span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,tpm_exp,neo,chr,position,gene) <span class="sc">%>%</span> </span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">rename</span>(<span class="at">exp=</span>tpm_exp)</span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="sc">%>%</span></span>
<span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(sample) <span class="sc">%>%</span></span>
<span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">n_a=</span><span class="fu">sum</span>(neo<span class="sc">==</span><span class="st">"not_neo"</span>),<span class="at">n_c=</span><span class="fu">sum</span>(neo<span class="sc">==</span><span class="st">"neo"</span>)) <span class="sc">%>%</span></span>
<span id="cb21-8"><a href="#cb21-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(n_a<span class="sc">>=</span><span class="dv">1</span>,n_c<span class="sc">>=</span><span class="dv">1</span>) <span class="ot">-></span> summ</span>
<span id="cb21-9"><a href="#cb21-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb21-10"><a href="#cb21-10" aria-hidden="true" tabindex="-1"></a>pancancer_mutation <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/pancancer_mutation.rds"</span>) <span class="sc">%>%</span> </span>
<span id="cb21-11"><a href="#cb21-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">index=</span><span class="fu">paste</span>(Sample_ID,chrom,start,<span class="at">sep =</span> <span class="st">":"</span>)) <span class="sc">%>%</span> </span>
<span id="cb21-12"><a href="#cb21-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(index,Amino_Acid_Change)</span>
<span id="cb21-13"><a href="#cb21-13" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="ot"><-</span> <span class="fu">left_join</span>(</span>
<span id="cb21-14"><a href="#cb21-14" aria-hidden="true" tabindex="-1"></a> all_mut_exp <span class="sc">%>%</span> <span class="fu">mutate</span>(<span class="at">index=</span><span class="fu">paste</span>(sample,chr,position,<span class="at">sep =</span> <span class="st">":"</span>)),</span>
<span id="cb21-15"><a href="#cb21-15" aria-hidden="true" tabindex="-1"></a> pancancer_mutation</span>
<span id="cb21-16"><a href="#cb21-16" aria-hidden="true" tabindex="-1"></a>)</span>
<span id="cb21-17"><a href="#cb21-17" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="ot"><-</span> all_mut_exp <span class="sc">%>%</span></span>
<span id="cb21-18"><a href="#cb21-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">gene_protein_change=</span><span class="fu">paste</span>(gene,Amino_Acid_Change,<span class="at">sep =</span> <span class="st">"-"</span>))</span>
<span id="cb21-19"><a href="#cb21-19" aria-hidden="true" tabindex="-1"></a>driver_mutations <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/driver_mutations.rds"</span>)</span>
<span id="cb21-20"><a href="#cb21-20" aria-hidden="true" tabindex="-1"></a>driver_mutations <span class="ot"><-</span> driver_mutations <span class="sc">%>%</span></span>
<span id="cb21-21"><a href="#cb21-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">gene_protein_change=</span><span class="fu">paste</span>(gene,protein_change,<span class="at">sep =</span> <span class="st">"-"</span>))</span>
<span id="cb21-22"><a href="#cb21-22" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb21-23"><a href="#cb21-23" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="ot"><-</span> all_mut_exp <span class="sc">%>%</span></span>
<span id="cb21-24"><a href="#cb21-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">is_driver=</span><span class="fu">ifelse</span>(gene_protein_change <span class="sc">%in%</span> driver_mutations<span class="sc">$</span>gene_protein_change,<span class="st">"yes"</span>,<span class="st">"no"</span>))</span>
<span id="cb21-25"><a href="#cb21-25" aria-hidden="true" tabindex="-1"></a><span class="fu">sum</span>(all_mut_exp<span class="sc">$</span>is_driver<span class="sc">==</span><span class="st">"yes"</span> <span class="sc">&</span> all_mut_exp<span class="sc">$</span>neo<span class="sc">==</span><span class="st">"neo"</span>) <span class="sc">/</span> <span class="fu">sum</span>(all_mut_exp<span class="sc">$</span>neo<span class="sc">==</span><span class="st">"neo"</span>)<span class="do">##0.004702473</span></span>
<span id="cb21-26"><a href="#cb21-26" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="sc">%>%</span> <span class="fu">group_by</span>(sample) <span class="sc">%>%</span></span>
<span id="cb21-27"><a href="#cb21-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">inter_gene=</span><span class="fu">intersect</span>(gene[neo<span class="sc">==</span><span class="st">"neo"</span>],</span>
<span id="cb21-28"><a href="#cb21-28" aria-hidden="true" tabindex="-1"></a> gene[is_driver<span class="sc">==</span><span class="st">"yes"</span>])) <span class="ot">-></span> aaa<span class="do">##778 samples</span></span>
<span id="cb21-29"><a href="#cb21-29" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="ot"><-</span> all_mut_exp <span class="sc">%>%</span></span>
<span id="cb21-30"><a href="#cb21-30" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">sample_neo_index=</span><span class="fu">paste</span>(sample,neo,gene,<span class="at">sep =</span> <span class="st">","</span>))</span>
<span id="cb21-31"><a href="#cb21-31" aria-hidden="true" tabindex="-1"></a>aaa <span class="ot"><-</span> aaa <span class="sc">%>%</span> <span class="fu">mutate</span>(<span class="at">sample_neo_index=</span><span class="fu">paste</span>(sample,<span class="st">"neo"</span>,inter_gene,<span class="at">sep =</span> <span class="st">","</span>))</span>
<span id="cb21-32"><a href="#cb21-32" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb21-33"><a href="#cb21-33" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="sc">%>%</span></span>
<span id="cb21-34"><a href="#cb21-34" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">in_aaa =</span> <span class="fu">ifelse</span>(sample_neo_index <span class="sc">%in%</span> aaa<span class="sc">$</span>sample_neo_index,<span class="st">"yes"</span>,<span class="st">"no"</span>)) <span class="sc">%>%</span></span>
<span id="cb21-35"><a href="#cb21-35" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(sample) <span class="sc">%>%</span></span>
<span id="cb21-36"><a href="#cb21-36" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">need_sample=</span><span class="fu">ifelse</span>(<span class="fu">any</span>(in_aaa<span class="sc">==</span><span class="st">"yes"</span>),<span class="st">"no"</span>,<span class="st">"yes"</span>)) <span class="sc">%>%</span></span>
<span id="cb21-37"><a href="#cb21-37" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(need_sample<span class="sc">==</span><span class="st">"no"</span>) <span class="ot">-></span> summ2</span>
<span id="cb21-38"><a href="#cb21-38" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb21-39"><a href="#cb21-39" aria-hidden="true" tabindex="-1"></a>neo_exp <span class="ot"><-</span> all_mut_exp <span class="sc">%>%</span> <span class="fu">filter</span>(sample <span class="sc">%in%</span> summ<span class="sc">$</span>sample) <span class="sc">%>%</span></span>
<span id="cb21-40"><a href="#cb21-40" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span>(sample <span class="sc">%in%</span> summ2<span class="sc">$</span>sample))</span>
<span id="cb21-41"><a href="#cb21-41" aria-hidden="true" tabindex="-1"></a>neo_exp <span class="ot"><-</span> neo_exp <span class="sc">%>%</span> </span>
<span id="cb21-42"><a href="#cb21-42" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,neo,exp)</span>
<span id="cb21-43"><a href="#cb21-43" aria-hidden="true" tabindex="-1"></a>cal_nes_warp <span class="ot"><-</span> <span class="cf">function</span>(dt){</span>
<span id="cb21-44"><a href="#cb21-44" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="at">length =</span> <span class="fu">length</span>(<span class="fu">unique</span>(dt<span class="sc">$</span>sample)))</span>
<span id="cb21-45"><a href="#cb21-45" aria-hidden="true" tabindex="-1"></a> <span class="fu">names</span>(results_ccf) <span class="ot"><-</span> <span class="fu">unique</span>(dt<span class="sc">$</span>sample)</span>
<span id="cb21-46"><a href="#cb21-46" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb21-47"><a href="#cb21-47" aria-hidden="true" tabindex="-1"></a> cl <span class="ot"><-</span> <span class="fu">makeCluster</span>(<span class="fu">getOption</span>(<span class="st">"cl.cores"</span>, <span class="dv">20</span>),<span class="at">type=</span><span class="st">"FORK"</span>)</span>
<span id="cb21-48"><a href="#cb21-48" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">parSapply</span>(<span class="at">cl=</span>cl,<span class="fu">names</span>(results_ccf),</span>
<span id="cb21-49"><a href="#cb21-49" aria-hidden="true" tabindex="-1"></a> <span class="cf">function</span>(x){</span>
<span id="cb21-50"><a href="#cb21-50" aria-hidden="true" tabindex="-1"></a> a <span class="ot"><-</span> NeoEnrichment<span class="sc">::</span><span class="fu">cales_t</span>(<span class="at">data =</span> dt,<span class="at">barcode =</span> x,<span class="at">type =</span> <span class="st">"II"</span>,</span>
<span id="cb21-51"><a href="#cb21-51" aria-hidden="true" tabindex="-1"></a> <span class="at">calp =</span> <span class="cn">TRUE</span>,<span class="at">sample_counts =</span> <span class="dv">1000</span>,</span>
<span id="cb21-52"><a href="#cb21-52" aria-hidden="true" tabindex="-1"></a> <span class="at">cal_type =</span> <span class="st">"exp"</span>)</span>
<span id="cb21-53"><a href="#cb21-53" aria-hidden="true" tabindex="-1"></a> <span class="co">#df <- data.frame(sample=x,es=a)</span></span>
<span id="cb21-54"><a href="#cb21-54" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(a)</span>
<span id="cb21-55"><a href="#cb21-55" aria-hidden="true" tabindex="-1"></a> },<span class="at">simplify =</span> <span class="cn">FALSE</span>)</span>
<span id="cb21-56"><a href="#cb21-56" aria-hidden="true" tabindex="-1"></a> <span class="fu">stopCluster</span>(cl)</span>
<span id="cb21-57"><a href="#cb21-57" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">Filter</span>(<span class="cf">function</span>(x){<span class="fu">length</span>(x)<span class="sc">></span><span class="dv">1</span>},results_ccf)</span>
<span id="cb21-58"><a href="#cb21-58" aria-hidden="true" tabindex="-1"></a> pancancer_nes_ccf <span class="ot"><-</span> <span class="fu">bind_rows</span>(results_ccf)</span>
<span id="cb21-59"><a href="#cb21-59" aria-hidden="true" tabindex="-1"></a> <span class="fu">return</span>(pancancer_nes_ccf)</span>
<span id="cb21-60"><a href="#cb21-60" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb21-61"><a href="#cb21-61" aria-hidden="true" tabindex="-1"></a>nes_exp <span class="ot"><-</span> <span class="fu">cal_nes_warp</span>(neo_exp)</span>
<span id="cb21-62"><a href="#cb21-62" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(nes_exp,<span class="at">file =</span> <span class="st">"../data/es_exp_filter_driver.rds"</span>)</span>
<span id="cb21-63"><a href="#cb21-63" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb21-64"><a href="#cb21-64" aria-hidden="true" tabindex="-1"></a>neo_exp <span class="ot"><-</span> all_mut_exp <span class="sc">%>%</span> <span class="fu">filter</span>(sample <span class="sc">%in%</span> summ<span class="sc">$</span>sample) <span class="sc">%>%</span> <span class="fu">select</span>(sample,neo,exp)</span>
<span id="cb21-65"><a href="#cb21-65" aria-hidden="true" tabindex="-1"></a>nes_exp <span class="ot"><-</span> <span class="fu">cal_nes_warp</span>(neo_exp)</span>
<span id="cb21-66"><a href="#cb21-66" aria-hidden="true" tabindex="-1"></a><span class="fu">saveRDS</span>(nes_exp,<span class="at">file =</span> <span class="st">"../data/es_exp_not_filter_driver.rds"</span>)</span>
<span id="cb21-67"><a href="#cb21-67" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb21-68"><a href="#cb21-68" aria-hidden="true" tabindex="-1"></a><span class="do">##sim</span></span>
<span id="cb21-69"><a href="#cb21-69" aria-hidden="true" tabindex="-1"></a>neo_nes <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/es_exp_not_filter_driver.rds"</span>)</span>
<span id="cb21-70"><a href="#cb21-70" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="ot"><-</span> <span class="fu">readRDS</span>(<span class="st">"../data/all_mut_tpm_not_filter.rds"</span>)</span>
<span id="cb21-71"><a href="#cb21-71" aria-hidden="true" tabindex="-1"></a>all_mut_exp <span class="ot"><-</span> all_mut_exp <span class="sc">%>%</span> </span>
<span id="cb21-72"><a href="#cb21-72" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(sample,tpm_exp,neo) <span class="sc">%>%</span> </span>
<span id="cb21-73"><a href="#cb21-73" aria-hidden="true" tabindex="-1"></a> <span class="fu">rename</span>(<span class="at">exp=</span>tpm_exp)</span>
<span id="cb21-74"><a href="#cb21-74" aria-hidden="true" tabindex="-1"></a>neo_missense <span class="ot"><-</span> all_mut_exp <span class="sc">%>%</span> <span class="fu">filter</span>(sample <span class="sc">%in%</span> neo_nes<span class="sc">$</span>sample)</span>
<span id="cb21-75"><a href="#cb21-75" aria-hidden="true" tabindex="-1"></a>neo_missense <span class="ot"><-</span> neo_missense <span class="sc">%>%</span> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(exp))</span>
<span id="cb21-76"><a href="#cb21-76" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb21-77"><a href="#cb21-77" aria-hidden="true" tabindex="-1"></a>cal_nes_warp <span class="ot"><-</span> <span class="cf">function</span>(dt){</span>
<span id="cb21-78"><a href="#cb21-78" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">vector</span>(<span class="st">"list"</span>,<span class="at">length =</span> <span class="fu">length</span>(<span class="fu">unique</span>(dt<span class="sc">$</span>sample)))</span>
<span id="cb21-79"><a href="#cb21-79" aria-hidden="true" tabindex="-1"></a> <span class="fu">names</span>(results_ccf) <span class="ot"><-</span> <span class="fu">unique</span>(dt<span class="sc">$</span>sample)</span>
<span id="cb21-80"><a href="#cb21-80" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb21-81"><a href="#cb21-81" aria-hidden="true" tabindex="-1"></a> cl <span class="ot"><-</span> <span class="fu">makeCluster</span>(<span class="fu">getOption</span>(<span class="st">"cl.cores"</span>, <span class="dv">40</span>),<span class="at">type=</span><span class="st">"FORK"</span>)</span>
<span id="cb21-82"><a href="#cb21-82" aria-hidden="true" tabindex="-1"></a> results_ccf <span class="ot"><-</span> <span class="fu">parSapply</span>(<span class="at">cl=</span>cl,<span class="fu">names</span>(results_ccf),</span>
<span id="cb21-83"><a href="#cb21-83" aria-hidden="true" tabindex="-1"></a> <span class="cf">function</span>(x){</span>
<span id="cb21-84"><a href="#cb21-84" aria-hidden="true" tabindex="-1"></a> a <span class="ot"><-</span> NeoEnrichment<span class="sc">::</span><span class="fu">cales_t</span>(<span class="at">data =</span> dt,<span class="at">barcode =</span> x,<span class="at">type =</span> <span class="st">"II"</span>,</span>
<span id="cb21-85"><a href="#cb21-85" aria-hidden="true" tabindex="-1"></a> <span class="at">calp =</span> <span class="cn">FALSE</span>,<span class="at">sample_counts =</span> <span class="dv">1000</span>,</span>
<span id="cb21-86"><a href="#cb21-86" aria-hidden="true" tabindex="-1"></a> <span class="at">cal_type =</span> <span class="st">"exp"</span>)</span>
<span id="cb21-87"><a href="#cb21-87" aria-hidden="true" tabindex="-1"></a> df <span class="ot"><-</span> <span class="fu">data.frame</span>(<span class="at">sample=</span>x,<span class="at">es=</span>a)</span>