figure-3.html 97.7 KB
Newer Older
Kosmas Hench's avatar
Kosmas Hench committed
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
<!DOCTYPE html>
<html >

<head>

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Script repository</title>
  <meta name="description" content="Scripts used to produce Figures and Supplementary Figures of ‘Association between vision and pigmentation genes during genomic divergence’.">
  <meta name="generator" content="bookdown 0.7 and GitBook 2.6.7">

  <meta property="og:title" content="Script repository" />
  <meta property="og:type" content="book" />
  
  
  <meta property="og:description" content="Scripts used to produce Figures and Supplementary Figures of ‘Association between vision and pigmentation genes during genomic divergence’." />
  <meta name="github-repo" content="k-hench/bookdown" />

  <meta name="twitter:card" content="summary" />
  <meta name="twitter:title" content="Script repository" />
  
  <meta name="twitter:description" content="Scripts used to produce Figures and Supplementary Figures of ‘Association between vision and pigmentation genes during genomic divergence’." />
  

<meta name="author" content="Kosmas Hench">


<meta name="date" content="2018-07-30">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  
  
<link rel="prev" href="figure-2.html">
<link rel="next" href="extendend-data-figure-1.html">
<script src="libs/jquery-2.2.3/jquery.min.js"></script>
<link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" />
<link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" />









<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
  margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>

<link rel="stylesheet" href="style.css" type="text/css" />
</head>

<body>



  <div class="book without-animation with-summary font-size-2 font-family-1" data-basepath=".">

    <div class="book-summary">
      <nav role="navigation">

<ul class="summary">
<li><a href="../">Script repository</a></li>

<li class="divider"></li>
<li class="chapter" data-level="1" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i><b>1</b> Intro</a><ul>
<li class="chapter" data-level="1.1" data-path="index.html"><a href="index.html#data"><i class="fa fa-check"></i><b>1.1</b> Data</a></li>
<li class="chapter" data-level="1.2" data-path="index.html"><a href="index.html#figures"><i class="fa fa-check"></i><b>1.2</b> Figures</a></li>
<li class="chapter" data-level="1.3" data-path="index.html"><a href="index.html#background"><i class="fa fa-check"></i><b>1.3</b> Background</a></li>
</ul></li>
<li class="chapter" data-level="2" data-path="workflow.html"><a href="workflow.html"><i class="fa fa-check"></i><b>2</b> Workflow</a><ul>
<li class="chapter" data-level="2.1" data-path="workflow.html"><a href="workflow.html#info"><i class="fa fa-check"></i><b>2.1</b> Info</a></li>
</ul></li>
<li class="chapter" data-level="3" data-path="figure-1.html"><a href="figure-1.html"><i class="fa fa-check"></i><b>3</b> Figure 1</a><ul>
<li class="chapter" data-level="3.1" data-path="figure-1.html"><a href="figure-1.html#summary"><i class="fa fa-check"></i><b>3.1</b> Summary</a></li>
<li class="chapter" data-level="3.2" data-path="figure-1.html"><a href="figure-1.html#details-of-f1.r"><i class="fa fa-check"></i><b>3.2</b> Details of <code>F1.R</code></a><ul>
<li class="chapter" data-level="3.2.1" data-path="figure-1.html"><a href="figure-1.html#fig.-1-a"><i class="fa fa-check"></i><b>3.2.1</b> Fig. 1 a)</a></li>
<li class="chapter" data-level="3.2.2" data-path="figure-1.html"><a href="figure-1.html#fig.-1-b"><i class="fa fa-check"></i><b>3.2.2</b> Fig. 1 b)</a></li>
<li class="chapter" data-level="3.2.3" data-path="figure-1.html"><a href="figure-1.html#fig.-1-c"><i class="fa fa-check"></i><b>3.2.3</b> Fig. 1 c)</a></li>
<li class="chapter" data-level="3.2.4" data-path="figure-1.html"><a href="figure-1.html#fig-1-complete"><i class="fa fa-check"></i><b>3.2.4</b> Fig 1 (complete)</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="4" data-path="figure-2.html"><a href="figure-2.html"><i class="fa fa-check"></i><b>4</b> Figure 2</a><ul>
<li class="chapter" data-level="4.1" data-path="figure-2.html"><a href="figure-2.html#summary-1"><i class="fa fa-check"></i><b>4.1</b> Summary</a></li>
<li class="chapter" data-level="4.2" data-path="figure-2.html"><a href="figure-2.html#details-of-f2.r"><i class="fa fa-check"></i><b>4.2</b> Details of <code>F2.R</code></a><ul>
<li class="chapter" data-level="4.2.1" data-path="figure-2.html"><a href="figure-2.html#reading-in-data"><i class="fa fa-check"></i><b>4.2.1</b> Reading in Data</a></li>
<li class="chapter" data-level="4.2.2" data-path="figure-2.html"><a href="figure-2.html#computing-99.98-fst-percentiles"><i class="fa fa-check"></i><b>4.2.2</b> Computing 99.98 <em>F<sub>ST</sub></em> percentiles</a></li>
<li class="chapter" data-level="4.2.3" data-path="figure-2.html"><a href="figure-2.html#plotting"><i class="fa fa-check"></i><b>4.2.3</b> Plotting</a></li>
<li class="chapter" data-level="4.2.4" data-path="figure-2.html"><a href="figure-2.html#composing-the-final-figure"><i class="fa fa-check"></i><b>4.2.4</b> Composing the final figure</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="5" data-path="figure-3.html"><a href="figure-3.html"><i class="fa fa-check"></i><b>5</b> Figure 3</a><ul>
<li class="chapter" data-level="5.1" data-path="figure-3.html"><a href="figure-3.html#summary-2"><i class="fa fa-check"></i><b>5.1</b> Summary</a></li>
<li class="chapter" data-level="5.2" data-path="figure-3.html"><a href="figure-3.html#details-of-f3.r"><i class="fa fa-check"></i><b>5.2</b> Details of <code>F3.R</code></a></li>
<li class="chapter" data-level="5.3" data-path="figure-3.html"><a href="figure-3.html#details-of-f3.functions.r"><i class="fa fa-check"></i><b>5.3</b> Details of <code>F3.functions.R</code></a></li>
<li class="chapter" data-level="5.4" data-path="figure-3.html"><a href="figure-3.html#details-of-f3.genomewide_box.r"><i class="fa fa-check"></i><b>5.4</b> Details of <code>F3.genomeWide_box.R</code></a></li>
<li class="chapter" data-level="5.5" data-path="figure-3.html"><a href="figure-3.html#details-of-f3.peakarea_box.r"><i class="fa fa-check"></i><b>5.5</b> Details of <code>F3.peakArea_box.R</code></a></li>
</ul></li>
<li class="chapter" data-level="6" data-path="extendend-data-figure-1.html"><a href="extendend-data-figure-1.html"><i class="fa fa-check"></i><b>6</b> Extendend Data Figure 1</a><ul>
<li class="chapter" data-level="6.1" data-path="extendend-data-figure-1.html"><a href="extendend-data-figure-1.html#summary-3"><i class="fa fa-check"></i><b>6.1</b> Summary</a></li>
<li class="chapter" data-level="6.2" data-path="extendend-data-figure-1.html"><a href="extendend-data-figure-1.html#details-of-e1.r"><i class="fa fa-check"></i><b>6.2</b> Details of <code>E1.R</code></a></li>
<li class="chapter" data-level="6.3" data-path="extendend-data-figure-1.html"><a href="extendend-data-figure-1.html#details-of-e1.plot_fun.r"><i class="fa fa-check"></i><b>6.3</b> Details of <code>E1.plot_fun.R</code></a></li>
</ul></li>
<li class="chapter" data-level="7" data-path="supplementary-figure-01.html"><a href="supplementary-figure-01.html"><i class="fa fa-check"></i><b>7</b> Supplementary Figure 01</a><ul>
<li class="chapter" data-level="7.1" data-path="supplementary-figure-01.html"><a href="supplementary-figure-01.html#preparation"><i class="fa fa-check"></i><b>7.1</b> Preparation</a></li>
<li class="chapter" data-level="7.2" data-path="supplementary-figure-01.html"><a href="supplementary-figure-01.html#content-of-circos_figure.r"><i class="fa fa-check"></i><b>7.2</b> Content of circos_figure.R</a></li>
</ul></li>
<li class="chapter" data-level="8" data-path="supplementary-figure-02.html"><a href="supplementary-figure-02.html"><i class="fa fa-check"></i><b>8</b> Supplementary Figure 02</a><ul>
<li class="chapter" data-level="8.1" data-path="supplementary-figure-02.html"><a href="supplementary-figure-02.html#summary-4"><i class="fa fa-check"></i><b>8.1</b> Summary</a></li>
<li class="chapter" data-level="8.2" data-path="supplementary-figure-02.html"><a href="supplementary-figure-02.html#details-of-s02.r"><i class="fa fa-check"></i><b>8.2</b> Details of <code>S02.R</code></a></li>
<li class="chapter" data-level="8.3" data-path="supplementary-figure-02.html"><a href="supplementary-figure-02.html#details-of-s02.functions.r"><i class="fa fa-check"></i><b>8.3</b> Details of <code>S02.functions.R</code></a></li>
</ul></li>
<li class="chapter" data-level="9" data-path="supplementary-figure-03.html"><a href="supplementary-figure-03.html"><i class="fa fa-check"></i><b>9</b> Supplementary Figure 03</a><ul>
<li class="chapter" data-level="9.1" data-path="supplementary-figure-03.html"><a href="supplementary-figure-03.html#summary-5"><i class="fa fa-check"></i><b>9.1</b> Summary</a></li>
<li class="chapter" data-level="9.2" data-path="supplementary-figure-03.html"><a href="supplementary-figure-03.html#details-of-s03.r"><i class="fa fa-check"></i><b>9.2</b> Details of <code>S03.R</code></a></li>
</ul></li>
<li class="chapter" data-level="10" data-path="supplementary-figure-05.html"><a href="supplementary-figure-05.html"><i class="fa fa-check"></i><b>10</b> Supplementary Figure 05</a><ul>
<li class="chapter" data-level="10.1" data-path="supplementary-figure-05.html"><a href="supplementary-figure-05.html#summary-6"><i class="fa fa-check"></i><b>10.1</b> Summary</a></li>
<li class="chapter" data-level="10.2" data-path="supplementary-figure-05.html"><a href="supplementary-figure-05.html#details-of-s05.r"><i class="fa fa-check"></i><b>10.2</b> Details of <code>S05.R</code></a><ul>
<li class="chapter" data-level="10.2.1" data-path="supplementary-figure-05.html"><a href="supplementary-figure-05.html#suppl.-fig.-05-a"><i class="fa fa-check"></i><b>10.2.1</b> Suppl. Fig. 05 a)</a></li>
<li class="chapter" data-level="10.2.2" data-path="supplementary-figure-05.html"><a href="supplementary-figure-05.html#suppl.-fig.-05-b"><i class="fa fa-check"></i><b>10.2.2</b> Suppl. Fig. 05 b)</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="11" data-path="supplementary-figure-06.html"><a href="supplementary-figure-06.html"><i class="fa fa-check"></i><b>11</b> Supplementary Figure 06</a><ul>
<li class="chapter" data-level="11.1" data-path="supplementary-figure-06.html"><a href="supplementary-figure-06.html#summary-7"><i class="fa fa-check"></i><b>11.1</b> Summary</a></li>
<li class="chapter" data-level="11.2" data-path="supplementary-figure-06.html"><a href="supplementary-figure-06.html#details-of-s06.r"><i class="fa fa-check"></i><b>11.2</b> Details of <code>S06.R</code></a><ul>
<li class="chapter" data-level="11.2.1" data-path="supplementary-figure-06.html"><a href="supplementary-figure-06.html#reading-in-data-1"><i class="fa fa-check"></i><b>11.2.1</b> Reading in Data</a></li>
<li class="chapter" data-level="11.2.2" data-path="supplementary-figure-06.html"><a href="supplementary-figure-06.html#computing-99.90-fst-percentiles"><i class="fa fa-check"></i><b>11.2.2</b> Computing 99.90 <em>F<sub>ST</sub></em> percentiles</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="12" data-path="supplementary-figure-07.html"><a href="supplementary-figure-07.html"><i class="fa fa-check"></i><b>12</b> Supplementary Figure 07</a><ul>
<li class="chapter" data-level="12.1" data-path="supplementary-figure-07.html"><a href="supplementary-figure-07.html#summary-8"><i class="fa fa-check"></i><b>12.1</b> Summary</a></li>
<li class="chapter" data-level="12.2" data-path="supplementary-figure-07.html"><a href="supplementary-figure-07.html#details-of-s07.r"><i class="fa fa-check"></i><b>12.2</b> Details of <code>S07.R</code></a></li>
</ul></li>
<li class="chapter" data-level="13" data-path="supplementary-figure-08.html"><a href="supplementary-figure-08.html"><i class="fa fa-check"></i><b>13</b> Supplementary Figure 08</a><ul>
<li class="chapter" data-level="13.1" data-path="supplementary-figure-08.html"><a href="supplementary-figure-08.html#summary-9"><i class="fa fa-check"></i><b>13.1</b> Summary</a></li>
<li class="chapter" data-level="13.2" data-path="supplementary-figure-08.html"><a href="supplementary-figure-08.html#details-of-s08.r"><i class="fa fa-check"></i><b>13.2</b> Details of <code>S08.R</code></a></li>
</ul></li>
<li class="chapter" data-level="14" data-path="supplementary-figure-09.html"><a href="supplementary-figure-09.html"><i class="fa fa-check"></i><b>14</b> Supplementary Figure 09</a><ul>
<li class="chapter" data-level="14.1" data-path="supplementary-figure-09.html"><a href="supplementary-figure-09.html#summary-10"><i class="fa fa-check"></i><b>14.1</b> Summary</a></li>
<li class="chapter" data-level="14.2" data-path="supplementary-figure-09.html"><a href="supplementary-figure-09.html#details-of-s09.r"><i class="fa fa-check"></i><b>14.2</b> Details of <code>S09.R</code></a></li>
</ul></li>
<li class="chapter" data-level="15" data-path="supplementary-figure-10.html"><a href="supplementary-figure-10.html"><i class="fa fa-check"></i><b>15</b> Supplementary Figure 10</a><ul>
<li class="chapter" data-level="15.1" data-path="supplementary-figure-10.html"><a href="supplementary-figure-10.html#summary-11"><i class="fa fa-check"></i><b>15.1</b> Summary</a></li>
<li class="chapter" data-level="15.2" data-path="supplementary-figure-10.html"><a href="supplementary-figure-10.html#details-of-s10.r"><i class="fa fa-check"></i><b>15.2</b> Details of <code>S10.R</code></a></li>
</ul></li>
<li class="chapter" data-level="16" data-path="supplementary-figure-11.html"><a href="supplementary-figure-11.html"><i class="fa fa-check"></i><b>16</b> Supplementary Figure 11</a><ul>
<li class="chapter" data-level="16.1" data-path="supplementary-figure-11.html"><a href="supplementary-figure-11.html#summary-12"><i class="fa fa-check"></i><b>16.1</b> Summary</a></li>
<li class="chapter" data-level="16.2" data-path="supplementary-figure-11.html"><a href="supplementary-figure-11.html#details-of-s11.r"><i class="fa fa-check"></i><b>16.2</b> Details of <code>S11.R</code></a></li>
</ul></li>
<li class="chapter" data-level="17" data-path="supplementary-figure-12.html"><a href="supplementary-figure-12.html"><i class="fa fa-check"></i><b>17</b> Supplementary Figure 12</a><ul>
<li class="chapter" data-level="17.1" data-path="supplementary-figure-12.html"><a href="supplementary-figure-12.html#summary-13"><i class="fa fa-check"></i><b>17.1</b> Summary</a></li>
<li class="chapter" data-level="17.2" data-path="supplementary-figure-12.html"><a href="supplementary-figure-12.html#details-of-s12.r"><i class="fa fa-check"></i><b>17.2</b> Details of <code>S12.R</code></a><ul>
<li class="chapter" data-level="17.2.1" data-path="supplementary-figure-12.html"><a href="supplementary-figure-12.html#reading-in-data-2"><i class="fa fa-check"></i><b>17.2.1</b> Reading in Data</a></li>
<li class="chapter" data-level="17.2.2" data-path="supplementary-figure-12.html"><a href="supplementary-figure-12.html#subfigure-s12-a"><i class="fa fa-check"></i><b>17.2.2</b> Subfigure S12 a</a></li>
<li class="chapter" data-level="17.2.3" data-path="supplementary-figure-12.html"><a href="supplementary-figure-12.html#subfigure-s12-b"><i class="fa fa-check"></i><b>17.2.3</b> Subfigure S12 b</a></li>
<li class="chapter" data-level="17.2.4" data-path="supplementary-figure-12.html"><a href="supplementary-figure-12.html#subfigure-s12-c"><i class="fa fa-check"></i><b>17.2.4</b> Subfigure S12 c</a></li>
</ul></li>
</ul></li>
<li class="chapter" data-level="18" data-path="supplementary-figure-13.html"><a href="supplementary-figure-13.html"><i class="fa fa-check"></i><b>18</b> Supplementary Figure 13</a><ul>
<li class="chapter" data-level="18.1" data-path="supplementary-figure-13.html"><a href="supplementary-figure-13.html#summary-14"><i class="fa fa-check"></i><b>18.1</b> Summary</a></li>
<li class="chapter" data-level="18.2" data-path="supplementary-figure-13.html"><a href="supplementary-figure-13.html#details-of-s13.r"><i class="fa fa-check"></i><b>18.2</b> Details of <code>S13.R</code></a></li>
</ul></li>
<li class="chapter" data-level="19" data-path="supplementary-figure-14.html"><a href="supplementary-figure-14.html"><i class="fa fa-check"></i><b>19</b> Supplementary Figure 14</a><ul>
<li class="chapter" data-level="19.1" data-path="supplementary-figure-14.html"><a href="supplementary-figure-14.html#summary-15"><i class="fa fa-check"></i><b>19.1</b> Summary</a></li>
<li class="chapter" data-level="19.2" data-path="supplementary-figure-14.html"><a href="supplementary-figure-14.html#details-of-s14.r"><i class="fa fa-check"></i><b>19.2</b> Details of <code>S14.R</code></a></li>
</ul></li>
<li class="chapter" data-level="20" data-path="supplementary-figure-15.html"><a href="supplementary-figure-15.html"><i class="fa fa-check"></i><b>20</b> Supplementary Figure 15</a><ul>
<li class="chapter" data-level="20.1" data-path="supplementary-figure-15.html"><a href="supplementary-figure-15.html#summary-16"><i class="fa fa-check"></i><b>20.1</b> Summary</a></li>
<li class="chapter" data-level="20.2" data-path="supplementary-figure-15.html"><a href="supplementary-figure-15.html#details-of-s15.r"><i class="fa fa-check"></i><b>20.2</b> Details of <code>S15.R</code></a><ul>
<li class="chapter" data-level="20.2.1" data-path="supplementary-figure-15.html"><a href="supplementary-figure-15.html#additions-in-s15.plot_fun.r"><i class="fa fa-check"></i><b>20.2.1</b> Additions in <code>S15.plot_fun.R</code></a></li>
</ul></li>
</ul></li>
<li class="divider"></li>
<li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li>
<li> <image src="GL.svg" alt="Smiley face" style="width:100%; height:100px;"> </li>

</ul>

      </nav>
    </div>

    <div class="book-body">
      <div class="body-inner">
        <div class="book-header" role="navigation">
          <h1>
            <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Script repository</a>
          </h1>
        </div>

        <div class="page-wrapper" tabindex="-1" role="main">
          <div class="page-inner">

            <section class="normal" id="section-">
<div id="figure-3" class="section level1">
<h1><span class="header-section-number">5</span> Figure 3</h1>
<div id="summary-2" class="section level2">
<h2><span class="header-section-number">5.1</span> Summary</h2>
<p>This is the accessory documentation of Figure 3.</p>
<p>The Figure can be recreated by running the <strong>R</strong> script <code>F3.R</code>:</p>
<div class="sourceCode"><pre class="sourceCode sh"><code class="sourceCode bash"><span class="bu">cd</span> <span class="va">$WORK</span>/3_figures/F_scripts

<span class="ex">Rscript</span> --vanilla F3.R
<span class="fu">rm</span> Rplots.pdf</code></pre></div>
</div>
<div id="details-of-f3.r" class="section level2">
<h2><span class="header-section-number">5.2</span> Details of <code>F3.R</code></h2>
<p>In the following, the individual steps of the R script are documented. Is an executable R script that depends on a variety of image manipulation and data managing and genomic data packages.</p>
<p>It Furthermore depends on the R scripts <code>F3.functions.R</code>,<code>F3.genomeWide_box.R</code> and <code>F3.peakArea_box.R</code> (all located under <code>$WORK/0_data/0_scripts</code>).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(tidyverse)
<span class="kw">library</span>(scales)
<span class="kw">library</span>(cowplot)
<span class="kw">library</span>(grid)
<span class="kw">library</span>(gridSVG)
<span class="kw">library</span>(grImport2)
<span class="kw">source</span>(<span class="st">&#39;../../0_data/0_scripts/F3.functions.R&#39;</span>)</code></pre></div>
<p>The script <code>F3.functions.R</code>contains a function (<code>trplot()</code>) that plots a single LD triangle as seen in Figure 3. The Details of this script are explained below. The output depends on the data set plotted (sub figure a contains additional annotations).</p>
<p>We create an empty list that is then filled with the subplots using the <code>trplot()</code> function.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">plts &lt;-<span class="st"> </span><span class="kw">list</span>()
<span class="cf">for</span>(k <span class="cf">in</span> <span class="dv">1</span><span class="op">:</span><span class="dv">7</span>){
  plts[[k]] &lt;-<span class="st"> </span><span class="kw">trplot</span>(k)
}</code></pre></div>
<p>An individual result will look like this (plts[[1]] &amp; plts[[2]]):</p>
<center>
<img src="F3_files/figure-html/basePlotSHOW-1.png" width="672" />
</center>
<p>The basic plots are transformed into <code>grid obgects</code>. These are afterwards rotated by 45 degrees.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">tN &lt;-<span class="st"> </span><span class="kw">theme</span>(<span class="dt">legend.position =</span> <span class="st">&#39;none&#39;</span>)
pG1 &lt;-<span class="st"> </span><span class="kw">ggplotGrob</span>(plts[[<span class="dv">1</span>]]<span class="op">+</span>tN)
pG2 &lt;-<span class="st"> </span><span class="kw">ggplotGrob</span>(plts[[<span class="dv">2</span>]]<span class="op">+</span>tN)
pG3 &lt;-<span class="st"> </span><span class="kw">ggplotGrob</span>(plts[[<span class="dv">3</span>]]<span class="op">+</span>tN)
pG4 &lt;-<span class="st"> </span><span class="kw">ggplotGrob</span>(plts[[<span class="dv">4</span>]]<span class="op">+</span>tN)
pG5 &lt;-<span class="st"> </span><span class="kw">ggplotGrob</span>(plts[[<span class="dv">5</span>]]<span class="op">+</span>tN)
pG6 &lt;-<span class="st"> </span><span class="kw">ggplotGrob</span>(plts[[<span class="dv">6</span>]]<span class="op">+</span>tN)
pG7 &lt;-<span class="st"> </span><span class="kw">ggplotGrob</span>(plts[[<span class="dv">7</span>]]<span class="op">+</span>tN)

pGr1 &lt;-<span class="st"> </span><span class="kw">editGrob</span>(pG1, <span class="dt">vp=</span><span class="kw">viewport</span>(<span class="dt">x=</span><span class="fl">0.5</span>, <span class="dt">y=</span><span class="fl">0.91</span>, <span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">width =</span> .<span class="dv">7</span>), <span class="dt">name=</span><span class="st">&quot;pG1&quot;</span>)
pGr2 &lt;-<span class="st"> </span><span class="kw">editGrob</span>(pG2, <span class="dt">vp=</span><span class="kw">viewport</span>(<span class="dt">x=</span><span class="fl">0.25</span>, <span class="dt">y=</span><span class="fl">0.535</span>, <span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">width =</span> .<span class="dv">28</span>), <span class="dt">name=</span><span class="st">&quot;pG2&quot;</span>)
pGr3 &lt;-<span class="st"> </span><span class="kw">editGrob</span>(pG3, <span class="dt">vp=</span><span class="kw">viewport</span>(<span class="dt">x=</span><span class="fl">0.25</span>, <span class="dt">y=</span><span class="fl">0.352</span>, <span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">width =</span> .<span class="dv">28</span>), <span class="dt">name=</span><span class="st">&quot;pG3&quot;</span>)
pGr4 &lt;-<span class="st"> </span><span class="kw">editGrob</span>(pG4, <span class="dt">vp=</span><span class="kw">viewport</span>(<span class="dt">x=</span><span class="fl">0.25</span>, <span class="dt">y=</span><span class="fl">0.17</span>, <span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">width =</span> .<span class="dv">28</span>), <span class="dt">name=</span><span class="st">&quot;pG4&quot;</span>)
pGr5 &lt;-<span class="st"> </span><span class="kw">editGrob</span>(pG5, <span class="dt">vp=</span><span class="kw">viewport</span>(<span class="dt">x=</span><span class="fl">0.75</span>, <span class="dt">y=</span><span class="fl">0.535</span>, <span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">width =</span> .<span class="dv">28</span>), <span class="dt">name=</span><span class="st">&quot;pG5&quot;</span>)
pGr6 &lt;-<span class="st"> </span><span class="kw">editGrob</span>(pG6, <span class="dt">vp=</span><span class="kw">viewport</span>(<span class="dt">x=</span><span class="fl">0.75</span>, <span class="dt">y=</span><span class="fl">0.352</span>, <span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">width =</span> .<span class="dv">28</span>), <span class="dt">name=</span><span class="st">&quot;pG5&quot;</span>)
pGr7 &lt;-<span class="st"> </span><span class="kw">editGrob</span>(pG7, <span class="dt">vp=</span><span class="kw">viewport</span>(<span class="dt">x=</span><span class="fl">0.75</span>, <span class="dt">y=</span><span class="fl">0.17</span>, <span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">width =</span> .<span class="dv">28</span>), <span class="dt">name=</span><span class="st">&quot;pG5&quot;</span>)</code></pre></div>
<p>Then, the data for the box plots are loaded and plotted within external scripts.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">source</span>(<span class="st">&#39;../../0_data/0_scripts/F3.genomeWide_box.R&#39;</span>)
<span class="kw">source</span>(<span class="st">&#39;../../0_data/0_scripts/F3.peakArea_box.R&#39;</span>)</code></pre></div>
<p>Additional annotations are generated and external annotations loaded. Then, variables used for placing the annotations are generated.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">pGRAD &lt;-<span class="st"> </span><span class="kw">ggplot</span>(<span class="dt">data =</span> <span class="kw">data.frame</span>(<span class="dt">x=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>,<span class="op">-</span><span class="dv">1</span>,<span class="dv">0</span>),
                                  <span class="dt">y=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">15</span>,<span class="dv">15</span>,<span class="dv">0</span>)),
                <span class="kw">aes</span>(x,y))<span class="op">+</span><span class="kw">geom_polygon</span>(<span class="dt">fill=</span><span class="st">&#39;lightgray&#39;</span>)<span class="op">+</span><span class="kw">coord_equal</span>()<span class="op">+</span><span class="kw">theme_void</span>()

nigGrob &lt;-<span class="st"> </span><span class="kw">gTree</span>(<span class="dt">children=</span><span class="kw">gList</span>(<span class="kw">pictureGrob</span>(<span class="kw">readPicture</span>(<span class="st">&quot;../../0_data/0_img/nigricans-cairo.svg&quot;</span>))))
pueGrob &lt;-<span class="st"> </span><span class="kw">gTree</span>(<span class="dt">children=</span><span class="kw">gList</span>(<span class="kw">pictureGrob</span>(<span class="kw">readPicture</span>(<span class="st">&quot;../../0_data/0_img/puella-cairo.svg&quot;</span>))))
uniGrob &lt;-<span class="st"> </span><span class="kw">gTree</span>(<span class="dt">children=</span><span class="kw">gList</span>(<span class="kw">pictureGrob</span>(<span class="kw">readPicture</span>(<span class="st">&quot;../../0_data/0_img/unicolor-cairo.svg&quot;</span>))))

belGrob &lt;-<span class="st"> </span><span class="kw">gTree</span>(<span class="dt">children=</span><span class="kw">gList</span>(<span class="kw">pictureGrob</span>(<span class="kw">readPicture</span>(<span class="st">&quot;../../0_data/0_img/belize-cairo.svg&quot;</span>))))
honGrob &lt;-<span class="st"> </span><span class="kw">gTree</span>(<span class="dt">children=</span><span class="kw">gList</span>(<span class="kw">pictureGrob</span>(<span class="kw">readPicture</span>(<span class="st">&quot;../../0_data/0_img/honduras-cairo.svg&quot;</span>))))
panGrob &lt;-<span class="st"> </span><span class="kw">gTree</span>(<span class="dt">children=</span><span class="kw">gList</span>(<span class="kw">pictureGrob</span>(<span class="kw">readPicture</span>(<span class="st">&quot;../../0_data/0_img/panama-cairo.svg&quot;</span>))))
globGrob &lt;-<span class="st"> </span><span class="kw">gTree</span>(<span class="dt">children=</span><span class="kw">gList</span>(<span class="kw">pictureGrob</span>(<span class="kw">readPicture</span>(<span class="st">&quot;../../0_data/0_img/caribbean-cairo.svg&quot;</span>))))

leg &lt;-<span class="st"> </span><span class="kw">get_legend</span>(plts[[<span class="dv">1</span>]]<span class="op">+</span><span class="kw">theme</span>(<span class="dt">legend.direction =</span> <span class="st">&#39;horizontal&#39;</span>)<span class="op">+</span><span class="st"> </span><span class="kw">guides</span>(<span class="dt">fill =</span> <span class="kw">guide_legend</span>(<span class="dt">nrow=</span><span class="dv">1</span>)))
sY &lt;-<span class="st"> </span>.<span class="dv">035</span>;
sX &lt;-<span class="st"> </span><span class="op">-</span>.<span class="dv">03</span>;</code></pre></div>
<p>Finally, the complete Figure 3 is put together.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">F3 &lt;-<span class="st"> </span><span class="kw">ggdraw</span>(pGr1)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_plot</span>(pBOX,<span class="op">-</span>.<span class="dv">1</span>,.<span class="dv">54</span>,.<span class="dv">45</span>,.<span class="dv">21</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_plot</span>(boxGenes,.<span class="dv">65</span>,.<span class="dv">54</span>,.<span class="dv">45</span>,.<span class="dv">21</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_plot</span>(pGRAD,.<span class="dv">307</span>,<span class="op">-</span>.<span class="dv">018</span>,.<span class="dv">16</span>,.<span class="dv">53</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(pGr2,<span class="dv">0</span>,<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(leg,<span class="op">-</span>.<span class="dv">33</span>,.<span class="dv">22</span>,<span class="dv">1</span>,<span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(pGr3,<span class="dv">0</span>,<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(pGr4,<span class="dv">0</span>,<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(pGr5,<span class="dv">0</span>,<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(pGr6,<span class="dv">0</span>,<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(pGr7,<span class="dv">0</span>,<span class="dv">0</span>,<span class="dv">1</span>,<span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(nigGrob, <span class="fl">0.85</span>, <span class="fl">0.38</span>, <span class="fl">0.12</span>, <span class="fl">0.095</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(pueGrob, <span class="fl">0.85</span>, <span class="fl">0.2</span>, <span class="fl">0.12</span>, <span class="fl">0.095</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(uniGrob, <span class="fl">0.85</span>, <span class="dv">0</span>, <span class="fl">0.12</span>, <span class="fl">0.095</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(panGrob, <span class="fl">0.35</span><span class="op">+</span>sX<span class="op">+</span>.<span class="dv">01</span>, <span class="fl">0.37</span><span class="op">+</span>sY, <span class="fl">0.12</span>, <span class="fl">0.045</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(belGrob, <span class="fl">0.35</span><span class="op">+</span>sX<span class="op">+</span>.<span class="dv">01</span>, <span class="fl">0.19</span><span class="op">+</span>sY, <span class="fl">0.12</span>, <span class="fl">0.045</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(honGrob, <span class="fl">0.35</span><span class="op">+</span>sX, <span class="dv">0</span><span class="op">+</span>sY, <span class="fl">0.14</span>, <span class="fl">0.045</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_grob</span>(globGrob, <span class="fl">0.06</span>, .<span class="dv">925</span>, <span class="fl">0.08</span>, <span class="fl">0.08</span>)<span class="op">+</span>
<span class="st">  </span><span class="kw">draw_plot_label</span>(letters[<span class="dv">1</span><span class="op">:</span><span class="dv">5</span>],
                  <span class="dt">x =</span> <span class="kw">c</span>(<span class="kw">rep</span>(<span class="fl">0.01</span>,<span class="dv">2</span>),.<span class="dv">87</span>,<span class="fl">0.01</span>,.<span class="dv">54</span>),
                  <span class="dt">y=</span><span class="kw">c</span>(.<span class="dv">99</span>,.<span class="dv">81</span>,.<span class="dv">81</span>,.<span class="dv">57</span>,.<span class="dv">57</span>),
                  <span class="dt">size =</span> <span class="dv">14</span>)</code></pre></div>
<p>The final figure is then exported using <code>ggsave()</code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">ggsave</span>(<span class="dt">plot =</span> F3,<span class="dt">filename =</span> <span class="st">&#39;../output/F3.png&#39;</span>,<span class="dt">width =</span> <span class="dv">183</span>,<span class="dt">height =</span> <span class="dv">235</span>,<span class="dt">units =</span> <span class="st">&#39;mm&#39;</span>,<span class="dt">dpi =</span> <span class="dv">150</span>)</code></pre></div>
<center>
<img src="F3_files/figure-html/f4SHOW-1.png" width="691.65356544" />
</center>
<hr />
</div>
<div id="details-of-f3.functions.r" class="section level2">
<h2><span class="header-section-number">5.3</span> Details of <code>F3.functions.R</code></h2>
<p>The script first defines a function for standard error</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">se &lt;-<span class="st">  </span><span class="cf">function</span>(x){
  x2 &lt;-<span class="st"> </span>x[<span class="op">!</span><span class="kw">is.na</span>(x)]
  <span class="kw">return</span>(<span class="kw">sd</span>(x2)<span class="op">/</span><span class="kw">sqrt</span>(<span class="kw">length</span>(x2)))}</code></pre></div>
<p>And then the plotting function for the LD triangles is defined. Within the <code>trplot()</code> function the <code>sel</code> parameter specifies the selected data set. Then, a lot of annotation elements are generated, data is transformed to match the triangle layout of the plot and the base plot is created.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">trplot &lt;-<span class="st"> </span><span class="cf">function</span>(sel){
  <span class="co"># the inventory of LD data files</span>
  files &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;global&quot;</span>,<span class="st">&quot;boc&quot;</span>,<span class="st">&quot;bel&quot;</span>,<span class="st">&quot;hon&quot;</span>,<span class="st">&quot;pue&quot;</span>,<span class="st">&quot;nig&quot;</span>,<span class="st">&quot;uni&quot;</span>,<span class="st">&quot;nig-pue&quot;</span>,<span class="st">&quot;nig-uni&quot;</span>,<span class="st">&quot;pue-uni&quot;</span>)
  <span class="co"># reading in the LD data</span>
  data &lt;-<span class="st"> </span><span class="kw">read.csv</span>(<span class="kw">paste</span>(<span class="st">&#39;../../2_output/08_popGen/07_LD/&#39;</span>,files[sel],<span class="st">&#39;-10000-bins.txt&#39;</span>,<span class="dt">sep=</span><span class="st">&#39;&#39;</span>),<span class="dt">sep=</span><span class="st">&#39;</span><span class="ch">\t</span><span class="st">&#39;</span>)
  <span class="co"># confirm selection</span>
  <span class="kw">message</span>(files[sel])</code></pre></div>
<p>The genomic positions (start, end, length and spacing between) of the ranges of interest are stored.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  s1=<span class="dv">17620000</span>;s2=<span class="dv">19910000</span>;s3=<span class="dv">21960000</span>;s4=<span class="dv">22320000</span>;
  e2=<span class="dv">20660000</span>;e3=<span class="dv">22460000</span>;
  stp=<span class="dv">20000</span>;
  l1=<span class="dv">500000</span>;l2=<span class="dv">750000</span>;l3=<span class="dv">500000</span>;l4=<span class="dv">500000</span></code></pre></div>
<p>Then we define a vector containing the x-shift needed to transform the positions of the candidate genes on the respective LGs into the transformed x-axis of the LD triangles</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  scling &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="op">-</span>s1,<span class="op">-</span>s2<span class="op">+</span>(l1<span class="op">+</span>stp),<span class="op">-</span>s3<span class="op">+</span>(l1<span class="op">+</span>l2<span class="op">+</span><span class="dv">2</span><span class="op">*</span>stp),<span class="op">-</span>s4<span class="op">+</span>(l1<span class="op">+</span>l2<span class="op">+</span>l3<span class="op">+</span>(stp<span class="op">*</span><span class="dv">3</span>)))</code></pre></div>
<p>The LD data is read in and positions are transformed.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  dt &lt;-<span class="st"> </span>data <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">mutate</span>(<span class="dt">miX =</span> <span class="kw">floor</span>(Mx<span class="op">/</span><span class="dv">10000</span>),<span class="dt">miY=</span><span class="kw">floor</span>(My<span class="op">/</span><span class="dv">10000</span>))</code></pre></div>
<p>We generate a data frame that includes the gene positions (taken from the annotation file) the respective entry in our scale transformation vector, the LG and gene name. The genomic positions are then transformed.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  genes &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">start=</span><span class="kw">c</span>(<span class="dv">17871610</span>,<span class="dv">20186151</span>,<span class="dv">22225149</span>,<span class="dv">22553187</span>,<span class="dv">22556763</span>,<span class="dv">22561894</span>,<span class="dv">22573388</span>),
                      <span class="dt">end=</span><span class="kw">c</span>(<span class="dv">17873915</span>,<span class="dv">20347811</span>,<span class="dv">22228342</span>,<span class="dv">22555052</span>,<span class="dv">22559742</span>,<span class="dv">22566321</span>,<span class="dv">22575503</span>),
                      <span class="dt">sclr=</span><span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">3</span>,<span class="dv">4</span>,<span class="dv">4</span>,<span class="dv">4</span>,<span class="dv">4</span>),
                      <span class="dt">LG=</span><span class="kw">c</span>(<span class="st">&quot;LG09&quot;</span>,<span class="st">&quot;LG12-1&quot;</span>,<span class="st">&quot;LG12-2&quot;</span>,<span class="st">&quot;LG17&quot;</span>,<span class="st">&quot;LG17&quot;</span>,<span class="st">&quot;LG17&quot;</span>,<span class="st">&quot;LG17&quot;</span>),
                      <span class="dt">name=</span><span class="kw">c</span>(<span class="st">&quot;sox10&quot;</span>,<span class="st">&#39;casz1&#39;</span>,<span class="st">&quot;hoxc13a&quot;</span>,<span class="st">&quot;sws2a\u03B1&quot;</span>,<span class="st">&quot;sws2a\u03B2&quot;</span>,<span class="st">&quot;sws2b&quot;</span>,<span class="st">&quot;lws&quot;</span>))
  genes &lt;-<span class="st"> </span>genes <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">mutate</span>(<span class="dt">Nx1 =</span> (start<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>,<span class="dt">Nx2 =</span> (end<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>,
                            <span class="dt">labPOS =</span> (Nx1<span class="op">+</span>Nx2)<span class="op">/</span><span class="dv">2</span>)</code></pre></div>
<p>The position of some of the gene labels need shifting to avoid overlapping.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  genes<span class="op">$</span>labPOS[genes<span class="op">$</span>name <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;sws2a\u03B1&quot;</span>,<span class="st">&quot;sws2a\u03B2&quot;</span>,<span class="st">&quot;sws2b&quot;</span>,<span class="st">&quot;lws&quot;</span>)] &lt;-<span class="st"> </span>genes<span class="op">$</span>labPOS[genes<span class="op">$</span>name <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;sws2a\u03B1&quot;</span>,<span class="st">&quot;sws2a\u03B2&quot;</span>,<span class="st">&quot;sws2b&quot;</span>,<span class="st">&quot;lws&quot;</span>)]<span class="op">+</span><span class="kw">c</span>(<span class="op">-</span><span class="dv">16</span>,<span class="op">-</span><span class="dv">1</span>,<span class="dv">12</span>,<span class="dv">20</span>)</code></pre></div>
<p>Then we define a data frame for the polygons that zoom onto the gene position within the annotation/legend of sub figure a.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  GZrS &lt;-<span class="st"> </span><span class="dv">40000</span>;GZrS2 &lt;-<span class="st"> </span><span class="dv">20000</span>; <span class="co">#gene zoom offset</span>
  BS &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="op">-</span><span class="dv">5</span>,<span class="dv">5</span>,<span class="op">-</span><span class="dv">4</span>,<span class="dv">3</span>,<span class="op">-</span><span class="dv">8</span>,<span class="dv">8</span>,<span class="op">-</span><span class="dv">20</span>,<span class="op">-</span><span class="dv">10</span>,<span class="op">-</span><span class="dv">6</span>,<span class="dv">5</span>,<span class="dv">7</span>,<span class="dv">16</span>,<span class="dv">17</span>,<span class="dv">22</span>)<span class="op">*</span><span class="dv">10000</span> <span class="co"># Backshifter for gene zoom</span>
  GZdf &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">x=</span><span class="kw">c</span>(genes<span class="op">$</span>start[<span class="dv">1</span>],genes<span class="op">$</span>end[<span class="dv">1</span>],genes<span class="op">$</span>end[<span class="dv">1</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">1</span>],genes<span class="op">$</span>start[<span class="dv">1</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">2</span>],genes<span class="op">$</span>start[<span class="dv">1</span>],
                         genes<span class="op">$</span>start[<span class="dv">2</span>],genes<span class="op">$</span>end[<span class="dv">2</span>],genes<span class="op">$</span>end[<span class="dv">2</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">3</span>],genes<span class="op">$</span>start[<span class="dv">2</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">4</span>],genes<span class="op">$</span>start[<span class="dv">2</span>],
                         genes<span class="op">$</span>start[<span class="dv">3</span>],genes<span class="op">$</span>end[<span class="dv">3</span>],genes<span class="op">$</span>end[<span class="dv">3</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">5</span>],genes<span class="op">$</span>start[<span class="dv">3</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">6</span>],genes<span class="op">$</span>start[<span class="dv">3</span>],
                         genes<span class="op">$</span>start[<span class="dv">4</span>],genes<span class="op">$</span>end[<span class="dv">4</span>],genes<span class="op">$</span>end[<span class="dv">4</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">7</span>],genes<span class="op">$</span>start[<span class="dv">4</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">8</span>],genes<span class="op">$</span>start[<span class="dv">4</span>],
                         genes<span class="op">$</span>start[<span class="dv">5</span>],genes<span class="op">$</span>end[<span class="dv">5</span>],genes<span class="op">$</span>end[<span class="dv">5</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">9</span>],genes<span class="op">$</span>start[<span class="dv">5</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">10</span>],genes<span class="op">$</span>start[<span class="dv">5</span>],
                         genes<span class="op">$</span>start[<span class="dv">6</span>],genes<span class="op">$</span>end[<span class="dv">6</span>],genes<span class="op">$</span>end[<span class="dv">6</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">11</span>],genes<span class="op">$</span>start[<span class="dv">6</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">12</span>],genes<span class="op">$</span>start[<span class="dv">6</span>],
                         genes<span class="op">$</span>start[<span class="dv">7</span>],genes<span class="op">$</span>end[<span class="dv">7</span>],genes<span class="op">$</span>end[<span class="dv">7</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">13</span>],genes<span class="op">$</span>start[<span class="dv">7</span>]<span class="op">+</span>GZrS<span class="op">+</span>BS[<span class="dv">14</span>],genes<span class="op">$</span>start[<span class="dv">7</span>])<span class="op">+</span>GZrS2,
                     <span class="dt">y=</span><span class="kw">c</span>(genes<span class="op">$</span>start[<span class="dv">1</span>],genes<span class="op">$</span>end[<span class="dv">1</span>],genes<span class="op">$</span>end[<span class="dv">1</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">1</span>],genes<span class="op">$</span>start[<span class="dv">1</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">2</span>],genes<span class="op">$</span>start[<span class="dv">1</span>],
                         genes<span class="op">$</span>start[<span class="dv">2</span>],genes<span class="op">$</span>end[<span class="dv">2</span>],genes<span class="op">$</span>end[<span class="dv">2</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">3</span>],genes<span class="op">$</span>start[<span class="dv">2</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">4</span>],genes<span class="op">$</span>start[<span class="dv">2</span>],
                         genes<span class="op">$</span>start[<span class="dv">3</span>],genes<span class="op">$</span>end[<span class="dv">3</span>],genes<span class="op">$</span>end[<span class="dv">3</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">5</span>],genes<span class="op">$</span>start[<span class="dv">3</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">6</span>],genes<span class="op">$</span>start[<span class="dv">3</span>],
                         genes<span class="op">$</span>start[<span class="dv">4</span>],genes<span class="op">$</span>end[<span class="dv">4</span>],genes<span class="op">$</span>end[<span class="dv">4</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">7</span>],genes<span class="op">$</span>start[<span class="dv">4</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">8</span>],genes<span class="op">$</span>start[<span class="dv">4</span>],
                         genes<span class="op">$</span>start[<span class="dv">5</span>],genes<span class="op">$</span>end[<span class="dv">5</span>],genes<span class="op">$</span>end[<span class="dv">5</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">9</span>],genes<span class="op">$</span>start[<span class="dv">5</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">10</span>],genes<span class="op">$</span>start[<span class="dv">5</span>],
                         genes<span class="op">$</span>start[<span class="dv">6</span>],genes<span class="op">$</span>end[<span class="dv">6</span>],genes<span class="op">$</span>end[<span class="dv">6</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">11</span>],genes<span class="op">$</span>start[<span class="dv">6</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">12</span>],genes<span class="op">$</span>start[<span class="dv">6</span>],
                         genes<span class="op">$</span>start[<span class="dv">7</span>],genes<span class="op">$</span>end[<span class="dv">7</span>],genes<span class="op">$</span>end[<span class="dv">7</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">13</span>],genes<span class="op">$</span>start[<span class="dv">7</span>]<span class="op">-</span>GZrS<span class="op">+</span>BS[<span class="dv">14</span>],genes<span class="op">$</span>start[<span class="dv">7</span>])<span class="op">-</span>GZrS2,
                     <span class="dt">grp=</span><span class="kw">rep</span>(letters[<span class="dv">1</span><span class="op">:</span><span class="dv">7</span>],<span class="dt">each=</span><span class="dv">5</span>)) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">    </span><span class="kw">mutate</span>(<span class="dt">sclr=</span><span class="kw">rep</span>(<span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">2</span>,<span class="dv">3</span>,<span class="dv">4</span>,<span class="dv">4</span>,<span class="dv">4</span>,<span class="dv">4</span>),<span class="dt">each=</span><span class="dv">5</span>),
           <span class="dt">Nx1 =</span> (x<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>,
           <span class="dt">Nx2 =</span> (y<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>)</code></pre></div>
<p>Some parameters are set for plotting (base colors for the LD color gradient, gene annotation color, zoom color and y offsets for LG labels, LG background and gene-axis).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  clr =<span class="st"> </span><span class="kw">c</span>(viridis<span class="op">::</span><span class="kw">inferno</span>(<span class="dv">5</span>)[<span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">1</span><span class="op">:</span><span class="dv">5</span>)])
  Gcol &lt;-<span class="st"> &#39;#3bb33b&#39;</span>
  Zcol =<span class="st"> </span><span class="kw">rgb</span>(.<span class="dv">94</span>,.<span class="dv">94</span>,.<span class="dv">94</span>)
  DG &lt;-<span class="st"> </span><span class="kw">rgb</span>(.<span class="dv">4</span>,.<span class="dv">4</span>,.<span class="dv">4</span>)
  LGoffset &lt;-<span class="st"> </span><span class="dv">15</span>
  GLABoffset &lt;-<span class="st"> </span><span class="dv">8</span></code></pre></div>
<p>At this point, the data set selection is checked. If the current selection is the global data set, the additional annotation is included.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  <span class="cf">if</span>(sel <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(<span class="dv">1</span>,<span class="dv">8</span>)){</code></pre></div>
<p>For the additional annotation, several helpers are needed and defined as data frames. The construction of these is obscured by the fact that in the base plot, the later horizontal bands are plotted tilted by an angle of 45 degrees. Therefore, a simple y offset affects both x and y axis in the base plot.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">    rS &lt;-<span class="st"> </span><span class="dv">100000</span> <span class="co"># width of grey annotation band</span>
    zmRange &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">x=</span><span class="kw">c</span>(s1,s1<span class="op">+</span>l1,s1<span class="op">+</span>l1<span class="op">+</span>rS,s1<span class="op">+</span>rS,s1,
                              s2,s2<span class="op">+</span>l2,s2<span class="op">+</span>l2<span class="op">+</span>rS,s2<span class="op">+</span>rS,s2,
                              s3,s3<span class="op">+</span>l3,s3<span class="op">+</span>l3<span class="op">+</span>rS,s3<span class="op">+</span>rS,s3,
                              s4,s4<span class="op">+</span>l4,s4<span class="op">+</span>l4<span class="op">+</span>rS,s4<span class="op">+</span>rS,s4),
                          <span class="dt">y=</span><span class="kw">c</span>(s1,s1<span class="op">+</span>l1,s1<span class="op">+</span>l1<span class="op">-</span>rS,s1<span class="op">-</span>rS,s1,
                              s2,s2<span class="op">+</span>l2,s2<span class="op">+</span>l2<span class="op">-</span>rS,s2<span class="op">-</span>rS,s2,
                              s3,s3<span class="op">+</span>l3,s3<span class="op">+</span>l3<span class="op">-</span>rS,s3<span class="op">-</span>rS,s3,
                              s4,s4<span class="op">+</span>l4,s4<span class="op">+</span>l4<span class="op">-</span>rS,s4<span class="op">-</span>rS,s4),
                          <span class="dt">grp=</span><span class="kw">rep</span>(letters[<span class="dv">1</span><span class="op">:</span><span class="dv">4</span>],<span class="dt">each=</span><span class="dv">5</span>)) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">      </span><span class="kw">mutate</span>(<span class="dt">sclr=</span><span class="kw">rep</span>(<span class="dv">1</span><span class="op">:</span><span class="dv">4</span>,<span class="dt">each=</span><span class="dv">5</span>),
             <span class="dt">Nx1 =</span> (x<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span><span class="op">-</span><span class="dv">1</span>,
             <span class="dt">Nx2 =</span> (y<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>)
    
    rS2 &lt;-<span class="st"> </span>.<span class="dv">75</span><span class="op">*</span>rS <span class="co"># width of dark grey LG label band</span>
    zmRange2 &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">x=</span><span class="kw">c</span>(s1,s1<span class="op">+</span>l1,s1<span class="op">+</span>l1<span class="op">+</span>rS2,s1<span class="op">+</span>rS2,s1,
                               s2,s2<span class="op">+</span>l2,s2<span class="op">+</span>l2<span class="op">+</span>rS2,s2<span class="op">+</span>rS2,s2,
                               s3,s3<span class="op">+</span>l3,s3<span class="op">+</span>l3<span class="op">+</span>rS2,s3<span class="op">+</span>rS2,s3,
                               s4,s4<span class="op">+</span>l4,s4<span class="op">+</span>l4<span class="op">+</span>rS2,s4<span class="op">+</span>rS2,s4),
                           <span class="dt">y=</span><span class="kw">c</span>(s1,s1<span class="op">+</span>l1,s1<span class="op">+</span>l1<span class="op">-</span>rS2,s1<span class="op">-</span>rS2,s1,
                               s2,s2<span class="op">+</span>l2,s2<span class="op">+</span>l2<span class="op">-</span>rS2,s2<span class="op">-</span>rS2,s2,
                               s3,s3<span class="op">+</span>l3,s3<span class="op">+</span>l3<span class="op">-</span>rS2,s3<span class="op">-</span>rS2,s3,
                               s4,s4<span class="op">+</span>l4,s4<span class="op">+</span>l4<span class="op">-</span>rS2,s4<span class="op">-</span>rS2,s4),
                           <span class="dt">grp=</span><span class="kw">rep</span>(letters[<span class="dv">1</span><span class="op">:</span><span class="dv">4</span>],<span class="dt">each=</span><span class="dv">5</span>)) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">      </span><span class="kw">mutate</span>(<span class="dt">sclr=</span><span class="kw">rep</span>(<span class="dv">1</span><span class="op">:</span><span class="dv">4</span>,<span class="dt">each=</span><span class="dv">5</span>),
             <span class="dt">Nx1 =</span> (x<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span><span class="op">-</span><span class="dv">1</span>,
             <span class="dt">Nx2 =</span> (y<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>)
    
    rS3 &lt;-<span class="st"> </span>.<span class="dv">07</span><span class="op">*</span>rS <span class="co"># width of dark grey gene axis</span>
    zmRange3 &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">x=</span><span class="kw">c</span>(s1,s1<span class="op">+</span>l1,s1<span class="op">+</span>l1<span class="op">+</span>rS3,s1<span class="op">+</span>rS3,s1,
                               s2,s2<span class="op">+</span>l2,s2<span class="op">+</span>l2<span class="op">+</span>rS3,s2<span class="op">+</span>rS3,s2,
                               s3,s3<span class="op">+</span>l3,s3<span class="op">+</span>l3<span class="op">+</span>rS3,s3<span class="op">+</span>rS3,s3,
                               s4,s4<span class="op">+</span>l4,s4<span class="op">+</span>l4<span class="op">+</span>rS3,s4<span class="op">+</span>rS3,s4),
                           <span class="dt">y=</span><span class="kw">c</span>(s1,s1<span class="op">+</span>l1,s1<span class="op">+</span>l1<span class="op">-</span>rS3,s1<span class="op">-</span>rS3,s1,
                               s2,s2<span class="op">+</span>l2,s2<span class="op">+</span>l2<span class="op">-</span>rS3,s2<span class="op">-</span>rS3,s2,
                               s3,s3<span class="op">+</span>l3,s3<span class="op">+</span>l3<span class="op">-</span>rS3,s3<span class="op">-</span>rS3,s3,
                               s4,s4<span class="op">+</span>l4,s4<span class="op">+</span>l4<span class="op">-</span>rS3,s4<span class="op">-</span>rS3,s4),
                           <span class="dt">grp=</span><span class="kw">rep</span>(letters[<span class="dv">1</span><span class="op">:</span><span class="dv">4</span>],<span class="dt">each=</span><span class="dv">5</span>)) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">      </span><span class="kw">mutate</span>(<span class="dt">sclr=</span><span class="kw">rep</span>(<span class="dv">1</span><span class="op">:</span><span class="dv">4</span>,<span class="dt">each=</span><span class="dv">5</span>),
             <span class="dt">Nx1 =</span> (x<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span><span class="op">-</span><span class="dv">1</span>,
             <span class="dt">Nx2 =</span> (y<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>)</code></pre></div>
<p>Then one data frame is defined containing the LG labels and positions and another one containing the borders of the genomic regions.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">    zmLab &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">x=</span><span class="kw">c</span>(s1<span class="op">+</span>.<span class="dv">5</span><span class="op">*</span>l1,s2<span class="op">+</span>.<span class="dv">5</span><span class="op">*</span>l2,s3<span class="op">+</span>.<span class="dv">5</span><span class="op">*</span>l3,s4<span class="op">+</span>.<span class="dv">5</span><span class="op">*</span>l4),
                        <span class="dt">label=</span><span class="kw">c</span>(<span class="st">&#39;LG09 (A)&#39;</span>,<span class="st">&#39;LG12 (B)&#39;</span>,<span class="st">&#39;LG12 (C)&#39;</span>,<span class="st">&#39;LG17 (D)&#39;</span>)) <span class="op">%&gt;%</span><span class="st">  </span>
<span class="st">      </span><span class="kw">mutate</span>(<span class="dt">sclr=</span><span class="dv">1</span><span class="op">:</span><span class="dv">4</span>, <span class="dt">Nx=</span> (x<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>)
    
    zmEND &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">x=</span><span class="kw">c</span>(s1,s1<span class="op">+</span>l1,
                            s2,s2<span class="op">+</span>l2,
                            s3,s3<span class="op">+</span>l3,
                            s4,s4<span class="op">+</span>l4)) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">      </span><span class="kw">mutate</span>(<span class="dt">sclr=</span><span class="kw">rep</span>(<span class="dv">1</span><span class="op">:</span><span class="dv">4</span>,<span class="dt">each=</span><span class="dv">2</span>),
             <span class="dt">Nx =</span> ((x<span class="op">+</span>scling[sclr])<span class="op">/</span><span class="dv">10000</span>)<span class="op">+</span><span class="kw">rep</span>(<span class="kw">c</span>(<span class="fl">2.5</span>,<span class="op">-</span><span class="dv">4</span>),<span class="dv">4</span>),
             <span class="dt">label=</span><span class="kw">round</span>((x<span class="op">/</span><span class="dv">1000000</span>),<span class="dv">2</span>))</code></pre></div>
<p>Three vectors containing text sizes (adjusted to Figure 3 &amp; Suppl. Figure 12) are created.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">    textSCALE1 &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="fl">1.8</span>,<span class="kw">rep</span>(<span class="ot">NA</span>,<span class="dv">6</span>),.<span class="dv">7</span>)
    textSCALE2 &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="dv">2</span>,<span class="kw">rep</span>(<span class="ot">NA</span>,<span class="dv">6</span>),<span class="dv">1</span>)
    textSCALE3 &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="fl">3.5</span>,<span class="kw">rep</span>(<span class="ot">NA</span>,<span class="dv">6</span>),<span class="fl">1.75</span>)    </code></pre></div>
<p>Then, the base plot is created and stored in <code>p1</code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">      <span class="co"># the data set is filtered to remove missing values</span>
      p1 &lt;-<span class="st"> </span><span class="kw">ggplot</span>(dt <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">filter</span>(<span class="op">!</span><span class="kw">is.na</span>(Mval)),<span class="kw">aes</span>(<span class="dt">fill=</span>Mval))<span class="op">+</span>
<span class="st">        </span><span class="co"># the aspect ratio of x and y scale needs to be fixed to 1:1</span>
<span class="st">        </span><span class="kw">coord_equal</span>()<span class="op">+</span>
<span class="st">        </span><span class="co"># adding the light gray band highlighting the genomic ganges </span>
<span class="st">        </span><span class="kw">geom_polygon</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>zmRange,
                     <span class="kw">aes</span>(<span class="dt">x=</span>Nx1<span class="op">+</span><span class="dv">1</span>,<span class="dt">y=</span>Nx2<span class="op">-</span><span class="dv">1</span>,<span class="dt">group=</span>grp),<span class="dt">fill=</span><span class="st">&#39;lightgray&#39;</span>)<span class="op">+</span>
<span class="st">        </span><span class="co"># adding the dark gray background of the LG labels</span>
<span class="st">        </span><span class="kw">geom_polygon</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>zmRange2,
                     <span class="kw">aes</span>(<span class="dt">x=</span>Nx1<span class="op">+</span><span class="dv">11</span>,<span class="dt">y=</span>Nx2<span class="op">-</span><span class="dv">11</span>,<span class="dt">group=</span>grp),<span class="dt">fill=</span>DG)<span class="op">+</span>
<span class="st">        </span><span class="co"># adding the dark gray gene axis</span>
<span class="st">        </span><span class="kw">geom_polygon</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>zmRange3,
                     <span class="kw">aes</span>(<span class="dt">x=</span>Nx1<span class="op">+</span><span class="fl">1.1</span>,<span class="dt">y=</span>Nx2<span class="op">-</span><span class="fl">1.1</span>,<span class="dt">group=</span>grp),<span class="dt">fill=</span>DG)<span class="op">+</span>
<span class="st">         </span><span class="co"># adding the light gene zoom polygons</span>
<span class="st">        </span><span class="kw">geom_polygon</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>GZdf,
                     <span class="kw">aes</span>(<span class="dt">x=</span>Nx1,<span class="dt">y=</span>Nx2,<span class="dt">group=</span>grp),<span class="dt">fill=</span>Zcol)<span class="op">+</span>
<span class="st">        </span><span class="co"># adding green gene highlights </span>
<span class="st">        </span><span class="kw">geom_segment</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>genes,
                     <span class="kw">aes</span>(<span class="dt">x=</span>Nx1<span class="op">+</span><span class="dv">1</span>,<span class="dt">y=</span>Nx1<span class="op">-</span><span class="dv">1</span>,<span class="dt">xend=</span>Nx2<span class="op">+</span><span class="dv">1</span>,<span class="dt">yend=</span>Nx2<span class="op">-</span><span class="dv">1</span>),
                     <span class="dt">col=</span>Gcol,<span class="dt">size=</span><span class="fl">1.5</span>)<span class="op">+</span>
<span class="st">        </span><span class="co"># adding LD data</span>
<span class="st">        </span><span class="kw">geom_tile</span>(<span class="kw">aes</span>(<span class="dt">x=</span>miX,<span class="dt">y=</span>miY))<span class="op">+</span>
<span class="st">        </span><span class="co"># adding labels for genomic range labels</span>
<span class="st">        </span><span class="kw">geom_text</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>zmEND,
                  <span class="kw">aes</span>(<span class="dt">x=</span>Nx<span class="op">+</span>LGoffset,<span class="dt">y=</span>Nx<span class="op">-</span>LGoffset,<span class="dt">label=</span><span class="kw">paste</span>(label,<span class="st">&#39;</span><span class="ch">\n</span><span class="st">(Mb)&#39;</span>)),
                  <span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">size=</span>textSCALE1[sel])<span class="op">+</span>
<span class="st">        </span><span class="co"># adding gene labels</span>
<span class="st">        </span><span class="kw">geom_text</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>genes,
                  <span class="kw">aes</span>(<span class="dt">x=</span>labPOS<span class="op">+</span>GLABoffset,<span class="dt">y=</span>labPOS<span class="op">-</span>GLABoffset,<span class="dt">label=</span>name),
                  <span class="dt">angle=</span><span class="op">-</span><span class="dv">45</span>,<span class="dt">fontface=</span><span class="st">&#39;italic&#39;</span>,<span class="dt">size=</span>textSCALE2[sel])<span class="op">+</span>
<span class="st">        </span><span class="co"># adding LG labels</span>
<span class="st">        </span><span class="kw">geom_text</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>zmLab,
                  <span class="kw">aes</span>(<span class="dt">x=</span>Nx<span class="op">+</span>LGoffset<span class="op">-</span>.<span class="dv">8</span>,<span class="dt">y=</span>Nx<span class="op">-</span>LGoffset<span class="op">+</span>.<span class="dv">8</span>,<span class="dt">label=</span>label),
                  <span class="dt">angle=</span><span class="op">-</span><span class="dv">45</span>,<span class="dt">fontface=</span><span class="st">&#39;bold&#39;</span>,<span class="dt">size=</span>textSCALE3[sel],<span class="dt">col=</span><span class="st">&#39;white&#39;</span>)<span class="op">+</span>
<span class="st">        </span><span class="co"># format x and y axis</span>
<span class="st">        </span><span class="kw">scale_x_continuous</span>(<span class="dt">expand=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">0</span>))<span class="op">+</span>
<span class="st">        </span><span class="kw">scale_y_continuous</span>(<span class="dt">expand=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">0</span>),
                           <span class="dt">trans =</span> <span class="st">&#39;reverse&#39;</span>)<span class="op">+</span>
<span class="st">        </span><span class="co"># manual color gradient for LD data</span>
<span class="st">        </span><span class="kw">scale_fill_gradientn</span>(<span class="dt">name=</span><span class="kw">expression</span>(<span class="kw">bar</span>(<span class="kw">italic</span>(r)<span class="op">^</span><span class="dv">2</span>)),<span class="dt">colours=</span>clr,
                             <span class="dt">values=</span><span class="kw">rescale</span>(<span class="kw">c</span>(<span class="dv">1</span>,.<span class="dv">08</span>,.<span class="dv">03</span>,.<span class="dv">015</span>,.<span class="dv">01</span>,<span class="dv">0</span>)),
                             <span class="dt">limits=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>),<span class="dt">guide =</span> <span class="st">&#39;legend&#39;</span>,<span class="dt">breaks=</span><span class="kw">c</span>(<span class="dv">0</span>,.<span class="dv">005</span>,.<span class="dv">01</span>,.<span class="dv">02</span>,.<span class="dv">03</span>,.<span class="dv">1</span>,<span class="dv">1</span>))<span class="op">+</span>
<span class="st">        </span><span class="co"># plot layout theme</span>
<span class="st">        </span><span class="kw">theme_void</span>()<span class="op">+</span>
<span class="st">        </span><span class="kw">theme</span>(<span class="dt">legend.position =</span> <span class="kw">c</span>(.<span class="dv">7</span>,.<span class="dv">75</span>),<span class="dt">legend.direction =</span> <span class="st">&#39;vertical&#39;</span>)</code></pre></div>
<p>If the current selection is not the global data set, the only the base triangle is plotted.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  <span class="er">}</span> <span class="cf">else</span> {
    <span class="co"># the data set is filtered to remove missing values</span>
    p1 &lt;-<span class="st"> </span><span class="kw">ggplot</span>(dt <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">filter</span>(<span class="op">!</span><span class="kw">is.na</span>(Mval)),<span class="kw">aes</span>(<span class="dt">fill=</span>Mval))<span class="op">+</span>
<span class="st">      </span><span class="co"># the aspect ratio of x and y scale needs to be fixed to 1:1</span>
<span class="st">      </span><span class="kw">coord_equal</span>()<span class="op">+</span>
<span class="st">      </span><span class="co"># adding green gene highlights </span>
<span class="st">      </span><span class="kw">geom_segment</span>(<span class="dt">inherit.aes =</span> F,<span class="dt">data=</span>genes,
                   <span class="kw">aes</span>(<span class="dt">x=</span>Nx1<span class="op">+</span><span class="fl">1.5</span>,<span class="dt">y=</span>Nx1<span class="op">-</span><span class="fl">1.5</span>,<span class="dt">xend=</span>Nx2<span class="op">+</span><span class="fl">1.5</span>,<span class="dt">yend=</span>Nx2<span class="op">-</span><span class="fl">1.5</span>),
                   <span class="dt">col=</span>Gcol,<span class="dt">size=</span><span class="dv">1</span>)<span class="op">+</span>
<span class="st">      </span><span class="co"># adding LD data</span>
<span class="st">      </span><span class="kw">geom_tile</span>(<span class="kw">aes</span>(<span class="dt">x=</span>miX,<span class="dt">y=</span>miY))<span class="op">+</span>
<span class="st">      </span><span class="co"># format x and y axis</span>
<span class="st">      </span><span class="kw">scale_x_continuous</span>(<span class="dt">expand=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">0</span>))<span class="op">+</span>
<span class="st">      </span><span class="kw">scale_y_continuous</span>(<span class="dt">expand=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">0</span>),
                         <span class="dt">trans =</span> <span class="st">&#39;reverse&#39;</span>)<span class="op">+</span>
<span class="st">      </span><span class="co"># manual color gradient for LD data</span>
<span class="st">      </span><span class="kw">scale_fill_gradientn</span>(<span class="dt">name=</span><span class="kw">expression</span>(<span class="kw">bar</span>(r<span class="op">^</span><span class="dv">2</span>)),<span class="dt">colours=</span>clr,
                           <span class="dt">values=</span><span class="kw">rescale</span>(<span class="kw">c</span>(<span class="dv">1</span>,.<span class="dv">08</span>,.<span class="dv">03</span>,.<span class="dv">015</span>,.<span class="dv">01</span>,<span class="dv">0</span>)),
                           <span class="dt">limits=</span><span class="kw">c</span>(<span class="dv">0</span>,<span class="dv">1</span>),<span class="dt">guide =</span> <span class="st">&#39;legend&#39;</span>,<span class="dt">breaks=</span><span class="kw">c</span>(<span class="dv">0</span>,.<span class="dv">005</span>,.<span class="dv">01</span>,.<span class="dv">02</span>,.<span class="dv">03</span>,.<span class="dv">1</span>,<span class="dv">1</span>))<span class="op">+</span>
<span class="st">      </span><span class="co"># plotting layout theme</span>
<span class="st">      </span><span class="kw">theme_void</span>()<span class="op">+</span>
<span class="st">      </span><span class="kw">theme</span>(<span class="dt">legend.position =</span> <span class="kw">c</span>(.<span class="dv">7</span>,.<span class="dv">75</span>),<span class="dt">legend.direction =</span> <span class="st">&#39;vertical&#39;</span>)
    
  }</code></pre></div>
<p>Finally, the function returns the current base plot stored in <code>p1</code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">  <span class="kw">return</span>(p1)
<span class="er">}</span></code></pre></div>
<hr />
</div>
<div id="details-of-f3.genomewide_box.r" class="section level2">
<h2><span class="header-section-number">5.4</span> Details of <code>F3.genomeWide_box.R</code></h2>
<p>Within this script, the ILD data of the genome wide subsets of SNPs is loaded and and plotted.</p>
<p>First we read in the global data set, then we loop over the individual population subsets and append the data to the global data set. Since we’re only interested in the distribution of r[2], we select only this column and create extra columns for the run ID, and the run type (global, subset by species, subset by location)</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">BW &lt;-<span class="st"> </span><span class="kw">read.csv</span>(<span class="st">&#39;../../2_output/08_popGen/07_LD/subsets/glob_between.interchrom.hap.ld&#39;</span>,<span class="dt">sep=</span><span class="st">&#39;</span><span class="ch">\t</span><span class="st">&#39;</span>) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">  </span><span class="kw">select</span>(R.<span class="dv">2</span>) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">  </span><span class="kw">mutate</span>(<span class="dt">type=</span><span class="st">&#39;Global&#39;</span>,<span class="dt">run=</span><span class="st">&#39;Global&#39;</span>)

<span class="cf">for</span>(j <span class="cf">in</span> <span class="dv">1</span><span class="op">:</span><span class="dv">6</span>){
  flS &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;boc&quot;</span>,<span class="st">&quot;bel&quot;</span>,<span class="st">&quot;hon&quot;</span>,<span class="st">&quot;pue&quot;</span>,<span class="st">&quot;nig&quot;</span>,<span class="st">&quot;uni&quot;</span>)
  flL &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;Panana&quot;</span>,<span class="st">&quot;Belize&quot;</span>,<span class="st">&quot;Honduras&quot;</span>,<span class="st">&quot;H. puella&quot;</span>,<span class="st">&quot;H. nigricans&quot;</span>,<span class="st">&quot;H. unicolor&quot;</span>)
  flT &lt;-<span class="st"> </span><span class="kw">c</span>(<span class="kw">rep</span>(<span class="st">&#39;Geo&#39;</span>,<span class="dv">3</span>),<span class="kw">rep</span>(<span class="st">&#39;Spec&#39;</span>,<span class="dv">3</span>))
  k &lt;-<span class="st"> </span>flS[j]
  q &lt;-<span class="st"> </span>flL[j]
  u &lt;-<span class="st"> </span>flT[j]
  <span class="kw">print</span>(j)
  BW &lt;-<span class="st"> </span>BW <span class="op">%&gt;%</span>
<span class="st">    </span><span class="kw">rbind</span>(.,(<span class="kw">read.csv</span>(<span class="kw">paste</span>(<span class="st">&#39;../../2_output/08_popGen/07_LD/subsets/glob_between.&#39;</span>,k,<span class="st">&#39;.interchrom.hap.ld&#39;</span>,<span class="dt">sep=</span><span class="st">&#39;&#39;</span>),
                      <span class="dt">sep=</span><span class="st">&#39;</span><span class="ch">\t</span><span class="st">&#39;</span>) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">               </span><span class="kw">select</span>(R.<span class="dv">2</span>) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">               </span><span class="kw">mutate</span>(<span class="dt">type=</span>u,<span class="dt">run=</span>q)))
}</code></pre></div>
<p>Then, we arrange the order of the runs.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">BW<span class="op">$</span>run &lt;-<span class="st"> </span><span class="kw">factor</span>(BW<span class="op">$</span>run,<span class="dt">levels=</span><span class="kw">c</span>(<span class="st">&#39;Global&#39;</span>,<span class="st">&quot;Panana&quot;</span>,<span class="st">&quot;Belize&quot;</span>,<span class="st">&quot;Honduras&quot;</span>,
                                 <span class="st">&quot;H. nigricans&quot;</span>,<span class="st">&quot;H. puella&quot;</span>,<span class="st">&quot;H. unicolor&quot;</span>)) </code></pre></div>
<p>To be able to include the mean values to the box plots we create a small summary table of the LD data.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dt2 &lt;-<span class="st"> </span>BW <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">  </span><span class="kw">group_by</span>(run) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">  </span><span class="kw">summarise</span>(<span class="dt">meanR2=</span><span class="kw">mean</span>(R.<span class="dv">2</span>,<span class="dt">na.rm =</span> T),<span class="dt">medR2=</span><span class="kw">median</span>(R.<span class="dv">2</span>,<span class="dt">na.rm =</span> T)) <span class="op">%&gt;%</span>
<span class="st">  </span><span class="kw">gather</span>(<span class="dt">key =</span> <span class="st">&#39;type&#39;</span>,<span class="dt">value =</span> <span class="st">&#39;val&#39;</span>,<span class="dv">2</span><span class="op">:</span><span class="dv">3</span>)</code></pre></div>
<p>The the colors for the plot are set.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">BC &lt;-<span class="kw">rgb</span>(.<span class="dv">7</span>,.<span class="dv">7</span>,.<span class="dv">7</span>)
clr &lt;-<span class="kw">colorRampPalette</span>(<span class="dt">colors =</span> <span class="kw">c</span>(<span class="st">&#39;white&#39;</span>,BC,<span class="st">&#39;black&#39;</span>))(<span class="dv">8</span>)</code></pre></div>
<p>And finally , the data is plotted.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># initializing the plot</span>
pBOX &lt;-<span class="st"> </span><span class="kw">ggplot</span>(BW,<span class="kw">aes</span>(<span class="dt">x=</span>run,<span class="dt">y=</span>R.<span class="dv">2</span>))<span class="op">+</span>
<span class="st">  </span><span class="co"># adding box plots</span>
<span class="st">  </span><span class="kw">geom_boxplot</span>(<span class="dt">fill=</span>BC,<span class="dt">width=</span>.<span class="dv">7</span>,<span class="dt">outlier.size =</span> .<span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="co"># set a fixed aspect ratio</span>
<span class="st">  </span><span class="kw">coord_fixed</span>(<span class="dt">ylim=</span><span class="kw">c</span>(<span class="dv">0</span>,.<span class="dv">031</span>),<span class="dt">ratio =</span> <span class="dv">250</span>)<span class="op">+</span>
<span class="st">  </span><span class="co"># adding mean and median values</span>
<span class="st">  </span><span class="kw">geom_point</span>(<span class="dt">inherit.aes =</span> F, <span class="dt">data=</span>dt2,<span class="kw">aes</span>(<span class="dt">x=</span>run,<span class="dt">y=</span>val,<span class="dt">fill=</span>type),<span class="dt">shape=</span><span class="dv">23</span>,<span class="dt">size=</span><span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="co"># settting the axis and color labels</span>
<span class="st">  </span><span class="kw">scale_x_discrete</span>(<span class="dt">labels =</span> <span class="kw">expression</span>(Global,Panama,Belize,Honduas,
                                       <span class="kw">italic</span>(<span class="st">&quot;H. nigricans&quot;</span>),<span class="kw">italic</span>(<span class="st">&quot;H. puella&quot;</span>),<span class="kw">italic</span>(<span class="st">&quot;H. unicolor&quot;</span>)))<span class="op">+</span>
<span class="st">  </span><span class="kw">scale_y_continuous</span>(<span class="dt">name=</span><span class="kw">expression</span>(genome<span class="op">~</span>wide<span class="op">~</span>ILD<span class="op">~</span>(<span class="kw">italic</span>(r)<span class="op">^</span><span class="dv">2</span>)))<span class="op">+</span>
<span class="st">  </span><span class="kw">scale_fill_manual</span>(<span class="st">&#39;&#39;</span>,<span class="dt">values =</span> clr[<span class="kw">c</span>(<span class="dv">6</span>,<span class="dv">1</span>)],<span class="dt">labels=</span><span class="kw">c</span>(<span class="st">&#39;mean&#39;</span>,<span class="st">&#39;median&#39;</span>))<span class="op">+</span>
<span class="st">  </span><span class="co"># formatting the legend</span>
<span class="st">  </span><span class="kw">guides</span>(<span class="dt">shape =</span> <span class="kw">guide_legend</span>(<span class="dt">ncol =</span> <span class="dv">1</span>))<span class="op">+</span>
<span class="st">  </span><span class="co"># adjusting the plot theme</span>
<span class="st">  </span><span class="kw">theme</span>(<span class="dt">legend.position =</span> <span class="kw">c</span>(<span class="op">-</span>.<span class="dv">4</span>,<span class="fl">1.27</span>),
        <span class="dt">text =</span> <span class="kw">element_text</span>(<span class="dt">size=</span><span class="dv">10</span>),
        <span class="dt">axis.title.x =</span> <span class="kw">element_blank</span>(),
        <span class="dt">axis.text.y =</span> <span class="kw">element_text</span>(<span class="dt">size=</span><span class="dv">7</span>),
        <span class="dt">axis.text.x =</span> <span class="kw">element_text</span>(<span class="dt">size=</span><span class="dv">7</span>,<span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">hjust =</span> <span class="dv">1</span>),
        <span class="dt">panel.background =</span> <span class="kw">element_blank</span>(),
        <span class="dt">plot.background =</span> <span class="kw">element_blank</span>())</code></pre></div>
<hr />
</div>
<div id="details-of-f3.peakarea_box.r" class="section level2">
<h2><span class="header-section-number">5.5</span> Details of <code>F3.peakArea_box.R</code></h2>
<p>Within this script, the ILD data of the peak area subsets of SNPs is loaded and and plotted.</p>
<p>First, we loop over the individual runs and combine them into a single data set. Since we’re only interested in the distribution of r^2, we select only this column and create extra columns for the run ID, and the run type (global, subset by species, subset by location)</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dataBoxGenes &lt;-<span class="st"> </span><span class="kw">data.frame</span>(<span class="dt">R.2=</span><span class="kw">c</span>(),<span class="dt">run=</span><span class="kw">c</span>(),<span class="dt">stringsAsFactors =</span> F)

<span class="cf">for</span> (file <span class="cf">in</span> <span class="kw">dir</span>(<span class="st">&quot;../../2_output/08_popGen/07_LD/&quot;</span>,<span class="dt">pattern =</span> <span class="st">&quot;interchrom.hap.ld.gz&quot;</span>)) {
  nm &lt;-<span class="st"> </span><span class="kw">str_remove_all</span>(file, <span class="st">&quot;spotlight.&quot;</span>) <span class="op">%&gt;%</span><span class="st"> </span><span class="kw">str_remove_all</span>(.,<span class="st">&quot;.interchrom.hap.ld.gz&quot;</span>)
  <span class="cf">if</span>(nm <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(<span class="st">&quot;global&quot;</span>,<span class="st">&quot;uni&quot;</span>,<span class="st">&quot;pue&quot;</span>,<span class="st">&quot;nig&quot;</span>,<span class="st">&quot;hon&quot;</span>,<span class="st">&quot;bel&quot;</span>,<span class="st">&quot;boc&quot;</span>)){
    dataBoxGenes &lt;-<span class="st"> </span><span class="kw">read.csv</span>(<span class="kw">gzfile</span>(<span class="kw">paste</span>(<span class="st">&#39;../../2_output/08_popGen/07_LD/&#39;</span>,file,<span class="dt">sep=</span><span class="st">&#39;&#39;</span>)),<span class="dt">sep=</span><span class="st">&#39;</span><span class="ch">\t</span><span class="st">&#39;</span>) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">      </span><span class="kw">mutate</span>(<span class="dt">run =</span> nm) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">      </span><span class="kw">select</span>(R.<span class="dv">2</span>,run) <span class="op">%&gt;%</span>
<span class="st">      </span><span class="kw">rbind</span>(dataBoxGenes,.)
  }
}</code></pre></div>
<p>Then, we arrange the order of the runs.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dataBoxGenes<span class="op">$</span>xS &lt;-<span class="st"> </span><span class="kw">factor</span>(dataBoxGenes<span class="op">$</span>run,
                          <span class="dt">levels =</span> <span class="kw">c</span>(<span class="st">&quot;global&quot;</span>,<span class="st">&quot;boc&quot;</span>,<span class="st">&quot;bel&quot;</span>,<span class="st">&quot;hon&quot;</span>,<span class="st">&quot;nig&quot;</span>,<span class="st">&quot;pue&quot;</span>,<span class="st">&quot;uni&quot;</span>))</code></pre></div>
<p>To be able to include the mean values to the box plots we create a small summary table of the LD data.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">BoxGenes_summary &lt;-<span class="st"> </span>dataBoxGenes <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">  </span><span class="kw">group_by</span>(xS) <span class="op">%&gt;%</span><span class="st"> </span>
<span class="st">  </span><span class="kw">summarise</span>(<span class="dt">run =</span> run[<span class="dv">1</span>],
            <span class="dt">meanR2 =</span> <span class="kw">mean</span>(R.<span class="dv">2</span>,<span class="dt">na.rm =</span> T),
            <span class="dt">medR2 =</span> <span class="kw">median</span>(R.<span class="dv">2</span>,<span class="dt">na.rm =</span> T),
            <span class="dt">sdR2 =</span> <span class="kw">sd</span>(R.<span class="dv">2</span>,<span class="dt">na.rm=</span>T),
            <span class="dt">seR2 =</span> <span class="kw">se</span>(R.<span class="dv">2</span>),
            <span class="dt">nanr =</span> <span class="kw">sum</span>(<span class="kw">is.na</span>(R.<span class="dv">2</span>)),
            <span class="dt">minR2 =</span> <span class="kw">min</span>(R.<span class="dv">2</span>,<span class="dt">na.rm =</span> T),
            <span class="dt">maxR2 =</span> <span class="kw">max</span>(R.<span class="dv">2</span>,<span class="dt">na.rm =</span> T),
            <span class="dt">lengthR2 =</span> <span class="kw">length</span>(R.<span class="dv">2</span>)) <span class="op">%&gt;%</span>
<span class="st">  </span><span class="kw">select</span>(xS,meanR2,medR2) <span class="op">%&gt;%</span>
<span class="st">  </span><span class="kw">gather</span>(<span class="dt">key =</span> <span class="st">&#39;type&#39;</span>,<span class="dt">value =</span> <span class="st">&#39;val&#39;</span>,<span class="dv">2</span><span class="op">:</span><span class="dv">3</span>)</code></pre></div>
<p>And finally , the data is plotted.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="co"># initializing the plot</span>
boxGenes &lt;-<span class="st"> </span><span class="kw">ggplot</span>(dataBoxGenes,<span class="kw">aes</span>(<span class="dt">x=</span>xS))<span class="op">+</span>
<span class="st">  </span><span class="co"># adding box plots</span>
<span class="st">  </span><span class="kw">geom_boxplot</span>(<span class="kw">aes</span>(<span class="dt">y=</span>R.<span class="dv">2</span>),<span class="dt">fill=</span>BC,<span class="dt">width=</span>.<span class="dv">7</span>,<span class="dt">outlier.size =</span> .<span class="dv">1</span>) <span class="op">+</span>
<span class="st">  </span><span class="co"># adding mean and median values</span>
<span class="st">  </span><span class="kw">geom_point</span>(<span class="dt">data=</span>BoxGenes_summary,<span class="kw">aes</span>(<span class="dt">y=</span>val,<span class="dt">fill=</span>type),<span class="dt">shape=</span><span class="dv">23</span>,<span class="dt">size=</span><span class="dv">1</span>)<span class="op">+</span>
<span class="st">  </span><span class="co"># set a fixed aspect ratio</span>
<span class="st">  </span><span class="kw">coord_fixed</span>(<span class="dt">ylim=</span><span class="kw">c</span>(<span class="dv">0</span>,.<span class="dv">031</span>),<span class="dt">ratio =</span> <span class="dv">133</span>)<span class="op">+</span>
<span class="st">  </span><span class="co"># settting the axis and color labels</span>
<span class="st">  </span><span class="kw">scale_y_continuous</span>(<span class="kw">expression</span>(candidate<span class="op">~</span>gene<span class="op">~</span>ILD<span class="op">~</span>(<span class="kw">italic</span>(r)<span class="op">^</span><span class="dv">2</span>)))<span class="op">+</span>
<span class="st">  </span><span class="kw">scale_x_discrete</span>(<span class="dt">labels =</span> <span class="kw">expression</span>(Global,Panama,Belize,Honduas,
                                       <span class="kw">italic</span>(<span class="st">&quot;H. nigricans&quot;</span>),<span class="kw">italic</span>(<span class="st">&quot;H. puella&quot;</span>),<span class="kw">italic</span>(<span class="st">&quot;H. unicolor&quot;</span>)))<span class="op">+</span>
<span class="st">  </span><span class="kw">scale_fill_manual</span>(<span class="st">&#39;&#39;</span>,<span class="dt">values =</span> clr[<span class="kw">c</span>(<span class="dv">6</span>,<span class="dv">1</span>)],<span class="dt">labels=</span><span class="kw">c</span>(<span class="st">&#39;mean&#39;</span>,<span class="st">&#39;median&#39;</span>))<span class="op">+</span>
<span class="st">  </span><span class="co"># formatting the legend</span>
<span class="st">  </span><span class="kw">guides</span>(<span class="dt">shape =</span> <span class="kw">guide_legend</span>(<span class="dt">ncol =</span> <span class="dv">1</span>))<span class="op">+</span>
<span class="st">  </span><span class="co"># adjusting the plot theme</span>
<span class="st">  </span><span class="kw">theme</span>(<span class="dt">legend.position =</span> <span class="kw">c</span>(.<span class="dv">35</span>,<span class="fl">1.27</span>),
        <span class="dt">text =</span> <span class="kw">element_text</span>(<span class="dt">size=</span><span class="dv">10</span>),
        <span class="dt">axis.title.x =</span> <span class="kw">element_blank</span>(),
        <span class="dt">axis.title.y =</span> <span class="kw">element_text</span>(<span class="dt">hjust=</span><span class="fl">1.25</span>),
        <span class="dt">axis.text.y =</span> <span class="kw">element_text</span>(<span class="dt">size=</span><span class="dv">7</span>),
        <span class="dt">axis.text.x =</span> <span class="kw">element_text</span>(<span class="dt">size=</span><span class="dv">7</span>,<span class="dt">angle=</span><span class="dv">45</span>,<span class="dt">hjust =</span> <span class="dv">1</span>),
        <span class="dt">panel.background =</span> <span class="kw">element_blank</span>(),
        <span class="dt">plot.background =</span> <span class="kw">element_blank</span>())</code></pre></div>

</div>
</div>
            </section>

          </div>
        </div>
      </div>
<a href="figure-2.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a>
<a href="extendend-data-figure-1.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a>
    </div>
  </div>
<script src="libs/gitbook-2.6.7/js/app.min.js"></script>
<script src="libs/gitbook-2.6.7/js/lunr.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-search.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script>
<script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script>
<script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script>
<script>
gitbook.require(["gitbook"], function(gitbook) {
gitbook.start({
"sharing": {
"github": false,
"facebook": true,
"twitter": true,
"google": false,
"linkedin": false,
"weibo": false,
"instapper": false,
"vk": false,
"all": ["facebook", "google", "twitter", "linkedin", "weibo", "instapaper"]
},
"fontsettings": {
"theme": "white",
"family": "sans",
"size": 2
},
"edit": {
"link": null,
"text": null
},
"download": null,
"toc": {
"collapse": "section"
}
});
});
</script>

<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    var src = "";
    if (src === "" || src === "true") src = "https://cdn.bootcss.com/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML";
    if (location.protocol !== "file:" && /^https?:/.test(src))
      src = src.replace(/^https?:/, '');
    script.src = src;
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script>
</body>

</html>