@@ -140,7 +140,7 @@ sleuth_live <- function(obj, settings = sleuth_live_settings(),
140140 ' enter a gene identifier that matches that column.' ,
141141 ' The most significant gene by q-value for the first test within the currently selected test type is already entered.");' ,
142142 ' } </script>' ),
143- value = textOutput( " default_top_hit " ) )
143+ value = ' ' )
144144 ),
145145 column(3 ,
146146 selectInput(' bsg_var_color_by' ,
@@ -277,7 +277,7 @@ sleuth_live <- function(obj, settings = sleuth_live_settings(),
277277 ' alert("Enter a space-separated list of transcript names here to view a hierarchical clustering of those transcripts.",
278278 "The ten most significant transcripts for the first test of the currently selected test type have been listed for you by default.");' ,
279279 ' } </script>' ),
280- value = textOutput( " default_top_ten " ) )
280+ value = ' ' )
281281 ),
282282 column(8 , style = " margin-top:15px;" ,
283283 checkboxGroupInput(' hm_covars' ,
@@ -458,7 +458,10 @@ sleuth_live <- function(obj, settings = sleuth_live_settings(),
458458 uiOutput(' group_by_lrt' )
459459 )
460460 ),
461- dataTableOutput(' lrt_de_dt' )
461+ dataTableOutput(' lrt_de_dt' ),
462+ fluidRow(
463+ div(align = " right" , style = " margin-right:15px; margin-bottom:10px" ,
464+ downloadButton(" download_test_table" , " Download Table" )))
462465 )
463466 ),
464467
@@ -782,7 +785,10 @@ sleuth_live <- function(obj, settings = sleuth_live_settings(),
782785 ),
783786 fluidRow(
784787 plotOutput(' fld_plt' )
785- )
788+ ),
789+ fluidRow(
790+ div(align = " right" , style = " margin-right:15px; margin-bottom: 10px" ,
791+ downloadButton(" download_fld_plt" , " Download Table" )))
786792 ),
787793
788794 # ###
@@ -1044,7 +1050,8 @@ sleuth_live <- function(obj, settings = sleuth_live_settings(),
10441050 sample_table = NULL ,
10451051 kallisto_table = NULL ,
10461052 hm_plt = NULL ,
1047- bs_var_plt = NULL
1053+ bs_var_plt = NULL ,
1054+ fld_plt = NULL
10481055 )
10491056 user_settings <- reactiveValues(save_width = 45 , save_height = 11 )
10501057 # TODO: Once user settings are available, read these values from input
@@ -1065,29 +1072,112 @@ sleuth_live <- function(obj, settings = sleuth_live_settings(),
10651072 current_ui
10661073 })
10671074
1068- output $ default_top_hit <- renderText({
1069- default_test <- ifelse(length(valid_test_types ) == 0 , NULL ,
1070- ifelse(input $ settings_test_type == ' wt' ,
1071- obj $ tests [[' wt' ]][[1 ]][[1 ]],
1072- obj $ tests [[' lrt' ]][[1 ]])
1073- )
1075+ # ## CODE TO FILL IN DEFAULT VALUES FOR TEXT BOXES
1076+ defaults <- reactiveValues(
1077+ top_hit = ' ' ,
1078+ top_gene = ' ' ,
1079+ top_ten = ' '
1080+ )
1081+
1082+ # # Observe to see if the test type changes
1083+ # # Pick the top transcript for the first test of that type
1084+ observe({
1085+ test_type <- input $ settings_test_type
1086+ default_test <- if (length(valid_test_types ) == 0 ) {
1087+ NULL
1088+ } else if (test_type == " wt" ) {
1089+ obj $ tests [[" wt" ]][[1 ]][[1 ]]
1090+ } else {
1091+ obj $ tests [[" lrt" ]][[1 ]]
1092+ }
1093+
1094+ default_id <- ifelse(is.null(default_test ), " No tests found. This feature won't work" ,
1095+ default_test [order(default_test $ qval ), " target_id" ][1 ])
1096+ defaults $ top_hit <- default_id
1097+ })
1098+
1099+ # # Observe to see if the test type changes
1100+ # # Pick the top 10 hits for the first test of that type
1101+ observe({
1102+ test_type <- input $ settings_test_type
1103+ default_test <- if (length(valid_test_types ) == 0 ) {
1104+ NULL
1105+ } else if (test_type == " wt" ) {
1106+ obj $ tests [[" wt" ]][[1 ]][[1 ]]
1107+ } else {
1108+ obj $ tests [[" lrt" ]][[1 ]]
1109+ }
1110+
1111+ default_ids <- if (is.null(default_test )) {
1112+ c(" No tests found. This feature won't work" )
1113+ } else {
1114+ default_test [order(default_test $ qval ), " target_id" ][1 : 10 ]
1115+ }
1116+
1117+ defaults $ top_ten <- paste(default_ids , collapse = " " )
1118+ })
1119+
1120+ # # Observe to see if the test type changes or the gene column changes
1121+ # # Pick the gene with the most significant transcript for the first test of that type
1122+ observe({
1123+ gene_col <- input $ gv_gene_colname
1124+ test_type <- input $ settings_test_type
1125+ default_test <- if (length(valid_test_types ) == 0 ) {
1126+ NULL
1127+ } else if (test_type == " wt" ) {
1128+ obj $ tests [[" wt" ]][[1 ]][[1 ]]
1129+ } else {
1130+ obj $ tests [[" lrt" ]][[1 ]]
1131+ }
10741132 default_id <- ifelse(is.null(default_test ), " No tests found. This feature won't work" ,
1075- default_test [order(default_test $ qval ), " target_id" ][1 ])
1076- default_id
1133+ default_test [order(default_test $ qval ), " target_id" ][1 ])
1134+ id_row <- which(obj $ target_mapping $ target_id == default_id )
1135+ defaults $ top_gene <- obj $ target_mapping [id_row , gene_col ]
1136+ })
1137+
1138+ # # Check if the transcript input is empty or invalid
1139+ # # Fill in with default value if either of above are true
1140+ observe({
1141+ var_input <- input $ bs_var_input
1142+ if (is.null(var_input ) || ! var_input %in% obj $ target_mapping $ target_id ) {
1143+ updateTextInput(session , " bs_var_input" , value = defaults $ top_hit )
1144+ }
1145+ })
1146+
1147+ # # Check if the gene input is empty or invalid
1148+ # # Fill in with default value if either of above are true
1149+ observe({
1150+ var_input <- input $ bsg_var_input
1151+ gene_col <- obj $ gene_column
1152+ genes <- obj $ target_mapping [, gene_col ]
1153+ if (is.null(genes )) {
1154+ updateTextInput(session , " bsg_var_input" , value = " This won't work" )
1155+ } else if (is.null(var_input ) || ! var_input %in% genes ) {
1156+ updateTextInput(session , " bsg_var_input" , value = defaults $ top_hit )
1157+ }
10771158 })
10781159
1079- output $ default_top_ten <- renderText({
1080- default_test <- ifelse(length(valid_test_types ) == 0 , NULL ,
1081- ifelse(input $ settings_test_type == ' wt' ,
1082- obj $ tests [[' wt' ]][[1 ]][[1 ]],
1083- obj $ tests [[' lrt' ]][[1 ]])
1084- )
1085- default_ids <- ifelse(is.null(default_test ), " No tests found. This feature won't work" ,
1086- default_test [order(default_test $ qval ), " target_id" ][1 : 10 ])
1087- default_ids <- paste(default_ids , collapse = " " )
1088- default_ids
1160+ # # Check if the gene input is empty or invalid
1161+ # # Fill in with default value if either of above are true
1162+ observe({
1163+ var_input <- input $ gv_var_input
1164+ gene_col <- input $ gene_col
1165+ genes <- obj $ target_mapping [, gene_col ]
1166+ if (is.null(var_input ) || ! var_input %in% genes ) {
1167+ updateTextInput(session , " gv_var_input" , value = defaults $ top_gene )
1168+ }
10891169 })
10901170
1171+ # # Check if the list of inputs is empty
1172+ # # Fill in with default top 10 if either of above are true
1173+ observe({
1174+ hm_input <- input $ hm_transcripts
1175+ if (is.null(hm_input ) || hm_input == " " ) {
1176+ updateTextInput(session , " hm_transcripts" , value = defaults $ top_ten )
1177+ }
1178+ })
1179+ # ## END OF CODE FOR DEFAULT VALUES
1180+
10911181 output $ qqplot <- renderPlot({
10921182 poss_tests <- list_tests(obj , input $ settings_test_type )
10931183 current_test <- NULL
@@ -1378,6 +1468,19 @@ sleuth_live <- function(obj, settings = sleuth_live_settings(),
13781468
13791469 output $ fld_plt <- renderPlot({
13801470 plot_fld(obj , input $ fld_sample )
1471+ # saved_plots_and_tables$fld_plt <- plot_fld(obj, input$fld_sample)
1472+ # saved_plots_and_tables$fld_plt
1473+ })
1474+
1475+ output $ download_fld_plt <- downloadHandler(
1476+ filename = function () {
1477+ " fld_plot.pdf"
1478+ },
1479+ content = function (file ) {
1480+ ggsave(file , saved_plots_and_tables $ fld_plt ,
1481+ width = user_settings $ save_width ,
1482+ height = user_settings $ save_height ,
1483+ units = " cm" )
13811484 })
13821485
13831486 output $ bias_weights_table <- renderDataTable({
@@ -1700,7 +1803,7 @@ sleuth_live <- function(obj, settings = sleuth_live_settings(),
17001803 ' You can find target_ids in the test table under Analyses. The most significant transcript' ,
17011804 ' by q-value for the first test within the currently selected test type is already entered.");' ,
17021805 ' } </script>' ),
1703- value = textOutput( " default_top_hit " ) )
1806+ value = ' ' )
17041807 ),
17051808 column(4 ,
17061809 selectInput(' bs_var_color_by' ,
0 commit comments