-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSelecting_GRM_with_Lheuristic.html
More file actions
1771 lines (1743 loc) · 134 KB
/
Selecting_GRM_with_Lheuristic.html
File metadata and controls
1771 lines (1743 loc) · 134 KB
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" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.2.335">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="dcterms.date" content="2023-04-21">
<title>Selection of L-shaped genes using a heuristic algorithm</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
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;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script src="Selecting_GRM_with_Lheuristic_files/libs/clipboard/clipboard.min.js"></script>
<script src="Selecting_GRM_with_Lheuristic_files/libs/quarto-html/quarto.js"></script>
<script src="Selecting_GRM_with_Lheuristic_files/libs/quarto-html/popper.min.js"></script>
<script src="Selecting_GRM_with_Lheuristic_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="Selecting_GRM_with_Lheuristic_files/libs/quarto-html/anchor.min.js"></script>
<link href="Selecting_GRM_with_Lheuristic_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="Selecting_GRM_with_Lheuristic_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="Selecting_GRM_with_Lheuristic_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="Selecting_GRM_with_Lheuristic_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="Selecting_GRM_with_Lheuristic_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script async="" src="https://hypothes.is/embed.js"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
</head>
<body>
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#introduction" id="toc-introduction" class="nav-link active" data-scroll-target="#introduction">Introduction</a>
<ul class="collapse">
<li><a href="#basic-pipeline" id="toc-basic-pipeline" class="nav-link" data-scroll-target="#basic-pipeline">Basic pipeline</a></li>
</ul></li>
<li><a href="#the-data-for-the-analysis" id="toc-the-data-for-the-analysis" class="nav-link" data-scroll-target="#the-data-for-the-analysis">The data for the analysis</a>
<ul class="collapse">
<li><a href="#real-datasets" id="toc-real-datasets" class="nav-link" data-scroll-target="#real-datasets">Real datasets</a>
<ul class="collapse">
<li><a href="#gene-zbtb18" id="toc-gene-zbtb18" class="nav-link" data-scroll-target="#gene-zbtb18">Gene ZBTB18</a></li>
</ul></li>
<li><a href="#artificial-true-and-false-l-shaped-genes" id="toc-artificial-true-and-false-l-shaped-genes" class="nav-link" data-scroll-target="#artificial-true-and-false-l-shaped-genes">Artificial TRUE and FALSE L-shaped genes</a>
<ul class="collapse">
<li><a href="#genes-extracted-from-da-dataset" id="toc-genes-extracted-from-da-dataset" class="nav-link" data-scroll-target="#genes-extracted-from-da-dataset">Genes extracted from DA dataset</a></li>
<li><a href="#geos-true-and-false-l-shaped-genes-list" id="toc-geos-true-and-false-l-shaped-genes-list" class="nav-link" data-scroll-target="#geos-true-and-false-l-shaped-genes-list">GEO’s TRUE and FALSE L-shaped genes list</a></li>
</ul></li>
</ul></li>
<li><a href="#scoring-scatterplots" id="toc-scoring-scatterplots" class="nav-link" data-scroll-target="#scoring-scatterplots">Scoring scatterplots</a>
<ul class="collapse">
<li><a href="#the-three-band-rule" id="toc-the-three-band-rule" class="nav-link" data-scroll-target="#the-three-band-rule">The “three band rule”</a></li>
<li><a href="#computing-on-a-grid" id="toc-computing-on-a-grid" class="nav-link" data-scroll-target="#computing-on-a-grid">Computing on a grid</a></li>
<li><a href="#examples" id="toc-examples" class="nav-link" data-scroll-target="#examples">Examples</a>
<ul class="collapse">
<li><a href="#scoring-the-truefalse-da-dataset" id="toc-scoring-the-truefalse-da-dataset" class="nav-link" data-scroll-target="#scoring-the-truefalse-da-dataset">Scoring the TRUE/FALSE DA dataset</a></li>
</ul></li>
</ul></li>
<li><a href="#putting-all-together-selecting-l-shaped-genes" id="toc-putting-all-together-selecting-l-shaped-genes" class="nav-link" data-scroll-target="#putting-all-together-selecting-l-shaped-genes">Putting all together: Selecting L-shaped genes</a>
<ul class="collapse">
<li><a href="#parameters-selection" id="toc-parameters-selection" class="nav-link" data-scroll-target="#parameters-selection">Parameters selection</a>
<ul class="collapse">
<li><a href="#parameters-for-da-and-geo-datasets-small-samples" id="toc-parameters-for-da-and-geo-datasets-small-samples" class="nav-link" data-scroll-target="#parameters-for-da-and-geo-datasets-small-samples">Parameters for DA and GEO datasets (small samples)</a></li>
<li><a href="#parameters-for-tcga-datasets-big-samples" id="toc-parameters-for-tcga-datasets-big-samples" class="nav-link" data-scroll-target="#parameters-for-tcga-datasets-big-samples">Parameters for TCGA datasets (big samples)</a></li>
</ul></li>
<li><a href="#scoring-datasets" id="toc-scoring-datasets" class="nav-link" data-scroll-target="#scoring-datasets">Scoring datasets</a></li>
</ul></li>
<li><a href="#references" id="toc-references" class="nav-link" data-scroll-target="#references">References</a></li>
</ul>
</nav>
</div>
<main class="content page-columns page-full" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Selection of L-shaped genes using a heuristic algorithm</h1>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Authors</div>
<div class="quarto-title-meta-contents">
<p>Sánchez-Pla, Alex<span class="math inline">\(^{1,3}\)</span>, </p>
<p>Miró, Berta<span class="math inline">\(^3\)</span>, </p>
<p>Carmona, Francesc<span class="math inline">\(^1\)</span>, </p>
<p>Bazzoco, Sara<span class="math inline">\(^2\)</span>, </p>
<p>Arango, Diego<span class="math inline">\(^2\)</span> </p>
</div>
</div>
<div>
<div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents">
<p class="date">April 21, 2023</p>
</div>
</div>
</div>
</header>
<!-- ```{r include=FALSE} -->
<!-- require(Hmisc) -->
<!-- options(qproject='rms', prType='html') -->
<!-- getRs('reptools.r') -->
<!-- getRs('qbookfun.r') -->
<!-- hookaddcap() -->
<!-- knitr::set_alias(w = 'fig.width', h = 'fig.height', cap = 'fig.cap', scap ='fig.scap') -->
<!-- ``` -->
<section id="introduction" class="level1">
<h1>Introduction</h1>
<p>This document contains examples on how to select genes potentially regulated by methylation and characterized by an L-shaped scatterplot using an heuristic algorithm, implemented in the R <code>Lheuristic</code>package.</p>
<p>The idea is to “keep-it-simple” so it can teach potentially users on how to select L-shaped genes started from a pair of matrices, an expression and a methylation matrix, matched by rows (genes) and columns (individuals).</p>
<p>A graphical user interface based in Shiny is also available to use the package.</p>
<section id="basic-pipeline" class="level2">
<h2 class="anchored" data-anchor-id="basic-pipeline">Basic pipeline</h2>
<p>The basic steps for selecting L-shaped genes using the package is as follows:</p>
<ol type="1">
<li>Input data</li>
</ol>
<ul>
<li>Select/Load expression values from a csv file.</li>
<li>Select/Load methylation values from a csv file.</li>
</ul>
<ol start="2" type="1">
<li>Prepare data for the analysis</li>
</ol>
<ul>
<li>Preprocess and normalize each dataset separately as required by the technology used.</li>
<li>Format both datasets so taht they match by row names and colum names.</li>
</ul>
<ol start="3" type="1">
<li>Set parameter values</li>
</ol>
<ul>
<li>For data use. For instance keep only those genes that pass certain filters such as showing negative correlation between expression and methylation.</li>
<li>For L-shape selection method
<ul>
<li>Select the methods to be used (naive, negative correlation or L-shape) and the parameters to apply each method.</li>
</ul></li>
</ul>
<ol start="4" type="1">
<li>Process data</li>
</ol>
<ul>
<li>Run the computation and call genes as TRUE or FALSE L-shapes,.</li>
<li>Draw the scatterplots of either all genes or only selected genes</li>
<li>Compare the output of naive and L-shape methods.</li>
</ul>
<ol start="5" type="1">
<li>Data output (For each method and set of parameters …)</li>
</ol>
<ul>
<li>Save (Download) the resulting gene list(s)</li>
<li>Save (Download) the scatterplots</li>
</ul>
<div class="cell">
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> (<span class="sc">!</span>(<span class="fu">require</span>(VennDiagram))) <span class="fu">install.packages</span>(<span class="st">"VennDiagram"</span>)</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span> (<span class="sc">!</span>(<span class="fu">require</span>(org.Hs.eg.db)))</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> biocManager<span class="sc">::</span><span class="fu">install</span>(<span class="st">"org.Hs.eg.db"</span>)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span>(<span class="sc">!</span>(<span class="fu">require</span>(Lheuristic)))</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> devtools<span class="sc">::</span><span class="fu">install_github</span>(<span class="st">"aspresearch/Lheuristic"</span>, <span class="at">force=</span><span class="cn">TRUE</span>)</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(Lheuristic)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
</section>
<section id="the-data-for-the-analysis" class="level1 page-columns page-full">
<h1>The data for the analysis</h1>
<section id="real-datasets" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="real-datasets">Real datasets</h2>
<p>There are several datasets available for analysis obtained from distinct sources:</p>
<div class="page-columns page-full"><p></p><div class="no-row-height column-margin column-container"><span class="">Add reference to sources in the bibliography</span></div></div>
<ol type="1">
<li>DA1. Expression microarrays (<code>DAMicroarrays.csv</code>) and methylation array (<code>DAMetilacion.csv</code>) on 25 cell llines.</li>
<li>DA2. Expression RNAseq (<code>DARNAseq.csv</code>) and methylation array (<code>DAMetilacion.csv</code>) on 25 cell llines.</li>
<li>GEO1. Expression microarrays (Illumina beadchips, <code>geoMicroarrays.csv</code>) and methylation array (Illumina 25kMethArray, <code>geoMetilacion.csv</code>) on 25 CRC samples. The data have been collected from the GEO database records: GSE25062 for the methylation data and GSE25070 for the expression data. The dataset has been created by taking the expression values available for 26 CRC tumors and matching with their corresponding methylation values.</li>
<li><code>TCGA</code> dataset has been obtained from The Cancer Genome Atlas Database (TCGA) (Colon Adenocarcinoma (<code>COAD</code>) Nature 2012 dataset) and downloaded through the cBioportal website.</li>
</ol>
<p>A summary of each datasets follows below:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="fu">require</span>(printr)</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>DAExprData <span class="ot"><-</span> <span class="fu">as.matrix</span>(<span class="fu">read.table</span>(<span class="at">file=</span><span class="fu">file.path</span>(dadesDir,<span class="st">"DatosMicroarrays.csv"</span>), <span class="at">header=</span><span class="cn">TRUE</span>, <span class="at">sep=</span><span class="st">";"</span>, <span class="at">dec=</span><span class="st">","</span>, <span class="at">row.names =</span> <span class="dv">1</span>))</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a>DAMetilData <span class="ot"><-</span> <span class="fu">as.matrix</span>(<span class="fu">read.table</span>(<span class="at">file=</span><span class="fu">file.path</span>(dadesDir,<span class="st">"DatosMetilacion.csv"</span>), <span class="at">header=</span><span class="cn">TRUE</span>, <span class="at">sep=</span><span class="st">";"</span>,<span class="at">dec=</span><span class="st">","</span>, <span class="at">row.names =</span> <span class="dv">1</span>))</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a><span class="co">#DARNAseqData <- as.matrix(read.table(file=file.path(dadesDir,"DatosRNAseq.csv"), header=TRUE, sep=";",dec=",", row.names = 1))</span></span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span>(<span class="st">"DA Microarray data : "</span>, <span class="fu">dim</span>(DAExprData), <span class="st">"</span><span class="sc">\n</span><span class="st">"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>DA Microarray data : 11359 30 </code></pre>
</div>
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span>(<span class="st">"DA Methylation data: "</span>, <span class="fu">dim</span>(DAMetilData), <span class="st">"</span><span class="sc">\n</span><span class="st">"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>DA Methylation data: 11359 30 </code></pre>
</div>
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co"># cat("DA RNASeq data : ", dim(DARNAseqData), "\n")</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a><span class="fu">save</span>(DAExprData, DAMetilData, <span class="at">file=</span><span class="st">"dades/DataMatrices-DA.Rda"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>geoExprData <span class="ot"><-</span> <span class="fu">as.matrix</span>(<span class="fu">read.table</span>(<span class="at">file=</span><span class="fu">file.path</span>(dadesDir,<span class="st">"GEOExpData.csv"</span>), <span class="at">header=</span><span class="cn">TRUE</span>, <span class="at">sep=</span><span class="st">";"</span>, <span class="at">dec=</span><span class="st">"."</span>))</span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>geoMetilData <span class="ot"><-</span> <span class="fu">as.matrix</span>(<span class="fu">read.table</span>(<span class="at">file=</span><span class="fu">file.path</span>(dadesDir,<span class="st">"GEOMethData.csv"</span>), <span class="at">header=</span><span class="cn">TRUE</span>, <span class="at">sep=</span><span class="st">";"</span>, <span class="at">dec=</span><span class="st">"."</span>))</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span>(<span class="st">"GEO Microarray data : "</span>, <span class="fu">dim</span>(geoExprData), <span class="st">"</span><span class="sc">\n</span><span class="st">"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>GEO Microarray data : 11191 25 </code></pre>
</div>
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span>(<span class="st">"GEO Methylation data: "</span>, <span class="fu">dim</span>(geoMetilData), <span class="st">"</span><span class="sc">\n</span><span class="st">"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>GEO Methylation data: 11191 25 </code></pre>
</div>
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a><span class="fu">save</span>(geoExprData, geoMetilData, <span class="at">file=</span><span class="st">"dades/DataMatrices-GEO.Rda"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a>TCGAExprData <span class="ot"><-</span> <span class="fu">as.matrix</span>(<span class="fu">read.table</span>(<span class="at">file=</span><span class="fu">file.path</span>(dadesDir,<span class="st">"TCGA-cBioPortal-Expressions.csv"</span>), <span class="at">header=</span><span class="cn">TRUE</span>, <span class="at">sep=</span><span class="st">","</span>, <span class="at">dec=</span><span class="st">"."</span>, <span class="at">row.names=</span><span class="dv">1</span>))</span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>TCGAMetilData <span class="ot"><-</span> <span class="fu">as.matrix</span>(<span class="fu">read.csv</span>(<span class="at">file=</span><span class="fu">file.path</span>(dadesDir,<span class="st">"TCGA-cBioPortal-Methylations.csv"</span>), <span class="at">header=</span><span class="cn">TRUE</span>, <span class="at">sep=</span><span class="st">","</span>, <span class="at">dec=</span><span class="st">"."</span>, <span class="at">row.names=</span><span class="dv">1</span>))</span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span>(<span class="st">"TCGA Microarray data : "</span>, <span class="fu">dim</span>(TCGAExprData), <span class="st">"</span><span class="sc">\n</span><span class="st">"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>TCGA Microarray data : 11788 223 </code></pre>
</div>
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="fu">cat</span>(<span class="st">"TCGA Methylation data: "</span>, <span class="fu">dim</span>(TCGAMetilData), <span class="st">"</span><span class="sc">\n</span><span class="st">"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>TCGA Methylation data: 11788 223 </code></pre>
</div>
<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="fu">save</span>(TCGAExprData, TCGAMetilData, <span class="at">file=</span><span class="st">"dades/DataMatrices-TCGA.Rda"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>inCommon<span class="ot"><-</span> <span class="fu">length</span>(<span class="fu">intersect</span>(<span class="fu">rownames</span>(DAExprData), <span class="fu">rownames</span>(geoExprData)))</span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a>inCommon2 <span class="ot"><-</span> <span class="fu">length</span>(<span class="fu">intersect</span>(<span class="fu">rownames</span>(DAExprData), <span class="fu">rownames</span>(TCGAExprData)))</span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a>inCommon3 <span class="ot"><-</span> <span class="fu">length</span>(<span class="fu">intersect</span>(<span class="fu">rownames</span>(geoExprData), <span class="fu">rownames</span>(TCGAExprData)))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>There are genes in common between the DAX dataset and the GEO datasets. There are common genes between the DAX dataset and the TCGA dataset and common genes between the GEO dataset and the TCGA dataset.</p>
<p>This can be visualized using a Venn diagram</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a>myVenn4<span class="ot"><-</span> <span class="fu">venn.diagram</span>(<span class="at">x=</span><span class="fu">list</span>(<span class="at">DA=</span><span class="fu">rownames</span>(DAExprData),</span>
<span id="cb18-2"><a href="#cb18-2" aria-hidden="true" tabindex="-1"></a> <span class="at">GEO=</span><span class="fu">rownames</span>(geoExprData),</span>
<span id="cb18-3"><a href="#cb18-3" aria-hidden="true" tabindex="-1"></a> <span class="at">TCGA=</span><span class="fu">rownames</span>(TCGAExprData)),</span>
<span id="cb18-4"><a href="#cb18-4" aria-hidden="true" tabindex="-1"></a> <span class="at">filename=</span><span class="cn">NULL</span>, <span class="at">lty =</span> <span class="st">"blank"</span>,</span>
<span id="cb18-5"><a href="#cb18-5" aria-hidden="true" tabindex="-1"></a> <span class="at">fill=</span><span class="fu">c</span>(<span class="st">"pink1"</span>, <span class="st">"skyblue"</span>, <span class="st">"mediumorchid"</span>),</span>
<span id="cb18-6"><a href="#cb18-6" aria-hidden="true" tabindex="-1"></a> <span class="at">main=</span><span class="st">"Genes in common between the three datasets"</span>)</span>
<span id="cb18-7"><a href="#cb18-7" aria-hidden="true" tabindex="-1"></a><span class="fu">grid.newpage</span>()</span>
<span id="cb18-8"><a href="#cb18-8" aria-hidden="true" tabindex="-1"></a><span class="fu">grid.draw</span>(myVenn4)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<p><img src="Selecting_GRM_with_Lheuristic_files/figure-html/vennCommonGenesin3lists-1.png" class="img-fluid" width="768"></p>
</div>
</div>
<p>The data for these analyses must have a common structure: <strong>Each pair of matrices (Expression-Methylation) must have the same rome and column names</strong>, that is both datasets must contain information for the same genes and same samples at their corresponding positions.</p>
<p>This can be checked using a simple function such as <code>checkData</code> available in the package.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="fu">try</span>(<span class="cf">if</span>(<span class="sc">!</span><span class="fu">checkPairing</span>(DAExprData, DAMetilData)) <span class="fu">stop</span>(<span class="st">"Row names and/or column names do not match"</span>))</span>
<span id="cb19-2"><a href="#cb19-2" aria-hidden="true" tabindex="-1"></a><span class="fu">try</span>(<span class="cf">if</span>(<span class="sc">!</span><span class="fu">checkPairing</span>(geoExprData, geoMetilData)) <span class="fu">stop</span>(<span class="st">"Row names and/or column names do not match"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>When one is studying the relation between methylation and expression for a bunch of genes it may be convenient to (be able) to plot the scatterplots depicting the relation between these variables. Function <code>plotGenesMat</code> allows to draw such plots.</p>
<p>Some examples of using this function with the first four genes of the TCGA dataset are shown below.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>selectedGenes <span class="ot"><-</span> <span class="fu">c</span>(<span class="st">"ALDH1A2"</span>, <span class="st">"ALDH1A3"</span>, <span class="st">"APCDD1"</span>, <span class="st">"ARHGDIB"</span>)</span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a>opt<span class="ot"><-</span> <span class="fu">par</span>(<span class="at">mfrow=</span><span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plotGenesMat</span> (<span class="at">mets=</span>DAMetilData[selectedGenes, ],</span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a> <span class="at">expres=</span>DAExprData[selectedGenes,], <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a> <span class="at">percY1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a> <span class="at">fileName=</span><span class="cn">NULL</span>, <span class="at">plotGrid =</span> <span class="cn">TRUE</span>)</span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a><span class="fu">par</span>(opt)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Selecting_GRM_with_Lheuristic_files/figure-html/plot4Genes1-1.png" class="img-fluid figure-img" width="768"></p>
<p></p><figcaption class="figure-caption">Scatter plot of first four genes in DA dataset (microarrays)</figcaption><p></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb21"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb21-1"><a href="#cb21-1" aria-hidden="true" tabindex="-1"></a>selectedGenes <span class="ot"><-</span> <span class="fu">c</span>(<span class="st">"ALDH1A2"</span>, <span class="st">"ALDH1A3"</span>, <span class="st">"APCDD1"</span>, <span class="st">"ARHGDIB"</span>)</span>
<span id="cb21-2"><a href="#cb21-2" aria-hidden="true" tabindex="-1"></a>opt<span class="ot"><-</span> <span class="fu">par</span>(<span class="at">mfrow=</span><span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
<span id="cb21-3"><a href="#cb21-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plotGenesMat</span> (<span class="at">mets=</span>geoMetilData[selectedGenes,],</span>
<span id="cb21-4"><a href="#cb21-4" aria-hidden="true" tabindex="-1"></a> <span class="at">expres=</span>geoExprData[selectedGenes,],</span>
<span id="cb21-5"><a href="#cb21-5" aria-hidden="true" tabindex="-1"></a> <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb21-6"><a href="#cb21-6" aria-hidden="true" tabindex="-1"></a> <span class="at">fileName=</span><span class="cn">NULL</span>, <span class="at">plotGrid =</span> <span class="cn">TRUE</span>)</span>
<span id="cb21-7"><a href="#cb21-7" aria-hidden="true" tabindex="-1"></a><span class="fu">par</span>(opt)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Selecting_GRM_with_Lheuristic_files/figure-html/plot4Genes3-1.png" class="img-fluid figure-img" width="768"></p>
<p></p><figcaption class="figure-caption">Scatter plot of first four genes in GEO dataset (microarrays)</figcaption><p></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>selectedGenes <span class="ot"><-</span> <span class="fu">c</span>(<span class="st">"ALDH1A2"</span>, <span class="st">"ALDH1A3"</span>, <span class="st">"APCDD1"</span>, <span class="st">"ARHGDIB"</span>)</span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a>opt<span class="ot"><-</span> <span class="fu">par</span>(<span class="at">mfrow=</span><span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a><span class="fu">plotGenesMat</span> (<span class="at">mets=</span>TCGAMetilData[selectedGenes,],</span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a> <span class="at">expres=</span>TCGAExprData[selectedGenes,],</span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a> <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a> <span class="at">fileName=</span><span class="cn">NULL</span>, <span class="at">plotGrid =</span> <span class="cn">TRUE</span>)</span>
<span id="cb22-7"><a href="#cb22-7" aria-hidden="true" tabindex="-1"></a><span class="fu">par</span>(opt)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Selecting_GRM_with_Lheuristic_files/figure-html/plot4Genes4-1.png" class="img-fluid figure-img" width="768"></p>
<p></p><figcaption class="figure-caption">Scatter plot of first four genes in TCGA dataset (microarrays)</figcaption><p></p>
</figure>
</div>
</div>
</div>
<p>Looking at the figuresabove shows that although the genes may behave similarly between datasets methods for selecting GRM must be robust and adaptable to for eample distinct sample sizes.</p>
<section id="gene-zbtb18" class="level3">
<h3 class="anchored" data-anchor-id="gene-zbtb18">Gene ZBTB18</h3>
<p>Figure <strong>?@sec-plotZBTB18</strong> shows how the scatterplot looks like for a gene that has been described bu the researchers as regulated by methylation</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="co">#selectedGenes <- c("A1BG","A2ML1", "A4GALT", "AAAS" )</span></span>
<span id="cb23-2"><a href="#cb23-2" aria-hidden="true" tabindex="-1"></a>selectedGene <span class="ot"><-</span> <span class="fu">c</span>(<span class="st">"ZBTB18"</span>, <span class="st">"ZBTB18"</span>)</span>
<span id="cb23-3"><a href="#cb23-3" aria-hidden="true" tabindex="-1"></a>opt<span class="ot"><-</span> <span class="fu">par</span>(<span class="at">mfrow=</span><span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
<span id="cb23-4"><a href="#cb23-4" aria-hidden="true" tabindex="-1"></a><span class="fu">plotGenesMat</span> (<span class="at">mets=</span>DAMetilData[selectedGene, ],</span>
<span id="cb23-5"><a href="#cb23-5" aria-hidden="true" tabindex="-1"></a> <span class="at">expres=</span>DAExprData[selectedGene,], <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb23-6"><a href="#cb23-6" aria-hidden="true" tabindex="-1"></a> <span class="at">percY1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb23-7"><a href="#cb23-7" aria-hidden="true" tabindex="-1"></a> <span class="at">fileName=</span><span class="cn">NULL</span>, <span class="at">plotGrid =</span> <span class="cn">TRUE</span>)</span>
<span id="cb23-8"><a href="#cb23-8" aria-hidden="true" tabindex="-1"></a><span class="fu">abline</span>( <span class="fu">lm</span>(DAExprData[<span class="st">"ZBTB18"</span>,]<span class="sc">~</span> DAMetilData[<span class="st">"ZBTB18"</span>, ]))</span>
<span id="cb23-9"><a href="#cb23-9" aria-hidden="true" tabindex="-1"></a><span class="fu">plotGenesMat</span> (<span class="at">mets=</span>DAMetilData[selectedGene, ],</span>
<span id="cb23-10"><a href="#cb23-10" aria-hidden="true" tabindex="-1"></a> <span class="at">expres=</span>DAExprData[selectedGene,], <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb23-11"><a href="#cb23-11" aria-hidden="true" tabindex="-1"></a> <span class="at">percY1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">2</span>, <span class="at">percY2=</span><span class="dv">3</span><span class="sc">/</span><span class="dv">4</span>,</span>
<span id="cb23-12"><a href="#cb23-12" aria-hidden="true" tabindex="-1"></a> <span class="at">fileName=</span><span class="cn">NULL</span>, <span class="at">plotGrid =</span> <span class="cn">TRUE</span>)</span>
<span id="cb23-13"><a href="#cb23-13" aria-hidden="true" tabindex="-1"></a><span class="fu">abline</span>( <span class="fu">lm</span>(DAExprData[<span class="st">"ZBTB18"</span>,]<span class="sc">~</span> DAMetilData[<span class="st">"ZBTB18"</span>, ]))</span>
<span id="cb23-14"><a href="#cb23-14" aria-hidden="true" tabindex="-1"></a><span class="fu">par</span>(opt)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Selecting_GRM_with_Lheuristic_files/figure-html/plotZBTB18-1.png" class="img-fluid figure-img" width="768"></p>
<p></p><figcaption class="figure-caption">Scatter plot of gene ZBTB18. It seems clear that this gene will be selected by a method that selects genes negatively correlated rather than <em>L-shaped</em>, although the grid could be adequately tuned for selecting it as shown in the plot.</figcaption><p></p>
</figure>
</div>
</div>
</div>
</section>
</section>
<section id="artificial-true-and-false-l-shaped-genes" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="artificial-true-and-false-l-shaped-genes">Artificial TRUE and FALSE L-shaped genes</h2>
<section id="genes-extracted-from-da-dataset" class="level3 page-columns page-full">
<h3 class="anchored" data-anchor-id="genes-extracted-from-da-dataset">Genes extracted from DA dataset</h3>
<div class="page-columns page-full"><p>Two small sets of genes<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a> have been compiled with genes that were clearly L-shaped or clearly non-L-Shaped. Because these sets have been prepared arbitrarily we decide not to use them as “TRUE POSITIVE” and “TRUE NEGATIVES” except for illustrative purposes.</p><div class="no-row-height column-margin column-container"><li id="fn1"><p><sup>1</sup> TRUE and FALSE genes from the original dataset ” DA” have been obtained by doing an extensive sampling on the original dataset and selecting genes that <em>seemed</em> to have an L-shape and those that did not</p></li></div></div>
<div class="cell">
<div class="sourceCode cell-code" id="cb24"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb24-1"><a href="#cb24-1" aria-hidden="true" tabindex="-1"></a><span class="do">## Genes True i False</span></span>
<span id="cb24-2"><a href="#cb24-2" aria-hidden="true" tabindex="-1"></a>trueLGeneDF <span class="ot"><-</span><span class="fu">read.table</span>(<span class="fu">file.path</span>(dadesDir, <span class="st">"genesTrueLNEW.txt"</span>))</span>
<span id="cb24-3"><a href="#cb24-3" aria-hidden="true" tabindex="-1"></a>(trueLGeneNames <span class="ot"><-</span> <span class="fu">as.character</span>(trueLGeneDF[,<span class="dv">1</span>]))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code> [1] "ABCG2" "ADH6" "AKR1C4" "BCL11B" "CA9"
[6] "CCR6" "CST7" "CX3CL1" "DAPP1" "CYP27A1"
[11] "ELAVL2" "FAM84A" "GREM1" "HSD17B2" "INHBB"
[16] "KCNV1" "LHFP" "MEP1A" "LRP2" "MAGEE1"
[21] "MEP1A" "MYT1" "NOX1" "OAS2" "PHYHIPL"
[26] "POF1B" "POPDC3" "PRDM16" "PRDM5" "QPCT"
[31] "RASGRF2" "RAB6B" "RASEF" "RNF186" "SOX2"
[36] "SOSTDC1" "SPON1" "ST6GALNAC1" "STEAP4" "STK33"
[41] "TAPBPL" "SYN2" "THRB" "TRAM1L1" "WNK4" </code></pre>
</div>
<div class="sourceCode cell-code" id="cb26"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb26-1"><a href="#cb26-1" aria-hidden="true" tabindex="-1"></a>falseLGeneDF <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="fu">file.path</span>(dadesDir, <span class="st">"genesFalseLNEW.txt"</span>))</span>
<span id="cb26-2"><a href="#cb26-2" aria-hidden="true" tabindex="-1"></a>(falseLGeneNames <span class="ot"><-</span> <span class="fu">as.character</span>(falseLGeneDF[,<span class="dv">1</span>]))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code> [1] "ACOX2" "ADA" "AKR1B1" "ALDH1A3" "AMT" "ANXA3"
[7] "ARHGAP4" "ARL14" "ATP6AP2" "AUTS2" "BHLHB9" "BMP7"
[13] "C19orf33" "C1QTNF6" "CAB39L" "CDH17" "CDX1" "CFTR"
[19] "CIDEB" "CMTM3" "DNAJA4" "DUSP9" "ELF3" "ELMO3"
[25] "FBP1" "FGD4" "FKBP10" "FOXC1" "FUCA2" "GNG4"
[31] "GPRC5A" "GRAMD3" "H1F0" "HIST1H2BH" "HNMT" "HOOK1"
[37] "HOOK3" "HOXB3" "HOXB2" "HOXB5" "HS3ST1" "LCMT2"
[43] "LAMA3" "LDHB" </code></pre>
</div>
<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a>trueLExpr <span class="ot"><-</span> DAExprData[<span class="fu">rownames</span>(DAExprData) <span class="sc">%in%</span> trueLGeneNames ,]</span>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a>falseLExpr <span class="ot"><-</span> DAExprData[<span class="fu">rownames</span>(DAExprData) <span class="sc">%in%</span> falseLGeneNames ,]</span>
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a>trueLMet <span class="ot"><-</span> DAMetilData[<span class="fu">rownames</span>(DAMetilData) <span class="sc">%in%</span> trueLGeneNames ,]</span>
<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a>falseLMet <span class="ot"><-</span> DAMetilData[<span class="fu">rownames</span>(DAMetilData) <span class="sc">%in%</span> falseLGeneNames ,]</span>
<span id="cb28-5"><a href="#cb28-5" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span>(<span class="sc">!</span>(<span class="fu">file.exists</span>(<span class="st">"DATrueLExpression.csv"</span>)))</span>
<span id="cb28-6"><a href="#cb28-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">write.table</span>(trueLExpr, <span class="fu">file.path</span>(dadesDir, <span class="st">"DATrueLExpression.csv"</span>),</span>
<span id="cb28-7"><a href="#cb28-7" aria-hidden="true" tabindex="-1"></a> <span class="at">sep=</span><span class="st">";"</span>, <span class="at">dec=</span><span class="st">"."</span>, <span class="at">quote=</span><span class="cn">FALSE</span>)</span>
<span id="cb28-8"><a href="#cb28-8" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span>(<span class="sc">!</span>(<span class="fu">file.exists</span>(<span class="st">"DATrueLMetilacion.csv"</span>)))</span>
<span id="cb28-9"><a href="#cb28-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">write.table</span>(trueLMet, <span class="fu">file.path</span>(dadesDir, <span class="st">"DATrueLMetilacion.csv"</span>),</span>
<span id="cb28-10"><a href="#cb28-10" aria-hidden="true" tabindex="-1"></a> <span class="at">sep=</span><span class="st">";"</span>, <span class="at">dec=</span><span class="st">"."</span>, <span class="at">quote=</span><span class="cn">FALSE</span>)</span>
<span id="cb28-11"><a href="#cb28-11" aria-hidden="true" tabindex="-1"></a> <span class="co"># tt<- read.table(file.path(dadesDir, "DATrueLMetilacion.csv"), sep=";", dec=".")</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Figures <strong>?@sec-Lshaped1</strong> and <strong>?@sec-Lshaped2</strong> show the first four genes of each type for illustrative purposes.</p>
<p>opt<- par(mfrow=c(2,2)) <!-- ?---></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb29"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a>opt<span class="ot"><-</span> <span class="fu">par</span>(<span class="at">mfrow=</span><span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plotGenesMat</span> (<span class="at">mets=</span>falseLMet[<span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>,], <span class="at">expres=</span>falseLExpr[<span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>,],</span>
<span id="cb29-3"><a href="#cb29-3" aria-hidden="true" tabindex="-1"></a> <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb29-4"><a href="#cb29-4" aria-hidden="true" tabindex="-1"></a> <span class="at">fileName=</span><span class="cn">NULL</span>, <span class="at">plotGrid =</span> <span class="cn">TRUE</span>)</span>
<span id="cb29-5"><a href="#cb29-5" aria-hidden="true" tabindex="-1"></a><span class="fu">par</span>(opt)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Selecting_GRM_with_Lheuristic_files/figure-html/plotFALSE1-1.png" class="img-fluid figure-img" width="768"></p>
<p></p><figcaption class="figure-caption">Example of True ‘NON-L-shaped’ genes</figcaption><p></p>
</figure>
</div>
</div>
</div>
</section>
<section id="geos-true-and-false-l-shaped-genes-list" class="level3">
<h3 class="anchored" data-anchor-id="geos-true-and-false-l-shaped-genes-list">GEO’s TRUE and FALSE L-shaped genes list</h3>
<p>Similarly to what we have done with the researcher’s dataset we have <strong>visually</strong> selected a set of L-shaped genes Two small sets of genes have been compiled with genes that were clearly L-shaped or clearly non-L-Shaped. Because these sets have been prepared arbitrarily we decide not to use them as “TRUE POSITIVE” and “TRUE NEGATIVES” except for illustrative purposes.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb30"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="do">## Genes True i False</span></span>
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a>GEOTrueFalse <span class="ot"><-</span> <span class="fu">read.table</span>(<span class="fu">file.path</span>(dadesDir, <span class="st">"GEOTrueFalse.txt"</span>))</span>
<span id="cb30-3"><a href="#cb30-3" aria-hidden="true" tabindex="-1"></a>(GEOtrueLGeneNames <span class="ot"><-</span> <span class="fu">as.character</span>(GEOTrueFalse[GEOTrueFalse[,<span class="dv">2</span>]<span class="sc">!=</span><span class="dv">0</span>,<span class="dv">1</span>]))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code> [1] "Gene" "LRRTM1" "P8" "B4GALT6" "C1QL1" "CNR1"
[7] "DMBT1" "ELOVL6" "EOMES" "ERG" "GSTM3" "IL17RC"
[13] "LPHN2" "MME" "MMP19" "MOSPD2" "MSX2" "MTCP1"
[19] "MTMR8" "NCOR2" "P4HA3" "SH3GL2" "SMARCA1" "SMO"
[25] "TITF1" "TLR7" "TP53INP1" "TRPM8" "UBL4A" "ZNF550"
[31] "ZNF71" </code></pre>
</div>
<div class="sourceCode cell-code" id="cb32"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb32-1"><a href="#cb32-1" aria-hidden="true" tabindex="-1"></a>(GEOfalseLGeneNames <span class="ot"><-</span> <span class="fu">as.character</span>(GEOTrueFalse[GEOTrueFalse[,<span class="dv">2</span>]<span class="sc">==</span><span class="dv">0</span>,<span class="dv">1</span>]))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code> [1] "KLHL20" "PPM2C" "SNX27" "C6orf114" "IMMP2L" "NOL3"
[7] "P15RS" "PCGF2" "NCOA2" "PQLC2" "SLC20A1" "AQP9"
[13] "KIT" "AP4B1" "FOXO1A" "C1orf102" "NSD1" "ANKRD23"
[19] "MCL1" "SPATA21" "C6orf72" "ATP2A1" "EGLN1" "TFAP2E"
[25] "TMC6" "KRTHA4" "CHST8" "SKI" "MCART1" "MYBPC3"
[31] "ZNF542" "ICT1" "RALBP1" "SPINK5" "IL10RB" "BTBD10"
[37] "TMTC3" "WNT3" "C1orf142" "MX2" "DDX19A" "BXDC5"
[43] "SIX6" "COG1" "ALPPL2" "TNFRSF4" "FLJ45983" "IFT80"
[49] "LOC388407" "TIGD1" "NKX6-2" "PARD3" "SYT3" "FOXB1"
[55] "FLJ90166" "EMR2" "ABCB10" "NDUFA4" "TLOC1" "SLC14A1"
[61] "DDX3X" "TACC2" "PLEKHA8" "SP6" "EPB41L1" "ASB6"
[67] "LY6G6C" "LRP6" "GPR30" "GPR1" </code></pre>
</div>
<div class="sourceCode cell-code" id="cb34"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb34-1"><a href="#cb34-1" aria-hidden="true" tabindex="-1"></a>GEOtrueLExpr <span class="ot"><-</span> geoExprData[<span class="fu">rownames</span>(geoExprData) <span class="sc">%in%</span> GEOtrueLGeneNames ,]</span>
<span id="cb34-2"><a href="#cb34-2" aria-hidden="true" tabindex="-1"></a>GEOfalseLExpr <span class="ot"><-</span> geoExprData[<span class="fu">rownames</span>(geoExprData) <span class="sc">%in%</span> GEOfalseLGeneNames ,]</span>
<span id="cb34-3"><a href="#cb34-3" aria-hidden="true" tabindex="-1"></a>GEOtrueLMet <span class="ot"><-</span> geoMetilData[<span class="fu">rownames</span>(geoMetilData) <span class="sc">%in%</span> GEOtrueLGeneNames ,]</span>
<span id="cb34-4"><a href="#cb34-4" aria-hidden="true" tabindex="-1"></a>GEOfalseLMet <span class="ot"><-</span> geoMetilData[<span class="fu">rownames</span>(geoMetilData) <span class="sc">%in%</span> GEOfalseLGeneNames ,]</span>
<span id="cb34-5"><a href="#cb34-5" aria-hidden="true" tabindex="-1"></a>GEOTrueFalseExpr <span class="ot"><-</span> geoExprData[<span class="fu">rownames</span>(geoExprData) <span class="sc">%in%</span> <span class="fu">c</span>(GEOtrueLGeneNames,GEOfalseLGeneNames) ,]</span>
<span id="cb34-6"><a href="#cb34-6" aria-hidden="true" tabindex="-1"></a>GEOTrueFalseMet <span class="ot"><-</span> geoMetilData[<span class="fu">rownames</span>(geoMetilData) <span class="sc">%in%</span> <span class="fu">c</span>(GEOtrueLGeneNames,GEOfalseLGeneNames) ,]</span>
<span id="cb34-7"><a href="#cb34-7" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span>(<span class="sc">!</span>(<span class="fu">file.exists</span>(<span class="st">"GEOTrueLExpression.csv"</span>)))</span>
<span id="cb34-8"><a href="#cb34-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">write.table</span>(GEOtrueLExpr, <span class="fu">file.path</span>(dadesDir, <span class="st">"GEOTrueLExpression.csv"</span>),</span>
<span id="cb34-9"><a href="#cb34-9" aria-hidden="true" tabindex="-1"></a> <span class="at">sep=</span><span class="st">";"</span>, <span class="at">dec=</span><span class="st">"."</span>, <span class="at">quote=</span><span class="cn">FALSE</span>)</span>
<span id="cb34-10"><a href="#cb34-10" aria-hidden="true" tabindex="-1"></a><span class="cf">if</span>(<span class="sc">!</span>(<span class="fu">file.exists</span>(<span class="st">"GEOTrueLMetilacion.csv"</span>)))</span>
<span id="cb34-11"><a href="#cb34-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">write.table</span>(GEOtrueLMet, <span class="fu">file.path</span>(dadesDir, <span class="st">"GEOTrueLMetilacion.csv"</span>),</span>
<span id="cb34-12"><a href="#cb34-12" aria-hidden="true" tabindex="-1"></a> <span class="at">sep=</span><span class="st">";"</span>, <span class="at">dec=</span><span class="st">"."</span>, <span class="at">quote=</span><span class="cn">FALSE</span>)</span>
<span id="cb34-13"><a href="#cb34-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># tt<- read.table(file.path(dadesDir, "GEOTrueLMetilacion.csv"), sep=";", dec="."); head(tt)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Figures <strong>?@sec-GEOLshaped1</strong> and <strong>?@sec-GEOLshaped2</strong> show the first four genes of each type for illustrative purposes.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb35"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb35-1"><a href="#cb35-1" aria-hidden="true" tabindex="-1"></a>opt<span class="ot"><-</span> <span class="fu">par</span>(<span class="at">mfrow=</span><span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
<span id="cb35-2"><a href="#cb35-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plotGenesMat</span> (<span class="at">mets=</span>GEOtrueLMet[<span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>,], <span class="at">expres=</span>GEOtrueLExpr[<span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>,],</span>
<span id="cb35-3"><a href="#cb35-3" aria-hidden="true" tabindex="-1"></a> <span class="at">fileName=</span><span class="cn">NULL</span>, <span class="at">plotGrid =</span> <span class="cn">TRUE</span>)</span>
<span id="cb35-4"><a href="#cb35-4" aria-hidden="true" tabindex="-1"></a><span class="fu">par</span>(opt)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Selecting_GRM_with_Lheuristic_files/figure-html/plotTRUE2-1.png" class="img-fluid figure-img" width="768"></p>
<p></p><figcaption class="figure-caption">Example of ‘True’ L-shaped genes</figcaption><p></p>
</figure>
</div>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb36"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb36-1"><a href="#cb36-1" aria-hidden="true" tabindex="-1"></a>opt<span class="ot"><-</span> <span class="fu">par</span>(<span class="at">mfrow=</span><span class="fu">c</span>(<span class="dv">2</span>,<span class="dv">2</span>))</span>
<span id="cb36-2"><a href="#cb36-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plotGenesMat</span> (<span class="at">mets=</span>GEOfalseLMet[<span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>,], <span class="at">expres=</span>GEOfalseLExpr[<span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>,],</span>
<span id="cb36-3"><a href="#cb36-3" aria-hidden="true" tabindex="-1"></a> <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">y1=</span>y1, <span class="at">y2=</span>y2,</span>
<span id="cb36-4"><a href="#cb36-4" aria-hidden="true" tabindex="-1"></a> <span class="at">fileName=</span><span class="cn">NULL</span>, <span class="at">plotGrid =</span> <span class="cn">TRUE</span>)</span>
<span id="cb36-5"><a href="#cb36-5" aria-hidden="true" tabindex="-1"></a><span class="fu">par</span>(opt)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="Selecting_GRM_with_Lheuristic_files/figure-html/plotFALSE2-1.png" class="img-fluid figure-img" width="768"></p>
<p></p><figcaption class="figure-caption">Example of ‘True’ NON-L-shaped genes</figcaption><p></p>
</figure>
</div>
</div>
</div>
</section>
</section>
</section>
<section id="scoring-scatterplots" class="level1">
<h1>Scoring scatterplots</h1>
<section id="the-three-band-rule" class="level2">
<h2 class="anchored" data-anchor-id="the-three-band-rule">The “three band rule”</h2>
<p>After trying different approaches to detect L-shapes, one often comes back to a naive approach like <em>“L-shaped” genes should show an L shape in the scatterplot, that is, values should tend to be scattered near the vertical and horizontal axes, and the more we move from these positions the least L-shaped the gene should be</em>.</p>
<p>This idea can be made more explicit by introducing a “three-band rule” as follows:</p>
<ol type="1">
<li><p>Overimpose a <span class="math inline">\(3\times 3\)</span> grid on the scatterplot.</p></li>
<li><p>Classify the scatterplot as <strong>“L” or “non-L”</strong> based on a small set of conditions:</p>
<pre><code>i) There must be a _minimum_ number of points in the upper-left (cell (1,1)) and lower right (cell (3,3)) corners of the grid.
i) There must be a _maximum_ number of points in the upper right (cell (1,3)) because points there mean hypermethylation and hyperexpression which is the opposite of what we are looking for.
i) We will usually _not require to have a minimum of points in cell (3,1)_ unless we are really willing to have an L-shape (in our setting we will also be happy tho recover diagonals, which also reflect a negative correlation!).</code></pre></li>
<li><p>Score points on each subgrid in such a way that</p>
<pre><code>i) Points in permitted regions (left-outer margin, i.e. cells: (1,1), (2,2), (3,1), (3,2), (3,3)) score positively if the scatterplot has been classified as L or zero if it has been classified as non-L.
i) Points in non-desired regions (outer band. i.e. cells (1,2), (1,3), (2,3)) score negatively in all cases.
i) Some regions may be declared neutral and not-score, such as cell (2,2).</code></pre></li>
<li><p>Use cross-validation to tune scoring parameters (<strong>if a set of positive and negative L-shaped genes is available</strong>).</p></li>
</ol>
<p>The previous scheme can be summarized using the following equation. <span class="math display">\[
S(X) = W_L \circ X \times \mathbbm{1}_L(X) + W_{L^C} \circ X \times \mathbbm{1}_{L^c}(X),
\]</span> where</p>
<ul>
<li><span class="math inline">\({X}\)</span> is the matrix of <em>counts</em>, i.e. the number of counts in each cell of the grid,</li>
<li><span class="math inline">\({W_L}\)</span> is the matrix of scores per cell and point <em>if the scatterplot has been classified as <span class="math inline">\(L\)</span></em>,</li>
<li><span class="math inline">\({W_{L^c}}\)</span> is the matrix of scores per cell and point <em>if the scatterplot has been classified as non-<span class="math inline">\(L\)</span> (<span class="math inline">\(L^c\)</span>)</em>,</li>
</ul>
<p>and <span class="math inline">\(\circ\)</span> represents the hadamard product of the two matrices <span class="math inline">\(W_{L/L^c}\)</span> (i.e. elementwise multiplication of the two matrices) and <span class="math inline">\(\mathbbm{1}_{L/L^c}()\)</span> is the indicator function for <span class="math inline">\(L\)</span> or <span class="math inline">\(L^c\)</span>.</p>
<p>The fact that the scatterplot is assigned to <span class="math inline">\(L\)</span> or <span class="math inline">\(L^c\)</span> can also be described as the hadamard product of three matrices: <span class="math display">\[
\mathbold{1}_L(X) = \bigwedge_{i,j} X \circ C \circ \left( mMP \times \sum_{i,j}x_{ij}\right),
\]</span> where:</p>
<ul>
<li><span class="math inline">\({X}\)</span> is the matrix of <em>counts</em>, i.e. the number of counts in each cell of the grid,</li>
<li><span class="math inline">\(C\)</span> is the matrix of conditions to be verified <em>if the scatterplot has to be classified as <span class="math inline">\(L\)</span></em>,</li>
<li><span class="math inline">\(mMP\)</span> is the matrix of minimum and Maximum Percentages of points to have in each cell <em>if the scatterplot has to be classified as <span class="math inline">\(L\)</span></em>,</li>
<li><span class="math inline">\(\circ\)</span> represents the pointwise logical operation which allows that the product of the three cells becomes a logical operation and</li>
<li><span class="math inline">\(\bigwedge_{i,j}\)</span> represents an logical “AND” operation of all cells, that is if all cells are TRUE the result is assigned to <span class="math inline">\(L\)</span> and if one fails it is assigned to <span class="math inline">\(L^c\)</span>.</li>
</ul>
<p>This idea is summarized in figure <strong>?@sec-Lscore</strong></p>
<div class="cell">
<div class="sourceCode cell-code" id="cb39"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb39-1"><a href="#cb39-1" aria-hidden="true" tabindex="-1"></a>knitr<span class="sc">::</span><span class="fu">include_graphics</span>(<span class="st">"images/Lscoring.png"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="images/Lscoring.png" class="img-fluid figure-img" style="width:50.0%"></p>
<p></p><figcaption class="figure-caption">The heuristic method is based in scoring differently depending on where the points are found on a grid</figcaption><p></p>
</figure>
</div>
</div>
</div>
</section>
<section id="computing-on-a-grid" class="level2">
<h2 class="anchored" data-anchor-id="computing-on-a-grid">Computing on a grid</h2>
<p>We have developed several functions to help detect and select L–shape scatterplots. Their use is described in the package help but they are illustrated here to clarify the code below.</p>
<ul>
<li><code>calcFreqs</code> counts the number of points in each cell of the grid for given vertical (defined by parameters <code>x1</code>, <code>x2</code>) and horizontal lines (defined by parameters <code>y1</code>, <code>y2</code>, <code>percY1</code>, <code>percY2</code>)</li>
<li><code>binScore</code> classifies (<em>scores binarily</em>) a scatterplot based on the rules described above, that is it checks if the minimal assumptions for an L-shape hold or not. It needs a matrix of <em>min-max frequency counts</em>.</li>
<li><code>numScore</code> scores a scatterplot using a matrix of weights that defines the score given to each point depending on the cell where it is located.
<ul>
<li>If the scatterplot has been classified as having L-shape all points are scored, those in favorable regions score positively and those in non-favorable regions negatively.</li>
<li>If the scatterplot has not been classifed as “L” only points in non-favourable regions score negatively.</li>
</ul></li>
<li><code>scoreGenesMat</code> is a wrapper for scoring the genes provided in two related matrices that is, it first applies the <code>binScore</code> function and depending on its results it computes the <code>numericScore</code> function with all the genes in the (pair of) matrices.</li>
<li>Function <code>plotGenesMat</code> is not a computing function but it is worth to enumerate it here because it complements the other functions by allowing to visualize the data that have generated a certain score from a given scatterplot.</li>
</ul>
</section>
<section id="examples" class="level2">
<h2 class="anchored" data-anchor-id="examples">Examples</h2>
<section id="scoring-the-truefalse-da-dataset" class="level3">
<h3 class="anchored" data-anchor-id="scoring-the-truefalse-da-dataset">Scoring the TRUE/FALSE DA dataset</h3>
<p>The first example below show that genes that have been marked as TRUE or FALSE L in the DA dataset <strong>may</strong> score different.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb40"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb40-1"><a href="#cb40-1" aria-hidden="true" tabindex="-1"></a>xVecTrue<span class="ot"><-</span> <span class="fu">as.numeric</span>(trueLMet[<span class="dv">1</span>,])</span>
<span id="cb40-2"><a href="#cb40-2" aria-hidden="true" tabindex="-1"></a>yVecTrue<span class="ot"><-</span> <span class="fu">as.numeric</span>(trueLExpr[<span class="dv">1</span>,])</span>
<span id="cb40-3"><a href="#cb40-3" aria-hidden="true" tabindex="-1"></a>reqPercentages <span class="ot"><-</span> <span class="fu">matrix</span> (<span class="fu">c</span>(<span class="dv">10</span>, <span class="dv">20</span>, <span class="dv">0</span>, <span class="dv">5</span>, <span class="dv">0</span>, <span class="dv">20</span>, <span class="dv">0</span>, <span class="dv">5</span>, <span class="dv">5</span>), <span class="at">nrow=</span><span class="dv">3</span>, <span class="at">byrow=</span><span class="cn">TRUE</span>)</span>
<span id="cb40-4"><a href="#cb40-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb40-5"><a href="#cb40-5" aria-hidden="true" tabindex="-1"></a><span class="fu">messageTitle</span>(<span class="st">"Frequency count in first 'TRUE' gene"</span>)</span>
<span id="cb40-6"><a href="#cb40-6" aria-hidden="true" tabindex="-1"></a>(geneGridTrue <span class="ot"><-</span> <span class="fu">calcFreqs</span>(<span class="at">xMet=</span>xVecTrue, <span class="at">yExp=</span>yVecTrue, <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb40-7"><a href="#cb40-7" aria-hidden="true" tabindex="-1"></a> <span class="at">y1=</span><span class="cn">NULL</span>, <span class="at">y2=</span><span class="cn">NULL</span>, <span class="at">percY1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">4</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">11</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="odd">
<td style="text-align: right;">10</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2</td>
</tr>
</tbody>
</table>
</div>
<div class="sourceCode cell-code" id="cb41"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb41-1"><a href="#cb41-1" aria-hidden="true" tabindex="-1"></a>(maxminCountsT <span class="ot"><-</span> <span class="fu">toReqMat</span> (<span class="fu">sum</span>(geneGridTrue), reqPercentages))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">3</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">2</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">6</td>
</tr>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">2</td>
</tr>
</tbody>
</table>
</div>
<div class="sourceCode cell-code" id="cb42"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb42-1"><a href="#cb42-1" aria-hidden="true" tabindex="-1"></a>(<span class="at">aWeightMifL=</span><span class="fu">matrix</span> (<span class="fu">c</span>(<span class="dv">2</span>,<span class="sc">-</span><span class="dv">2</span>,<span class="sc">-</span><span class="dv">25</span>,<span class="dv">1</span>,<span class="dv">0</span>,<span class="sc">-</span><span class="dv">2</span>,<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">2</span>), <span class="at">nrow=</span><span class="dv">3</span>, <span class="at">byrow=</span><span class="cn">TRUE</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">2</td>
<td style="text-align: right;">-2</td>
<td style="text-align: right;">-25</td>
</tr>
<tr class="even">
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">-2</td>
</tr>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">2</td>
</tr>
</tbody>
</table>
</div>
<div class="sourceCode cell-code" id="cb43"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb43-1"><a href="#cb43-1" aria-hidden="true" tabindex="-1"></a>(<span class="at">aWeightMifNonL=</span><span class="fu">matrix</span> (<span class="fu">c</span>(<span class="dv">0</span>,<span class="sc">-</span><span class="dv">2</span>,<span class="sc">-</span><span class="dv">25</span>,<span class="dv">0</span>,<span class="dv">0</span>,<span class="sc">-</span><span class="dv">2</span>,<span class="dv">0</span>,<span class="dv">0</span>,<span class="dv">0</span>), <span class="at">nrow=</span><span class="dv">3</span>, <span class="at">byrow=</span><span class="cn">TRUE</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">-2</td>
<td style="text-align: right;">-25</td>
</tr>
<tr class="even">
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">-2</td>
</tr>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
</tbody>
</table>
</div>
<div class="sourceCode cell-code" id="cb44"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb44-1"><a href="#cb44-1" aria-hidden="true" tabindex="-1"></a><span class="fu">messageTitle</span>(<span class="st">"Binary and numeric soring in first 'TRUE' gene"</span>)</span>
<span id="cb44-2"><a href="#cb44-2" aria-hidden="true" tabindex="-1"></a>(binSc<span class="ot"><-</span> <span class="fu">binScore</span> (geneGridTrue, maxminCountsT ))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] TRUE</code></pre>
</div>
<div class="sourceCode cell-code" id="cb46"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb46-1"><a href="#cb46-1" aria-hidden="true" tabindex="-1"></a>(nsT<span class="ot"><-</span> <span class="fu">numScore</span>(geneGridTrue, <span class="at">LShaped =</span> binSc, aWeightMifL, aWeightMifNonL))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 36</code></pre>
</div>
</div>
<div class="cell">
<div class="sourceCode cell-code" id="cb48"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb48-1"><a href="#cb48-1" aria-hidden="true" tabindex="-1"></a>xVecFalse<span class="ot"><-</span> <span class="fu">as.numeric</span>(falseLMet[<span class="dv">1</span>,])</span>
<span id="cb48-2"><a href="#cb48-2" aria-hidden="true" tabindex="-1"></a>yVecFalse<span class="ot"><-</span> <span class="fu">as.numeric</span>(falseLExpr[<span class="dv">1</span>,])</span>
<span id="cb48-3"><a href="#cb48-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb48-4"><a href="#cb48-4" aria-hidden="true" tabindex="-1"></a><span class="fu">messageTitle</span>(<span class="st">"Frequency count in first 'FALSE' gene"</span>)</span>
<span id="cb48-5"><a href="#cb48-5" aria-hidden="true" tabindex="-1"></a>(geneGridFalse <span class="ot"><-</span> <span class="fu">calcFreqs</span>(<span class="at">xMet=</span>xVecFalse, <span class="at">yExp=</span>yVecFalse, <span class="at">x1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">x2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>,</span>
<span id="cb48-6"><a href="#cb48-6" aria-hidden="true" tabindex="-1"></a> <span class="at">y1=</span><span class="cn">NULL</span>, <span class="at">y2=</span><span class="cn">NULL</span>, <span class="at">percY1=</span><span class="dv">1</span><span class="sc">/</span><span class="dv">3</span>, <span class="at">percY2=</span><span class="dv">2</span><span class="sc">/</span><span class="dv">3</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">2</td>
</tr>
<tr class="even">
<td style="text-align: right;">2</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">3</td>
</tr>
<tr class="odd">
<td style="text-align: right;">3</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">15</td>
</tr>
</tbody>
</table>
</div>
<div class="sourceCode cell-code" id="cb49"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb49-1"><a href="#cb49-1" aria-hidden="true" tabindex="-1"></a>(maxminCountsF <span class="ot"><-</span> <span class="fu">toReqMat</span> (<span class="fu">sum</span>(geneGridFalse), reqPercentages))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">3</td>
<td style="text-align: right;">6</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">2</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">6</td>
</tr>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">2</td>
</tr>
</tbody>
</table>
</div>
<div class="sourceCode cell-code" id="cb50"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb50-1"><a href="#cb50-1" aria-hidden="true" tabindex="-1"></a><span class="co"># Same value as maxminCountsT because it depends only on required percentages and sample size</span></span>
<span id="cb50-2"><a href="#cb50-2" aria-hidden="true" tabindex="-1"></a><span class="fu">messageTitle</span>(<span class="st">"Binary and numeric soring in first 'FALSE' gene"</span>)</span>
<span id="cb50-3"><a href="#cb50-3" aria-hidden="true" tabindex="-1"></a>(binSc<span class="ot"><-</span><span class="fu">binScore</span> (geneGridFalse, maxminCountsF))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] FALSE</code></pre>
</div>
<div class="sourceCode cell-code" id="cb52"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb52-1"><a href="#cb52-1" aria-hidden="true" tabindex="-1"></a>(nsF<span class="ot"><-</span> <span class="fu">numScore</span>(geneGridFalse, <span class="at">LShaped =</span> binSc, aWeightMifL, aWeightMifNonL))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-output cell-output-stdout">
<pre><code>[1] -58</code></pre>
</div>
</div>
<div class="cell">
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">2</td>
<td style="text-align: right;">-2</td>
<td style="text-align: right;">-30</td>
</tr>
<tr class="even">
<td style="text-align: right;">1</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">-2</td>
</tr>
<tr class="odd">
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">2</td>
</tr>
</tbody>
</table>
</div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">-2</td>
<td style="text-align: right;">-30</td>
</tr>
<tr class="even">
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">-2</td>
</tr>
<tr class="odd">
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">0</td>
</tr>
</tbody>
</table>
</div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<tbody>
<tr class="odd">
<td style="text-align: right;">10</td>
<td style="text-align: right;">20</td>
<td style="text-align: right;">0</td>
</tr>
<tr class="even">
<td style="text-align: right;">10</td>
<td style="text-align: right;">0</td>
<td style="text-align: right;">20</td>
</tr>
<tr class="odd">
<td style="text-align: right;">20</td>
<td style="text-align: right;">10</td>
<td style="text-align: right;">10</td>
</tr>
</tbody>
</table>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>Number of scatterplots scored : 44 </code></pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>Number of L-shape scatterplots : 9 </code></pre>
</div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<thead>
<tr class="header">
<th style="text-align: right;">FALSE</th>
<th style="text-align: right;">TRUE</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">35</td>
<td style="text-align: right;">9</td>
</tr>
</tbody>
</table>
</div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<thead>
<tr class="header">
<th style="text-align: right;">-30</th>
<th style="text-align: right;">-10</th>
<th style="text-align: right;">-8</th>
<th style="text-align: right;">-4</th>
<th style="text-align: right;">-2</th>
<th style="text-align: right;">0</th>
<th style="text-align: right;">34</th>
<th style="text-align: right;">36</th>
<th style="text-align: right;">37</th>
<th style="text-align: right;">41</th>
<th style="text-align: right;">43</th>
<th style="text-align: right;">45</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">3</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">5</td>
<td style="text-align: right;">23</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">1</td>
<td style="text-align: right;">3</td>
<td style="text-align: right;">2</td>
<td style="text-align: right;">1</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="cell">
<div class="cell-output cell-output-stdout">
<pre><code>Number of scatterplots scored : 44 </code></pre>
</div>
<div class="cell-output cell-output-stdout">
<pre><code>Number of L-shape scatterplots : 0 </code></pre>
</div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<thead>
<tr class="header">
<th style="text-align: right;">FALSE</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: right;">44</td>
</tr>
</tbody>
</table>
</div>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<colgroup>
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 4%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 3%">
<col style="width: 2%">
<col style="width: 2%">
<col style="width: 2%">
<col style="width: 2%">
<col style="width: 2%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: right;">-256</th>
<th style="text-align: right;">-206</th>
<th style="text-align: right;">-168</th>
<th style="text-align: right;">-148</th>
<th style="text-align: right;">-112</th>
<th style="text-align: right;">-110</th>
<th style="text-align: right;">-108</th>
<th style="text-align: right;">-96</th>
<th style="text-align: right;">-92</th>
<th style="text-align: right;">-76</th>
<th style="text-align: right;">-72</th>
<th style="text-align: right;">-68</th>
<th style="text-align: right;">-66</th>
<th style="text-align: right;">-46</th>
<th style="text-align: right;">-42</th>
<th style="text-align: right;">-40</th>
<th style="text-align: right;">-36</th>
<th style="text-align: right;">-34</th>
<th style="text-align: right;">-32</th>
<th style="text-align: right;">-18</th>
<th style="text-align: right;">-16</th>
<th style="text-align: right;">-12</th>
<th style="text-align: right;">-10</th>
<th style="text-align: right;">-8</th>
<th style="text-align: right;">-6</th>
<th style="text-align: right;">-4</th>
<th style="text-align: right;">-2</th>
<th style="text-align: right;">0</th>
</tr>