Created
March 8, 2025 11:19
-
-
Save vjcitn/699259c82e8a4da45b01704396d03135 to your computer and use it in GitHub Desktop.
explore cellNexus metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exploreCN = function() { | |
md = cellNexus::get_metadata() | |
vbls = colnames(md) | |
ui = fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
helpText("navigate metadata of cellNexus"), | |
checkboxGroupInput("vars", "vbls", | |
choices=sort(colnames(md)), inline=TRUE) | |
), | |
mainPanel( | |
tabsetPanel( | |
tabPanel("head", | |
DT::dataTableOutput("bag") | |
), | |
tabPanel("strat", | |
uiOutput("v1"), | |
uiOutput("v2"), | |
DT::dataTableOutput("strat") | |
) | |
) | |
) | |
) | |
) | |
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", "development_stage")) | |
}) | |
output$v2 = renderUI({ | |
radioButtons("factor", "x", c("sample_id", "sex", "tissue", "development_stage")) | |
}) | |
output$strat = DT::renderDataTable({ | |
validate(need(length(input$resp)>0, "pick y")) | |
validate(need(length(input$factor)>0, "pick x")) | |
validate(need(!(input$factor == input$resp), "keep x and y distinct")) | |
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