jokergoo / InteractiveComplexHeatmap

Make Interactive Complex Heatmaps
https://jokergoo.github.io/InteractiveComplexHeatmap/
Other
130 stars 24 forks source link

Duplicate Click Action #115

Closed gturco closed 4 months ago

gturco commented 4 months ago

I created a click action to display addtional information about the row using the code below. When I click on the row the columns duplicate?

Screenshot 2024-07-29 at 11 26 05 AM

Code Subset:

click_action = function(df, input, output, session) {

scanFile = scan_reactive()
sample_tab = sample_reactive()
pName <- selected_data()[1]

# Convert total peptide signals to percentiles
ecdf_func <- ecdf(scanFile$TotalCount)
scanFile$HeatCount <- ecdf_func(scanFile$TotalCount) * 100

# First subset the peptides table
print(pName)
smallPep <- scanFile[which(scanFile$group_var == pName), ]
# Figure out which columns contain the plotting data
colI <- which(colnames(smallPep) %in% toupper(paste0("X",sample_tab$Channel)))
heatMat <- smallPep[ , colI]

output[["info"]] = renderUI({
  if(!is.null(df)) {
    sample_info = sample_tab[df$column_index,]
    scan_info = smallPep[c('Gene','Protein','Peptide','Hydrophobicity','pI')]
    info <- cbind(data.frame(Intensity=signif(heatMat[df$row_index,df$column_index],2), Ion_Count_Pctl_color=signif(smallPep$HeatCount[df$row_index],2)),sample_info,scan_info)
    HTML(kable_styling(kbl(t(info), format = "html"), full_width = FALSE, position = "left"))
  }
})

}

gturco commented 4 months ago

This was a bug caused by me! scan_info contains multiple rows sometimes so the code was trying to accommodate.