Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster page UI #13

Closed
wants to merge 11 commits into from
29 changes: 0 additions & 29 deletions .github/workflows/R-CMD-check.yaml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
4 changes: 3 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -28,3 +28,5 @@ jobs:
- name: Lint
run: lintr::lint_package()
shell: Rscript {0}
env:
LINTR_ERROR_ON_LINT: true
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Suggests:
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
43 changes: 24 additions & 19 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,30 +83,34 @@ app_server = function(input, output, session) {
shiny::bindCache(input$widgetChoice)


# Mutation colouring ------------------------------------------------------
# Mutation colouring ------------------------------------------------------

# disable dropdown unless mutation treeview
shiny::observe({
choice = ifelse(input$widgetChoice != "", input$widgetChoice, "")
# toggle mutation dropdown
shinyjs::toggleElement(id = "mutationChoice",
condition = choice == "tree-mutations.rds")
shinyjs::toggleElement(
id = "mutationChoice",
condition = choice == "tree-mutations.rds"
)
# toggle sequence dropdown
shinyjs::toggleElement(id = "sequenceChoice",
condition = choice == "tree-sequences.rds")
shinyjs::toggleElement(
id = "sequenceChoice",
condition = choice == "tree-sequences.rds"
)
# select input for sequences
if (choice == "tree-sequences.rds") {
avail_seqs = data.table::as.data.table(available_sequences(data_dir))
names(avail_seqs) = "Sequences"
shiny::updateSelectInput(inputId = "sequenceChoice",
choices = avail_seqs
)
shiny::updateSelectInput(
inputId = "sequenceChoice",
choices = avail_seqs
)
}
})

# get selected nodes from mutation choice
shiny::observeEvent(input$mutationChoice, {

nodeChoice = selected_mut_nodes(input$mutationChoice, data_dir)

# the 'node' column contains integers that define the IDs for graph-nodes in the htmlwidget
Expand All @@ -124,11 +128,10 @@ app_server = function(input, output, session) {
)
})

# Sequence colouring ------------------------------------------------------
# Sequence colouring ------------------------------------------------------

# get selected nodes from sequence choice
shiny::observeEvent(input$sequenceChoice, {

nodeChoice = selected_seq_nodes(input$sequenceChoice, data_dir)

# the 'node' column contains integers that define the IDs for graph-nodes in the htmlwidget
Expand All @@ -146,15 +149,17 @@ app_server = function(input, output, session) {
)
})

# Get click ---------------------------------------------------------------
# Get click ---------------------------------------------------------------

# get selected cluster id based on widget choice
selected_cluster_id = shiny::reactive({
shiny::req(input$widgetChoice)
shiny::req(input$treeview_selected)
get_selected_cluster_id(widgetChoice = input$widgetChoice,
treeviewSelected = utils::tail(input$treeview_selected, 1),
data_dir = data_dir)
get_selected_cluster_id(
widgetChoice = input$widgetChoice,
treeviewSelected = utils::tail(input$treeview_selected, 1),
data_dir = data_dir
)
}) %>%
shiny::bindCache(input$widgetChoice, input$treeview_selected)

Expand All @@ -169,9 +174,10 @@ app_server = function(input, output, session) {
shiny::req(input$widgetChoice)
fname = stringr::str_replace(input$widgetChoice, ".rds", ".md")
shiny::includeMarkdown(system.file("app", "www", "content", "treeview",
fname,
package = "tfpbrowser",
mustWork = TRUE))
fname,
package = "tfpbrowser",
mustWork = TRUE
))
})

# Tables Tab --------------------------------------------------------------
Expand All @@ -194,5 +200,4 @@ app_server = function(input, output, session) {
cluster_choice = selected_cluster_id,
data_dir = data_dir
)

} # end server function
141 changes: 60 additions & 81 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,103 +3,83 @@
#' @param request Internal parameter for `{shiny}`.
#' @noRd
app_ui = function(request) {
data_dir <- get_data_dir()
data_dir = get_data_dir()

shiny::tagList(

shinyjs::useShinyjs(),
shinybrowser::detect(),

shiny::navbarPage(
# title
title = place_title_logo(),

header = add_ext_resources(data_dir),
# theme
theme = bslib::bs_theme(version = 4,
bootswatch = "minty",
bg = "#EBEEEE",
fg = "#002147",
primary = "#003E74",
secondary = "#9D9D9D"),
theme = bslib::bs_theme(
version = 4,
bootswatch = "minty",
bg = "#EBEEEE",
fg = "#002147",
primary = "#003E74",
secondary = "#9D9D9D"
),

# Input widgets
shiny::tabPanel(
title = "Data",

shiny::fluidRow(
shiny::column(12,
# use details and summary to create expandable section
htmltools::tags$details(
# preview of expandable section
htmltools::tags$summary("Cluster statistics (click to expand)"),

shiny::br(),

# text to print choice
shiny::textOutput("select_text"),
shiny::br(),

# output options
shiny::tabsetPanel(id = "plot_tabs",

# Tables tab
tablesUI("table1"),

# Plots tab
plotsUI("plot1"),

# RDS tab
rdsUI("rds1")

)
)
)
shiny::column(12, clusterStatsUI(id = NULL))
), # end fluid row

# Bottom row - show tree (static html output from tfpscanner)
shiny::fluidRow(
shiny::column(12,
id="view-container",
shiny::div(id="view-selection",
htmltools::tags$details(
id="sidebar-toggle",
open="open",
`aria-role`="button",
`aria-label`="Toggle sidebar visibility",
htmltools::tags$summary(
shiny::span(">>"),
shiny::span("<<")
)
),
# choose type of treeview
shiny::selectInput(inputId = "widgetChoice",
label = "View",
choices = c("None" = ""),
selectize = FALSE),

# choose type of mutation
shiny::selectInput(inputId = "mutationChoice",
label = "Mutation",
choices = character(0),
selectize = FALSE),

# choose type of sequence
shiny::selectInput(inputId = "sequenceChoice",
label = "Sequence",
choices = NULL,
selectize = FALSE),
id = "view-container",
shiny::div(
id = "view-selection",
htmltools::tags$details(
id = "sidebar-toggle",
open = "open",
`aria-role` = "button",
`aria-label` = "Toggle sidebar visibility",
htmltools::tags$summary(
shiny::span(">>"),
shiny::span("<<")
)
),
# choose type of treeview
shiny::selectInput(
inputId = "widgetChoice",
label = "View",
choices = c("None" = ""),
selectize = FALSE
),

# choose type of mutation
shiny::selectInput(
inputId = "mutationChoice",
label = "Mutation",
choices = character(0),
selectize = FALSE
),

# choose type of sequence
shiny::selectInput(
inputId = "sequenceChoice",
label = "Sequence",
choices = NULL,
selectize = FALSE
),
),
shiny::div(id="view-graphic",
# markdown files to add description
shiny::uiOutput("tree_md_files"),

# show treeview widget
shiny::wellPanel(
ggiraph::girafeOutput("treeview"),
style = "background: white; height: 1800px;",
),
shiny::br()
shiny::div(
id = "view-graphic",
# markdown files to add description
shiny::uiOutput("tree_md_files"),

# show treeview widget
shiny::wellPanel(
ggiraph::girafeOutput("treeview"),
style = "background: white; height: 1800px;",
),
shiny::br()
)
)
) # end fluid row
Expand All @@ -109,11 +89,10 @@ app_ui = function(request) {
shiny::tabPanel(
title = "About",
shiny::includeMarkdown(system.file("app", "www", "content", "about.md",
package = "tfpbrowser",
mustWork = TRUE))
package = "tfpbrowser",
mustWork = TRUE
))
)

) # end navbar page
) # end tag list

}
2 changes: 1 addition & 1 deletion R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#'
#' @return Scalar string. The data-directory for use in the app.

get_data_dir <- function() {
get_data_dir = function() {
Sys.getenv(
"APP_DATA_DIR",
system.file("app", "www", "data", package = "tfpbrowser")
Expand Down
Loading
Loading