Skip to content

Instantly share code, notes, and snippets.

@vjcitn
Created March 7, 2025 23:00
Show Gist options
  • Save vjcitn/9f6dd449673cc5fbaf702eecb3f04bb5 to your computer and use it in GitHub Desktop.
Save vjcitn/9f6dd449673cc5fbaf702eecb3f04bb5 to your computer and use it in GitHub Desktop.
simple descriptive data interactively filtered, for CuratedAtlasQueryR
library(shiny)
library(CuratedAtlasQueryR)
library(dplyr)
library(rlang)
library(DT)
#' explore the CuratedAtlasQueryR metadata
#' @export
exploreCAQ = function() {
md = CuratedAtlasQueryR::get_metadata()
vbls = colnames(md)
ui = fluidPage(
sidebarLayout(
sidebarPanel(
helpText("navigate metadata of CuratedAtlasQueryR"),
checkboxGroupInput("vars", "vbls",
choices=colnames(md), inline=TRUE)
),
mainPanel(
tabsetPanel(
tabPanel("head",
DT::dataTableOutput("bag")
),
tabPanel("strat",
DT::dataTableOutput("strat"),
uiOutput("v1"),
uiOutput("v2")
)
)
)
)
)
server = function(input, output) {
output$bag = renderDataTable({
validate(need(length(input$vars)>0, "pick variable(s)"))
md |> head() |> dplyr::select(all_of(input$vars)) |> as.data.frame()
})
output$v1 = renderUI({
radioButtons("resp", "y", c("age_days", "disease"))
})
output$v2 = renderUI({
radioButtons("factor", "x", c("sample_id_db", "sex", "tissue"))
})
output$strat = DT::renderDataTable({
validate(need(length(input$resp)>0, "pick y"))
validate(need(length(input$factor)>0, "pick x"))
md |> dplyr::select(all_of(c(input$resp, input$factor))) |> group_by(!!sym(input$resp), !!sym(input$factor)) |>
summarise(n=n()) |> as.data.frame()
})
}
runApp(list(ui=ui, server=server))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment