jokergoo / InteractiveComplexHeatmap

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

interactivecomplexheatmap in shiny module #92

Open wanlinrong opened 2 years ago

wanlinrong commented 2 years ago

I hope you can provide some examples of interactive complexheatmap used in a shiny module ( not on the shiny top level, it works well )

wanlinrong commented 2 years ago
##not work
module.ui <- function(id){
  ns <- NS(id)
  fluidPage(
  InteractiveComplexHeatmapOutput(ns('ss'))
 )
}

module.server <- function(id) {
  moduleServer(
    id,
    function(input, output, session) {
     ns <- NS(id)
    makeInteractiveComplexHeatmap(input, output, session, Heatmap(iris),ns('ss')) 
    #still not work : makeInteractiveComplexHeatmap(input, output, session, Heatmap(iris),'ss') 
    }
  )}

shiny::shinyApp(ui=module.ui('test'), server = function(input,output,session){
   module.server('test')
 })

####works well 
ui = fluidPage(
  InteractiveComplexHeatmapOutput('ss')
)
server = function(input, output, session) {
  makeInteractiveComplexHeatmap(input, output, session, Heatmap(iris),'ss')
}
shiny::shinyApp(ui, server)
jokergoo commented 2 years ago

Unfortunately it does not support Shiny module now. I will put it into my to-do list.

jokergoo commented 2 years ago

After some explorations of shiny module, I would say I will not support module in InteractiveComplexHeatmap, for two reasons: 1. I have very limited knowledge on shiny modules and 2. InteractiveComplexHeatmap contains very complex logics in server function and in the communication between frontend and backend via javascript, thus it would a lot of work to take care of "namespaces".

I don't know how will you use modules, basically ns('ss') adds a prefix with value in id to 'ss'. Maybe you can separate use of makeInteractiveComplexHeatmap() e.g.:

module.ui <- function(id){
  ns <- NS(id)
  fluidPage(
  InteractiveComplexHeatmapOutput(ns('ss'))
 )
}

module.server <- function(id) {
  moduleServer(
    id,
    function(input, output, session) {
     ns <- NS(id)
     # other code defined in modules
    }
  )}

shiny::shinyApp(ui=module.ui('test'), server = function(input,output,session){
   module.server('test')

   makeInteractiveComplexHeatmap(input, output, session, Heatmap(iris),"test-ss") 
 })