Context

Ferments du Futur (FdF)

Siduri: a user-friendly portal for fermentation

Galaxy

Connect Siduri and Galaxy

Express vs Core

Express vs core: UI and server code

  • No distinction between UI and server

  • Implicit elements placement

# Core
from shiny import App, reactive, render, ui
from datetime import datetime

app_ui = ui.page_fixed(
    ui.h1("Title"),
    ui.output_code("greeting"),
)

def server(input, output, session):
    @reactive.calc
    def time():
        reactive.invalidate_later(1)
        return datetime.now()

    @render.code
    def greeting():
        return f"Hello, world!\nIt's currently {time()}."

app = App(app_ui, server)
# Express
from shiny import reactive
from shiny.express import render, ui 
from datetime import datetime

ui.h1("Title")

@reactive.calc
def time():
    reactive.invalidate_later(1)
    return datetime.now()

@render.code
def greeting():
    return f"Hello, world!\nIt's currently {time()}."

Express vs core: UI containers

Containers as function in Shiny Core or as context in Shiny Express

# Core
from shiny import ui, render, App

app_ui = ui.page_sidebar(
    ui.sidebar(
        ui.input_text("txt_in", "Type something here:"),
        open="always",
    ),
    ui.card(
        ui.output_code("result"),
    )
)

def server(input, output, session):
    @render.code
    def result():
        return f"You entered '{input.txt_in()}'."

app = App(app_ui, server)
# Express
from shiny.express import input, render, ui

with ui.sidebar():
    ui.input_text("txt_in", "Type something here:")

with ui.card():
    @render.code
    def result():
        return f"You entered '{input.txt_in()}'."

Express vs core: Sum-up

Shiny Express

  • Since 2024
  • Easy for begginners
  • Almost all elements from Shiny Core
  • For Proof of Concept

Shiny Core

  • Since 2022
  • Easy to maintain
  • For large and long-lived app
  • Similar to R Shiny

Shiny R vs Python

Python vs R: Decorators vs functions

from shiny import ui, render, App

app_ui = ui.page_fluid(
    ui.input_slider("n", "N", 0, 100, 40),
    ui.output_text_verbatim("txt"),
)

def server(input, output, session):
    @render.text
    def txt():
        return f"n*2 is {input.n() * 2}"

app = App(app_ui, server)

library(shiny)

ui <- fluidPage(
  sliderInput("n", "N", 0, 100, 40),
  verbatimTextOutput("txt")
)

server <- function(input, output, session) {
  output$txt <- renderText({
    paste0("n*2 is ", input$n, " * 2")
  })
}

shinyApp(ui, server)

Python vs R: Differences in function names

from shiny import App, reactive, render, ui

app_ui = ui.page_fluid(
    ui.input_slider("n", "N", 0, 100, 40),
    ui.output_text_verbatim("txt"),
    ui.input_action_button("reset", "Reset"),
)

def server(input, output, session):
    @reactive.calc
    def val():
        return input.n()

    @reactive.effect
    def _():
        input.reset()
        ui.update_slider("n", value=40)

    @render.text
    def txt():
        return f"n*2 is {val() * 2}"

app = App(app_ui, server)

library(shiny)

ui <- fluidPage(
  sliderInput("n", "N", 0, 100, 40),
  verbatimTextOutput("txt"),
  actionButton("reset", "Reset")
)

server <- function(input, output, session) {

  val <- reactive({input$n})


  observe({
    input$reset
    updateSliderInput(session, "n", value = 40)
  })

  output$txt <- renderText({
    paste0("n*2 is ", val()," * 2")
  })
}

shinyApp(ui, server)

Python vs R: Sum-up

  • Very similar in UI and conception with Shiny Core
  • Some changes in name of functions
  • Unique Shiny Python Express mode to easily create POC
  • Enable Python users to explore Shiny capabilities without switching to R
  • Documentation can be tricky to find for Python

Siduri-x-Galaxy

Deployment

  • Deploy on Migale infrastructure for confidentiality reasons
  • Dedicated module developed by OpenSILEX to deploy Shiny app using ShinyProxy
  • Requires a zip archive containing the app and a Dockerfile
  • Allows both R and Python applications

Conclusion

Take home messages

  • Shiny Python is designed to attract Python users…
  • … but Python users may turn to streamlit, Flask or other web framework

  • Shiny Express is fun for POC but can be a mess for large app
  • Shiny R and Python are slighlty different
  • Not enough documentation about cybersecurity on Posit website

Perspective for Siduri-x-Galaxy

  • Find a ✨ catchy ✨ name for the application
  • Open the app to all OpenSILEX and Galaxy instances
  • Expand functionalities (workflow invocation, store Galaxy API key…)

Acknoledgements

Many thanks to:

  • The organisation comitee for this event
  • Migale facility and Siduri-dev team
  • Ferments du Futur program for funding this project