From a1269d3f82c34ee1cb20fd65f4687e8aa79a27b2 Mon Sep 17 00:00:00 2001 From: Marcos Date: Wed, 29 Nov 2017 16:24:21 +0100 Subject: [PATCH] Checkbox sample names for heatmaps --- server.R | 31 ++++++++++++++++++++++++++++--- ui.R | 8 +++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/server.R b/server.R index 4384e06..a543576 100644 --- a/server.R +++ b/server.R @@ -393,8 +393,8 @@ shinyServer(function(input, output,session){ # PLOT somatic mutation prevalence output$smp <- renderPlot({ - #Error managemente for file format + #Error managemente for file format error_message<-"File format error, please select the correct input file format before uploading your file/s." if (input$datatype=="VCF"){ @@ -555,6 +555,15 @@ shinyServer(function(input, output,session){ return(invisible(NULL)) } }) + + #check if sample names are needed + output$heatmap_sample_names<-renderUI({ + if (input$tab == "contrib" | input$tab == "comp_canc_sign"){ + checkboxInput("samplenames","Show sample names",value=TRUE) + } else { + return(invisible(NULL)) + } + }) #HeatMap output$heatmap_signatures <- renderPlotly({ @@ -564,6 +573,8 @@ shinyServer(function(input, output,session){ a<-my_contributions() if (ncol(a)==1) colnames(a)<-colnames(my_contributions()) ## fix colnames when there is only one sample + + rownames(a)<-colnames(cancer_signatures)[1:30] colorends <- c("white","red") dendro <- "none" @@ -571,6 +582,10 @@ shinyServer(function(input, output,session){ if (input$col_d_heatmap=="yes") dendro<-"column" if (input$row_d_heatmap=="yes" & input$col_d_heatmap=="yes") dendro<-"both" + if (input$samplenames==FALSE){ + colnames(a)<-1:length(colnames(a)) + } + heatmaply(a, scale_fill_gradient_fun = scale_fill_gradientn(colours = colorends, limits = c(0,1)), dendrogram = dendro, k_row = 1, k_col = 1, column_text_angle = 90 ) }) @@ -591,7 +606,9 @@ shinyServer(function(input, output,session){ if (input$col_d_heatmap=="yes") dendro<-"column" if (input$row_d_heatmap=="yes" & input$col_d_heatmap=="yes") dendro<-"both" - + if (input$samplenames==FALSE){ + colnames(a)<-1:length(colnames(a)) + } heatmaply(a, scale_fill_gradient_fun = scale_fill_gradientn(colours = colorends, limits = c(0,1)), dendrogram = dendro, k_row = 1, k_col = 1, column_text_angle = 90, @@ -721,7 +738,11 @@ shinyServer(function(input, output,session){ if (input$col_c_heatmap=="yes") dendro<-"column" if (input$row_c_heatmap=="yes" & input$col_c_heatmap=="yes") dendro<-"both" - heatmaply(a, scale_fill_gradient_fun = scale_fill_gradientn(colours = colorends, limits = c(0,3)), + if (input$samplenames==FALSE){ + colnames(a)<-1:length(colnames(a)) + } + + heatmaply(a, scale_fill_gradient_fun = scale_fill_gradientn(colours = colorends, limits = c(0,3)), dendrogram = dendro, k_row = 1, k_col = 1, column_text_angle = 90, hide_colorbar = TRUE) }) @@ -755,6 +776,10 @@ shinyServer(function(input, output,session){ if (input$col_c_heatmap=="yes") dendro<-"column" if (input$row_c_heatmap=="yes" & input$col_c_heatmap=="yes") dendro<-"both" + if (input$samplenames==FALSE){ + colnames(a)<-1:length(colnames(a)) + } + heatmaply(a, scale_fill_gradient_fun = scale_fill_gradientn(colours = colorends, limits = c(0,3)), dendrogram = dendro, k_row = 1, k_col = 1, column_text_angle = 90, hide_colorbar = TRUE, file = ff) diff --git a/ui.R b/ui.R index e9c6f51..cb422c9 100644 --- a/ui.R +++ b/ui.R @@ -69,6 +69,7 @@ shinyUI(fluidPage( uiOutput("row_dendro_heatmap"), uiOutput("col_dendro_cancers"), uiOutput("row_dendro_cancers"), + uiOutput("heatmap_sample_names"), #Clear button actionButton("clear","Clear") @@ -164,9 +165,10 @@ shinyUI(fluidPage( radioButtons("type_pca_plot","Format",c("pdf","png","tiff")), downloadButton("download_pca_plot","OK")), p(), - plotOutput("pca_plot",height=700,width=700), - p(), - tableOutput("pca_plot_table") + fluidRow( + column(7,plotOutput("pca_plot",height=600,width=600)), + column(5,tableOutput("pca_plot_table")) + ) ) )