如何从单选按钮获取数据,从我读过的文件中绘图

时间:2017-04-18 12:06:13

标签: r shiny

我已经阅读了FCS文件并且我在单选按钮中获得了参数,我能够读取表格数据,但我不知道如何绘制数据。 这里有6个频道,如下所示。我以表格格式打印数据。enter image description here

我的ui.r脚本是

rm(list = ls())

library(shiny)
library(flowCore)


shinyUI(fluidPage(
 titlePanel("CD4/CD8 count GUI DEMO"),

 fluidRow(
column(3,
       fileInput('fcsFiles', strong('Choose fcs file:'), 
                 accept = c('text/fcs', '.fcs')),

       actionButton("goButton", "Submit!"),
       hr(),


       ## sample limits: 50
       uiOutput("sample_select"),

       lapply(1:50, function(i) {
         uiOutput(paste0('timeSlider', i))
       }),

       hr(),
       uiOutput(outputId= "marker_select"),

       uiOutput(outputId= "marker_select121"),
       hr()


),


sidebarPanel(


  numericInput("num1", label = h6("WBC COUNT"), value = 1,min = 0, max = NA, step = NA),

  hr(),
  fluidRow(column(3, verbatimTextOutput("wbc"))),

  numericInput("num2", label = h6("lymphocyte percentage"), value = 1,min = 0, max = NA, step = NA),

  hr(),

  fluidRow(column(3, verbatimTextOutput("lymphocyte"))),

  textOutput("ablymph"),
  uiOutput(outputId= "xaxis"),
  hr(),


  uiOutput(outputId= "yaxis"),
  hr(),


  actionButton("goButton", "Submit!")
),
mainPanel(
  tableOutput("filetable"),
  plotOutput("fowardside"),

  plotOutput("cd3plot"),
  plotOutput("cd4plot"),
  plotOutput("meplot"),
  plotOutput("cd8plot")

  )
 )
))

我的Server.R脚本是

rm(list = ls())


library(flowCore)
library(shiny)
library(flowViz)
library(flowStats)

shinyServer(function(input, output,session) {

output$ablymph <- renderText({
W <- input$num1
L <- input$num2
x <- W*(L/100)
paste("Absolute Lymphocytes Count is =", x)
})

set <- reactive({
if (input$goButton == 0)
  return()
isolate({fcsFiles<- input$fcsFiles
if (is.null(fcsFiles))
  return (NULL)
set <- read.flowSet(fcsFiles$datapath)
sampleNames(set)<- fcsFiles$name})
return(set)
print(set)
})


output$sample_select <- renderUI({
if(is.null(set())){
  return(NULL)
}else{

  checkboxGroupInput('samples', strong('Select samples:'), 
                     sampleNames(set()), selected = sampleNames(set()))
}   
}) 
markerNames <- reactive({
if(is.null(set()))
  return(NULL)
pd <- set()[[1]]@parameters@data
markers <- paste("<", pd$name, ">:", pd$desc, sep = "")
return(markers)
})

output$marker_select <- renderUI({
if(is.null(markerNames())){
  return(NULL)
}else{
  radioButtons(inputId = 'paras', label = ('Select markers for X-AXIS:'), 
                     choices =  markerNames(), selected = )
}   

})

output$marker_select121 <- renderUI({
if(is.null(markerNames())){
  return(NULL)
}else{
  radioButtons(inputId = 'paras1', label = ('Select markers for Y-AXIS:'), 
                     choices =  markerNames(), selected = NULL)
}   


})
output$filetable <- renderTable({
data1<- set()[[1]]@parameters@data
return(data1)
})
output$cd3plot<-renderPlot({
plot(set()[[1]]@parameters@data1[paras],set()[[1]]@parameters@data1[paras1])


})

})

任何人都可以帮助我 感谢

0 个答案:

没有答案