Created
February 1, 2022 19:32
-
-
Save vjcitn/70e70ad67d2f8b2cd66b807dd948edd1 to your computer and use it in GitHub Desktop.
sketch of app to work with mtmorgan/cellxgenedp
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
library(shiny) | |
library(cellxgenedp) | |
library(jsonlite) | |
db = try(db()) | |
if (inherits(db, "try-error")) stop("can't get db") | |
jsdb = fromJSON(db) # is character, makes data.frame! | |
nn = jsdb$name | |
names(nn) = paste(seq_len(nrow(jsdb)), nn) | |
colls = collections(db) | |
cname = colls$name | |
names(cname) = colls$collection_id | |
ds = datasets(db) | |
sds = split(ds, ds$collection_id) | |
names(sds) = cname[names(sds)] | |
nn = names(sds) | |
names(nn) = paste(seq_len(nrow(jsdb)), nn) | |
ui = fluidPage( | |
sidebarLayout( | |
sidebarPanel( | |
helpText("cellxgene data portal browser for AnVIL"), | |
selectInput("coll", "collections", choices=nn) | |
), | |
mainPanel( | |
dataTableOutput("curdat") | |
) | |
) | |
) | |
server = function(input, output, session) { | |
output$curdat = renderDataTable({ | |
tab0 = sds[[input$coll]] | |
isl = sapply(tab0, is.list) | |
tab1 = tab0[,-which(isl)] | |
tab1 = tab1[, c("name", "collection_visibility", "cell_count")] | |
tab2 = tab1 | |
assay = sapply(tab0$assay[[1]], "[", "label") | |
ds_id = tab0$dataset_id | |
cbind(tab2, assay=assay, dataset=ds_id) | |
}) | |
} | |
runApp(list(ui=ui, server=server)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment