【发布时间】:2019-07-18 20:12:23
【问题描述】:
我写了一个 Rshiny 应用程序。在这里,用户输入一个基因列表,应用程序会从中创建一个生物网络。示例输入如下所示。该代码在shinyapp 中作为R 脚本运行。输入是文本而不是数字。
在 SO here 上研究了类似的问题,但没有多大用处,我的输入是文本。
非常感谢任何帮助。
library(shiny)
library(shinydashboard)
library(STRINGdb)
sidebar <- dashboardSidebar(
sidebarMenu(
menuItem("Analysis", tabName = "analysis")
))
body <- dashboardBody(
tabItems(
# Text Area Input for gene list
tabItem(tabName = "analysis",
fluidRow(
box(
title = "Input gene list here", status = "warning", width
= 6, textAreaInput("title1","",value = "", width =
'100%',rows=5),
actionButton("submit", "Submit")
)
),
fluidRow(
box(
title = "Stirng DB network", status = "warning", width = 8, plotOutput("stringplot")
)
)
)))
# User interface --
ui <- dashboardPage(
dashboardHeader(title = "Analysis", titleWidth = 300),
sidebar,
body
)
# Server logic
server <- function(input, output) {
subset_dataset <- eventReactive(input$submit,
{data.frame(strsplit(input$title1,split='[\r\n]'),col.names='genes')})
output$stringplot <- renderPlot({
string_db <- STRINGdb$new()
mapped_genes <- string_db$map(subset_dataset,subset_dataset()$genes,removeUnmappedRows = TRUE)
hits_2<-mapped_genes$STRING_id
string_db$plot_network(hits_2)})
}
shinyApp(ui = ui, server = server)
示例输入为:
BRAF
NF1
NRAS
ERBB3
FLT3
PIK3CA
PTEN
TP53
CTNNB1
APC
SMAD4
NCOR1
【问题讨论】:
标签: r shiny shinydashboard