From ae0643741a4e4d812ec1fb8611773b871dac99fb Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Thu, 7 Oct 2021 12:59:04 +0200 Subject: [PATCH] Add buttons to copy results --- server.R | 28 ++++++++++++++++++++++++++++ ui.R | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/server.R b/server.R index 8948c35..14d6a57 100644 --- a/server.R +++ b/server.R @@ -2,6 +2,7 @@ library(data.table) library(DT) library(gprofiler2) library(plotly) +library(rclipboard) library(shiny) source("init.R") @@ -100,6 +101,33 @@ server <- function(input, output) { ) }) + output$copy <- renderUI({ + results <- results() + + gene_ids <- results[, gene] + names <- results[name != "", name] + + genes_text <- paste(gene_ids, collapse = "\n") + names_text <- paste(names, collapse = "\n") + + splitLayout( + rclipButton( + "copy_ids_button", + "Copy gene IDs", + genes_text, + icon = icon("clipboard"), + width = "100%" + ), + rclipButton( + "copy_names_button", + "Copy gene names", + names_text, + icon = icon("clipboard"), + width = "100%" + ) + ) + }) + output$scatter <- renderPlot({ results <- results() diff --git a/ui.R b/ui.R index a162974..96cb2aa 100644 --- a/ui.R +++ b/ui.R @@ -1,8 +1,10 @@ library(DT) library(plotly) +library(rclipboard) library(shiny) ui <- fluidPage( + rclipboardSetup(), titlePanel("TPE-OLD candidates"), column( width = 3, @@ -59,6 +61,10 @@ ui <- fluidPage( wellPanel( h3("Results"), textOutput("synposis"), + div( + style = "margin-top: 16px", + uiOutput("copy") + ), div( style = "overflow-x: auto; overflow-y: auto; margin-top: 16px", DTOutput("genes")