Skip to content

Instantly share code, notes, and snippets.

@vjcitn
Created September 19, 2024 04:55
Show Gist options
  • Save vjcitn/a9f54717246b2f65057c5c8d6698fc98 to your computer and use it in GitHub Desktop.
Save vjcitn/a9f54717246b2f65057c5c8d6698fc98 to your computer and use it in GitHub Desktop.
small app for zarr store of xenium
library(shiny)
library(xenLite)
library(SpatialExperiment)
what = "LUAD"
ui = fluidPage(
sidebarLayout(
sidebarPanel(
uiOutput("topbox"),
# uiOutput("secbox"),
sliderInput("xstart", "xstart", min=1, max=32000, step=500, value=19000),
sliderInput("ystart", "ystart", min=1, max=9000, step=100, value=8200),
sliderInput("width", "width", min=200, max=3000, step=100, value=2700),
radioButtons("imagetype", "image", choices=c("he_image",
"morphology_focus"))
# uiOutput("cellcount"),
# selectInput("gene", "gene", choices=sort(rowData(xspep)$Symbol), selected="EPCAM")
# actionButton("go", "go", class="btn-success")
),
mainPanel(
tabsetPanel(
tabPanel("cells", plotOutput("cells", height="600px", width="800px")),
# tabPanel("map", plotOutput("map", height="600px", width="600px")),
tabPanel("about", verbatimTextOutput("showx"))
)
)
)
)
server = function(input, output) {
doread = reactive({
sda = reticulate::import("spatialdata")
sda$read_zarr("/home/vincent/XEN_ZARR/lungdata.zarr")
})
output$cells = renderPlot({
dat = rast_zarr(doread(), xlim=c(input$xstart, input$xstart+input$width), ylim=c(input$ystart, input$ystart+input$width), image_name=input$imagetype,
target_width=900.)
ii = EBImage::Image(dat, colormode="Color")
plot(ii)
})
output$showx = renderPrint({
doread()
})
output$topbox = renderUI({
helpText(sprintf("xenLite package version %s; interactive view of TENx Xenium %s", packageVersion("xenLite"),
what))
})
output$secbox = renderUI({
helpText("Use 'map' tab to see complete cell layout. White rectangle is region of interest. Position and resize the region using sliders. Use checkbox and text field below to visualize positions of transcripts for a selected gene.")
})
}
runApp(list(ui=ui, server=server))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment