-
Notifications
You must be signed in to change notification settings - Fork 7
/
RADseq.html
1953 lines (1853 loc) · 88.1 KB
/
RADseq.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<title>RADseq</title>
<script src="site_libs/header-attrs-2.28/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>
<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>
<style type="text/css">
/* for pandoc --citeproc since 2.11 */
div.csl-bib-body { }
div.csl-entry {
clear: both;
margin-bottom: 0em;
}
.hanging div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}
</style>
<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="RDAtraitPredictionTutorial.html">Redundancy Analysis (RDA) Trait Prediction</a>
</li>
<li>
<a href="POP_08_PCA.html">PCA</a>
</li>
<li>
<a href="POP_09_aDNA.html">Ancient & Degraded DNA</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">RADseq</h1>
<h3 class="subtitle"><em>Katherine Silliman, Danielle
Davenport</em></h3>
</div>
<p>Initial publication year: 2022 <br> <a
href="https://marineomics.github.io/#How_to_Cite">How to cite</a></p>
<div id="setup-for-running-code" class="section level1">
<h1>Setup for running code</h1>
<p>If you would like to run the R code examples that are scattered
throughout the guide (recommended but not required!), you will need to
install some R packages. Only need to run this code once:</p>
<pre class="r"><code>install.packages("tidyverse")
if (!requireNamespace("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("SeqArray")
BiocManager::install("SNPRelate")</code></pre>
<p>Now load those packages, if using:</p>
<pre class="r"><code>library(SeqArray) # efficient storage and filtering of genomic data</code></pre>
<pre><code>## Loading required package: gdsfmt</code></pre>
<pre><code>##
## Attaching package: 'SeqArray'</code></pre>
<pre><code>## The following object is masked from 'package:stringr':
##
## fixed</code></pre>
<pre class="r"><code>library(tidyverse) # plotting data formatting and manipulation
library(SNPRelate) # PCA and other popgen analyses</code></pre>
<pre><code>## SNPRelate</code></pre>
<p>We also provide optional alternative coding examples that are based
only on the command line, requiring these software packages:</p>
<ul>
<li><a
href="https://vcftools.github.io/man_latest.html">vcftools</a></li>
<li><a
href="https://riptutorial.com/gnuplot/example/11275/installation-or-setup">gnuplot</a></li>
</ul>
</div>
<div id="reduced-representation-sequencing-radseqgbs"
class="section level1">
<h1>Reduced Representation Sequencing (RADseq/GBS)</h1>
<p>“Restriction-site Associated DNA sequencing” - RADseq - combines
restriction enzymes with next-gen, massively parallel, short-read
sequencing. RADseq involves the use of restriction enzymes, which are
used to shear DNA at restriction enzyme cutsites. RADseq comes in
different flavors. Double-digest RADseq (ddRAD; <span
class="citation">Peterson et al. (2012)</span>) selects markers with two
restriction enzymes with different cut frequencies.
Genotype-by-Sequencing (GBS; <span class="citation">Elshire et al.
(2011)</span>) uses a frequent-cutting restriction enzyme with PCR size
selection. There are a number of reviews comparing different RADseq and
GBS methods (e.g., <span class="citation">Andrews et al. (2016)</span>).
In this guide we use the term “RADseq” to refer to any of these
protocols, including those that don’t involve random shearing of data.
When recommendations are specific to a certain type of RAD/GBS, we will
explicitly say so.</p>
<!--Some aspects of RADseq data that are unique compared to whole genome resequencing (more):-->
<p>Using RADseq to generate single nucleotide polymorphisms (SNPs)
involves:</p>
<ol style="list-style-type: decimal">
<li>library preparation in the lab</li>
<li>bioinformatic processing through assembly and/or mapping to a
reference, then</li>
<li>filtering of SNPs and individuals for quality.</li>
</ol>
<p>All of these steps can (and will) introduce some error, so the goal
is to minimize this error through mitigation steps at all three parts of
the process. Every dataset is different!<br />
<!--add more about philosophy over best practices--></p>
<p>Much of this guide is directly inspired by <a
href="https://onlinelibrary.wiley.com/doi/10.1111/mec.14792">this
excellent review paper</a> <span class="citation">(O’Leary et al.
2018)</span>, especially the section on minimizing errors due to library
prep. We recommend reading and cross-referencing with this paper, and
citing it if you follow its suggestions. Table 1 from this paper
summarizes the various potential issues that can arise from RAD datasets
and some mitigation steps. The goal of this guide is to expand on the
O’Leary paper and provide some example code to help implement quality
control and mitigation steps.</p>
<div class="float">
<img src="POP_02_RADseq_files/oleary_table1.png"
alt="Table 1 from (O’Leary et al. 2018)." />
<div class="figcaption">Table 1 from <span class="citation">(O’Leary et
al. 2018)</span>.</div>
</div>
</div>
<div id="labwork" class="section level1">
<h1>Considerations During Lab Work</h1>
<p>There are steps you can take before you even sequence RAD libraries
that can help minimize issues downstream. Here, we use “library” to
refer to a set of RADseq fragments from a group of individuals that are
barcoded and sequenced together on a single lane or group of lanes.
While specific RAD library prep methods have their own nuances for
minimizing error, there are some steps you can take that are common
across methods.</p>
<ul>
<li><p>If this RAD/GBS method has not been done in your species or in
your molecular lab setup before, spend some time optimizing the protocol
using a representative subset of individuals. Then try to keep
everything about the library prep as consistent as possible across
samples (eg, DNA extraction kit, PCR cycles, sequencing platform). This
isn’t always possible, especially if you need to optimize the protocol
for certain tricky samples. Just make sure to keep track of
everything!</p></li>
<li><p>Randomize samples across library prep batches and sequencing
lanes! For example, if you are sequencing two different groups of
samples on two different sequencing lanes, make sure they are randomized
with respect to sample location or whatever your groups of interest are.
If you are preparing groups of individuals in different batches to be
pooled later, randomize across these batches. <a
href="https://mastrettayanes-lab.org/">Alicia Mastretta-Yanes</a> even
recommends randomizing across DNA extractions, especially if the person
doing the extractions is new to molecular work. This is to allow you to
control for potential <a href="#batch">batch effects</a> that are often
observed with RAD data.</p></li>
</ul>
<!--ADW: add figure showing random plate design-->
<ul>
<li>Keep track of all potential batch effect sources in a Metadata file
(eg, storage conditions of tissue/DNA, date/method of DNA extraction,
date/method library prep batch, sequencing lane).<br />
</li>
<li>Have a core set of 2-4 technical sample replicates across all
libraries. Ideally these are true technical replicates, meaning the same
tissue/DNA sample is processed multiple times all the way from library
preparation to sequencing. Sequencing replicates, where you sequence the
same sample library preparation multiple times, can also be useful for
downstream quality control.</li>
</ul>
<!--ADW: add figure or text to define sequencing replicates vs technical replicates-->
</div>
<div id="principles-for-analyzing-your-data" class="section level1">
<h1>Principles for Analyzing Your Data</h1>
<div id="steps-for-a-robust-rad-analysis" class="section level2">
<h2>Steps for a robust RAD analysis</h2>
<p>This is just one approach for working through your data. Some people
will prefer to run just a subset of samples through a pipeline at first
and evaluate parameters, then run all the samples through. Either way,
be prepared to make MULTIPLE assemblies and go through this process
iteratively, especially if this is a new-to-you study system.</p>
<!-- 1) [Look at your raw data.](#fastqc)
2) [Run an assembly pipeline](#assembly) through to a SNP dataset, using either all samples or a representative subset. Parameters can come from those used in a similar study, or default parameters.
3) Filter your data minimally, then [evaluate for potential sources of error.](#error)
4) Subset or remove individuals based on initial evaluation.
5) Using a representative subset of samples, [test key parameters](#test) to optimize your assembly.
6) Run your optimized assembly on all non-removed samples.
7) Evaluate the difference between multiple filtering schemes for your analyses of interest. *Popgen analysis guide coming soon*
8) Repeat as needed. -->
<ol style="list-style-type: decimal">
<li><a href="#fastqc">Look at your raw data.</a></li>
<li><a href="#assembly">Run an assembly pipeline</a>, using either all
samples or a representative subset.</li>
<li><a href="#error">Evaluate potential sources of error.</a></li>
<li><a href="#bad">Remove individuals based on initial
evaluation</a>.<br />
</li>
<li><a href="#test">Test a range of key parameters</a> to optimize your
assembly.</li>
<li>Run your optimized assembly on all non-removed samples.</li>
<li><a href="#filter">Filter your SNPs</a></li>
<li><a href="#repeat">Repeat as needed!</a></li>
</ol>
</div>
<div id="fastqc" class="section level2">
<h2>First, look at the raw data!</h2>
<p>Always look at your data with <a
href="https://www.bioinformatics.babraham.ac.uk/projects/fastqc/">FastQC</a>
before starting an assembly. First, this is a good check to just make
sure the sequencing worked. If you have demultiplexed data, you can use
<a href="https://multiqc.info/">MultiQC</a> to generate FastQC plots for
all individuals and quickly identify ones that did not sequence
well.</p>
<p>Check out <a
href="https://datacarpentry.org/wrangling-genomics/02-quality-control/index.html">this
informative tutorial</a> on running FastQC and interpreting the
output.</p>
<p><strong>Questions to ask:</strong> Do you have a lot of adapter
sequences? Are the ends of your reads very low quality? If so, you
should expect a fair amount of trimming and read filtering to occur
prior to assembly. If that doesn’t occur or if too many reads are being
filtered so as to only recover a small number of SNPs, something might
need to be tweaked with your trimming and filtering step.
<!--ADW: elaborating what you mean by 'tweaked' or possibly providing a link to some resources for how someone might thoughtfully change the parameters for their trimming and filtering steps.--></p>
<p>You should also look at the top few reads in the Terminal.</p>
<pre><code>## zcat: unZip and conCATenate the file to the screen
## head -n 20: Just take the first 8 lines of input
$ zcat raw-fastqs/BC2_10_C5.fastq.gz | head -n 20
@BC2_10_C5.1 1 length=96
CAGCGTGTAATAGTCACCGGCGGCTCCCTCTGGAGAATAGCACAAGTGATCATTTTGCTCATCTTCCGTCCACTGGTGATTGTGGACCAGCCTCAC
+BC2_10_C5.1 1 length=96
<GGGGGA<GGGGIIIGIGGIGGGIIIIIGGGGGGGGGGGGGGGGGIIIIIIIIGGIIIGGGGIGIIGIGGGIIIIIAGGGGIIIGIIGGGGGAAGG
@BC2_10_C5.2 2 length=96
CTGCTACATGCAGTGTTCTGTATTACTTTTATTGTACGTTGATATGAATGAATGAGTGTTTTGTATACTTAGAGTACAAGTTTGTCAGTCATATCG
+BC2_10_C5.2 2 length=96
GIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIGGIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIG
@BC2_10_C5.3 3 length=96
CAGCACATGTTCCTGTGTAGAAAGCTTGTTAGTAGAATAAATAACACATGGCTGGTCAAACACAACACATGAAGAAACAACTTTCTGAACAGTTTT
+BC2_10_C5.3 3 length=96
GIIGIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIGIIIIIIIIIIIIIIIIIIIIIIIIGGGGIIGIIIGGGII
@BC2_10_C5.4 4 length=96
CAGCGATTCGGCCCAAATTTGCACCACATCAGGCCCTTGACAGGGCGCTTCGATGGTGCAAATTTGGTGCGATTCGCTGCGCACCTAGCATATATG
+BC2_10_C5.4 4 length=96
AGGGIGIIIGIGGGIIGIGGGIIIGGGGAGGGGGAGGIGIGGIGGGGAGGGGGGGGGGGGGGGIIIII.G<GGIGGGIIIGGGGGIGGIIIGAGGI
@BC2_10_C5.5 5 length=96
CAGCAGTTTGGTGGAGTTCTGCAACCTTCCATTTCCAAAGAATTACCCAGGAGCTCTTCCCAGTGAATTTCTTCGGCACTTTTCATTGACCTTTTA
+BC2_10_C5.5 5 length=96
GGAGAAA.<AGAA.G.GGAGA<.GGA.<GAAGGAAGGIA<...<GA<..<G.<.<<.<AAAGGGG..<GGGGG<G.A.<GGGII.AG..<.GGGGG
</code></pre>
<p>If the sequencing center gave you one fastq file with all your
samples, you should expect to see a barcode sequence, followed by the
cutsite at the start of the read. If the Data are already demultiplexed
(as the example is), you should only see the cutsite overhang (in this
case, CWGC). Sometimes you can look at your fastq data files and see
that there was a problem with the sequencing such that the cut site is
either offset by one or more bases, or contains many errors. If this is
not being addressed by the default filtering steps in your assembly
pipeline, you can trim off N bases from the beginning or end of R1 and
R2 reads in <a
href="https://ipyrad.readthedocs.io/en/latest/index.html">ipyrad</a>
(<code>trim_reads</code> param), or with cutadapt before using stacks,
or customize the Trimmoatic step for <a
href="https://www.ddocent.com/">dDocent</a>.</p>
</div>
<div id="assembly" class="section level2">
<h2>Run an assembly pipeline</h2>
<p>There are a number of freely available pipelines for processing
RADseq data, with the most popular being <a
href="https://www.ddocent.com/">dDocent</a>, <a
href="https://catchenlab.life.illinois.edu/stacks/">Stacks</a>, and <a
href="https://ipyrad.readthedocs.io/en/latest/index.html">ipyrad</a>.
These pipelines vary slightly in their underlying methodologies,
customization options, and additional included analyses.</p>
<table>
<colgroup>
<col width="25%" />
<col width="25%" />
<col width="25%" />
<col width="25%" />
</colgroup>
<thead>
<tr class="header">
<th></th>
<th><a href="https://www.ddocent.com/">dDocent</a></th>
<th><a
href="https://ipyrad.readthedocs.io/en/latest/index.html">ipyrad</a></th>
<th><a
href="https://catchenlab.life.illinois.edu/stacks/">Stacks2</a></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>Supported datatypes</td>
<td>Paired-end: ddRAD, ezRAD, RAD (random shearing), data with large
overlap between forward and reverse reads; Single-end: any RADseq method
de novo and reference-based. If doing de novo assembly, reads cannot be
trimmed outside of dDocent</td>
<td>Wide range of RAD/GBS methods with paired/single end data, see <a
href="https://ipyrad.readthedocs.io/en/master/4-data.html">ipyrad
documentation</a></td>
<td>Paired-end and single-end data for single and double digest RAD and
DART; GBS with single-end sequencing. NOT suitable for paired-end
GBS.</td>
</tr>
<tr class="even">
<td>Unique aspects</td>
<td>Novel data reduction approach used to inform coverage cutoffs</td>
<td>Python API for popgen and phylogenetic analyses written specifically
for RAD data</td>
<td><code>populations</code> module calculates sliding window and
site-specific popgen metrics</td>
</tr>
<tr class="odd">
<td>Documentation</td>
<td>Very good (esp. tutorials), active community support on Google
Groups</td>
<td>Excellent (esp. installation, parameter explanations, and
tutorials), active community support on Gitter</td>
<td>Very good, in depth tutorials as published manuscripts, active
community support on Google Groups</td>
</tr>
<tr class="even">
<td>Speed/Accuracy (based on discussion in <a
href="https://www.youtube.com/watch?v=C74GBESeIq4">panel
seminar</a>)</td>
<td>fastest and most accurate</td>
<td>close to dDocent accuracy, more over-splitting is possible if
parameters are not tuned</td>
<td>produces some untrue genome fragments (esp. with higher levels of
indel polymorphism), but can be addressed with downstream filtering</td>
</tr>
<tr class="odd">
<td>Open source/development</td>
<td>Open source, primarily combines existing software</td>
<td>Open source</td>
<td>No</td>
</tr>
<tr class="even">
<td>Filtering options</td>
<td>Minimal default filtering as implemented in VCFtools. Ideal for
those who want full freedom in filtering their SNPs.</td>
<td>Wide range of filtering options, some hard-coded filtering to deal
with paralogs</td>
<td>Moderate range of filtering options</td>
</tr>
<tr class="odd">
<td>Output options</td>
<td>Only produces a VCF, fasta of the de novo assembly, and individual
BAM files from mapping to the reference</td>
<td>Lots of output formats (see <a
href="https://ipyrad.readthedocs.io/en/master/output_formats.html">documentation</a>)</td>
<td>Lots of Stacks-specific output and log files, as well as various
inputs for popgen programs (see <a
href="https://catchenlab.life.illinois.edu/stacks/comp/populations.php">documentation</a>)</td>
</tr>
<tr class="even">
<td>Popgen analyses</td>
<td>No additional popgen analyses included</td>
<td>Unique, flexible Python API implementing range of popgen and
phylogenetic methods (see <a
href="https://ipyrad.readthedocs.io/en/master/API-analysis/index.html">documentation</a>)</td>
<td>Popgen summary statistics (F-statistics, pi), including
kernel-smoothing along reference genome. Underlying equations and
assumptions for these are not very clear.</td>
</tr>
<tr class="odd">
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<p>Some groups have also developed pipelines for specific flavors of RAD
(e.g., <a
href="https://github.com/z0on/2bRAD_denovo/blob/master/2bRAD_README.sh">Matz
lab for 2b-RAD</a>) or proprietary software (eg, <a
href="http://georges.biomatix.org/storage/app/media/uploaded-files/dartR_Workbook.pdf">DARTseq</a>).
<strong>In most cases, it is recommended that you use a pipeline
developed and tested for RAD data, especially if you are making a de
novo assembly.</strong> <span class="citation">(LaCava et al.
2020)</span> have an excellent study where they review various <em>de
novo</em> assemblers that are used in these pipelines. Assemblers that
were not explicitly developed for short reads (eg, Velvet, ABySS)
performed very poorly, while CD-HIT (the assembler in dDocent) performed
the best. Stacks/Stacks2 and vsearch (the assembler in ipyrad) both
performed worse when analyzing simulated data with indels. It should be
noted that all of these RAD pipelines have optimized the specific
parameters of these de novo assemblers to work with RAD data of various
flavors, which may not be fully reflected in the LaCava study.</p>
<p>Based on the MarineOmics RAD panel, the general consensus is that all
the popular pipelines can produce adequately accurate datasets (with
appropriate parameter optimization and data filtering).<br />
<img src="POP_02_RADseq_files/lacavaTable3.png"
alt="Table 3 from LaCava et al 2019. CD-HIT is used in dDocent, VSEARCH is used in ipyrad." /></p>
</div>
<div id="error" class="section level2">
<h2>Evaluate potential sources of error</h2>
<p>Once you have processed your samples (or a subset of samples) through
a genotyping pipeline, you will have a bunch of different output file
options for genetic data. The VCF file is one of the most popular file
formats, and is the most versatile for initial data exploration as many
programs exist to filter and accept VCF files. Below are a list of
potential confounding factors that may exist in your data, and how to
tease them out.</p>
<p><strong>Using SeqArray in R</strong> If you are following along with
the R code examples, we need to 1st read in our data (skip this section
if not running R code).</p>
<p>For the code examples in this section, we primarily make use of the R
package SeqArray <span class="citation">(Zheng et al. 2017)</span>,
which can read and manipulate VCFs. If you’re familiar with R, SeqArray
is simple to use. The package can efficiently store sequence variant
calls with hundreds of thousands of individuals, variants (e.g., SNPs,
indels and structural variation calls) and annotations. It employs a
data container called a CoreArray Genomic Data Structure (GDS). It’s
super-fast (5X faster than PLINK v1.9; 16X faster than vcftools) and it
integrates well with other R packages you might use in your analysis
pipeline. (i.e. SNPRelate, SeqVarTools). We also like it because you can
filter your data before running certain analyses without 1st generating
a separate filtered VCF file.</p>
<p>First, we need to convert our VCF file into the GDS format. We will
do this once here, then use the GDS file for subsequent code
examples.</p>
<pre class="r"><code>filename = "OL_subset" #replace with y our file name
filename.gds = paste0("POP_02_RADseq_files/", paste0(filename, ".gds"))
filename.vcf = paste0("POP_02_RADseq_files/", paste0(filename, ".vcf"))
# 1 . Convert VCF to GDS
SeqArray::seqVCF2GDS(vcf.fn = filename.vcf, out.fn = filename.gds, storage.option="ZIP_RA")</code></pre>
<pre><code>## Sat Mar 18 13:56:29 2023
## Variant Call Format (VCF) Import:
## file(s):
## OL_subset.vcf (22.3M)
## file format: VCFv4.0
## genome reference: pseudo-reference (most common base at site)
## the number of sets of chromosomes (ploidy): 2
## the number of samples: 18
## genotype storage: bit2
## compression method: ZIP_RA
## # of samples: 18
## Output:
## POP_02_RADseq_files/OL_subset.gds
## Parsing 'OL_subset.vcf':
## + genotype/data { Bit2 2x18x70005 ZIP_ra(34.4%), 216.0K }
## Digests:
## sample.id [md5: dd28e5c928ffd0a817743a0e9447a808]
## variant.id [md5: 03df6156357de104368e6ed4694ebf92]
## position [md5: 690fe39440c87b7bfb5eeb07d7c0a310]
## chromosome [md5: 9f967c382b54d12060ab45d8c293652b]
## allele [md5: fb5bdfa95fb2448dd960bb41c96f7bff]
## genotype [md5: 25350d469a1102cc70b367663332282f]
## phase [md5: cd66242aebb89cfc3f2082c9413847dc]
## annotation/id [md5: c95d7c12f4fdae536da42bfec73942c9]
## annotation/qual [md5: 2864e4ded2a2cdc9dccfeb45c4fb3465]
## annotation/filter [md5: 2134c67ca1fdd51b7d3bf17ca1ca2c9e]
## annotation/info/NS [md5: 4ad6db26b594a567be24b0bff7f1f909]
## annotation/info/DP [md5: c0e5e2a0856c1f43788d2fa9842d2e7a]
## annotation/format/DP [md5: ae6991de5adbf082a733198faf0f11ca]
## annotation/format/CATG [md5: 71d62ffa848999a375e8bb5f329be275]
## Done.
## Sat Mar 18 13:56:30 2023
## Optimize the access efficiency ...
## Clean up the fragments of GDS file:
## open the file 'POP_02_RADseq_files/OL_subset.gds' (2.8M)
## # of fragments: 214
## save to 'POP_02_RADseq_files/OL_subset.gds.tmp'
## rename 'POP_02_RADseq_files/OL_subset.gds.tmp' (2.8M, reduced: 1.8K)
## # of fragments: 64
## Sat Mar 18 13:56:30 2023</code></pre>
<pre class="r"><code>gdsin = SeqArray::seqOpen(filename.gds)
print(paste0("The number of SAMPLES in data: ", length(c(SeqArray::seqGetData(gdsin, "sample.id")))))</code></pre>
<pre><code>## [1] "The number of SAMPLES in data: 18"</code></pre>
<pre class="r"><code>print(paste0("The number of SNPs in data: ", length(c(SeqArray::seqGetData(gdsin, "variant.id")))))</code></pre>
<pre><code>## [1] "The number of SNPs in data: 69989"</code></pre>
<p>It is always helpful to have a metadata file with information for
each sample, such as sampling site, sequencing library, etc. In our
example, our metadata file (OL.popmap) is tab-delimited and has the
column headers:<br />
ID: sample ID STRATA: sampling location/population PLATE: sequencing
batch<br />
Next we read in our metadata file, and make sure the samples are in the
same order as your VCF file:</p>
<pre class="r"><code>metafile = "POP_02_RADseq_files/OL.popmap"
sample.ids = seqGetData(gdsin, "sample.id")
sample.strata = read.table(metafile, header = T, sep = "\t") %>%
dplyr::select(ID, STRATA, PLATE)</code></pre>
<p>Now, on to evaluating our data!</p>
<div id="bad" class="section level3">
<h3>“Bad” samples</h3>
<p>Sometimes a sample doesn’t sequence well (few sequencing reads,
higher error rate). This can be due to DNA quality, an issue during
library prep, or not enough sequencing depth (average # of reads per
sample). Generally, it will lead to a sample with fewer sequencing
reads, higher missing data in a SNP dataset, and fewer shared loci with
other samples. Identifying and then removing these samples
<em>prior</em> to the final RADseq assembly analysis can help minimize
mis-assembled loci, genotyping errors, and excessive filtering of
acceptable loci.</p>
<p>The process of identifying low quality individuals is usually
iterative, as the way you initially filter your SNPs will influence the
amount of missing data and locus sharing among samples. This is why we
recommend minimally filtering your SNPs for sample coverage (the # of
individuals a locus is called in) when initially exploring your data.
Some ways to identify bad samples:</p>
<ol style="list-style-type: decimal">
<li>For every SNP dataset you generate, it is a good idea is always
evaluate the missingness per sample (and report this distribution in
your manuscript!). Identify samples with way more missingness than the
rest, and observe how they look in a PCA and locus sharing plot. If they
stick out or all cluster together in the middle, then try removing them
from the assembly and seeing if it changes downstream analyses. If so,
you may want to specify a missingness cutoff for including samples in
the final analysis.</li>
</ol>
<p><strong>Missingness in R with SeqArray</strong></p>
<pre class="r"><code>#using previously loaded gdsin object
print("Per variant: ")</code></pre>
<pre><code>## [1] "Per variant: "</code></pre>
<pre class="r"><code>summary(m1 <- SeqArray::seqMissing(gdsin, per.variant=TRUE))</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.2778 0.3889 0.3855 0.4444 0.9444</code></pre>
<pre class="r"><code>print("Per sample: ")</code></pre>
<pre><code>## [1] "Per sample: "</code></pre>
<pre class="r"><code>summary(m2 <- SeqArray::seqMissing(gdsin, per.variant=FALSE))</code></pre>
<pre><code>## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.1218 0.1574 0.2287 0.3855 0.6213 0.9177</code></pre>
<pre class="r"><code>samples <- SeqArray::seqGetData(gdsin, "sample.id")
cbind(samples,m2)[order(-m2),]</code></pre>
<pre><code>## samples m2
## [1,] "OR3_13_C3" "0.917672777150695"
## [2,] "CA4_12_C1" "0.886539313320665"
## [3,] "OR3_3_C7" "0.873308662789867"
## [4,] "CA4_13_C1" "0.692623126491306"
## [5,] "BC2_6_C2" "0.634999785680607"
## [6,] "BC2_9_C4" "0.580248324736744"
## [7,] "CA4_8_C9" "0.365486004943634"
## [8,] "CA4_1_C4" "0.292274500278615"
## [9,] "OR3_1_C3" "0.245538584634728"
## [10,] "CA4_2_C3" "0.211790424209519"
## [11,] "CA4_14_C8" "0.201074454557145"
## [12,] "OR3_20_C4" "0.180756976096244"
## [13,] "BC2_10_C5" "0.165683178785238"
## [14,] "OR3_9_C8" "0.154638586063524"
## [15,] "OR3_5b_C6" "0.15163811456086"
## [16,] "BC2_17_C7" "0.132277929388904"
## [17,] "BC2_12_C6" "0.130006143822601"
## [18,] "BC2_16_C6" "0.121776279129578"</code></pre>
<pre class="r"><code>#plot histogram
hist(m2,breaks=50)</code></pre>
<p><img src="POP_02_RADseq_files/figure-html/unnamed-chunk-7-1.png" width="960" /></p>
<p>Another common method of filtering and evaluating you data without
ever using R is <a
href="https://vcftools.github.io/man_latest.html">VCFtools</a>.</p>
<p><strong>Missingness with vcftools, on the command line</strong></p>
<pre class="bash"><code>vcftools --vcf POP_02_RADseq_files/OL_subset.vcf --missing-indv --out POP_02_RADseq_files/OL_subset
# sort the file by most missing data and print the top 10 samples
cat POP_02_RADseq_files/OL_subset.imiss | (read h; echo "$h"; sort -k5 -r) </code></pre>
<pre><code>## /Users/jason/.bashrc: line 1: /Users/jason/perl5/perlbrew/etc/bashrc: No such file or directory
##
## VCFtools - 0.1.17
## (C) Adam Auton and Anthony Marcketta 2009
##
## Parameters as interpreted:
## --vcf POP_02_RADseq_files/OL_subset.vcf
## --missing-indv
## --out POP_02_RADseq_files/OL_subset
##
## After filtering, kept 18 out of 18 Individuals
## Outputting Individual Missingness
## After filtering, kept 69989 out of a possible 69989 Sites
## Run Time = 0.00 seconds
## INDV N_DATA N_GENOTYPES_FILTERED N_MISS F_MISS
## OR3_13_C3 69989 0 64227 0.917673
## CA4_12_C1 69989 0 62048 0.886539
## OR3_3_C7 69989 0 61122 0.873309
## CA4_13_C1 69989 0 48476 0.692623
## BC2_6_C2 69989 0 44443 0.635
## BC2_9_C4 69989 0 40611 0.580248
## CA4_8_C9 69989 0 25580 0.365486
## CA4_1_C4 69989 0 20456 0.292275
## OR3_1_C3 69989 0 17185 0.245539
## CA4_2_C3 69989 0 14823 0.21179
## CA4_14_C8 69989 0 14073 0.201074
## OR3_20_C4 69989 0 12651 0.180757
## BC2_10_C5 69989 0 11596 0.165683
## OR3_9_C8 69989 0 10823 0.154639
## OR3_5b_C6 69989 0 10613 0.151638
## BC2_17_C7 69989 0 9258 0.132278