-
Notifications
You must be signed in to change notification settings - Fork 95
/
shiny.R
2106 lines (1939 loc) · 82 KB
/
shiny.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
#
# sleuth: inspect your RNA-Seq with a pack of kallistos
#
# Copyright (C) 2015 Harold Pimentel, Nicolas Bray, Pall Melsted, Lior Pachter
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#' Interactive sleuth visualization with Shiny
#'
#' Interactive sleuth visualization with Shiny. To exit, type \code{ESC} in R.
#'
#' @param obj a \code{sleuth} object already processed and has run
#' \code{\link{sleuth_fit}} and \code{\link{sleuth_wt}} or \code{\link{sleuth_lrt}}
#' @param settings see the function \code{\link{sleuth_live_settings}} for options
#' @param options additional options which are sent to shiny
#' @param ... additional parameters sent to plotting functions
#' @return a \code{\link{shinyApp}} result
#' @export
#' @seealso \code{\link{sleuth_fit}}, \code{\link{sleuth_live_settings}}, \code{\link{sleuth_deploy}}
sleuth_live <- function(obj, settings = sleuth_live_settings(),
options = list(port = 42427), ...) {
stopifnot( is(obj, 'sleuth') )
if ( !require('shiny') ) {
stop("'sleuth_live()' requires 'shiny'. Please install it using
install.packages('shiny')")
}
group_by_choices <- setdiff(names(obj$target_mapping), "target_id")
if (obj$gene_mode) {
counts_unit <- "scaled_reads_per_base"
index <- which(group_by_choices == obj$gene_column)
group_by_choices <- c(group_by_choices[index], group_by_choices[-index])
gene_mode_choice <- "true"
} else {
counts_unit <- "est_counts"
gene_mode_choice <- "false"
}
# set up for the different types of tests
poss_covars <- dplyr::setdiff(
colnames(obj$sample_to_covariates),
'sample')
samp_names <- obj$sample_to_covariates[['sample']]
poss_models <- names(models(obj, verbose = FALSE))
poss_wt <- list_tests(obj, 'wt')
poss_lrt <- list_tests(obj, 'lrt')
valid_test_types <- if (!is.null(poss_wt)) {
c('Wald' = 'wt')
} else {
c()
}
if (!is.null(poss_lrt)) {
valid_test_types <- c(valid_test_types, c('likelihood ratio' = 'lrt'))
}
# if (length(valid_test_types) == 0) {
# stop("We found no valid tests. Please add some tests and rerun sleuth_live()")
# }
p_layout <- navbarPage(
a('sleuth', href = 'http://pachterlab.github.io/sleuth', target = '_blank',
style = 'color: black;'),
windowTitle = 'sleuth',
tabPanel('overview',
fluidRow(
div(h3('sleuth live'), align = 'center')
),
fluidRow(
column(10, offset = 1,
p('This Shiny app is designed for exploratory data analysis of
kallisto-sleuth processed RNA-Seq data. There are four menu tabs
that can be used to choose plots and tables to view.'),
p(strong('sleuth live features:')),
tags$ul(
tags$li(strong('v0.29.0'),
':',
'Integration of gene mode, and enhancements to heat maps',
'by Warren McGee.'
),
tags$li(strong('v0.28.0'),
':',
'Download buttons for plots and tables by Alex Tseng.',
'PCA variance explained and loadings by Daniel Li.',
'Fragment length distribution plot, bias table,',
'and integration of likelihood ratio test by Harold Pimentel.'
),
tags$li(strong('v0.27.3'),
':',
'Gene table, gene viewer, transcript heatmap,',
'and volcano plot by Pascal Sturmfels.'
),
tags$li(strong('v0.27.2'),
':',
'Design matrix, kallisto table, transcript view,',
'and QQplot by Harold Pimentel.'
),
tags$li(strong('v0.27.1'),
':',
'Densities, MA plot, mean-variance plot, PCA,',
'processed data, sample heatmap, scatter plots,',
'and test table by Harold Pimentel.')
)
))),
navbarMenu('analyses',
tabPanel('gene view',
conditionalPanel(
condition = 'input.settings_gene_mode == "true"',
fluidRow(
column(12,
p(
h3('gene view'),
'Boxplots of gene abundances showing technical variation in each sample.')
),
offset = 1),
fluidRow(
column(3,
textInput('bsg_var_input',
label = HTML('gene: ',
'<button onclick="bsg_var_input()">?</button>',
'<script> function bsg_var_input() {',
'alert("Enter the target_id of a gene here to view a boxplot of its technical variation.',
'You can find target_ids in the test table under Analyses.',
'If you select a different column from "genes from",',
'enter a gene identifier that matches that column.',
'The most significant gene by q-value for the first test within the currently selected test type is already entered.");',
'} </script>'),
value = textOutput("default_top_hit"))
),
column(3,
selectInput('bsg_var_color_by',
label = HTML('color by: ',
'<button onclick="bsg_var_color_by()">?</button>',
'<script> function bsg_var_color_by() {',
'alert("Color the box plots by different column names from your design file.',
'Doing so can help explain which traits of a given gene best explain the',
'difference across samples.");',
'} </script>'),
choices = c(NULL, poss_covars), selected = NULL)
),
column(3,
selectInput('bsg_var_units',
label = HTML('units: ',
'<button onclick="bsg_var_units()">?</button>',
'<script> function bsg_var_units() {',
'alert("tpm: Transcripts Per Million\\n',
'scaled_reads_per_base: The average number of reads mapping to each base across the whole gene\\n',
'\\nFor a better understanding of the units, see https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/");',
'} </script>'),
choices = (if (length(obj$bs_quants) == 0) { c('N/A') }
else { names(obj$bs_quants[[1]]) } ),
selected = (if (length(obj$bs_quants) == 0) { 'N/A' }
else { names(obj$bs_quants[[1]])[1] })
)),
column(3,
selectInput('bsg_gene_colname',
label = HTML('genes from: ',
'<button onclick="bsg_gene_colname()">?</button>',
'<script> function bsg_gene_colname() {',
'alert("Choose a column name from your target mapping data frame.',
'This allows you to use alternative gene identifiers (e.g. HGNC symbol)',
'to select a gene instead of the target ID.',
'The column you used to aggregate at the gene level is the default");',
'} </script>'),
choices = group_by_choices)
)
),
fluidRow(HTML(' '), actionButton('bsg_go', 'view')),
fluidRow(plot <- (if (length(obj$bs_quants) == 0) {
HTML('     You need to run sleuth with at least ',
'one of extra_bootstrap_summary or ',
'read_bootstrap_tpm to use this feature.<br>') }
else { plotOutput('bsg_var_plt') }
)),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom:10px",
downloadButton("download_bsg_var_plt", "Download Plot"))
)
),
conditionalPanel(
condition = 'input.settings_gene_mode == "false"',
fluidRow(
column(12,
p(h3('gene view'),
'Boxplots of abundances of transcripts mapping to a given gene,',
'and their technical variation.',
'This step can take a while, especially with many plots.')
),
offset = 1),
fluidRow(column(3,
textInput('gv_var_input',
label = HTML('gene: ',
'<button onclick="gv_var_input()">?</button>',
'<script> function gv_var_input() {',
'alert("Enter the gene identifier (determined by what is selected for \'genes from\')',
'here to view a boxplot of the technical variation of its top transcripts ranked by q-value.',
'The number is determined by \'# of plots\'.',
'You can find gene identifiers in the test table under Analyses.");',
'} </script>'), value = '')
),
column(3,
selectInput('gv_var_color_by',
label = HTML('color by: ',
'<button onclick="gv_var_color_by()">?</button>',
'<script> function gv_var_color_by() {',
'alert("Color the box plots by different column names from your design file.',
'Doing so can help explain which traits of a given transcript best explain the',
'difference in counts/TPMs of that transcript across samples.");',
'} </script>'),
choices = c(NULL, poss_covars),
selected = NULL)),
column(3,
selectInput('gv_var_units',
label = HTML('units: ',
'<button onclick="gv_var_units()">?</button>',
'<script> function gv_var_units() {',
'alert("tpm: Transcripts Per Million\\nest_counts (transcript mode only): Counts/Number of aligned reads\\n',
'\\nFor a better understanding of the units, see https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/");',
'} </script>'),
choices = c(counts_unit, 'tpm'),
selected = counts_unit)),
column(3,
uiOutput('gv_gene_column')
)
),
fluidRow(
column(3, actionButton('gv_go', 'view')),
column(3, numericInput('gv_maxplots', label = '# of plots (max 15): ', value = 3,
min = 1, max = 15, step = 1))
),
fluidRow(uiOutput('no_genes_message')),
fluidRow(plot <- (if (length(obj$bs_quants) == 0) {
HTML(paste('     You need to run sleuth with at ',
'least one of extra_bootstrap_summary or',
'read_bootstrap_tpm to use this feature.<br>'))
} else { uiOutput('gv_var_plts') }
))
)
),
####
tabPanel('heat map',
fluidRow(
column(12,
p(h3('heat map'),
HTML('Plot of select abundances in a clustered heat map using the',
'R <a target="_blank" href="https://stat.ethz.ch/R-manual/R-devel/library/stats/html/hclust.html">',
'hclust function</a>. The heat map iteratively groups together transcripts with',
'similar expression patterns, highlighting similarities among the transcripts themselves.',
'For a more in-depth discussion of hierarchical clustering, see',
'<a target="_blank" href="http://link.springer.com/article/10.1007/BF02289588">10.1007/BF02289588</a>.',
'</br>Enter space-separated values (The ten transcripts with the lowest q-values',
'are already entered. Click view to see them!).'))
),
offset = 1
),
fluidRow(
column(4,
textInput('hm_transcripts', label = HTML('enter target ids: ',
'<button onclick="hm_transcripts()">?</button>',
'<script> function hm_transcripts() {',
'alert("Enter a space-separated list of transcript names here to view a hierarchical clustering of those transcripts.",
"The ten most significant transcripts for the first test of the currently selected test type have been listed for you by default.");',
'} </script>'),
value = textOutput("default_top_ten"))
),
column(8, style = "margin-top:15px;",
checkboxGroupInput('hm_covars',
label = HTML('covariates:',
'<button onclick="hm_covars()">?</button>',
'<script> function hm_covars() {',
'alert("Add annotation information from different column names from your design file.',
'Doing so can help explain which traits of a given sample best explain the',
'clustering across samples.");',
'} </script>'),
choices = as.list(poss_covars), inline = TRUE)
)),
fluidRow(
column(3,
selectInput('hm_units', label = HTML('units: ',
'<button onclick="hm_units()">?</button>',
'<script> function hm_units() {',
'alert("tpm: Transcripts Per Million\\nest_counts (transcript mode only): Counts/Number of aligned reads\\n',
'scaled_reads_per_base (gene mode only): The average number of reads mapping to each base across the whole gene\\n',
'\\nFor a better understanding of the units, see https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/");',
'} </script>'),
choices = c(counts_unit, 'tpm'), selected = 'tpm')
),
column(2,
textInput('hm_trans', label = HTML('transform: ',
'<button onclick="hm_trans()">?</button>',
'<script> function hm_trans() {',
'alert("A transformation to be applied to the raw data before clustering.");',
'} </script>'), value = 'log')
),
column(2,
numericInput('hm_offset', label = HTML('offset: ',
'<button onclick="hm_offset()">?</button>',
'<script> function hm_offset() {',
'alert("A constant amount to be added to the raw data before the transformation and clustering.");',
'} </script>'), value = 1)),
column(2, style = "margin-top: 10px;",
checkboxInput('hm_cluster', label = HTML('cluster transcripts',
'<button onclick="hm_cluster()">?</button>',
'<script> function hm_trans() {',
'alert("Check this box to use hierarchical clustering on the selected transcripts.\\n',
'Note that hierarchical clustering of the samples is already turned on by default.");',
'} </script>'),
value = TRUE)),
column(1,
actionButton('hm_go', 'view')
)
),
tags$style(type = 'text/css', "#hm_go {margin-top: 25px}"),
fluidRow(plotOutput('hm_plot')),
fluidRow(uiOutput("download_hm_plt_button"))
),
####
tabPanel('MA plot',
fluidRow(
column(12,
p(h3('MA plot'),
'Plot of abundance versus fixed effect (e.g. fold change).',
'Select a set of transcripts to explore their variance across samples.')
),
offset = 1),
conditionalPanel(condition = 'input.settings_test_type == "wt"',
fluidRow(
column(2,
numericInput('max_fdr', label = 'max Fdr:', value = 0.10,
min = 0, max = 1, step = 0.01)),
column(4,
selectInput('which_model_ma', label = 'fit: ',
choices = poss_models,
selected = poss_models[1])
),
column(4,
uiOutput('which_beta_ctrl_ma')
),
column(2,
numericInput('ma_alpha', label = 'opacity:', value = 0.2,
min = 0, max = 1, step = 0.01))
),
fluidRow(plotOutput('ma', brush = 'ma_brush')),
fluidRow(
div(align = "right", style = "margin-right:15px",
downloadButton("download_ma_plt", "Download Plot"))),
fluidRow(plotOutput('vars')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom:10px",
downloadButton("download_ma_var_plt", "Download Plot"))),
fluidRow(dataTableOutput('ma_brush_out')),
fluidRow(uiOutput("download_ma_table_button"))
),
conditionalPanel(condition = 'input.settings_test_type == "lrt"',
strong(paste("Only supported for 'setting' Wald tests.",
"Go to the settings tab to change the 'test type' setting."))
)
),
####
tabPanel('test table',
conditionalPanel(condition = 'input.settings_test_type == "wt"',
fluidRow(column(12, p(h3('test table'),
HTML('Table of transcript names, gene names (if supplied),',
'sleuth parameter estimates, tests, and summary statistics.',
'<button onclick="tableType()">What do the column names mean?</button>',
'<script> function tableType() {',
'alert("Transcript Table Columns:\\n',
'target_id: Transcript name (dependent on transcriptome used in kallisto)\\n',
'pval: p-value of the transcript for the selected test\\n',
'qval: False discovery rate adjusted p-value, using Benjamini-Hochberg\\n',
'b: the "beta" value (effect size). Technically a biased estimator of the fold change\\n',
'se_b: the standard error of the beta\\n',
'mean_obs: Mean of natural log counts of observations\\n',
'var_obs: Variance of observation\\n',
'tech_var: Technical variance of observation from the bootstraps\\n',
'sigma_sq: Raw estimator of the variance once the technical variance has been removed\\n',
'sigma_sq_pmax: max(sigma_sq, 0)\\n',
'smooth_sigma_sq: Smooth regression fit for the shrinkage estimation\\n',
'final_simga_sq: max(sigma_sq, smooth_sigma_sq) – used for covariance estimation of beta\\n',
'");',
'} </script>'))
), offset = 1),
fluidRow(
column(3,
selectInput('which_model_de', label = 'fit: ',
choices = poss_models,
selected = poss_models[1])
),
column(3,
uiOutput('which_beta_ctrl_de')
),
column(3,
uiOutput('table_type')
),
column(3,
uiOutput('group_by')
)
),
dataTableOutput('de_dt'),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom:10px",
downloadButton("download_test_table", "Download Table")))
),
conditionalPanel(condition = 'input.settings_test_type == "lrt"',
fluidRow(column(12, p(h3('test table'),
HTML('Table of transcript names, gene names (if supplied),',
'sleuth parameter estimates, tests, and summary statistics.',
'<button onclick="tableType()">What do the column names mean?</button>',
'<script> function tableType() {',
'alert("Transcript Table Columns:\\n',
'target_id: Transcript name (dependent on transcriptome used in kallisto)\\n',
'pval: p-value of the transcript for the selected test\\n',
'qval: False discovery rate adjusted p-value, using Benjamini-Hochberg\\n',
'test_stat: Chi-squared test statistic (likelihood ratio test)\\n',
'rss: residual sum of squares under the null model\\n',
'degrees_free: the degrees of freedom for the test_that\\n',
'mean_obs: Mean of natural log counts of observations\\n',
'var_obs: Variance of observation\\n',
'tech_var: Technical variance of observation from the bootstraps\\n',
'sigma_sq: Raw estimator of the variance once the technical variance has been removed\\n',
'sigma_sq_pmax: max(sigma_sq, 0)\\n',
'smooth_sigma_sq: Smooth regression fit for the shrinkage estimation\\n',
'final_simga_sq: max(sigma_sq, smooth_sigma_sq) – used for covariance estimation of beta\\n',
'");',
'} </script>'))
), offset = 1),
fluidRow(
column(3,
uiOutput('test_control_de')
),
column(3,
uiOutput('table_type_lrt')
),
column(3,
uiOutput('group_by_lrt')
)
),
dataTableOutput('lrt_de_dt')
)
),
####
tabPanel('transcript view',
uiOutput('transcript_view')
),
####
tabPanel('volcano plot',
fluidRow(
column(12,
p(
h3('volcano plot'),
'Plot of beta value (regression) versus log of significance.',
'Select a set of transcripts to explore their variance across samples.'
)
),
offset = 1),
conditionalPanel(condition = 'input.settings_test_type == "wt"',
fluidRow(
column(2,
numericInput('max_fdr_vol', label = 'max Fdr:', value = 0.10,
min = 0, max = 1, step = 0.01)),
column(4,
selectInput('which_model_vol', label = 'fit: ',
choices = poss_models,
selected = poss_models[1])
),
column(4,
uiOutput('which_beta_ctrl_vol')
),
column(2,
numericInput('vol_alpha', label = 'opacity:', value = 0.2,
min = 0, max = 1, step = 0.01))
),
fluidRow(plotOutput('vol', brush = 'vol_brush')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom:10px",
downloadButton("download_volcano_plt", "Download Plot"))),
fluidRow(dataTableOutput('vol_brush_out')),
fluidRow(uiOutput("download_volcano_table_button"))
),
conditionalPanel(condition = 'input.settings_test_type == "lrt"',
strong('Only supported for "setting" Wald test.')
)
)
),
navbarMenu('maps',
####
tabPanel('PCA',
fluidRow(
column(12,
p(
h3('principal component analysis'),
'PCA projections of sample abundances onto any pair of components.',
' PCA is computed on the transcript expression.',
' Each sample is a vector with dimension equal to the number of transcripts.',
' See',
a(href="https://liorpachter.wordpress.com/2014/05/26/what-is-principal-component-analysis/",
target="_blank", 'this blog post'),
'for an overview of PCA.')
),
offset = 1),
fluidRow(
column(2,
selectInput('pc_x', label = 'x-axis PC: ', choices = 1:5,
selected = 1)
),
column(2,
selectInput('pc_y', label = 'y-axis PC: ', choices = 1:5,
selected = 2)
),
column(3,
selectInput('color_by',
label = HTML('color by: ',
'<button onclick="color_by()">?</button>',
'<script> function color_by() {',
'alert("Color the PCA plot by different column names from your design file.',
'Doing so can help explain which traits of a given sample best explain the',
'clustering of samples on the PCA plot.");',
'} </script>'),
choices = c(NULL, poss_covars), selected = NULL)
),
column(2,
numericInput('pca_point_size', label = 'size: ', value = 3)),
column(3,
selectInput('pca_units',
label = HTML('units: ',
'<button onclick="pca_units()">?</button>',
'<script> function pca_units() {',
'alert("tpm: Transcripts Per Million\\nest_counts (transcript mode only): Counts/Number of aligned reads\\n',
'scaled_reads_per_base (gene mode only): The average number of reads mapping to each base across the whole gene\\n',
'\\nFor a better understanding of the units, see https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/");',
'} </script>'),
choices = c(counts_unit, 'tpm'),
selected = counts_unit))
),
fluidRow(
column(2,
checkboxInput('pca_filt',
label = HTML('filter',
'<button onclick="pca_filt()">?</button>',
'<script> function pca_filt() {',
'alert("Check this box to use only those transripts that passed the filter for the PCA analysis.");',
'} </script>'),
value = TRUE)
),
column(2,
checkboxInput('text_labels', label = 'text labels',
value = TRUE)
)
),
fluidRow(plotOutput('pca_plt')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom:10px",
downloadButton("download_pca_plt", "Download Plot"))),
fluidRow(
column(12,
p(
h3('loadings'),
'observe contributions of samples or transcripts to the principal component')
),
offset = 1),
fluidRow(
column(3,
textInput('sample', label = 'transcript: ', value = '',
)
),
column(2,
selectInput('pc_input', label = 'principal component: ', choices = 1:5,
selected = 1)
),
column(3,
selectInput('pc_count', label = 'number of PCs or transcripts: ', choices = 1:10,
selected = 5)),
column(2,
checkboxInput('pca_loading_abs', label = 'absolute value',
value = TRUE)
),
column(2,
checkboxInput('scale', label = 'scale',
value = FALSE)
)
),
fluidRow(
column(12,
p(h3('variance explained'))
),
offset = 1),
fluidRow(plotOutput('plt_pc_var')),
fluidRow(
column(12,
p(h3('loadings'))
),
offset = 1),
fluidRow(plotOutput('plt_pc_loadings'))
),
###
tabPanel('sample heatmap',
fluidRow(
column(12,
p(h3('sample heatmap'),
a(href='https://en.wikipedia.org/wiki/Jensen%E2%80%93Shannon_divergence',
target='_blank', 'Jensen-Shannon divergence'),
'between pairs of samples computed at the transcript level.',
' The larger this value, the more dissimilar the samples are.')
),
offset = 1),
fluidRow(column(1, style = "margin-top: 15px;",
checkboxInput('samp_heat_filt',
label = HTML('filter',
'<button onclick="samp_heat_filt()">?</button>',
'<script> function samp_heat_filt() {',
'alert("Check this box to use only those transripts that passed the filter before clustering.");',
'} </script>'),
value = TRUE)),
column(2, style = "margin-top: 15px;",
checkboxInput('samp_heat_cluster',
label = HTML('cluster samples',
'<button onclick="samp_heat_cluster()">?</button>',
'<script> function samp_heat_cluster() {',
'alert("Check this box to use hierarchical clustering on the samples.");',
'} </script>'), value = TRUE)
),
column(9,
checkboxGroupInput('samp_heat_covars',
label = HTML('covariates:',
'<button onclick="samp_heat_covars()">?</button>',
'<script> function samp_heat_covars() {',
'alert("Add annotation information from different column names from your design file.',
'Doing so can help explain which traits of a given sample best explain the',
'clustering across samples.");',
'} </script>'),
choices = as.list(poss_covars), inline = TRUE)
)),
fluidRow(plotOutput('samp_heat_plt')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom:10px",
downloadButton("download_samp_heat_plt", "Download Map")))
)
),
navbarMenu('summaries',
####
tabPanel('densities',
fluidRow(
column(12,
p(
h3('distribution of abundances'),
'Distributions of abundances of individual samples or groupings by covariates.'
)
),
offset = 1),
fluidRow(
column(4,
selectInput('cond_dens_grp', 'grouping: ',
choices = poss_covars,
selected = poss_covars[1])
),
column(2,
selectInput('cond_dens_units',
label = HTML('units: ',
'<button onclick="cond_dens_units()">?</button>',
'<script> function cond_dens_units() {',
'alert("tpm: Transcripts Per Million\\nest_counts (transcript mode only): Counts/Number of aligned reads\\n',
'scaled_reads_per_base (gene mode only): The average number of reads mapping to each base across the whole gene\\n',
'\\nFor a better understanding of the units, see https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/");',
'} </script>'),
choices = c('tpm', counts_unit),
selected = 'tpm')),
column(2,
checkboxInput('cond_dens_filt',
label = HTML('filter',
'<button onclick="cond_dens_filt()">?</button>',
'<script> function cond_dens_filt() {',
'alert("Check this box to use only those transripts',
'that passed the filter before plotting.");',
'} </script>'),
value = TRUE)),
column(2,
textInput('cond_dens_trans',
label = HTML('transform: ',
'<button onclick="cond_dens_trans()">?</button>',
'<script> function cond_dens_trans() {',
'alert("A transformation to be applied to the raw data before plotting.");',
'} </script>'),
value = 'log')),
column(2,
numericInput('cond_dens_offset',
label = HTML('offset: ',
'<button onclick="cond_dens_offset()">?</button>',
'<script> function cond_dens_offset() {',
'alert("A constant amount to be added to the raw data before the transformation and clustering.");',
'} </script>'),
value = 1))
),
fluidRow(plotOutput('condition_density')),
fluidRow(
div(align = "right", style = "margin-right:15px",
downloadButton("download_cond_dens_plt", "Download Plot"))),
fluidRow(
column(4,
selectInput('samp_dens', 'sample: ',
choices = samp_names,
selected = samp_names[1]))),
fluidRow(plotOutput('sample_density')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom: 10px",
downloadButton("download_samp_dens_plt", "Download Plot")))
),
###
tabPanel('design matrix',
fluidRow(
column(12,
p(h3('design matrix'), "View the design matrix used to fit each model.")
),
offset = 1),
fluidRow(
column(4,
selectInput('which_model_design', label = 'fit: ',
choices = poss_models,
selected = poss_models[1])
)
),
fluidRow(
verbatimTextOutput('design_matrix')
#tableOutput('design_matrix')
)
),
####
tabPanel('fragment length distribution',
fluidRow(
column(12,
p(
h3('fragment length distribution plot'),
'Plot fragment length distribution used by kallisto in a particular sample.',
' In paired-end data, kallisto learns this fragment length distribution by looking at the beginning coordinate and at the end coordinate of unique pseudoalignments.',
' In single-end data, the fragment length distribution is provided by the user.')
)
),
fluidRow(
column(4,
selectInput('fld_sample', label = 'sample: ',
choices = samp_names,
selected = samp_names[1]
)
)
),
fluidRow(
plotOutput('fld_plt')
)
),
####
tabPanel('processed data',
fluidRow(
column(12,
p(
h3('processed data'),
'Names of samples, number of mapped reads, number of boostraps performed by kallisto,',
'and sample to covariate mappings.'
)
),
offset = 1),
fluidRow(
column(12,
p(strong('kallisto version(s): '), obj$kal_versions)),
offset = 1
),
fluidRow(dataTableOutput('summary_dt')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom: 10px",
downloadButton("download_summary_table", "Download Table")))
),
###
tabPanel('kallisto table',
fluidRow(
column(12, p(h3('kallisto abundance table'),
"All of the abundance estimates pulled in from kallisto results into the
sleuth object.",
' The covariates button will include covariates from the `sample_to_covariates` table defined in `sleuth_prep`.',
' `eff_len` and `len` are the effective length and true length of the transcript (`target_id`).',
' An overview of these units can be found ',
a(href = 'https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/',
target = '_blank', 'here'), '.'
))
),
fluidRow(
column(3,
checkboxInput('norm_tbl', label = 'normalized ',
value = TRUE)),
column(3,
checkboxInput('filt_tbl', label = 'filter ',
value = TRUE)),
column(3,
checkboxInput('covar_tbl', label = 'covariates ',
value = FALSE))
),
fluidRow(dataTableOutput('kallisto_table')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom:10px",
downloadButton("download_kallisto_table", "Download Table")))
)
),
navbarMenu('diagnostics',
####
tabPanel('bias weights',
fluidRow(
column(12,
p(h3('bias weights'),
"View the bias parameters modeled by kallisto.")
)
),
fluidRow(
column(4,
selectInput('bias_sample', label = 'sample: ',
choices = samp_names,
selected = samp_names[1]
)
)
),
fluidRow(
dataTableOutput('bias_weights_table')
)
),
####
tabPanel('mean-variance plot',
fluidRow(
column(12,
p(
h3('mean-variance plot'),
'Plot of abundance versus square root of standard deviation which is used for shrinkage estimation.',
'The blue dots are in the interquartile range and the red curve is the fit used by sleuth.',
' Any points at y = 0 have inferential variance greater than observed total raw variance.'
)
),
offset = 1),
fluidRow(plotOutput('mv_plt')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom:10px",
downloadButton("download_mv_plt", "Download Plot")))
),
tabPanel('scatter plots',
####
fluidRow(
column(12,
p(
h3('scatter plot '),
"Display scatter plot for any two samples and then select",
"a set of transcripts to explore their variance across samples.")
),
offset = 1),
fluidRow(
column(4,
selectInput('sample_x', label = 'x-axis: ',
choices = samp_names,
selected = samp_names[1])
),
column(4,
selectInput('sample_y', label = 'y-axis: ',
choices = samp_names,
selected = samp_names[2])
),
column(2,
textInput('trans',
label = HTML('transform: ',
'<button onclick="trans()">?</button>',
'<script> function trans() {',
'alert("A transformation to be applied to the raw data before plotting.");',
'} </script>'),
value = 'log')),
column(2,
numericInput('scatter_offset',
label = HTML('offset: ',
'<button onclick="scatter_offset()">?</button>',
'<script> function scatter_offset() {',
'alert("A constant amount to be added to the raw data before the transformation and clustering.");',
'} </script>'),
value = 1))
),
fluidRow(
column(2,
selectInput('scatter_units',
label = HTML('units: ',
'<button onclick="scatter_units()">?</button>',
'<script> function scatter_units() {',
'alert("tpm: Transcripts Per Million\\nest_counts (transcript mode only): Counts/Number of aligned reads\\n',
'scaled_reads_per_base (gene mode only): The average number of reads mapping to each base across the whole gene\\n',
'\\nFor a better understanding of the units, see https://haroldpimentel.wordpress.com/2014/05/08/what-the-fpkm-a-review-rna-seq-expression-units/");',
'} </script>'),
choices = c(counts_unit, 'tpm'),
selected = counts_unit)),
column(2,
checkboxInput('scatter_filt',
label = HTML('filter',
'<button onclick="scatter_filt()">?</button>',
'<script> function scatter_filt() {',
'alert("Check this box to use only those transripts',
'that passed the filter before plotting.");',
'} </script>'),
value = TRUE)),
column(2,
numericInput('scatter_alpha', label = 'opacity:', value = 0.2,
min = 0, max = 1, step = 0.01))
),
fluidRow(plotOutput('scatter', brush = 'scatter_brush')),
fluidRow(
div(align = "right", style = "margin-right:15px",
downloadButton("download_scatter_plt", "Download Plot"))),
fluidRow(plotOutput('scatter_vars')),
fluidRow(
div(align = "right", style = "margin-right:15px; margin-bottom: 10px",
downloadButton("download_scatter_var_plt", "Download Plot"))),
fluidRow(dataTableOutput('scatter_brush_table')),
fluidRow(uiOutput("download_scatter_table_button"))
),
tabPanel('Q-Q plot',
####
fluidRow(
column(12,
p(
h3('Q-Q plot'),
"Select the test and view the appropriate quantile-quantile plot.",
'Points that are color red are considered "significant" at the selected fdr-level.')
),
offset = 1
),
fluidRow(
column(2,
numericInput('max_fdr_qq', label = 'max Fdr:', value = 0.10,
min = 0, max = 1, step = 0.01)),
conditionalPanel(condition = 'input.settings_test_type == "wt"',
column(4,
selectInput('which_model_qq', label = 'fit: ',
choices = poss_models,
selected = poss_models[1])
),
column(4,
uiOutput('which_beta_ctrl_qq')
)
),
conditionalPanel(condition = 'input.settings_test_type == "lrt"',
column(4,
selectInput('test_qq', label = 'test: ',
choices = poss_lrt, selected = poss_lrt[1]))
)
),
fluidRow(
plotOutput('qqplot')
),
fluidRow(