-
Notifications
You must be signed in to change notification settings - Fork 7
/
POP_05_RDAtraitPredictionTutorial.html
997 lines (888 loc) · 41.7 KB
/
POP_05_RDAtraitPredictionTutorial.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
<!DOCTYPE html>
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-53GH9PV49T"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-53GH9PV49T');
</script>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<meta name="author" content="KE Lotterhos" />
<meta name="date" content="2023-02-08" />
<title>RDA trait prediction tutorial</title>
<script src="site_libs/header-attrs-2.25/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/cosmo.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="site_libs/jqueryui-1.13.2/jquery-ui.min.js"></script>
<link href="site_libs/tocify-1.9.1/jquery.tocify.css" rel="stylesheet" />
<script src="site_libs/tocify-1.9.1/jquery.tocify.js"></script>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/default.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<link href="site_libs/pagedtable-1.1/css/pagedtable.css" rel="stylesheet" />
<script src="site_libs/pagedtable-1.1/js/pagedtable.js"></script>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<link rel="stylesheet" href="tutorial.css" type="text/css" />
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
details > summary > p:only-child {
display: inline;
}
pre code {
padding: 0;
}
</style>
<style type="text/css">
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #adb5bd;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script type="text/javascript">
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark the anchor link active (and if it's in a dropdown, also mark that active)
var dropdown = menuAnchor.closest('li.dropdown');
if (window.bootstrap) { // Bootstrap 4+
menuAnchor.addClass('active');
dropdown.find('> .dropdown-toggle').addClass('active');
} else { // Bootstrap 3
menuAnchor.parent().addClass('active');
dropdown.addClass('active');
}
// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
var style = document.createElement('style');
var pt = "padding-top: " + navHeight + "px; ";
var mt = "margin-top: -" + navHeight + "px; ";
var css = "";
// offset scroll position for anchor links (for fixed navbar)
for (var i = 1; i <= 6; i++) {
css += ".section h" + i + "{ " + pt + mt + "}\n";
}
style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
document.head.appendChild(style);
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before, .tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "\e259";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "\e258";
font-family: 'Glyphicons Halflings';
border: none;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
<style type="text/css">
#TOC {
margin: 25px 0px 20px 0px;
}
@media (max-width: 768px) {
#TOC {
position: relative;
width: 100%;
}
}
@media print {
.toc-content {
/* see https://github.com/w3c/csswg-drafts/issues/4434 */
float: right;
}
}
.toc-content {
padding-left: 30px;
padding-right: 40px;
}
div.main-container {
max-width: 1200px;
}
div.tocify {
width: 20%;
max-width: 260px;
max-height: 85%;
}
@media (min-width: 768px) and (max-width: 991px) {
div.tocify {
width: 25%;
}
}
@media (max-width: 767px) {
div.tocify {
width: 100%;
max-width: none;
}
}
.tocify ul, .tocify li {
line-height: 20px;
}
.tocify-subheader .tocify-item {
font-size: 0.90em;
}
.tocify .list-group-item {
border-radius: 0px;
}
.tocify-subheader {
display: inline;
}
.tocify-subheader .tocify-item {
font-size: 0.95em;
}
</style>
</head>
<body>
<div class="container-fluid main-container">
<!-- setup 3col/9col grid for toc_float and main content -->
<div class="row">
<div class="col-xs-12 col-sm-4 col-md-3">
<div id="TOC" class="tocify">
</div>
</div>
<div class="toc-content col-xs-12 col-sm-8 col-md-9">
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-bs-toggle="collapse" data-target="#navbar" data-bs-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">MarineOmics</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="ADMIN_04_best_principles.html">Best Principles</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Contributions
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="ADMIN_01_submissions_instructions.html">Guide for Building a Page</a>
</li>
<li>
<a href="ADMIN_02_contributions.html">Past and Current Contributors</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Population Genomics
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="POP_01_choosing_population_genetics.html">Choosing a Population Genomics Approach</a>
</li>
<li>
<a href="POP_04_WGS_intro.html">Whole Genome Resequencing</a>
</li>
<li>
<a href="RADseq.html">Reduced Representation Sequencing</a>
</li>
<li>
<a href="POP_03_poolseq.html">Poolseq</a>
</li>
<li>
<a href="POP_05_RDAtraitPredictionTutorial.html">Redundancy Analysis (RDA) Trait Prediction</a>
</li>
<li>
<a href="POP_08_PCA.html">PCA</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Functional Genomics
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="DGE_comparison_v2.html">Mutifactorial RNAseq</a>
</li>
<li>
<a href="FUN_02_DNA_methylation.html">DNA Methylation Assessment</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Genome-Phenome
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li class="dropdown-header">coming soon!</li>
</ul>
</li>
<li>
<a href="ADMIN_03_panels.html">Panel Seminars</a>
</li>
<li>
<a href="https://github.com/MarineOmics/marineomics.github.io/discussions">Discussion Forum</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'G-53GH9PV49T', 'auto');
ga('send', 'pageview');
</script>
<div id="header">
<h1 class="title toc-ignore">RDA trait prediction tutorial</h1>
<h4 class="author">KE Lotterhos</h4>
<h4 class="date">2023-02-08</h4>
</div>
<p><a href="https://marineomics.github.io/#How_to_Cite">How to
cite</a></p>
<p>This tutorial accompanies the paper <a
href="https://doi.org/10.1073/pnas.2220313120">“The paradox of adaptive
trait clines with non-clinal patterns in the underlying genes”</a>
published in PNAS.</p>
<div id="abstract" class="section level1">
<h1>Abstract</h1>
<p>Multivariate climate change presents an urgent need to understand how
species adapt to complex environments. Population genetic theory
predicts that loci under selection will form monotonic allele frequency
clines with their selective environment, which has led to the wide use
of genotype-environment associations (GEAs). However, the accuracy of
GEA methods to identify adapted loci is limited, as shown in the main
paper.</p>
<p>This tutorial shows how to apply a novel extension of multivariate
ordination, which accurately predicted individual multivariate traits
from genotype and environmental data on simulated data regardless of
whether inference from GEAs was accurate.</p>
</div>
<div id="install-packages" class="section level1">
<h1>Install packages</h1>
<p>If the following packages are not installed, be sure to install them
first:</p>
<pre><code>install.packages("vegan")
install.packages("lfmm")
install.packages("gplots")
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("LEA")</code></pre>
<div id="load-the-libraries" class="section level2">
<h2>Load the libraries:</h2>
<pre class="r"><code>libraries_needed <- c("vegan", "LEA", "lfmm", "gplots")
for (i in 1:length(libraries_needed)){
library(libraries_needed[i],character.only = TRUE) #laptop
}
knitr::opts_chunk$set(message = FALSE, warning = FALSE, cache = FALSE) </code></pre>
<p>Don’t forget to set your working directory!</p>
</div>
</div>
<div id="background-on-the-simulation" class="section level1">
<h1>Background on the simulation</h1>
<p>This data was simulated in SLiM and is associated with the complex
multivariate simulation presented in Figure 6 in the paper. Briefly, a
non-Wright-Fisher model was simulated on a landscape with 6
environmental variables that reflect different aspects of thermal stress
and precipitation in British Columbia. The simulation included 6
environmental traits, each of which adapted to a different environmental
variable.</p>
<p>The six environmental variables are based on real data from western
Canada and are shown below, clockwise from upper right: Clockwise from
upper left: precipitation of driest month, precipitation of warmest
quarter, mean annual temperature, precipitation of wettest month, mean
temperature of wettest quarter, mean temperature of driest quarter.
Background colors correspond to the optimum trait value on each
landscape, and each small square is a simulated individual, with its
color representing its trait value in that environment.</p>
<p><img
src="POP_05_RDAtraitPredictionTutorial_files/multivar.png" /></p>
</div>
<div id="load-the-data" class="section level1">
<h1>Load the data</h1>
<ul>
<li>A matrix of genotypes in 012 format (counts of reference allele)
<ul>
<li>number of rows = number of individuals</li>
<li>number of columns = number of SNPs</li>
</ul></li>
<li>A table with information about sampled individuals (each individual
in a row)</li>
<li>A table with information about SNPs (each SNP in a row)</li>
</ul>
<p>The <code>ind</code> table includes the xy location for each
individual, the 6 exact trait values (note that these won’t exactly
equal the trait value calculated from the genotype matrix because of MAF
filtering), and the 6 environmental values at their xy location.</p>
<p>The <code>muts</code> table includes the linkage group
<code>LG</code>, the position of the mutation on the genetic map
<code>pos_pyslim</code>, a unique ID <code>mutname</code>, the allele
frequency based on the 1000 sampled individuals
<code>a_freq_subset</code>, and whether or not it had effects on one or
more phenotypes <code>causal</code>.</p>
<p>Note that you will have to change the working directory to where the
data is stored on your computer.</p>
<pre class="r"><code>G <- read.table(unz("POP_05_RDAtraitPredictionTutorial_files/Genotypes.txt.zip", "Genotypes.txt"))
dim(G) # 1000 individuals and 26371 loci</code></pre>
<pre><code>## [1] 1000 26371</code></pre>
<pre class="r"><code>ind <- read.table("POP_05_RDAtraitPredictionTutorial_files/Individuals.txt", header=TRUE)
dim(ind) #corresponds to rows in G</code></pre>
<pre><code>## [1] 1000 15</code></pre>
<pre class="r"><code>head(ind)</code></pre>
<div data-pagedtable="false">
<script data-pagedtable-source type="application/json">
{"columns":[{"label":[""],"name":["_rn_"],"type":[""],"align":["left"]},{"label":["ind_index"],"name":[1],"type":["int"],"align":["right"]},{"label":["x"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["y"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["phenotype1_mat"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["phenotype2_MTWetQ"],"name":[5],"type":["dbl"],"align":["right"]},{"label":["phenotype3_MTDQ"],"name":[6],"type":["dbl"],"align":["right"]},{"label":["phenotype4_PDM"],"name":[7],"type":["dbl"],"align":["right"]},{"label":["phenotype5_PwarmQ"],"name":[8],"type":["dbl"],"align":["right"]},{"label":["phenotype6_PWM"],"name":[9],"type":["dbl"],"align":["right"]},{"label":["env1_mat"],"name":[10],"type":["dbl"],"align":["right"]},{"label":["env2_MTWetQ"],"name":[11],"type":["dbl"],"align":["right"]},{"label":["env3_MTDQ"],"name":[12],"type":["dbl"],"align":["right"]},{"label":["env4_PDM"],"name":[13],"type":["dbl"],"align":["right"]},{"label":["env5_PwarmQ"],"name":[14],"type":["dbl"],"align":["right"]},{"label":["env6_PWM"],"name":[15],"type":["dbl"],"align":["right"]}],"data":[{"1":"33","2":"0.4061840","3":"0.233272","4":"0.7379670","5":"-0.1914210","6":"0.142992","7":"-0.131894","8":"-0.452497","9":"-0.5416510","10":"0.762432","11":"-0.1622380","12":"0.2612810","13":"-0.332078","14":"-0.471502","15":"-0.4778210","_rn_":"1"},{"1":"34","2":"0.4256970","3":"0.837158","4":"-0.2740810","5":"-0.4283320","6":"-0.012880","7":"0.221058","8":"0.229296","9":"0.0665969","10":"-0.339330","11":"-0.4076670","12":"-0.0582962","13":"0.288030","14":"0.198810","15":"0.0176800","_rn_":"2"},{"1":"44","2":"0.6716730","3":"0.581744","4":"-0.6763260","5":"0.0866287","6":"-0.470671","7":"0.218813","8":"0.260098","9":"-0.1034650","10":"-0.567733","11":"0.0909278","12":"-0.4143530","13":"0.234899","14":"0.230255","15":"-0.0535109","_rn_":"3"},{"1":"45","2":"0.0174659","3":"0.329922","4":"-0.2832210","5":"-0.4039420","6":"-0.333718","7":"-0.200554","8":"-0.345915","9":"-0.4100010","10":"-0.245860","11":"-0.2007590","12":"-0.2674550","13":"-0.265260","14":"-0.389828","15":"-0.4589790","_rn_":"4"},{"1":"46","2":"0.0697436","3":"0.121221","4":"0.0576163","5":"-0.3032010","6":"0.731600","7":"0.195679","8":"-0.367110","9":"0.1962960","10":"-0.121500","11":"-0.3063790","12":"0.7028580","13":"0.211275","14":"-0.352307","15":"0.2127510","_rn_":"5"},{"1":"64","2":"0.1433610","3":"0.233237","4":"0.2656280","5":"-0.2318730","6":"0.214004","7":"-0.239776","8":"-0.517086","9":"-0.2582660","10":"0.103057","11":"-0.2863170","12":"0.1657060","13":"-0.190813","14":"-0.476650","15":"-0.2927740","_rn_":"6"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
<pre class="r"><code>muts <- read.table("POP_05_RDAtraitPredictionTutorial_files/SNPs.txt", header=TRUE)
dim(muts) #corresponds to columns in G</code></pre>
<pre><code>## [1] 26371 5</code></pre>
<pre class="r"><code>head(muts)</code></pre>
<div data-pagedtable="false">
<script data-pagedtable-source type="application/json">
{"columns":[{"label":[""],"name":["_rn_"],"type":[""],"align":["left"]},{"label":["LG"],"name":[1],"type":["int"],"align":["right"]},{"label":["pos_pyslim"],"name":[2],"type":["int"],"align":["right"]},{"label":["mutname"],"name":[3],"type":["chr"],"align":["left"]},{"label":["a_freq_subset"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["causal"],"name":[5],"type":["lgl"],"align":["right"]}],"data":[{"1":"1","2":"8","3":"1-8","4":"0.0175","5":"FALSE","_rn_":"1"},{"1":"1","2":"27","3":"1-27","4":"0.0120","5":"FALSE","_rn_":"2"},{"1":"1","2":"34","3":"1-34","4":"0.0370","5":"FALSE","_rn_":"3"},{"1":"1","2":"81","3":"1-81","4":"0.0330","5":"FALSE","_rn_":"4"},{"1":"1","2":"97","3":"1-97","4":"0.0170","5":"FALSE","_rn_":"5"},{"1":"1","2":"153","3":"1-153","4":"0.0225","5":"FALSE","_rn_":"6"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
<pre class="r"><code>rownames(G) <- as.character(paste0("i_",ind$ind_index))
colnames(G) <- as.character(muts$mutname)
#G <- as.matrix(G)
head(G[,1:10])</code></pre>
<div data-pagedtable="false">
<script data-pagedtable-source type="application/json">
{"columns":[{"label":[""],"name":["_rn_"],"type":[""],"align":["left"]},{"label":["1-8"],"name":[1],"type":["int"],"align":["right"]},{"label":["1-27"],"name":[2],"type":["int"],"align":["right"]},{"label":["1-34"],"name":[3],"type":["int"],"align":["right"]},{"label":["1-81"],"name":[4],"type":["int"],"align":["right"]},{"label":["1-97"],"name":[5],"type":["int"],"align":["right"]},{"label":["1-153"],"name":[6],"type":["int"],"align":["right"]},{"label":["1-154"],"name":[7],"type":["int"],"align":["right"]},{"label":["1-206"],"name":[8],"type":["int"],"align":["right"]},{"label":["1-287"],"name":[9],"type":["int"],"align":["right"]},{"label":["1-304"],"name":[10],"type":["int"],"align":["right"]}],"data":[{"1":"0","2":"0","3":"0","4":"0","5":"0","6":"0","7":"0","8":"0","9":"0","10":"0","_rn_":"i_33"},{"1":"0","2":"0","3":"0","4":"0","5":"0","6":"0","7":"0","8":"0","9":"0","10":"0","_rn_":"i_34"},{"1":"0","2":"0","3":"0","4":"0","5":"0","6":"0","7":"0","8":"0","9":"0","10":"0","_rn_":"i_44"},{"1":"0","2":"0","3":"0","4":"0","5":"0","6":"0","7":"0","8":"0","9":"0","10":"0","_rn_":"i_45"},{"1":"0","2":"0","3":"0","4":"0","5":"0","6":"0","7":"0","8":"0","9":"1","10":"0","_rn_":"i_46"},{"1":"2","2":"0","3":"0","4":"0","5":"0","6":"0","7":"0","8":"0","9":"0","10":"0","_rn_":"i_64"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
</div>
<div id="rda-trait-prediction-function" class="section level1">
<h1>RDA trait prediction function</h1>
<p>This function predicts an environmental trait through the
back-transformation of the RDA “site score” of an individual to a chosen
environmental variable (Equation 1 in the manuscript). It makes the
prediction for all the individuals that were used to run the RDA.</p>
<pre class="r"><code>rda_trait_pred <- function(rdaobj, env_row, K){
#rdaobj is RDA object
#env_row is the row of the environment in the biplot output
#K is the number of RDA axes
scores <- scores(rdaobj, choices=1:K)
ind.sc <- scores$sites
pred <- matrix(NA, nrow=nrow(ind.sc), ncol=K)
for (k in 1:K){
pred[,k] <- ind.sc[,k]*eigenvals(rdaobj)[k]*summary(rdaobj)$biplot[env_row,k]
}
trait_pred <- scale(rowSums(pred))
return(trait_pred)
}</code></pre>
<div id="example-of-an-rda-predicted-environmental-trait-value"
class="section level2">
<h2>Example of an RDA-predicted environmental trait value</h2>
<ol style="list-style-type: decimal">
<li>First, run the RDA:</li>
</ol>
<p>Scale the environmental variables to have a mean of 0 and standard
deviation of 1.</p>
<pre class="r"><code>ind$env1_mat <- scale(ind$env1_mat)
ind$env2_MTWetQ <- scale(ind$env2_MTWetQ)
ind$env3_MTDQ <- scale(ind$env3_MTDQ)
ind$env4_PDM <- scale(ind$env4_PDM)
ind$env5_PwarmQ <- scale(ind$env5_PwarmQ)
ind$env6_PWM <- scale(ind$env6_PWM)
# Run the RDA
rdaout <- rda(G ~ ind$env1_mat +
ind$env2_MTWetQ +
ind$env3_MTDQ +
ind$env4_PDM +
ind$env5_PwarmQ +
ind$env6_PWM
)</code></pre>
<ol start="2" style="list-style-type: decimal">
<li>Next, check the biplot output and decide how many RDA axes to use in
the prediction.</li>
</ol>
<pre class="r"><code># Check the biplot output
rdaout$CCA$biplot</code></pre>
<pre><code>## RDA1 RDA2 RDA3 RDA4 RDA5
## ind$env1_mat -0.5004451 0.01863416 -0.5476147 0.54418964 -0.37298079
## ind$env2_MTWetQ 0.4523477 0.19158505 -0.8296969 -0.11392353 0.03132509
## ind$env3_MTDQ -0.7128197 -0.22757653 0.1200761 0.48309488 0.33816827
## ind$env4_PDM -0.3843437 0.04904761 0.8297919 -0.24744529 0.09707124
## ind$env5_PwarmQ 0.6524152 0.56221376 0.4505148 0.02427266 -0.04630498
## ind$env6_PWM 0.3209795 -0.05176393 0.7346369 0.19495732 -0.08780176
## RDA6
## ind$env1_mat -0.1186113
## ind$env2_MTWetQ -0.2373183
## ind$env3_MTDQ -0.2791780
## ind$env4_PDM -0.3011107
## ind$env5_PwarmQ -0.2292885
## ind$env6_PWM -0.5557731</code></pre>
<pre class="r"><code># Decide how many RDA axes to use in calculation
a<- screeplot(rdaout)</code></pre>
<p><img src="POP_05_RDAtraitPredictionTutorial_files/figure-html/unnamed-chunk-1-1.png" width="672" /></p>
<pre class="r"><code> str(a)</code></pre>
<pre><code>## List of 4
## $ x : num [1:6] 0.7 1.9 3.1 4.3 5.5 6.7
## $ y : num [1:6] 189 103.1 66.1 37.8 30.9 ...
## $ xlab: NULL
## $ ylab: NULL</code></pre>
<pre class="r"><code> a$y # save this it's the eigenvalues</code></pre>
<pre><code>## [1] 189.02481 103.10740 66.10749 37.79033 30.86247 23.24983</code></pre>
<pre class="r"><code> prop_var <- round(a$y[1:6]/sum(a$y),3)
cumsum(prop_var)</code></pre>
<pre><code>## [1] 0.420 0.649 0.796 0.880 0.949 1.001</code></pre>
<pre class="r"><code> plot(cumsum(prop_var), xlab="Number of RDA axes",
ylab="Cumulative percent of variation explained", ylim=c(0,1))</code></pre>
<p><img src="POP_05_RDAtraitPredictionTutorial_files/figure-html/unnamed-chunk-1-2.png" width="672" /></p>
<ol start="3" style="list-style-type: decimal">
<li>In this case, the first 3 RDA axes explain 80% of the variance. Note
that choosing too many axes may result in overfitting. Here is an
example of a trait prediction for MAT using the first 3 RDA axes:</li>
</ol>
<pre class="r"><code># Make the trait prediction for MAT (1st row in biplot output)
K = 3 # use 3 RDA axes to make the trait prediction
MATtraitPredict <- rda_trait_pred(rdaout, 1, K)
# Since this is a simulation, we can compare the prediction to the true value
# Similarly, an empirical study could compare an empirically measured trait value
# to the RDA-predicted trait value to test how well landscape genomic data
# can predict functional traits
plot(scale(ind$phenotype1_mat), MATtraitPredict, xlab="Evolved trait value in simulations",
ylab="RDA trait prediction")
abline(0,1)</code></pre>
<p><img src="POP_05_RDAtraitPredictionTutorial_files/figure-html/unnamed-chunk-2-1.png" width="672" /></p>
<pre class="r"><code>#Correlation between the prediction and the true value:
cor(ind$phenotype1_mat, MATtraitPredict) </code></pre>
<pre><code>## [,1]
## [1,] 0.6461756</code></pre>
<div id="compare-to-other-functions-in-rda" class="section level3">
<h3>Compare to other functions in RDA</h3>
<p>Note that the <code>predict</code> function and it’s variations in
the R package <code>vegan</code> do not make the same kind of
predictions as <code>rda_trait_pred</code>. Here are the types of
outputs produced by the function <code>predict</code> and its
variations:</p>
<pre class="r"><code># This option in the `predict` function outputs the scores for each locus in RDA space
loci_scores_predict <- predict(rdaout, type="sp", newdata=G, scaling=2)
str(loci_scores_predict)</code></pre>
<pre><code>## num [1:26371, 1:6] -0.00957 -0.01685 -0.00659 0.08155 0.03396 ...
## - attr(*, "dimnames")=List of 2
## ..$ : chr [1:26371] "1-8" "1-27" "1-34" "1-81" ...
## ..$ : chr [1:6] "RDA1" "RDA2" "RDA3" "RDA4" ...</code></pre>
<pre class="r"><code># This option in the `predict` function outputs the fitted values from the multiple regression
# performed on each locus within each individual
fitted_values_predict <- predict(rdaout, newdata=G, type="response")
str(fitted_values_predict)</code></pre>
<pre><code>## num [1:1000, 1:26371] 0.1031 0.0345 -0.0436 0.1821 0.1753 ...
## - attr(*, "dimnames")=List of 2
## ..$ : chr [1:1000] "i_33" "i_34" "i_44" "i_45" ...
## ..$ : chr [1:26371] "1-8" "1-27" "1-34" "1-81" ...</code></pre>
<pre class="r"><code> # As a side note, it outputs the same thing as the `fitted` function
fitted_values_predict2 <- fitted(rdaout)
str(fitted_values_predict2)</code></pre>
<pre><code>## num [1:1000, 1:26371] 0.1031 0.0345 -0.0436 0.1821 0.1753 ...
## - attr(*, "METHOD")= chr "PCA"
## - attr(*, "dimnames")=List of 2
## ..$ : chr [1:1000] "i_33" "i_34" "i_44" "i_45" ...
## ..$ : chr [1:26371] "1-8" "1-27" "1-34" "1-81" ...</code></pre>
<pre class="r"><code># This option in the `predict` function outputs the individual scores in RDA space
# based on a linear combination of the predictor variables
X <- data.frame(ind$env1_mat ,
ind$env2_MTWetQ ,
ind$env3_MTDQ ,
ind$env4_PDM ,
ind$env5_PwarmQ ,
ind$env6_PWM)
ind_scores_predict <- predict(rdaout, type="lc", new=X, scal=2)
str(ind_scores_predict)</code></pre>
<pre><code>## num [1:1000, 1:6] -2.034 -0.19 0.543 0.253 -0.508 ...
## - attr(*, "dimnames")=List of 2
## ..$ : chr [1:1000] "1" "2" "3" "4" ...
## ..$ : chr [1:6] "RDA1" "RDA2" "RDA3" "RDA4" ...</code></pre>
<p>The <code>predict</code> function and its variations make predictions
in RDA space, and therefore do not output the same kind of predictions
as <code>rda_trait_predict</code> and Equation 1 in the paper.</p>
</div>
</div>
</div>
<div id="understanding-how-the-rda-is-built-on-multiple-regressions"
class="section level1">
<h1>Understanding how the RDA is built on multiple regressions</h1>
<p>Prior to ordination in the RDA, each locus is used in a multiple
regression model with the environmental variables to produce fitted
values for that locus across individuals.</p>
<p><em>SNP Genotype</em> ~ <em>Env1</em> + <em>Env2</em> + <em>Env3</em>
etc.</p>
<p>For example for the first SNP in the data:</p>
<pre class="r"><code> # multiple regression of 1st locus
mod <- lm(G[,1] ~ ind$env1_mat + ind$env2_MTWetQ + ind$env3_MTDQ + ind$env4_PDM +
ind$env5_PwarmQ + ind$env6_PWM)
coef(summary(mod))</code></pre>
<pre><code>## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.035000000 0.007404071 4.7271290 2.605782e-06
## ind$env1_mat -0.035729076 0.011338501 -3.1511287 1.675100e-03
## ind$env2_MTWetQ -0.062538545 0.012165353 -5.1407094 3.295576e-07
## ind$env3_MTDQ 0.007471565 0.013224098 0.5649962 5.722040e-01
## ind$env4_PDM -0.088670803 0.014835808 -5.9768099 3.169042e-09
## ind$env5_PwarmQ -0.069588746 0.014273932 -4.8752331 1.264746e-06
## ind$env6_PWM 0.047203246 0.013582893 3.4751982 5.325440e-04</code></pre>
<p>Although multiple regression is a linear combination of multiple
variables, it is able to model complex multivariate responses that
appear to be non-monotonic in any one dimension. For example, let’s look
at a the relationship between explanatory variable temperature and the
response variable genotype, across decreasing and increasing values of
the other explanatory variables:</p>
<pre class="r"><code>otherenv <- c(seq(1,0,length.out=100), seq(0,1,length.out=101))
newdata=data.frame(ind.env1_mat = seq(-1,1, by=0.01),
ind.env2_MTWetQ = otherenv,
ind.env3_MTDQ = otherenv,
ind.env4_PDM = otherenv,
ind.env5_PwarmQ =otherenv,
ind.env6_PWM = otherenv)
pred <- t(newdata)*(coef(summary(mod))[2:7,1]) + coef(summary(mod))[1,1]
plot(seq(-1,1, by=0.01), colSums(pred), xlab="Temperature", ylab="Genotype prediction")</code></pre>
<p><img src="POP_05_RDAtraitPredictionTutorial_files/figure-html/unnamed-chunk-5-1.png" width="672" /></p>
<p>Thus, there is flexibility with the RDA to capture the way
environmental variables may influence the patterns at one locus in a
different way than at another locus, which may not correlate with the
relationship between the environment and population structure.</p>
<p>It may be interesting for some studies to understand how each locus
is shaped by the environment - in other words, what are the slopes
associated with the environmental variables in the multiple regression
model for each locus?</p>
<p>Unfortunately there is not a way to output these slopes in the R
package <code>vegan</code>, but we can reproduce the first step of the
RDA to get the regression coefficients: (vegan source code at <a
href="https://github.com/cran/vegan/blob/master/R/simpleRDA2.R"
class="uri">https://github.com/cran/vegan/blob/master/R/simpleRDA2.R</a>)</p>
<pre class="r"><code>X <- data.frame(ind$env1_mat ,
ind$env2_MTWetQ ,
ind$env3_MTDQ ,
ind$env4_PDM ,
ind$env5_PwarmQ ,
ind$env6_PWM)
# Perform qr decomposition to do the regression for all SNPs at the same time
Q <- qr(X, tol=1e-6)
# str(Q) run this line if you want to understand the structure of Q
# Get the matrix of regression coefficients
Qr.coeff <- qr.coef(Q, G)
# This matrix has each SNP in a column and the regression coefficients
# for that SNP corresponds to each environmental variable.
# This is the step that is not performed in the `vegan` package -
# the package skips directly to predicting the fitted values,
# on which the ordination is performed.
# Here is an example of regression coefficients for the first 10 SNPs:
head(Qr.coeff[,1:10])</code></pre>
<pre><code>## [,1] [,2] [,3] [,4]
## ind.env1_mat -0.035729076 0.007247705 -0.001047802 -6.104895e-02
## ind.env2_MTWetQ -0.062538545 0.039624398 0.101004048 9.680467e-05
## ind.env3_MTDQ 0.007471565 -0.005698865 0.039132724 7.995858e-02
## ind.env4_PDM -0.088670803 0.017639011 0.027586476 -1.237919e-01
## ind.env5_PwarmQ -0.069588746 -0.043489428 0.005967464 1.262363e-01
## ind.env6_PWM 0.047203246 -0.012944110 -0.061687810 -6.657131e-03
## [,5] [,6] [,7] [,8] [,9]
## ind.env1_mat -0.063099759 0.02064869 0.02539415 0.002292975 -0.07305243
## ind.env2_MTWetQ 0.023736921 -0.03019428 0.01360083 0.112457789 -0.02354021
## ind.env3_MTDQ -0.019240464 -0.02199593 -0.06875513 0.043179895 0.10418350
## ind.env4_PDM -0.003946225 -0.11767281 0.05887330 0.032681938 -0.09642371
## ind.env5_PwarmQ -0.032384913 0.05976386 -0.07535789 0.008011003 -0.03393128
## ind.env6_PWM 0.018107020 0.06710304 0.06788231 -0.068827598 0.02928042
## [,10]
## ind.env1_mat 0.03694418
## ind.env2_MTWetQ -0.04964375
## ind.env3_MTDQ -0.05660635
## ind.env4_PDM 0.01149236
## ind.env5_PwarmQ -0.01743073
## ind.env6_PWM -0.01118472</code></pre>
<pre class="r"><code># Note that the regression coefficients for the first SNP from this
# approach is exactly the same as from our model above:
Qr.coeff[,1]</code></pre>
<pre><code>## ind.env1_mat ind.env2_MTWetQ ind.env3_MTDQ ind.env4_PDM ind.env5_PwarmQ
## -0.035729076 -0.062538545 0.007471565 -0.088670803 -0.069588746
## ind.env6_PWM
## 0.047203246</code></pre>
<pre class="r"><code> coef(summary(mod))[,1]</code></pre>
<pre><code>## (Intercept) ind$env1_mat ind$env2_MTWetQ ind$env3_MTDQ ind$env4_PDM
## 0.035000000 -0.035729076 -0.062538545 0.007471565 -0.088670803
## ind$env5_PwarmQ ind$env6_PWM
## -0.069588746 0.047203246</code></pre>
<p>We can visualize the regression coefficients with a heatmap. In this
case, we know the causal loci in the simulations, so we will just
visualize those loci.</p>
<p>This visualization illustrates how there are unique ways in which
environments are combined in the model to predict the pattern at each
SNP.</p>
<pre class="r"><code>dim(Qr.coeff)</code></pre>
<pre><code>## [1] 6 26371</code></pre>
<pre class="r"><code>colnames(Qr.coeff) <- muts$mutname
# look at the range of coefficients in the multiple regression model
summary(as.numeric(Qr.coeff[,which(muts$causal)]))</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -0.657086 -0.054464 0.001058 0.001041 0.056986 0.447236</code></pre>
<pre class="r"><code>brks <- seq(-0.7, 0.7, by=0.05) #set the color scale
heatmap.2(t(Qr.coeff[,which(muts$causal)]),
scale="none",
col = cm.colors(length(brks)-1),
breaks=brks,
dendrogram = "column",
Rowv=FALSE, #set this to "TRUE" if you would like to see which groups
trace="none",
key.title = "Coefficient in multiple\nregression model",
ylab="SNPs",
cexCol=1)</code></pre>
<p><img src="POP_05_RDAtraitPredictionTutorial_files/figure-html/unnamed-chunk-7-1.png" width="768" /></p>
<p>In the above heatmap, each row is a SNP. The SNPs are named according
to their linkage group (1 through 10) and cumulative position in the
genome (e.g. 9-448632 is on the 9th linkage group). Each linkage group
was 50,000 bases long, so the cumulative position ranges from 1 to
500,000 over the 10 linkage groups. Each column in the heatmap is an
environment, which is an explanatory variable in the model.</p>
<p>The color of the heatmap cells for a SNP shows the coefficients in
the multiple regression model for each corresponding environment. In
other words, the colors show how environments are combined in a multiple
regression model to predict the patterns at that SNP on the
landscape.</p>
<p>If we want to visualize clusters of SNPs that have similar
coefficients in the multiple regression model, we can allow for
clustering in the heatmap:</p>
<pre class="r"><code>heatmap.2(t(Qr.coeff[,which(muts$causal)]),
scale="none",
col = cm.colors(length(brks)-1),
breaks=brks,
dendrogram = "both",
Rowv=TRUE,
trace="none",
key.title = "Coefficient in multiple\nregression model",
ylab="SNPs",
cexCol=1)</code></pre>
<p><img src="POP_05_RDAtraitPredictionTutorial_files/figure-html/unnamed-chunk-8-1.png" width="768" /></p>
<p>Here is the information about the session when the tutorial was
built:</p>
<pre class="r"><code>sessionInfo()</code></pre>
<pre><code>## R version 4.2.2 (2022-10-31)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS 14.2.1
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] gplots_3.1.3 lfmm_1.1 LEA_3.10.2
## [4] vegan_2.6-4 lattice_0.22-5 permute_0.9-7
## [7] reticulate_1.34.0 lubridate_1.9.3 forcats_1.0.0
## [10] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2
## [13] readr_2.1.5 tidyr_1.3.0 tibble_3.2.1
## [16] ggplot2_3.4.4 tidyverse_2.0.0 kableExtra_1.3.4
## [19] knitcitations_1.0.12 knitr_1.45
##
## loaded via a namespace (and not attached):
## [1] httr_1.4.7 sass_0.4.8 jsonlite_1.8.8 viridisLite_0.4.2
## [5] splines_4.2.2 foreach_1.5.2 gtools_3.9.5 bslib_0.6.1
## [9] highr_0.10 yaml_2.3.8 pillar_1.9.0 backports_1.4.1
## [13] glue_1.7.0 digest_0.6.34 rvest_1.0.3 RefManageR_1.4.0
## [17] colorspace_2.1-0 htmltools_0.5.7 Matrix_1.6-5 plyr_1.8.9
## [21] pkgconfig_2.0.3 bibtex_0.5.1 scales_1.3.0 webshot_0.5.5
## [25] svglite_2.1.3 tzdb_0.4.0 timechange_0.3.0 mgcv_1.9-1
## [29] generics_0.1.3 cachem_1.0.8 withr_3.0.0 cli_3.6.2
## [33] magrittr_2.0.3 evaluate_0.23 fansi_1.0.6 nlme_3.1-164
## [37] MASS_7.3-60.0.1 xml2_1.3.6 tools_4.2.2 hms_1.1.3
## [41] lifecycle_1.0.4 munsell_0.5.0 cluster_2.1.6 compiler_4.2.2
## [45] jquerylib_0.1.4 caTools_1.18.2 systemfonts_1.0.5 rlang_1.1.3
## [49] grid_4.2.2 iterators_1.0.14 rstudioapi_0.15.0 bitops_1.0-7
## [53] rmarkdown_2.25 gtable_0.3.4 codetools_0.2-19 R6_2.5.1
## [57] fastmap_1.1.1 utf8_1.2.4 KernSmooth_2.23-22 stringi_1.8.3
## [61] parallel_4.2.2 Rcpp_1.0.12 vctrs_0.6.5 png_0.1-8
## [65] tidyselect_1.2.0 xfun_0.41</code></pre>
</div>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
<script>
$(document).ready(function () {
// temporarily add toc-ignore selector to headers for the consistency with Pandoc
$('.unlisted.unnumbered').addClass('toc-ignore')
// move toc-ignore selectors from section div to header
$('div.section.toc-ignore')
.removeClass('toc-ignore')
.children('h1,h2,h3,h4,h5').addClass('toc-ignore');
// establish options
var options = {
selectors: "h1,h2,h3",
theme: "bootstrap3",
context: '.toc-content',
hashGenerator: function (text) {
return text.replace(/[.\\/?&!#<>]/g, '').replace(/\s/g, '_');
},
ignoreSelector: ".toc-ignore",
scrollTo: 0
};
options.showAndHide = false;
options.smoothScroll = true;
// tocify
var toc = $("#TOC").tocify(options).data("toc-tocify");
});
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>