Skip to content

Commit

Permalink
add GatingSets menuItem that clicks into pData,tree,gateLayout and po…
Browse files Browse the repository at this point in the history
…pStats panels.
  • Loading branch information
mikejiang committed Sep 29, 2015
1 parent 9200ff5 commit 9f941ba
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 48 deletions.
74 changes: 57 additions & 17 deletions R/server.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,16 @@ function(input, output,session){
MAX_MB_UPLOAD = 1024 # one Gb limit.
options(shiny.maxRequestSize=MAX_MB_UPLOAD*1024^2)

# .getFilePaths = reactive({
# s = input$chooser_rows_selected
# if(length(s)){
# df = input$filechooser
# setDT(df)
# df[name%in%s,datapath]
# }
# })
#---init gs menu ---
output$gs_menu_obj <- renderMenu(menuItem("GatingSets", tabName = "gs_menu", icon = icon("database"), badgeLabel = "0", badgeColor = "orange"))
# .getFilePaths = reactive({
# s = input$chooser_rows_selected
# if(length(s)){
# df = input$filechooser
# setDT(df)
# df[name%in%s,datapath]
# }
# })
# select ws folder
shinyDirChoose(input, "ws_dir_btn", session = session, roots = roots)

Expand All @@ -64,12 +66,6 @@ function(input, output,session){
})

rv = reactiveValues()
observeEvent(rv$gs,{
output$tree = renderDiagonalNetwork({
tree = getPopStats(rv$gs[1],format="long",showHidden=TRUE)[,.(Parent,Population)]
diagonalNetwork(maketreelist(data.frame(tree),root="root"),fontSize=8,margin = c(100,100))
})
})

observeEvent(input$tabset,{
js$fire()
Expand Down Expand Up @@ -166,18 +162,60 @@ function(input, output,session){

observeEvent(input$parse_ws,{
shinyjs::show("message2")
rv$gs <<-try(parseWorkspace(rv$ws,name = input$grp_selected))
gs <- rv$gs
gs <- try(parseWorkspace(rv$ws,name = input$grp_selected))

if(inherits(gs,"try-error")){
output$message2 = renderText(paste(geterrmessage(),"\nMaybe you need to upload FCS files as well?"))
}else if(class(gs)=="GatingSet"){
output$message2 = renderText(paste0("Success!\n",capture.output(print(gs))))
rv$gs <<- gs
shinyjs::disable("parse_ws")
}else{
output$message2 = renderText("gs is a ",class(gs))
}
})

# select gs folder
#---- update gs panels ----
observeEvent(rv$gs,{
#update badge of gs menu
output$gs_menu_obj <- renderMenu(menuItem("GatingSets"
, tabName = "gs_menu"
, icon = icon("database")
, badgeLabel = "1"
, badgeColor = "green")
)
#update the pData tbl
output$pd_tbl <- DT::renderDataTable(pData(rv$gs))

#---- Populate sn selector ----
updateSelectInput(session, "sn_select"
, choices = sampleNames(rv$gs)
, label = NULL)

})

#---update gh related panels---
observeEvent(input$sn_select,{
sn <- input$sn_select

if(nchar(sn) > 0){
gh <- rv$gs[[sn]]
# gate
output$gate_layout <- renderPlot(plotGate(gh))

#pop stats
stats <- getPopStats(gh)
output$pop_stats_tbl <- DT::renderDataTable(stats)
# tree

output$tree = renderDiagonalNetwork({
tree = getPopStats(rv$gs[sn],format="long",showHidden=TRUE)[,.(Parent,Population)]
diagonalNetwork(maketreelist(data.frame(tree),root="root"),fontSize=8,margin = c(100,100))
})
}

})
#---- select gs folder ----
shinyDirChoose(input, "gs_dir_btn", session = session, roots = roots)
observeEvent(input$gs_dir_btn, {

Expand Down Expand Up @@ -231,6 +269,8 @@ function(input, output,session){
observeEvent(input$selnode,{
output$gateplot = renderImage(plt(),deleteFile = FALSE)
})


}


Expand Down
74 changes: 43 additions & 31 deletions R/ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ sidebar <- dashboardSidebar(
useShinyjs(),
extendShinyjs(script = "www/actions.js"),
sidebarMenu(
menuItem("Data", tabName = "Data",icon = icon("database"),
menuSubItem("Import workspaces", tabName = "Import", icon = icon("arrow-right"), selected = TRUE),
menuSubItem("Load GatingSets", tabName = "Load", icon = icon("folder-open"))
),
menuItem("Compensate & Transform", tabName = "Compensate", icon = icon("exchange")),
menuItem("Build a Gating Template",tabName = "GatingTemplate", icon = icon("table")),
menuItem("View Gating Tree", tabName = "Tree", icon = icon("bar-chart"))

menuItem("Import workspaces", tabName = "Import", icon = icon("arrow-right"), selected = TRUE)
, menuItem("Load GatingSets", tabName = "load_menu", icon = icon("folder-open"))
, menuItemOutput("gs_menu_obj")


, menuItem("Compensate & Transform", tabName = "Compensate", icon = icon("exchange"))
, menuItem("Build a Gating Template",tabName = "GatingTemplate", icon = icon("table"))

)
)

Expand All @@ -29,7 +31,7 @@ datadirectory = system.file("extdata",package = "flowWorkspaceData")#"~/rglab/wo

body <- dashboardBody(
tabItems(
tabItem("Data", title = "Data", h1("Please choose submenu: 'Import workspaces' or 'Load GatingSet'")),
# tabItem("Data", title = "Data", h1("Please choose submenu: 'Import workspaces' or 'Load GatingSet'"))
tabItem("Import", title = "Import"

, div(
Expand Down Expand Up @@ -60,37 +62,47 @@ body <- dashboardBody(
)


),
tabItem("Load",
box(
shinyDirButton("gs_dir_btn",label = "choose GatingSet ...", title = "Please select a folder", buttonType = "primary"),
textInput("path_gs", label = "", value = datadirectory),
myActionButton(inputId = "load",label = "Load Data"),
div(verbatimTextOutput("message"),style='width:90%'),
title = "Load GatingSets", solidHeader = TRUE, status = "primary", width = NULL
)
),
, tabItem("load_menu"
, box(shinyDirButton("gs_dir_btn",label = "choose GatingSet ...", title = "Please select a folder", buttonType = "primary")
, textInput("path_gs", label = "", value = file.path(datadirectory, "gs_manual"))
, myActionButton(inputId = "load",label = "Load Data")
, div(verbatimTextOutput("message"),style='width:90%')
, title = "Load GatingSets", solidHeader = TRUE, status = "primary", width = NULL
)
)

, tabItem("gs_menu"

, tabBox(id = "gs_tab", width = NULL
,tabPanel(title = "Pheno Data", value = "pd_tab", icon = icon("th")
,DT::dataTableOutput("pd_tbl")
)
,tabPanel(title = "Gating Tree", value = "tree_tab", icon = icon("sitemap")
,selectInput("sn_select", choices = c("select one sample ---" = ""), label = NULL)
# ,checkboxInput("isBool", "Show boolean gates")
,div(div(diagonalNetworkOutput("tree",width="400px",height="300px"),
style="display:inline-block;float:left;")
,div(imageOutput("gateplot",width = "300px",height="300px")
,style="margin-left:400px;", id = "tabSet")
,style="width:100%;height:100%;"
)
)
,tabPanel(title = "Gating Layout", value = "gate_layout_tab", icon = icon("picture-o")
, plotOutput("gate_layout"))
,tabPanel(title = "Pop Stats", value = "stats_tab", icon = icon("bar-chart")
,DT::dataTableOutput("pop_stats_tbl")
)
)
)


tabItem("Compensate",
, tabItem("Compensate",
box(title = "Compensate & Transform", solidHeader = TRUE, status = "primary")
),
tabItem("GatingTemplate",
box(title = "Build a Gating Template", solidHeader = TRUE, status = "primary")
),
tabItem("Tree",
# box(
div(div(diagonalNetworkOutput("tree",width="400px",height="300px"),
style="display:inline-block;float:left;")
,div(imageOutput("gateplot",width = "300px",height="300px")
,style="margin-left:400px;", id = "tabSet")
,style="width:100%;height:100%;"
)
# title = "View Gating Tree", solidHeader = TRUE, status = "primary", width = NULL
# )

)

)
)

Expand Down

0 comments on commit 9f941ba

Please sign in to comment.