File size: 3,069 Bytes
c038271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
box::use(
  shiny[bootstrapPage, div, icon, moduleServer, fluidRow, NS, renderUI, tags, uiOutput],
  bs4Dash[box, dashboardPage, tabItems, tabItem, sidebarMenu, menuItem, dashboardHeader, column, dashboardBrand, dashboardSidebar, dashboardBody],
  thematic[thematic_shiny],
  shinyjs[useShinyjs, runjs],
  gargoyle[init]
)

box::use(
  app/logic/data_preprocessor[preprocess_data],
  app/logic/data_preprocessor[preprocess_maf_data]
)

box::use(
  app/view/table,
  app/view/sankey,
  app/view/lollipop,
  app/view/browser
)

thematic_shiny()

#' @export
ui <- function(id) {
  ns <- NS(id)
  dashboardPage(
    header = dashboardHeader(
      title = "VarWiz",
      skin = "dark",
      status = "white"
    ),
    dark = NULL,
    help = NULL,
    sidebar = dashboardSidebar(
      collapsed = TRUE,
      status = "navy",
      skin = "dark",
      sidebarMenu(
        id = "side_menu",
        div(class = "menu-tab", menuItem("Visualization", tabName = "visualization_tab", icon = icon("chart-line"))),
        div(class = "menu-tab", menuItem("Browse data", tabName = "browse_tab", icon = icon("table"))),
        div(class = "menu-tab", menuItem("About", tabName = "about_tab", icon = icon("book-open"))),
        div(class = "menu-tab", menuItem("Start Tutorial", tabName = "tutorial", icon = icon("play")))
      )
    ),
    body = dashboardBody(
      tags$head(
        tags$script(
          "$(function() {
              $('[data-card-widget=\"maximize\"]').on('click', function() {
                setTimeout(function() {
                  var isMaximized = $('html').hasClass('maximized-card');
                  if (isMaximized) {
                    $('#app-sankey-sankey').css('height', '1000px');
                  } else {
                    $('#app-sankey-sankey').css('height', '400px');
                  }
                }, 300);
                $('#app-sankey-sankey').trigger('resize');
              });
            });
            "
        )
      ),
      
      useShinyjs(),
      tabItems(
        tabItem(
          tabName = "visualization_tab",
          fluidRow(
            column(
              width = 9,
              sankey$ui(ns("sankey")),
              lollipop$ui(ns("lollipop"))
            ),
            column(
              width = 3,
              table$ui(ns("table")),
            ),
          )
        ),
        
        tabItem(
          tabName = "browse_tab",
          browser$ui(ns("browser"))
          
        ),
        
        tabItem(
          tabName = "about_tab"
        )
      )
      
      
      
    )
  )
}

#' @export
server <- function(id) {
  moduleServer(id, function(input, output, session) {
    init("reset_sankey")
    
    # data <- preprocess_data()
    data <- preprocess_maf_data()
    browser$server("browser", data)
    selected_features <- table$server("table", data)
    selected_gene_rval <- sankey$server("sankey", data, selected_features()[[1]], selected_features()[[2]], selected_features()[[3]])
    lollipop$server("lollipop", data, selected_gene_rval)
  })
}