diff --git a/runs/shiny_prep/out/shiny_prep.RData b/runs/shiny/out/shiny_prep.RData similarity index 100% rename from runs/shiny_prep/out/shiny_prep.RData rename to runs/shiny/out/shiny_prep.RData diff --git a/runs/shiny/run.yml b/runs/shiny/run.yml new file mode 100644 index 0000000000000000000000000000000000000000..98c88c6cfa62eae5e623887de1d03f76f12d2095 --- /dev/null +++ b/runs/shiny/run.yml @@ -0,0 +1,3 @@ +in_kallisto_df: + class: File + path: ../sleuth/out/kallisto_df.csv \ No newline at end of file diff --git a/runs/shiny_plots.Rmd b/runs/shiny_plots.Rmd deleted file mode 100644 index 3a1e99cf680cdd3c67d2d5d55397db7e39147d13..0000000000000000000000000000000000000000 --- a/runs/shiny_plots.Rmd +++ /dev/null @@ -1,77 +0,0 @@ ---- -title: "Plot Talinum RNASeq data" -output: html_document -runtime: shiny ---- - -```{r setup, include=FALSE} -knitr::opts_chunk$set(echo = TRUE) -``` - - -```{r load_data, include=FALSE} - -load(file = "../runs/shiny_prep/out/shiny_prep.RData") - -``` - - -```{r load_libraries, message=TRUE, warning=TRUE, include=FALSE} - -# Load libraries - -library(kableExtra) -library(shiny) -library(RColorBrewer) -library(tidyverse) -``` - - -```{r, eval = FALSE, echo = FALSE} - -# 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() -``` - - -```{r shiny_part, echo=FALSE, message = F, error = FALSE, warning=FALSE} - -# 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) - }), - ) -) -``` diff --git a/runs/shiny_prep/run.cwl b/runs/shiny_prep/run.cwl deleted file mode 100644 index aa7ea15dbeb66f345b610edc8c2ba3b0043d7851..0000000000000000000000000000000000000000 --- a/runs/shiny_prep/run.cwl +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env cwl-runner - -cwlVersion: v1.2 -class: CommandLineTool - -inputs: -- id: r_script - type: File - inputBinding: - position: 0 -- id: out_folder - type: string - inputBinding: - position: 1 -- id: in_kallisto_df - type: File - inputBinding: - position: 2 - -outputs: -- id: outdir - type: - type: array - items: Directory - outputBinding: - glob: $(runtime.outdir)/$(inputs.out_folder) - -baseCommand: -- Rscript diff --git a/runs/shiny_prep/run.yml b/runs/shiny_prep/run.yml deleted file mode 100644 index 8e7954b4766c5dabe9c6c4bac267ad186782abef..0000000000000000000000000000000000000000 --- a/runs/shiny_prep/run.yml +++ /dev/null @@ -1,8 +0,0 @@ -cores: 1 -r_script: - class: File - path: ../../workflows/shiny_prep/shiny_prep.R -in_kallisto_df: - class: File - path: ../sleuth/out/kallisto_df.csv -out_folder: out \ No newline at end of file diff --git a/workflows/shiny/01-shiny-prep.R b/workflows/shiny/01-shiny-prep.R new file mode 100644 index 0000000000000000000000000000000000000000..b8ae084aa7c21681fda025b464f5eb349187a8a5 --- /dev/null +++ b/workflows/shiny/01-shiny-prep.R @@ -0,0 +1,10 @@ +#!/usr/bin/env Rscript + +args <- commandArgs(trailingOnly = T) +in_kallisto_df <- args[1] + +expression_data <- read.csv(file = in_kallisto_df) + +available_genes <- unique(expression_data$target_id) + +save(expression_data, available_genes, file = "01-shiny-prep.RData") diff --git a/workflows/shiny/01-shiny-prep.RData b/workflows/shiny/01-shiny-prep.RData new file mode 100644 index 0000000000000000000000000000000000000000..8750b371cd209ce904e08c21baac6b33a0be908a Binary files /dev/null and b/workflows/shiny/01-shiny-prep.RData differ diff --git a/workflows/shiny/01-shiny-prep.cwl b/workflows/shiny/01-shiny-prep.cwl new file mode 100644 index 0000000000000000000000000000000000000000..c79fdeec7154c8cf0638664ad6ffd3afaad75a77 --- /dev/null +++ b/workflows/shiny/01-shiny-prep.cwl @@ -0,0 +1,31 @@ +#!/usr/bin/env cwl-runner + +cwlVersion: v1.2 +class: CommandLineTool + +# hints: +# DockerRequirement: +# dockerPull: + +requirements: + - class: InitialWorkDirRequirement + listing: + - entryname: 01-shiny-prep.R + entry: + $include: 01-shiny-prep.R + - class: NetworkAccess + networkAccess: true + +baseCommand: [Rscript, 01-shiny-prep.R] + +inputs: + in_kallisto_df: + type: File + inputBinding: + position: 1 + +outputs: + outdir: + type: File + outputBinding: + glob: "01-shiny-prep.RData" \ No newline at end of file diff --git a/workflows/shiny/01-shiny-prep.yml b/workflows/shiny/01-shiny-prep.yml new file mode 100644 index 0000000000000000000000000000000000000000..b2ec0e3b78cda23f9085bd0625f52ecaabc25345 --- /dev/null +++ b/workflows/shiny/01-shiny-prep.yml @@ -0,0 +1,3 @@ +in_kallisto_df: + class: File + path: ../../runs/sleuth/results/kallisto_df.csv \ No newline at end of file diff --git a/workflows/shiny/02-shiny-app.R b/workflows/shiny/02-shiny-app.R new file mode 100644 index 0000000000000000000000000000000000000000..e2b3c8d56094dba4ebd5625a05d3878e22fd0c52 --- /dev/null +++ b/workflows/shiny/02-shiny-app.R @@ -0,0 +1,62 @@ + +#!/usr/bin/env Rscript + +args <- commandArgs(trailingOnly = T) +shiny_prep_data <- args[1] + +# Load libraries + +library(shiny) +library(RColorBrewer) + +# Load data + +load(file = shiny_prep_data) + +# Design app + +ui <- fluidPage( + + sidebarLayout( + sidebarPanel( + selectizeInput( + multiple = TRUE, "target", label = "Select Gene by target id", + selected = sample(available_genes, size = 3), + choices = NULL, # Start with no choices + options = list( + server = TRUE, # Enable server-side processing + delimiter = " ", + create = I("function(input, callback){return {value: input, text: input};}") + ) + ) + ), + mainPanel( + plotOutput("exPlot") + ) + ) +) + +# Server logic +server <- function(input, output, session) { + + # Dynamically load the available genes + observe({ + updateSelectizeInput(session, "target", choices = available_genes, server = TRUE) + }) + + output$exPlot <- renderPlot({ + plot_set <- subset(expression_data, target_id %in% input$target) + + # Facetted plot by gene + 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) + }) +} + +# Launch app + +shinyApp(ui, server) diff --git a/workflows/shiny_prep/shiny_prep.R b/workflows/shiny_prep/shiny_prep.R deleted file mode 100644 index 804ad85db72c912c214f19b868e6073316524bab..0000000000000000000000000000000000000000 --- a/workflows/shiny_prep/shiny_prep.R +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env Rscript - -################################################ -#### Read arguments from CLI -################################################ - -args <- commandArgs(trailingOnly = T) - -out_folder <- args[1] -in_kallisto_df <- args[2] - -################################################ -#### If it does not exist, create out dir -################################################ - -dir.create(out_folder, recursive = T, showWarnings = F) - -################################################ -#### Prep data for shiny app -################################################ - -expression_data <- read.csv(file = in_kallisto_df) - -available_genes <- unique(expression_data$target_id) - -save(expression_data, available_genes, file = paste(out_folder, 'shiny_prep.RData', sep = "/"))