-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.R
1559 lines (1208 loc) · 102 KB
/
app.R
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
# Please ensure R version: 3.6.0 is installed prior to running this tool
# Change max file upload to 20 Mb
options(shiny.maxRequestSize = 100*1024^2)
options(warn=-1)
# install.packages("plyr")
library(plyr)
# install.packages("ggplot2")
library(ggplot2)
# install.packages("shiny")
library(shiny)
# install.packages("shinyjs")
library(shinyjs)
# install.packages("shinyalert")
library(shinyalert)
# install.packages("shinyWidgets")
library(shinyWidgets)
# install.packages("jsonlite")
library(jsonlite)
# install.packages("rhandsontable")
library(rhandsontable)
# if (!requireNamespace("BiocManager", quietly = TRUE))
# install.packages("BiocManager")
# BiocManager::install("Biostrings")
# BiocManager::install("DECIPHER")
library(Biostrings)
library(DECIPHER)
# install.packages("RSQLite")
library(RSQLite)
# install.packages("foreach")
library(foreach)
# install.packages("TmCalculator")
library(TmCalculator)
# install.packages("stringi")
library(stringi)
# install.packages("d3heatmap")
library(d3heatmap)
# Read in of an example alignment for testing
exampleAlignment <- readDNAStringSet("sampleAlignment.fas")
ui <- tagList(useShinyalert(),
useShinyjs(),
tags$head(
tags$style(
HTML(".shiny-notification {
height: 100px;
width: 600px;
position:fixed;
top: calc(50% - 50px);;
left: calc(50% - 400px);;
}
"
)
)
),
tags$head(
HTML("<script>
var socket_timeout_interval
var n = 0
$(document).on('shiny:connected', function(event) {
socket_timeout_interval = setInterval(function(){
Shiny.onInputChange('count', n++)
}, 15000)
});
$(document).on('shiny:disconnected', function(event) {
clearInterval(socket_timeout_interval)
});
</script>"
)
),
navbarPage("ssPRIMER - A Web-Based Tool for Species-Specific Primer Design", id = "mainPage",
tabPanel("1. Upload Alignment", id='panel1', value="panel1",
textOutput("keepAlive"),
sidebarLayout(
sidebarPanel(
p("Welcome to the ssPRIMER homepage! ssPRIMER is a GUI based tool that provides a straightforward
process to designing species-specific primers and Taqman probes for qPCR Assays.
To start please upload a mulitple sequence alignment in fasta format.
More options will then be presented to begin the design process.
You can also run a test alignment to test out the functionality of the tool.
Once uploaded, an interactive visual representation of the alignment will be shown to the
right. This designs primers and probes primarily with integration from the DECIPHER, Biostrings and Tm Calculator packages."),
p(strong("***Please note this tool is still in beta testing and we are working hard to make it as
polished and functional as possible but it is currently running on a small server and
can't handle many users simultaneously. If you are running into issues with the tool
please contact us here: [email protected]***")),
tags$hr(),
div(id="alignmentLoad",
actionButton('exampleAlign', "Load Test Alignment", icon("info-circle"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
tags$hr(),
fileInput('alignmentFile', 'Choose an alignment to upload (.fas or .fa format),
max file size = 20 Mb. Ensure all sequences are the same length before
uploading, this may require an alignment trimming step before upload. Also ensure that
the sequences for the target species are named in exactly the same format.
Ex: Limnephilus_hyalinus and Limnephilus hyalinus would not be considered the same target group.',
multiple = F,
accept = c(
'.fa',
'.fas'
)
)),
tags$hr(),
conditionalPanel(
condition = "output.fileUploaded",
div(id="target",
p("First select a target species/OTU from your alignment that you would like to be
selectively amplified."),
selectInput("inSelectTarget", "Target Species/OTU",
choices = "Pending Upload"),
tags$hr(),
p("You can also restrict to a specific region of the alignment you would like targeted
by your primer set. It is recommended you do not select a region smaller than 75 bp
as this will greatly limit the number of potential primer sets and will greatly lower
the probability that a suitable probe can be found. The alignment visualization will
regenerate with the region specified automatically."),
sliderInput("inSlider1", "Restrict Amplification Region",
min = 1, max = 100, value = c(1,100))
),
a(id = "toggleAlignSettings", "View more alignment settings", href = "#"),
shinyjs::hidden(
div(id="alignSettings",
sliderInput("inSliderWidth", "Alignment Display Width",
min = 20, max = 200, value = 60, step = 20, post = "bp")
)
),
tags$hr(),
div(id="stepRun",
actionButton('run1', "Start Design Process!", icon("angle-double-right"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4")
),
width = 3
)),
mainPanel(
tags$style(type="text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
conditionalPanel(
condition = "output.fileUploaded",
htmlOutput("inc"),
width = 7)))
),
tabPanel("2. Set qPCR Reaction Conditions", id='panel2', value="panel2",
sidebarLayout(
sidebarPanel(
# Chose Reaction Conditions for qPCR
div(id="qPCRConditions",
p("You can either choose a pre-defined option from the dropdown menu or adjust manually.
IDT qPCR parameters will load by default for easy ordering of primers from IDT.
More reaction presets will be added in the future."),
selectInput("inSelect2", "Choose a Master Mix for qPCR",
choices = c("Default IDT qPCR Conditions","Chai Master Mix (Hot Start 2x)")),
p("Set conditions manually:"),
sliderInput("inSlider2", "[Mg]",
min = 0, max = 10, value = 3, step = 1, post = "mM"),
sliderInput("inSlider3", "[K]",
min = 0, max = 250, value = 0, step = 10, post = "mM"),
sliderInput("inSlider4", "[Na]",
min = 0, max = 250, value = 50, step = 10, post = "mM"),
sliderInput("inSlider5", "[dNTPs]",
min = 0, max = 2, value = 0.8, step = 0.1, post = "mM"),
sliderInput("inSlider6", "[Primers]",
min = 25, max = 500, value = 200, step = 25, post = "nM"),
selectInput("inSelectPolymerase", "DNA Polymerase",
choices = c("Taq polymerase", "High-fidelity polymerase")),
tags$hr(),
actionButton('back1', "Back", icon("angle-double-left"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
actionButton('reset1', "Reset to Default", icon("undo"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
actionButton('run2', "Proceed to Primer and Probe Constraints", icon("angle-double-right"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4")
), width = 5),
mainPanel(div(),
width=7))),
tabPanel("3. Set Primer and Probe Constraints", id='panel3', value="panel3",
sidebarLayout(
sidebarPanel(
div(id="Primers",
tabsetPanel(id="panels",
tabPanel("Primary Constraints", id='panel3a', value="panel3a",
tags$hr(),
p("Next, set the contraints on your primers and probes before designing them.
It is highly recommended you start with the default if you are new to
primer design. Default ranges and values are based on the IDT primer
design guidelines for Taqman based qPCR as well as suggested default
values from the Decipher package. More experienced users can navigate
to the secondary contraints tab, the contraints shown below are the
most critical to the design process."),
# Amplicon Length
uiOutput("slider9"),
# Minimum Coverage
# h5("Minimum fraction of the target species sequences that must be covered with the
# primer+probe set."),
sliderInput("inSlider12", "Min Target Coverage (minimum fraction of target
sequences from the alignment that must be covered with the
primers and probe)",
min = 20, max = 100, value = 90, post = "%"),
sliderInput("inSlider31", "Min Group Coverage (minimum fraction of target sequences
that must have sequence data in the region specified by the user, no gaps)",
min = 20, max = 100, value = 90, post = "%"),
# Minimum Amplification Efficiency
#h5("Minimum efficiency of hybridization desired for the primer set."),
sliderInput("inSlider13", "Min Target Hybridization Efficiency (minimum fraction
of target amplicons that will be amplified with the specified primer
set each PCR cycle, ***Very high hybridization efficiency of 95-100 will lower
specificity to the target species but low efficiency of 50 or below will greatly
lower the sensitivity of the primer set***)",
min = 20, max = 100, value = 80, post = "%"),
sliderInput("inSlider14", "Max Non-Target Hybridization Efficiency
(maximum fraction of non-target amplicons that will be amplified
with the specified primer set each PCR cycle. Ideally this should
be set as low as possible however setting it lower will limit the
number of potential primer sets that can be generated)",
min = 0, max = 70, value = 10, post = "%"),
# Primer set Tm
sliderInput("inSlider15", "Optimal Primer Set Annealing Temperature (C) (the tool will try and find a primer set
that matches as closely as possible to this temperature)",
min = 40, max = 70, value = 60, step = 0.1),
sliderInput("inSlider17", "Primer Set Annealing Temperature Range (C) (generated primer sets
must fall within this range of annealing temperatures)",
min = 40, max = 70, value = c(55, 65), step = 0.1),
sliderInput("inSlider29", "Max Annealing Temperature Difference (C) between FP and RP
(ideally should be within 0-3 degrees difference)",
min = 0, max = 10, value = 3, step = 0.1),
sliderInput("inSlider26", "Min Increase in Probe Annealing Temperature (C)
(ideally should be 7-10 degrees higher than primer set)",
min = 1, max = 20, value = 7, step = 0.1),
tags$hr(),
actionButton('back2', "Back", icon("angle-double-left"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
actionButton('reset2a', "Reset to Default", icon("undo"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
actionButton('advSettings', "Go to Secondary Constraints", icon("cogs"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
actionButton('run3a', "Design Primer and Probe Sets!", icon("angle-double-right"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4")
),
tabPanel("Secondary Constraints", id='panel3b', value="panel3b",
tags$hr(),
sliderInput("inSlider16", "Primer Length Range",
min = 18, max = 30, value = c(18, 23), step = 1, post = "bp"),
sliderInput("inSlider30", "Probe Length Range",
min = 20, max = 40, value = c(24, 28), step = 1, post = "bp"),
sliderInput("inSlider27", "Primer GC Percentage Range",
min = 30, max = 80, value = c(30, 70), step = 0.1, post = "%"),
sliderInput("inSlider28", "Probe GC Percentage Range",
min = 30, max = 80, value = c(30, 70), step = 0.1, post = "%"),
sliderTextInput("inSlider23", "Primer-Dimer Hybridization Efficiency
(less likely to form dimers < 1e-07 > more likely to form dimers.
Ideally you want this set as low as possible however setting it
lower will also limit the number of potential primer sets.)",
choices = c("1e-10", "1e-09", "1e-08", "1e-07", "1e-06", "1e-05", "1e-04"),
selected = c("1e-07")),
p("Long stretches of runs or repeats are generally unfavorable for your primers due to
mispriming. Run and repeat settings are set higher by default to allow for a greater
number of potential primer and probe sets but can be set lower if needed."),
sliderInput("inSlider20", "Max Run Length for Primers
(ex: AAA would be a run length of 3)",
min = 0, max = 10, value = 4, step = 1, post = "bp"),
sliderInput("inSlider21", "Max Repeat Length for Primers
(ex: CGCG would be a repeat length of 2)",
min = 0, max = 6, value = 3, step = 1, post = "bp"),
sliderInput("inSlider22", "Max Run Length for Probes
(ex: AAA would be a run length of 3)",
min = 0, max = 10, value = 5, step = 1, post = "bp"),
sliderInput("inSlider24", "Max Repeat Length for Probes
(ex: CGCG would be a repeat length of 2)",
min = 0, max = 6, value = 4, step = 1, post = "bp"),
tags$hr(),
actionButton('back3', "Back", icon("angle-double-left"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
actionButton('reset2b', "Reset to Default", icon("undo"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4")
))), width = 5),
mainPanel(div(),
width=7))),
tabPanel("4. Evaluate and Download Primer Sets", id='panel5', value="panel5",
sidebarLayout(
sidebarPanel(
p("Download primer and probe sets
in .csv"),
div(id="PrimerTableDownload",
downloadButton('downloadPrimers', 'Download')
), width = 2),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Potential Primer and Probe Sets", id='panelPrimerTable', value="panelPrimerTable",
tags$hr(),
p("Here the top 5 primer and probe sets will be shown and ranked according to
their target coverage (fraction of target sequences from the alignment that
are covered with the primers and probe). "),
tags$hr(),
div(rHandsontableOutput('primerTable')),
tags$hr(),
p("Not sure what a parameter means? Go to the help menu:"),
actionButton('help', "Help Menu", icon("angle-double-right"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4")
),
tabPanel("Primer Binding Visualization", id='panelPrimerBind', value="panelPrimerBind",
tags$hr(),
p("Select one of the primer sets from the dropdown menu and a primer binding visualization
will be generated based on your target species. Identical base positions are marked by dots
and mismatched bases will be highlighted to show differences between target and non-target
at regions where the primers and probe bind. All target species sequences will be sorted to
the top of the alignment."),
tags$hr(),
selectInput("inSelectPrimer", "Choose a Primer and Probe Set to Visualize",
choices = c("Waiting for Primer Sets")),
actionButton('run4a', "Generate Visualization", icon("angle-double-right"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
tags$hr(),
htmlOutput("inc2")),
tabPanel("Primer Set Comparison (Bar Plot)", id='panelPrimerGraphs', value="panelPrimerGraphs",
tags$hr(),
p("Here you can visualize in a bar plot the differences between each primer and probe
set based on many different parameters selectable from the dropdown menu shown below."),
tags$hr(),
selectInput("inSelectPrimer2", "Choose a Parameter to Compare across Sets",
choices = c("Waiting for Primer Sets")),
tags$hr(),
plotOutput('plot')),
tabPanel("Primer Set Comparison (Heat Map)", id='panelPrimerGraphs', value="panelPrimerGraphs",
tags$hr(),
p("Here you can visualize in a heat map the differences between each primer and probe
set based on their individual parameters. Max and min parameters set during the
primer design process are also presented for comparison"),
tags$hr(),
actionButton('heatmap', "Generate Heat Map", icon("angle-double-right"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
tags$hr(),
d3heatmapOutput("heatmap")),
tabPanel("Dimerization Check", id='panelPrimerDimer', value="panelPrimerDimer",
tags$hr(),
p("To check for possible dimerization, it is recommended that you head over to this website:"),
a(href="http://www.primer-dimer.com/", "PrimerDimer", target="_blank"),
tags$hr(),
p("You can simply copy the text output shown below for the generated primer sets, paste them into this tool using
the link provided above and the tool will find the most likely candidates for dimerization amongst the
generated primer sets. Select the multiplex analysis option. Look for dimer products less than -9 kcal/mol as these
are the most problematic. Cross-dimerization products between primer and probe sets can be ignored if multiple primer
sets are inputted at once."),
tags$hr(),
htmlOutput("primertext"),
tags$hr(),
p("PrimerDimer is a web-based, condition-independent primer dimerization tool and has been shown to
outperform other software tools in the accuracy of its dimerization predictions:"),
p("Lu, J et al. (2017) PrimerSuite: A High-Throughput Web-Based Primer Design Program for Multiplex Bisulfite PCR.
Sci. Rep.7, 41328; doi: 10.1038/srep41328."))
)))),
tabPanel("About", id='About', value="panel6",
sidebarLayout(
sidebarPanel(
# Chose Reaction Conditions for qPCR
div(id="about1",
p("ssPRIMER (or species-specific PRIMER) is a web-based software tool that can be used to
design species-specific primer sets and Taqman probes for qPCR assays. A multiple sequence alignment can
be imported in by a user, and the tool will then guide the user through the process of
designing and evaluating species-specific primer sets and Taqman probes.
The tool is designed to create primer sets that maximize amplification
efficiency for the target species (sensitivity) but minimize amplification efficiency
for non-target species (specificity). This tool is designed to benefit the users of eDNA
technology, including field biologists, ecologists, conservation researchers, and
environmental consultants and could contribute to environmental biomonitoring using
molecular methods."),
tags$hr(),
p("Author of tool: Matthew G. Orton, [email protected]"),
p("With contributions from Dr. Sally J. Adamowicz, Kamil Chatila-Amos, Alexandra Albin and Samantha Majoros."),
p("If you have any feedback to give on the tool, please contact me at my email above."),
p("You can also view the source code here:"),
a(href="https://github.com/m-orton/ssPRIMER", "ssPRIMER source code", target="_blank"),
tags$hr(),
p("Issues with the tool? You can also report bugs here:"),
a(href="https://github.com/m-orton/ssPRIMER/issues", "Report a bug", target="_blank"),
tags$hr(),
p("ssPRIMER is licensed under the GNU General Public License v3.0:"),
a(href="https://github.com/m-orton/ssPRIMER/blob/master/LICENSE", "GPLv3.0 License for ssPRIMER", target="_blank"),
tags$hr(),
p("This tool relies greatly on the DECIPHER, Biostrings and TmCalculator R packages and OligoArrayAux
software for design of primer sets:"),
a(href="https://bioconductor.org/packages/release/bioc/html/DECIPHER.html", "DECIPHER, ", target="_blank"),
a(href="http://bioconductor.org/packages/release/bioc/html/Biostrings.html", "Biostrings, ", target="_blank"),
a(href="https://cran.r-project.org/web/packages/TmCalculator/index.html", "TmCalculator, ", target="_blank"),
a(href="http://unafold.rna.albany.edu/?q=DINAMelt/OligoArrayAux", "OligoArrayAux", target="_blank"),
tags$hr(),
p("Citation for DECIPHER:"),
p("Wright, ES (2016) Using DECIPHER v2.0 to Analyze Big Biological Sequence Data in R. The R Journal, 8(1), 352-359."),
tags$hr(),
p("Citation for Biostrings:"),
p("Pagès H, Aboyoun P, Gentleman R, DebRoy S (2019) Biostrings: Efficient manipulation of biological strings.
R package version 2.52.0."),
tags$hr(),
p("Citations for OligoArrayAux:"),
p("Markham, NR & Zuker, M (2005) DINAMelt web server for nucleic acid melting prediction.
Nucleic Acids Res., 33, W577-W581."),
p("Markham, NR & Zuker, M (2008) UNAFold: software for nucleic acid folding and hybridization.
In Keith, J. M., editor, Bioinformatics, Volume II. Structure, Function and Applications,
number 453 in Methods in Molecular Biology, chapter 1, pages 3–31. Humana Press,
Totowa, NJ. ISBN 978-1-60327-428-9."),
tags$hr(),
p("Citation for PrimerDimer:"),
p("Lu, J et al. (2017) PrimerSuite: A High-Throughput Web-Based Primer Design Program for Multiplex Bisulfite PCR.
Sci. Rep.7, 41328; doi: 10.1038/srep41328."),
tags$hr(),
p("Links for other packages used:"),
a(href="https://cran.r-project.org/web/packages/shiny/index.html", "shiny, ", target="_blank"),
a(href="https://github.com/rstudio/d3heatmap", "d3HeatMap, ", target="_blank"),
a(href="https://github.com/jrowen/rhandsontable", "rhandsontable, ", target="_blank"),
a(href="https://github.com/daattali/shinyjs", "shinyjs, ", target="_blank"),
a(href="https://github.com/daattali/shinyalert", "shinyalert, ", target="_blank"),
a(href="https://github.com/dreamRs/shinyWidgets", "shinyWidgets, ", target="_blank"),
a(href="https://cran.r-project.org/web/packages/foreach/index.html", "foreach, ", target="_blank")
), width = 5),
mainPanel(div(),
width=6))),
tabPanel("Help", id='Help', value="panel7",
sidebarLayout(
sidebarPanel(
# Gives definitions of each parameter to help users
div(id="help1",
p(strong("setID:")),
p("A numerical identifier assigned for each generated primer and probe set."),
tags$hr(),
p(strong("identifier:")),
p("The target species/OTU that was selected on the initial webpage."),
tags$hr(),
p(strong("targetCoverage:")),
p("Represented as a % value, this is an average of the target coverages of the forward primer, reverse primer and probe.
Target coverage is the fraction of target sequences (either belonging to the same target species or target OTU) from
the alignment that the primers and probe will recognize. Generated primer and probe sets by default are sorted according to
this value."),
tags$hr(),
p(strong("ampliconLength:")),
p("The length in bp of the amplicon generated from the primer set."),
tags$hr(),
p(strong("forward_primer, reverse_primer, probe_seq:")),
p("The sequence in 5' to 3' for either the forward primer, reverse primer or probe."),
tags$hr(),
p(strong("lengthFP, lengthRP, length_probe:")),
p("Length in bp for either the forward primer, reverse primer or probe."),
tags$hr(),
p(strong("gcFP, gcRP, gcProbe:")),
p("% gc content for either the forward primer, reverse primer or probe."),
tags$hr(),
p(strong("Hybridization Efficiency (forward, reverse and average):")),
p("Represented as % values, these values represent the predicted fraction of target amplicons that will be amplified every cycle of pcr.
This value is presented individually for both forward and reverse primers and as an average. Non-target hybridization efficiency as
seen in the primary constraints tab represents the same concept but for non-target amplicons. Non-target efficiency represents the level of
specificity (as higher non-target efficiency would indicate lower specificity) of the assay whearas target efficiency represents the level
of sensitivity of the assay. On the secondary constaints tab there is also a setting for primer-dimer hybridization efficiency which would
represent the predicted fraction of primers (either forward or reverse) that will anneal to each other each cycle of pcr
(which should be minimized as much as possible)."),
tags$hr(),
p(strong("annealAverage:")),
p("Represented in degrees C and averaged between forward and reverse primers, this value represents the predicted annealing temperature
at which both the forward and reverse primers should anneal optimally to the target amplicon."),
tags$hr(),
p(strong("annealDiffprimer:")),
p("Represented in degrees C, the absolute difference in temperature between the forward and reverse primers."),
tags$hr(),
p(strong("annealProbe:")),
p("Represented in degrees C, the predicted annealing temperature at which the probe should anneal optimally to the target amplicon."),
tags$hr(),
p(strong("annealDiffProbe:")),
p("Represented in degrees C, the increase in annealing temperature of the probe subtracted from the annealing average of the primers."),
tags$hr(),
p(strong("startPosFP, endPosFP, etc. :")),
p("Start and end positions in the alignment for the primers and probe."),
tags$hr(),
p(strong("ampliconSeq:")),
p("The amplicon sequence generated from the first target sequence of the alignment for each generated primer and probe set.
This can be useful if for instance a gBlock needs to be synthesized for standard curve experiments"),
tags$hr(),
actionButton('back4', "Back to Homepage", icon("angle-double-left"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4"),
actionButton('back5', "Back to Primer Results", icon("angle-double-left"),
style="color: #fff; background-color: #337ab7; border-color: #2e6da4")
), width = 5),
mainPanel(div(),
width=6)))
)
)
server <- function(input, output, session){
# Setting conditional tabs so will only appear with click of an action button
observe({
toggle(condition = input$run1, selector = "#mainPage li a[data-value=panel2]")
})
observe({
toggle(condition = input$run2, selector = "#mainPage li a[data-value=panel3]")
})
observe({
toggle(condition = input$run3a, selector = "#mainPage li a[data-value=panel5]")
})
# Hide alignment settings
shinyjs::onclick("toggleAlignSettings",
shinyjs::toggle(id = "alignSettings", anim = TRUE))
reactUpload <- reactiveValues(upload=NULL, upload2=NULL, alignment=NULL)
observeEvent(input$exampleAlign, {
reactUpload$upload <- exampleAlignment
})
# Reactive variable for alignment upload
contentsrea <- reactive({
reactUpload$upload2 <- input$alignmentFile
if (is.null(reactUpload$upload2) && is.null(reactUpload$upload)){
return(NULL)
}
if (is.null(reactUpload$upload)){
reactUpload$alignment <- readDNAStringSet(reactUpload$upload2$datapath)
}
if (is.null(reactUpload$upload2)){
reactUpload$alignment <- reactUpload$upload
}
splitNames <- as.character(unlist(lapply(strsplit((names(reactUpload$alignment)), "[*]", fixed=TRUE), function(x) return(x[1]))))
})
# Reactive variable for alignment length
contentsrea2 <- reactive({
dnaLength <- as.numeric(nchar(reactUpload$alignment[[1]]))
})
# qPCR Reaction Pre-sets selectable in the UI
observeEvent(input$inSelect2, {
if(input$inSelect2 == 'Chai Master Mix (Hot Start 2x)'){
updateSliderInput(session, "inSlider2", value = 6)
updateSliderInput(session, "inSlider3", value = 100)
updateSliderInput(session, "inSlider4", value = 0)
updateSliderInput(session, "inSlider5", value = 0.6)
updateSliderInput(session, "inSlider6", value = 200)
}
if(input$inSelect2 == 'Default IDT qPCR Conditions'){
updateSliderInput(session, "inSlider2", value = 3)
updateSliderInput(session, "inSlider3", value = 0)
updateSliderInput(session, "inSlider4", value = 50)
updateSliderInput(session, "inSlider5", value = 0.8)
updateSliderInput(session, "inSlider6", value = 200)
}
})
reactSlider1 <- reactiveValues(sliderInput1=NULL, sliderInput2=NULL, sliderInput3=NULL, sliderInput4=NULL)
# Observe slider for target range of alignment
observeEvent(input$inSlider1, {
reactSlider1$sliderInput1 <- as.numeric(input$inSlider1[2]-input$inSlider1[1])
reactSlider1$sliderInput2 <- input$inSlider1[1]
reactSlider1$sliderInput3 <- input$inSlider1[2]
})
# Variable for display of alignment - width adjustment
observeEvent(input$inSliderWidth, {
reactSlider1$sliderInput4 <- input$inSliderWidth
})
# Generation of the alignment visualization from the uploaded alignment
contentsrea3 <- reactive({
if (is.null(reactUpload$alignment)){
return(NULL)
} else {
alignment <- subseq(reactUpload$alignment, reactSlider1$sliderInput2, reactSlider1$sliderInput3)
BrowseSeqs(alignment, htmlFile = paste(tempdir(), "/myAlignment.html", sep = ""), openURL = FALSE,
patterns=c("-", "A", "C", "G", "T"),
colors=c("#999999", "#E69F00", "#56B4E9", "#009E73", "#0072B2"), colWidth=reactSlider1$sliderInput4)
}
})
# Display html file for alignment visualization
getPage<-function() {
return(includeHTML( file (contentsrea3() )))
}
output$inc<-renderUI({
if (is.null(reactUpload$alignment)){
return(NULL)
} else {
getPage()
}
})
# Only show a portion of the UI before upload and then reveal after alignment uplaod
output$fileUploaded <- reactive({
return(!is.null(contentsrea()))
})
outputOptions(output, 'fileUploaded', suspendWhenHidden=FALSE)
# Update sliders based on alignment properties
observe({
updateSelectInput(session, "inSelectTarget", choices = contentsrea())
updateSliderInput(session, "inSlider1", value = c(1, contentsrea2()), max = contentsrea2())
})
reactTarget <- reactiveValues(target=NULL)
# Calculation of amplicon length range slider based on target range amplification region
output$slider9 <- renderUI({
if(reactSlider1$sliderInput1 < 75){
sliderInput("inSlider9", "Amplicon Length Range", min = (reactSlider1$sliderInput1-10),
max = reactSlider1$sliderInput1, value = c((reactSlider1$sliderInput1-5), reactSlider1$sliderInput1), post="bp")
} else {
sliderInput("inSlider9", "Amplicon Length Range", min = 75, max = reactSlider1$sliderInput1, value = c(75, 150), post="bp")
}
})
observeEvent(input$inSlider9, {
if(as.numeric(input$inSlider9[2]-input$inSlider9[1]) < 75){
shinyalert("Oh no!", "It seems your maximum amplicon length is shorter than 75 bp. You may have difficulty finding primer sets with such a short amplicon length.", type = "warning")
}
})
# Observe which target is selected
observeEvent(input$inSelectTarget, {
reactTarget$target <- as.character(input$inSelectTarget)
})
# Primer design Variables
primerVar <- reactiveValues(startPos=NULL, endPos=NULL, minLength=NULL, maxLength=NULL, primer=NULL,
probe=NULL, mono=NULL, div=NULL, dNTP=NULL, annealTempProbe=NULL, minProductSize=NULL,
maxProductSIze=NULL, annealTempPrimer=NULL, minEfficiency=NULL, numPrimerSets=NULL,
minCoverage=NULL, numPrimerSets=NULL, primerPosStart=NULL, primerPosEnd=NULL, gcPrimerMin=NULL,
gcPrimerMax=NULL, gcProbeMin=NULL, gcProbeMax=NULL, annealDiffPrimerMin=NULL, annealDiffPrimerMax=NULL,
probeMinLength=NULL, probeMaxLength=NULL, annealTempProbe=NULL, monovalentNa=NULL, monovalentK=NULL,
divalentMg=NULL, primerConc=NULL, dNTP=NULL, dimers=NULL, maxNonTarget=NULL, setID=NULL, startPosFP=NULL,
endPosFP=NULL, startPosProbe=NULL, endPosProbe=NULL, startPosRP=NULL, endPosRP=NULL, chosenSetId=NULL,
repeatL=NULL, runL=NULL, repeatLP=NULL, runLP=NULL, polymerase=NULL, annealRangeMin=NULL, annealRangeMax=NULL)
# Observe primer design choices selected by user
observeEvent(input$inSelectPolymerase, {
if(input$inSelectPolymerase == 'Taq polymerase'){
primerVar$polymerase <- TRUE
}
if(input$inSelectPolymerase == 'High-fidelity polymerase'){
primerVar$polymerase <- FALSE
}
})
observeEvent(input$inSlider1[1], {
primerVar$startPos <- as.numeric(input$inSlider1[1])
})
observeEvent(input$inSlider1[2], {
primerVar$endPos <- as.numeric(input$inSlider1[2])
})
observeEvent(input$inSlider2, {
primerVar$divalentMg <- as.numeric(input$inSlider2)
})
observeEvent(input$inSlider3, {
primerVar$monovalentK <- as.numeric(input$inSlider3)
})
observeEvent(input$inSlider4, {
primerVar$monovalentNa <- as.numeric(input$inSlider4)
})
observeEvent(input$inSlider5, {
primerVar$dNTP <- as.numeric(input$inSlider5)
})
observeEvent(input$inSlider6, {
primerVar$primerConc <- as.numeric(input$inSlider6)
})
observeEvent(input$inSlider9[1], {
primerVar$minProductSize <- as.numeric(input$inSlider9[1])
})
observeEvent(input$inSlider9[2], {
primerVar$maxProductSize <- as.numeric(input$inSlider9[2])
})
observeEvent(input$inSlider12, {
primerVar$minCoverage <- as.numeric(input$inSlider12) / 100
})
observeEvent(input$inSlider13, {
primerVar$minEfficiency <- as.numeric(input$inSlider13) / 100
})
observeEvent(input$inSlider14, {
primerVar$maxNonTarget <- as.numeric(input$inSlider14)
})
observeEvent(input$inSlider15, {
if(as.numeric(input$inSlider15) < as.numeric(input$inSlider17[1]) | as.numeric(input$inSlider15) > as.numeric(input$inSlider17[2])){
shinyalert("Oh no!", "Please ensure your optimal annealing temperature falls within the annealing temperature range you have set.", type = "warning")
}
primerVar$annealTempPrimer <- as.numeric(input$inSlider15)
})
observeEvent(input$inSlider16[1], {
primerVar$minLength <- as.numeric(input$inSlider16[1])
})
observeEvent(input$inSlider16[2], {
primerVar$maxLength <- as.numeric(input$inSlider16[2])
})
observeEvent(input$inSlider17[1], {
primerVar$annealRangeMin <- as.numeric(input$inSlider17[1])
})
observeEvent(input$inSlider17[2], {
primerVar$annealRangeMax <- as.numeric(input$inSlider17[2])
})
observeEvent(input$inSlider20, {
primerVar$runL <- as.numeric(input$inSlider20) + 1
})
observeEvent(input$inSlider21, {
primerVar$repeatL <- as.numeric(input$inSlider21) + 1
})
observeEvent(input$inSlider22, {
primerVar$runLP <- as.numeric(input$inSlider22) + 1
})
observeEvent(input$inSlider23, {
primerVar$dimers <- as.numeric(input$inSlider23)
})
observeEvent(input$inSlider24, {
primerVar$repeatLP <- as.numeric(input$inSlider24) + 1
})
observeEvent(input$inSlider26, {
primerVar$annealTempProbe <- as.numeric(input$inSlider26)
})
observeEvent(input$inSlider27[1], {
primerVar$gcPrimerMin <- as.numeric(input$inSlider27[1]) / 100
})
observeEvent(input$inSlider27[2], {
primerVar$gcPrimerMax <- as.numeric(input$inSlider27[2]) / 100
})
observeEvent(input$inSlider28[1], {
primerVar$gcProbeMin <- as.numeric(input$inSlider28[1]) / 100
})
observeEvent(input$inSlider28[2], {
primerVar$gcProbeMax <- as.numeric(input$inSlider28[2]) / 100
})
observeEvent(input$inSlider29, {
primerVar$annealDiffPrimerMax <- as.numeric(input$inSlider29)
})
observeEvent(input$inSlider30[1], {
primerVar$probeMinLength <- as.numeric(input$inSlider30[1]) - 1
})
observeEvent(input$inSlider30[2], {
primerVar$probeMaxLength <- as.numeric(input$inSlider30[2]) + 1
})
observeEvent(input$inSlider31, {
primerVar$minGCoverage <- as.numeric(input$inSlider31) / 100
})
# Vars for table, visualizations and graphing outputs
dfPrimers <- reactiveValues(primerTab=NULL, primerBindTab=NULL, primerBindTab2=NULL, primerGraphTab=NULL)
# Tab navigation
observeEvent(input$run1, {
updateNavbarPage(session, "mainPage", selected = 'panel2')
})
observeEvent(input$run2, {
updateNavbarPage(session, "mainPage", selected = 'panel3')
})
observeEvent(input$run3a, {
updateNavbarPage(session, "mainPage", selected = 'panel5')
})
observeEvent(input$advSettings, {
updateTabsetPanel(session, "panels", selected = 'panel3b')
})
observeEvent(input$back1, {
updateTabsetPanel(session, "mainPage", selected = 'panel1')
})
observeEvent(input$back2, {
updateTabsetPanel(session, "mainPage", selected = 'panel2')
})
observeEvent(input$back3, {
updateTabsetPanel(session, "panels", selected = 'panel3a')
})
observeEvent(input$help, {
updateTabsetPanel(session, "mainPage", selected = 'panel7')
})
observeEvent(input$back4, {
updateTabsetPanel(session, "mainPage", selected = 'panel1')
})
observeEvent(input$back5, {
updateTabsetPanel(session, "mainPage", selected = 'panel5')
})
# Generating primer and probe sets
observeEvent(input$run3a, {
withProgress(message = "Starting Design Process...", value = 0, {
dbConn <- dbConnect(SQLite(), ":memory:")
Seqs2DB(reactUpload$alignment, "XStringSet", dbConn, "userAlignment")
desc <- dbGetQuery(dbConn, "select description from Seqs")
desc <- unlist(lapply(strsplit(desc$description, "userAlignment", fixed=TRUE),
function(x) return(x[length(x)])))
Add2DB(data.frame(identifier=desc), dbConn)
incProgress(0.1, detail = "Organizing sequences into tiles...")
tiles <- TileSeqs(dbConn)
incProgress(0.1, detail = "Starting design of primers...")
# Generate Initial Primer and Probe Sets that will then be filtered by GC content further down
primers <- try(DesignPrimers(tiles, identifier=reactTarget$target, start=primerVar$startPos, end=primerVar$endPos,
minLength=primerVar$minLength, maxLength=primerVar$maxLength, minCoverage=primerVar$minCoverage,
minGroupCoverage=primerVar$minGCoverage, annealingTemp=primerVar$annealTempPrimer,
P=(primerVar$primerConc/1000000000), monovalent=((primerVar$monovalentNa+primerVar$monovalentK)/1000),
divalent=(primerVar$divalentMg/1000), dNTPs=(primerVar$dNTP/1000), minEfficiency=primerVar$minEfficiency,
numPrimerSets=50, minProductSize=primerVar$minProductSize, maxProductSize=primerVar$maxProductSize,
primerDimer=primerVar$dimers, taqEfficiency=primerVar$polymerase), silent = TRUE)
if(dim(primers)[1] == 0){
# Error for initial design of the primer sets
shinyalert("Oh no!", "Sorry no primer sets met your specified constraints. Please check the following constraints: amplicon length,
target amplification region, qPCR reaction settings, min and max primer length, primer-dimer hybridization efficiency,
min target and min group coverage, min target hybridization efficiency and primer annealing temperature.
The most probable causes are either your target hybridization efficiency value is set too high or your min target
coverage value is set too high.", type = "error")
updateNavbarPage(session, "mainPage", selected = 'panel3')
} else {
incProgress(0.2, detail = "Filtering primer sets based on settings...")