Skip to content

Commit

Permalink
Checkbox sample names for heatmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
marcos-diazg committed Nov 29, 2017
1 parent b96fba6 commit a1269d3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
31 changes: 28 additions & 3 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"){
Expand Down Expand Up @@ -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({
Expand All @@ -564,13 +573,19 @@ 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"
if (input$row_d_heatmap=="yes") dendro<-"row"
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 )
})
Expand All @@ -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,
Expand Down Expand Up @@ -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)

})
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"))
)
)

)
Expand Down

0 comments on commit a1269d3

Please sign in to comment.