Skip to content

Commit

Permalink
Fix2 for Heatmap. Row annotation did not work and left the dataset wi…
Browse files Browse the repository at this point in the history
…th no data (#246)
  • Loading branch information
PaulJonasJost authored Jul 7, 2024
1 parent 80b4506 commit e2467c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion program/shinyApp/R/heatmap/fun_entitieSelection.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ entitieSelection <- function(
if(any(additionalInput_row_anno_factor=="all")){
filtered_data <- filtered_data
} else{
filtered_data <- filtered_data[which(data$annotation_rows[, additionalInput_row_anno] %in% additionalInput_row_anno_factor),]
filtered_data <- filtered_data[which(rowData(data)[, additionalInput_row_anno] %in% additionalInput_row_anno_factor),]
}
}
if(!(is.na(additionalInput_sample_annotation_types)) & !(is.na(additionalInput_ctrl_idx)) & !(is.na(additionalInput_cmp_idx))){
Expand Down
23 changes: 12 additions & 11 deletions program/shinyApp/R/heatmap/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,6 @@ heatmap_server <- function(id, data, params, updates){
print("No entitie selection")
data2HandOver <- as.data.frame(assay(data$data))
}else{
# entitie selection is a custom function -> wrap it in a tryCatch
tryCatch({
data2HandOver <- entitieSelection(
data$data,
Expand Down Expand Up @@ -390,8 +389,6 @@ heatmap_server <- function(id, data, params, updates){
output$Options_selected_out_3 <- renderText("Choose another preprocessing, as there are negative values!")

}else if(doThis_flag){

# getLFC is a custom function -> wrap it in a tryCatch
tryCatch({
Data2Plot <- getLFCs(
data = as.data.frame(data2HandOver),
Expand All @@ -411,10 +408,11 @@ heatmap_server <- function(id, data, params, updates){
heatmap_data <- t(Data2Plot[,"LFC",drop=F])
# absolute maximum value
max_val <- max(abs(heatmap_data), na.rm = T)
breakings <- seq(-max_val, max_val, length.out = 101)
if (input$rowWiseScaled){
if (input$rowWiseScaled | max_val == Inf | max_val == -Inf){
max_val <- 1
breakings <- NA
} else {
breakings <- seq(-max_val, max_val, length.out = 101)
}
heatmap_plot <- pheatmap(
heatmap_data,
Expand Down Expand Up @@ -465,10 +463,11 @@ heatmap_server <- function(id, data, params, updates){
heatmap_data <- as.matrix(data2HandOver)
# absolute maximum value
max_val <- max(abs(heatmap_data), na.rm = T)
breakings <- seq(-max_val, max_val, length.out = 101)
if (input$rowWiseScaled){
if (input$rowWiseScaled | max_val == Inf | max_val == -Inf){
max_val <- 1
breakings <- NA
} else {
breakings <- seq(-max_val, max_val, length.out = 101)
}
heatmap_plot <- pheatmap(
heatmap_data,
Expand Down Expand Up @@ -500,10 +499,11 @@ heatmap_server <- function(id, data, params, updates){
heatmap_data <- t(res_tmp[[session$token]]$Heatmap[,"LFC",drop=F])
# absolute maximum value
max_val <- max(abs(heatmap_data), na.rm = T)
breakings <- seq(-max_val, max_val, length.out = 101)
if (input$rowWiseScaled){
if (input$rowWiseScaled | max_val == Inf | max_val == -Inf){
max_val <- 1
breakings <- NA
} else {
breakings <- seq(-max_val, max_val, length.out = 101)
}
heatmap_plot <- pheatmap(
heatmap_data,
Expand Down Expand Up @@ -544,10 +544,11 @@ heatmap_server <- function(id, data, params, updates){
heatmap_data <- as.matrix(res_tmp[[session$token]]$Heatmap)
# absolute maximum value
max_val <- max(abs(heatmap_data), na.rm = T)
breakings <- seq(-max_val, max_val, length.out = 101)
if (input$rowWiseScaled){
if (input$rowWiseScaled | max_val == Inf | max_val == -Inf){
max_val <- 1
breakings <- NA
} else {
breakings <- seq(-max_val, max_val, length.out = 101)
}
heatmap_plot <- pheatmap(
heatmap_data,
Expand Down

0 comments on commit e2467c9

Please sign in to comment.