Skip to content
Snippets Groups Projects
shiny_plots.Rmd 1.61 KiB
title: "Plot Talinum RNASeq data"
output: html_document
runtime: shiny
knitr::opts_chunk$set(echo = TRUE)

load(file = "../runs/shiny_prep/out/shiny_prep.RData")

# Load libraries

library(kableExtra)
library(shiny)
library(RColorBrewer)
library(tidyverse)

# Non-interactive test

current_selection <- sample(expression_data$target_id, 10)

plot_set <- subset(expression_data, target_id %in% current_selection)

ggplot(plot_set, aes(x = condition, y = tpm, group = condition)) +
  stat_summary(fun = "mean", geom = "bar") +
  geom_point(size = 0.5) +
  facet_wrap(~target_id, scales = "free") +
  theme_minimal()

# Let it shine

sidebarLayout(
  sidebarPanel(
    selectizeInput(
      multiple = T, "target", label = "Select Gene by target id",
      choices = available_genes,
      selected = sample(available_genes, size = 3),
      options = list(
        delimiter = " ",
        create = I("function(input, callback){return {value: input, text: input};}")
      )
    )
  ),
  mainPanel(
    renderPlot({
      plot_set <- subset(expression_data, target_id %in% input$target)

      ## Facetted by gene only

      ggplot(plot_set, aes(x = condition, y = tpm)) +
        stat_summary(fun = "mean", geom = "bar") +
        geom_point(size = 0.5) +
        facet_wrap(~target_id, scales = "free") +
        theme_minimal() +
        theme(aspect.ratio = 1)
    }),
  )
)