Skip to content
Snippets Groups Projects
index.qmd 23.6 KiB
Newer Older
Joseph Tran's avatar
Joseph Tran committed
title: "Développement d’une application Shiny et déploiement sur SK8"
subtitle: "AG CATI BARIC La Rochelle 2024"
Amandine Velt's avatar
Amandine Velt committed
author:
  - name: "Amandine Velt"
    orcid: "0000-0002-3287-0786"
    affiliations: "SVQV"
  - name: "Joseph Tran"
    orcid: "0000-0002-4624-0363"
    affiliations: "EGFV"
date: "2024-03-11"
date-format: long
from: markdown+emoji
Amandine Velt's avatar
Amandine Velt committed
format:
Joseph Tran's avatar
Joseph Tran committed
    footer: "Slides: [https://joseph.tran.pages.mia.inra.fr/quarto-shiny-sk8](https://joseph.tran.pages.mia.inra.fr/quarto-shiny-sk8)  •  Code: [Gitlab](https://forgemia.inra.fr/joseph.tran/quarto-shiny-sk8)"
    self-contained: false
    preview-links: true
Amandine Velt's avatar
Amandine Velt committed
    resources:
Amandine Velt's avatar
Amandine Velt committed
categories:
  - Shiny
  - SK8
  - R programming
image: assets/img/shiny-logo.png
draft: false
---

Amandine Velt's avatar
Amandine Velt committed
# Pourquoi utiliser R Shiny ?
Amandine Velt's avatar
Amandine Velt committed
## Comment communiquer autour de ses résultats R ?

[![Garrett Grolemund & Hadley Wickham](https://r4ds.hadley.nz/diagrams/data-science/communicate.png)](https://r4ds.hadley.nz/communicate)

## Comment communiquer autour de ses résultats R ?

En R simple, pour changer un paramètre, il faut modifier le code

::: {style="font-size: 0.8em"}
Amandine Velt's avatar
Amandine Velt committed
#| echo: fenced
#| code-line-numbers: "|6"
#| output-location: column-fragment
Amandine Velt's avatar
Amandine Velt committed
x <- faithful$waiting
# number of bins = 10
nbins <- 10
hist(x, breaks = nbins, col = "#75AADB",
     border = "white",
     xlab = "Waiting time to next eruption (in mins)",
     main = "Histogram of waiting times")
```
:::

## Comment communiquer autour de ses résultats R ? {.smaller}
Amandine Velt's avatar
Amandine Velt committed

En R simple, pour changer un paramètre, il faut modifier le code

::: {style="font-size: 0.8em"}
Amandine Velt's avatar
Amandine Velt committed
#| echo: fenced
#| code-line-numbers: "6"
Amandine Velt's avatar
Amandine Velt committed
#| output-location: column
x <- faithful$waiting
# number of bins = 50
nbins <- 50
hist(x, breaks = nbins, col = "#75AADB",
     border = "white",
     xlab = "Waiting time to next eruption (in mins)",
     main = "Histogram of waiting times")
```
:::

On aimerait avoir un slider pour le modifier rapidement
et sans avoir à modifier le code
Amandine Velt's avatar
Amandine Velt committed

. . .

::: {.callout-tip title="Solution avec Shiny"}
[Hello Application](https://prose.shinyapps.io/001-hello/)
:::
Amandine Velt's avatar
Amandine Velt committed

## Comment communiquer autour de ses résultats R ? {.smaller}
Amandine Velt's avatar
Amandine Velt committed

Shiny amène avec lui la réactivité

```{shinylive-r}
#| standalone: true
library(shiny)

# Define UI for app that draws a histogram ----
ui <- fluidPage(

  # App title ----
  titlePanel("Hello Shiny!"),

  # Sidebar layout with input and output definitions ----
  sidebarLayout(

    # Sidebar panel for inputs ----
    sidebarPanel(

      # Input: Slider for the number of bins ----
      sliderInput(inputId = "bins",
                  label = "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)

    ),

    # Main panel for displaying outputs ----
    mainPanel(

      # Output: Histogram ----
      plotOutput(outputId = "distPlot")

    )
  )
)

# Define server logic required to draw a histogram ----
server <- function(input, output) {

  # Histogram of the Old Faithful Geyser Data ----
  # with requested number of bins
  # This expression that generates a histogram is wrapped in a call
  # to renderPlot to indicate that:
  #
  # 1. It is "reactive" and therefore should be automatically
  #    re-executed when inputs (input$bins) change
  # 2. Its output type is a plot
  output$distPlot <- renderPlot({

    x    <- faithful$waiting
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    hist(x, breaks = bins, col = "#75AADB", border = "white",
         xlab = "Waiting time to next eruption (in mins)",
         main = "Histogram of waiting times")

    })

}

# Create Shiny app ----
shinyApp(ui = ui, server = server)
Amandine Velt's avatar
Amandine Velt committed
```

## Comment communiquer autour de ses résultats R ?

-   **Niveau 1 : Partager son code brute**
Amandine Velt's avatar
Amandine Velt committed
    -   Pas de contexte ou commentaire
    -   Peut être difficile à déchiffrer
    -   Aucune gestion des dépendances
-   **Niveau 2 : Utiliser un R Markdown**
Amandine Velt's avatar
Amandine Velt committed
    -   Rapport statique retraçant l’analyse
    -   Pas de ré-exécution possible

## Comment communiquer autour de ses résultats R ?

-   **Niveau 3 : Mettre en place une application Shiny**
Amandine Velt's avatar
Amandine Velt committed
    -   Interface graphique permettant de ne pas confronter l’utilisateur au code
    -   Paramètres modifiables et code ré-exécutable
    -   Possibilité d’exporter des plots et rapports
    -   L’utilisateur est responsable de l'installation de R et des packages

## Comment communiquer autour de ses résultats R ?

-   **Niveau 4 : Déployer l’application Shiny sur un serveur**
Amandine Velt's avatar
Amandine Velt committed
    -   L’application tourne sur un serveur dédié
    -   L’utilisateur n’a plus à se préoccuper de l’installation de R et des packages

## Communiquer autour de ses résultats R ? {.smaller}
Amandine Velt's avatar
Amandine Velt committed

::: columns
::: {.column width="40%" style="text-align: center;"}
Amandine Velt's avatar
Amandine Velt committed

![](https://www.rstudio.com/wp-content/uploads/2014/05/shinySiteBandOne.png){width=70% height=40%}
:::
Amandine Velt's avatar
Amandine Velt committed

::: {.column width="60%" style="text-align: center;"}
![](https://education.rstudio.com/blog/2020/07/palmerpenguins-cran/penguin-dashboard.jpeg){width=100% height=50%}
Amandine Velt's avatar
Amandine Velt committed

::: {style="text-align: center;"}
![](https://miro.medium.com/v2/resize:fit:4800/format:webp/1*5Ij1AccDmpjMazqt654fBA.png){width=40% height=5% text-align="center"}
Amandine Velt's avatar
Amandine Velt committed
:::
Amandine Velt's avatar
Amandine Velt committed

## Une documentation très complète {auto-animate="true"}

::: .r-stack
::: {data-id="shiny-doc" style="position: fixed; left: 10%;"}

![Shiny documentation](assets/img/shiny_documentation.png)
[Shiny documentation](https://shiny.posit.co/r/getstarted/shiny-basics/lesson1/index.html)
:::

## Une documentation très complète {auto-animate="true"}
::: .r-stack
::: {data-id="shiny-doc" style="position: fixed; left: 10%;" }
![Shiny gallery](assets/img/shiny_gallery.png)
[Shiny gallery](https://shiny.posit.co/r/gallery/)
:::
:::

## Une documentation très complète {auto-animate="true"}

::: .r-stack
::: {data-id="shiny-doc" style="position: fixed; left=10%;" }
![Shiny documentation](assets/img/shiny_documentation.png){width=55%}
[Shiny documentation](https://shiny.posit.co/r/getstarted/shiny-basics/lesson1/index.html)
:::

::: {data-id="shiny-doc" style="position: fixed; left: 55%;" }
![Shiny gallery](assets/img/shiny_gallery.png){width=80%}
[Shiny gallery](https://shiny.posit.co/r/gallery/)
:::
:::

# Fonctionnement d’une application Shiny

## Structure d’une application Shiny {auto-animate="true"}
::: .r-stack
::: {data-id="shinyapp_ui" style="position: fixed; left=10%;" }
```{r filename="ui.R"}
#| echo: fenced
#| eval: false
#| code-line-numbers: "16-35"
# This is the user-interface definition of a Shiny web application. You change
# run the application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here :
#
#      http://shiny.rstudio.com/
#

library(shiny)
library(shinythemes)

# Define UI for application that draws a Histogram
ui <- fluidPage(theme=shinytheme("flatly"),

  # Application titlePanel
  titlePanel("Old Faithful Geyser Data"),

  # Sidebar with a slider input for number of bins
  sidebarLayout(
    sidebarPanel(
      sliderInput("bins",
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),
    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("distPlot")
    )
  )
)
```
:::
## Structure d’une application Shiny {auto-animate="true"}

::: .r-stack
::: {data-id="shinyapp_server" style="position: fixed; left=10%;" }
```{r filename="server.R"}
#| echo: fenced
#| eval: false
#| code-line-numbers: "16-27"
#
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here :
#
#      http://shiny.rstudio.com/
#

library(shiny)

# Define server logic required to draw a histogram
server <- function(input, output, session){

  output$distPlot <- renderPlot({

    # generate bins based on input$bins from ui.R
    x <- faithful[,2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
}
```
:::
:::

## Structure d’une application Shiny

:::: columns
::: {.column width=50%}
::: {.fragment .fade-right width=50%}
```{r filename="app.R"}
#| echo: fenced
#| eval: false
#| code-line-numbers: "16-35"
# This is the user-interface definition of a Shiny web application. You change
# run the application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here :
#
#      http://shiny.rstudio.com/
#

library(shiny)
library(shinythemes)

# Define UI for application that draws a Histogram
ui <- fluidPage(theme=shinytheme("flatly"),

  # Application titlePanel
  titlePanel("Old Faithful Geyser Data"),

  # Sidebar with a slider input for number of bins
  sidebarLayout(
    sidebarPanel(
      sliderInput("bins",
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),
    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("distPlot")
    )
  )
)
```
:::
:::

::: {.column width=50%}
::: {.fragment .fade-left width=50%}
```{r filename="app.R"}
#| echo: fenced
#| eval: false
#| code-line-numbers: "16-27"
Joseph Tran's avatar
Joseph Tran committed
#
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here :
#
#      http://shiny.rstudio.com/
#

library(shiny)

# Define server logic required to draw a histogram
server <- function(input, output, session){

  output$distPlot <- renderPlot({

    # generate bins based on input$bins from ui.R
    x <- faithful[,2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
}
```
:::
:::
::::

## Fonctionnement d’une application Shiny

![Shiny gallery](assets/img/fonctionnement_appli_shiny.png)
## Fonctionnement d’une application Shiny

![Shiny gallery](assets/img/fonctionnement_appli_shiny2.png)

## Fonctionnement d’une application Shiny

::: columns
::: {.column width="50%"}
```{r filename="ui.R"}
#| eval: false
#| code-line-numbers: "24-29,32"
# This is the user-interface definition of a Shiny web application. You change
# run the application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here :
#
#      http://shiny.rstudio.com/
#

library(shiny)
library(shinythemes)

# Define UI for application that draws a Histogram
ui <- fluidPage(theme=shinytheme("flatly"),

  # Application titlePanel
  titlePanel("Old Faithful Geyser Data"),

  # Sidebar with a slider input for number of bins
  sidebarLayout(
    sidebarPanel(
      sliderInput("bins",
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    ),
    # Show a plot of the generated distribution
    mainPanel(
      plotOutput("distPlot")
    )
  )
)
```
:::

::: {.column width="50%"}
```{r filename="server.R"}
#| code-line-numbers: "18-26"
#
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Find out more about building applications with Shiny here :
#
#      http://shiny.rstudio.com/
#

library(shiny)

# Define server logic required to draw a histogram
server <- function(input, output, session){

  output$distPlot <- renderPlot({

    # generate bins based on input$bins from ui.R
    x <- faithful[,2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)

    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
}
```
:::
:::
![](assets/img/widgets_inputs.png){width=60%}
[Widgets d'inputs](https://shiny.rstudio.com/gallery/widget-gallery.html)

## Les différents types d'outputs

![](assets/img/outputs_shiny.png)

[Rendering functions](https://shiny.posit.co/r/getstarted/build-an-app/reactive-flow/render-functions.html)

## Structure du dossier d’une application Shiny

![](assets/img/structure_dossier.png)
# Côté UI : Focus sur les layouts
## Les layouts
-   Le framework Bootstrap qu’utilise Shiny définit une page comme une grille :
    -   Une page (fluidPage()) est divisée en colonnes (column()) et en ligne (fluidRow())
    -   La hauteur d’une ligne est celle de son plus grand élément
    -   La page est de taille 12 : une colonne de largeur (width) 6 occupera donc la moitié de l’espace horizontal
![](assets/img/fluidRow.png){width=50%}
## Les layouts

::: columns
::: {.column width="50%"}
``` r
#| echo: fenced
#| code-line-numbers: "14|16|17|48"
#| output-location: column
library(ggvis)

# For dropdown menu
actionLink <- function(inputId, ...) {
  tags$a(href='javascript:void',
         id=inputId,
         class='action-button',
         ...)
}

fluidPage(
  titlePanel("Movie explorer"),
  fluidRow(
    column(3,
      wellPanel(
        h4("Filter"),
        sliderInput("reviews", "Minimum number of reviews on Rotten Tomatoes",
          10, 300, 80, step = 10),
        sliderInput("year", "Year released", 1940, 2014, value = c(1970, 2014),
          sep = ""),
        sliderInput("oscars", "Minimum number of Oscar wins (all categories)",
          0, 4, 0, step = 1),
        sliderInput("boxoffice", "Dollars at Box Office (millions)",
          0, 800, c(0, 800), step = 1),
        selectInput("genre", "Genre (a movie can have multiple genres)",
          c("All", "Action", "Adventure", "Animation", "Biography", "Comedy",
            "Crime", "Documentary", "Drama", "Family", "Fantasy", "History",
            "Horror", "Music", "Musical", "Mystery", "Romance", "Sci-Fi",
            "Short", "Sport", "Thriller", "War", "Western")
        ),
        textInput("director", "Director name contains (e.g., Miyazaki)"),
        textInput("cast", "Cast names contains (e.g. Tom Hanks)")
      ),
      wellPanel(
        selectInput("xvar", "X-axis variable", axis_vars, selected = "Meter"),
        selectInput("yvar", "Y-axis variable", axis_vars, selected = "Reviews"),
        tags$small(paste0(
          "Note: The Tomato Meter is the proportion of positive reviews",
          " (as judged by the Rotten Tomatoes staff), and the Numeric rating is",
          " a normalized 1-10 score of those reviews which have star ratings",
          " (for example, 3 out of 4 stars)."
        ))
      )
    ),
    column(9,
      ggvisOutput("plot1"),
      wellPanel(
        span("Number of movies selected:",
          textOutput("n_movies")
        )
      )
    )
  )
)
```
:::

::: {.column width="50%"}
![](assets/img/layouts.png)
:::
:::
Amandine Velt's avatar
Amandine Velt committed
## Les layouts prédéfinis

![](assets/img/layouts_predefinis.png)

## Les layouts prédéfinis

![](assets/img/layouts_predefinis2.png)

## Les layouts en onglets

![](assets/img/layouts_onglets.png)

## Shiny Dashboard {.smaller}

::: columns
::: {.column width="75%"}
[shinydashboard](https://rstudio.github.io/shinydashboard/)
Amandine Velt's avatar
Amandine Velt committed

![](assets/img/shiny_dashboard.png)
:::
::: {.column width="25%"}
::: {.callout-tip title="Shiny Dashboard alternatives" .smaller}
-   [shinydashboardPlus](https://rinterface.github.io/shinydashboardPlus/)
-   [shiny.semantic](https://appsilon.github.io/shiny.semantic/)
-   [bs4Dash](https://rinterface.github.io/bs4Dash/index.html)
-   [bslib](https://rstudio.github.io/bslib/)
:::
:::
:::
Amandine Velt's avatar
Amandine Velt committed

# Focus sur Shiny et la réactivité

Amandine Velt's avatar
Amandine Velt committed
## La réactivité des applications Shiny

![](assets/img/reactivite_1.png){width=80%}

## La réactivité des applications Shiny

![](assets/img/reactivite_2.png)

## La réactivité des applications Shiny

![](assets/img/reactivite_3.png)

## La réactivité des applications Shiny

![](assets/img/reactivite_4.png)

## La réactivité des applications Shiny

![](assets/img/reactivite_5.png)

## La réactivité des applications Shiny

![](assets/img/reactivite_6.png)

## La réactivité des applications Shiny

![](assets/img/reactivite_7.png)

# Exemples d’utilisations à INRAE

## Exemples d’appli

-   GREAT (Amandine) [GREAT](https://great.colmar.inrae.fr/login)
    -   Source : [Gitlab](https://gitlab.com/avelt/great/)

-   Easy16S (Cédric) [easy16S](https://genome.jouy.inra.fr/shiny/easy16S/)
    -   Source : [Gitlab](https://gitlab.irstea.fr/cedric.midoux/easy16S)

-   Rosetta (Andrea) [rosetta](http://ls-shiny-prod.uwm.edu/rosetta/)
    -   Source : [Github](https://github.com/andreamrau/rosetta)

# Les solutions de partage d’une application Shiny

## Partager son application Shiny


-   Partage du code avec l’utilisateur.
    -   via un package R que l’utilisateur installe en local
    -   via un dépôt GitHub (shiny::runGitHub et shiny::runURL)

::: {.callout-warning title="Inconvénient"}
Nécessite d’installer R/Rstudio et de gérer l'installation des dépendances
:::

## Partager son application Shiny {.smaller}

**Application shinylive**

[R Shiny Live demo in Quarto!](https://joseph.tran.pages.mia.inra.fr/r-shinylive-demo/)

```{shinylive-r}
#| standalone: true
#| viewerHeight: 500
library(shiny)
library(bslib)

# Define UI for app that draws a histogram ----
ui <- page_sidebar(
  sidebar = sidebar(open = "open",
    numericInput("n", "Sample count", 100),
    checkboxInput("pause", "Pause", FALSE),
  ),
  plotOutput("plot", height=600, width=700)
)

server <- function(input, output, session) {
  data <- reactive({
    input$resample
    if (!isTRUE(input$pause)) {
      invalidateLater(1000)
    }
    rnorm(input$n)
  })

  output$plot <- renderPlot({
    hist(data(),
      breaks = 40,
      xlim = c(-2, 2),
      ylim = c(0, 1),
      lty = "blank",
      xlab = "value",
      freq = FALSE,
      main = ""
    )

    x <- seq(from = -2, to = 2, length.out = 500)
    y <- dnorm(x)
    lines(x, y, lwd=1.5)

    lwd <- 5
    abline(v=0, col="red", lwd=lwd, lty=2)
    abline(v=mean(data()), col="blue", lwd=lwd, lty=1)

    legend("topright", legend = c("Normal", "Mean", "Sample mean"),
      col = c("black", "red", "blue"),
      lty = c(1, 2, 1),
      lwd = c(1, lwd, lwd),
      cex = 0.6
    )
  }, res=140)
}

# Create Shiny app ----
shinyApp(ui = ui, server = server)
```

## Partager son application Shiny {.smaller}

**Application shinylive**

YouTube video: guide pas à pas pour créer une application Shiny sans serveur

[![Creating a Serverless Shiny App using Quarto with R Shinylive](https://img.youtube.com/vi/6y2FnAugP8E/0.jpg)](https://www.youtube.com/watch?v=6y2FnAugP8E)

## Partager son application Shiny

**[shinyapps.io](https://docs.rstudio.com/shinyapps.io/)**
::: columns
::: {.column width="70%"}
::: {.callout-tip title="Shinyapps.io" .my-callout}
-   L’application est hébergée sur les serveurs de RStudio.
    -   formule gratuite : 5 applications Shiny avec un usage total cumulé de 25h/mois

    -   13$/mois → 25 applications et 100 heures actives
-   Déploiement en 1 clic
-   Dashboard de suivi convivial
::: {.column width="30%"} 
::: {.callout-important title="Inconvénient" .my-callout}
-   Dépendance à RStudio
-   Freemium
-   Taille de l’appli limité à 1Go (données externes comprises)
:::
Amandine Velt's avatar
Amandine Velt committed
## Partager son application Shiny

Amandine Velt's avatar
Amandine Velt committed

::: {.callout-tip title="version free"}
-   un processus R / application qui peut servir plusieurs utilisateurs
-   Limite : quand beaucoup d’utilisateurs, ils se bloquent les uns les autres.
:::
::: {.callout-important title="version payante"}
-   plusieurs processus R / application.
-   Des utilisateurs concurrents vont être partagés entre plusieurs processus.
  -   On peut paramétrer le nombre d’utilisateurs / process et le nombre de process est illimité (selon capacité du serveur)
-   **Inconvénient** : version pro très chère → 10000 €/ an
:::
Amandine Velt's avatar
Amandine Velt committed

## Partager son application Shiny

**[Shinyproxy](https://www.shinyproxy.io/documentation/)**
Amandine Velt's avatar
Amandine Velt committed

![](assets/img/shinyproxy.png)

## Partager son application Shiny {auto-animate="true"}
Amandine Velt's avatar
Amandine Velt committed

**Déploiement avec SK8 (version kickflip, 2023)**
Amandine Velt's avatar
Amandine Velt committed

Joseph Tran's avatar
Joseph Tran committed
::: {style="font-size: 0.75em"}
Projet porté par **Jean-François Rey** puis porté par le CATI IMOTEP et passage en Inter-CATIs (2022).
Amandine Velt's avatar
Amandine Velt committed

::: .r-stack
:::{data-id="sk8-workflow" style="position: fixed; " }
![](assets/img/sk8_workflow.png)
:::
:::{data-id="sk8-workflow_infra" style="position: fixed; left: 90%; bottom: 90%; opacity: 0; " }
Amandine Velt's avatar
Amandine Velt committed
![](assets/img/sk8_1.png)
:::
:::

## Partager son application Shiny {auto-animate="true"}

**Déploiement avec SK8 (version kickflip, 2023)**
Joseph Tran's avatar
Joseph Tran committed
::: {style="font-size: 0.75em"}
Projet porté par Jean-François Rey puis porté par le CATI IMOTEP et passage en Inter-CATIs (2022).
:::

::: .r-stack
Joseph Tran's avatar
Joseph Tran committed
:::{data-id="sk8-workflow" style="position: fixed; bottom: 1%; opacity: 0; " }
![](assets/img/sk8_workflow.png)
:::
:::{data-id="sk8-workflow_infra" style="position: fixed; " }
![](assets/img/sk8_1.png)
:::
:::
Amandine Velt's avatar
Amandine Velt committed

## Partager son application Shiny

**Déploiement avec SK8 (version kickflip, 2023)**
Amandine Velt's avatar
Amandine Velt committed

Joseph Tran's avatar
Joseph Tran committed
::: {style="font-size: 0.75em"}
Amandine Velt's avatar
Amandine Velt committed
Infrastructure fonctionnelle, 60+ applications hébergées
Joseph Tran's avatar
Joseph Tran committed
:::
Amandine Velt's avatar
Amandine Velt committed

![](assets/img/sk8_2.png)

## Partager son application Shiny

**Déploiement avec SK8 (version kickflip, 2023)**
Joseph Tran's avatar
Joseph Tran committed

::: {style="font-size: 0.75em"}
Amandine Velt's avatar
Amandine Velt committed
Quelques exemples @INRAE
Joseph Tran's avatar
Joseph Tran committed
:::
Amandine Velt's avatar
Amandine Velt committed

[![CiTIQUE-TRACKER](assets/img/sk8_3-1.png)](https://ci-tique-tracker.sk8.inrae.fr/){width=70%}

## Partager son application Shiny

**Déploiement avec SK8 (version kickflip, 2023)**
Joseph Tran's avatar
Joseph Tran committed

::: {style="font-size: 0.75em"}
Amandine Velt's avatar
Amandine Velt committed
Quelques exemples @INRAE
Joseph Tran's avatar
Joseph Tran committed
:::
Amandine Velt's avatar
Amandine Velt committed

[![loup-ecrins-genetique.sk8.inrae.fr](assets/img/sk8_3-2.png)](https://loup-ecrins-genetique.sk8.inrae.fr/){width=70%}

## Partager son application Shiny

**Déploiement avec SK8 (version kickflip, 2023)**
Joseph Tran's avatar
Joseph Tran committed

::: {style="font-size: 0.75em"}
Amandine Velt's avatar
Amandine Velt committed
Quelques exemples @INRAE
Joseph Tran's avatar
Joseph Tran committed
:::
Amandine Velt's avatar
Amandine Velt committed

[![ShinyIDEA](assets/img/sk8_3-3.png)](https://shinyidea.sk8.inrae.fr/){width=70%}

## Partager son application Shiny

**Déploiement avec SK8 (version kickflip, 2023)**
Amandine Velt's avatar
Amandine Velt committed

::: {style="font-size: 0.75em"}
Plus d'information sur le site web [https://sk8.inrae.fr](https://sk8.inrae.fr/)
:::

![Processus d'hébergement d'une application shiny sur SK8](assets/img/sk8_4.png)
Amandine Velt's avatar
Amandine Velt committed

## Take Home Message

::: {.callout-tip title="R Shiny"}
Amandine Velt's avatar
Amandine Velt committed
-   R Shiny permet de rendre un script R interactif, facilement

-   Possibilité d’utiliser des packages R d’analyse et de faire tourner une application web avec

-   R Shiny est la solution idéale pour partager des résultats R qui peuvent être explorés

-   Plusieurs solutions de déploiement existent et fonctionnent bien, selon les besoins
Amandine Velt's avatar
Amandine Velt committed

## Take Home Message

::: {.callout-warning title="R Shiny warnings"}
Amandine Velt's avatar
Amandine Velt committed
-   Nécessité de prendre du temps pour optimiser son code. Notamment, il faut optimiser ce que R charge en mémoire, car une application Shiny peut rapidement saturer la RAM d’une VM

-   Nécessité de pré-calculer au maximum ce qu’on veut représenter (car R peut être lent)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
## Sources : Références

[Shiny gallery](https://shiny.posit.co/r/gallery/)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
[Gallery widget](https://shiny.posit.co/r/gallery/widgets/widget-gallery/)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
[Show me Shiny](http://www.showmeshiny.com/)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
[CheatSheet](https://raw.githubusercontent.com/rstudio/cheatsheets/main/shiny.pdf)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
[CheatSheet VF](https://thinkr.fr/pdf/shiny-french-cheatsheet.pdf)

## Sources : Tuto

[Tuto officiel](https://shiny.posit.co/r/getstarted/shiny-basics/lesson1/index.html)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
[École Thématique GeoViz](https://geoviz.sciencesconf.org/data/pages/GeoViz2018_R_shiny.pdf)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
[Introduction à Shiny](http://perso.ens-lyon.fr/lise.vaudor/Tuto_Shiny/)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
[Formation IFB](https://github.com/IFB-ElixirFr/IFB_Shiny_training)
Amandine Velt's avatar
Amandine Velt committed

Amandine Velt's avatar
Amandine Velt committed
[Organisation de l’UI](https://speakerdeck.com/jcheng5/styling-shiny)

Amandine Velt's avatar
Amandine Velt committed

[Learnr tutoriel shiny](https://forgemia.inra.fr/joseph.tran/shiny-tutorial)