2017-03-01 6 views
0

반짝이는 서버를 사용하여 서버에 하나의 반짝이는 응용 프로그램을 배포했습니다. 샘플 예는 다음과 같습니다 :모든 패키지가로드 될 때까지 메시지 표시

ui.R

#library(shinyjs) 
library(shiny) 

#filenames <- list.files(path = "data",pattern="\\.csv$") 
#names(filenames) <- gsub(pattern = "\\.csv$", "", filenames) 
shinyUI(fluidPage(
    titlePanel(
    headerPanel( 
     h3("Testing....", 
     align="center", style="bold") 
    ) 
    ), 
    br(), 
    br(), 
    #useShinyjs(), ## initialize shinyjs to reset input files. 
    sidebarLayout(
    sidebarPanel(
     h5("Upload Data Files",style="bold"), 
     fileInput("files", 
       "Choose CSV/txt processed files or raw files", 
       multiple = "TRUE", 
       accept=c('text/csv', 
'text/comma-separated-values, 
text/plain', '.csv','.cel','.TXT','.txt')), 
#selectInput('dataset',"Choose platform annotation file", c("Please select a file" ='',filenames)), 
fluidRow(
    column(5, 
     radioButtons("radio", label = h5("Data uploaded"), 
         choices = list("Affymetrix" = 1, "Codelink" = 2, 
            "Illumina" = 3),selected = NULL) 
     ) 
), 
fluidRow(
    column(10, 
     h5("Differential Expression Call", style = "bold"), 
     checkboxInput("checkbox", 
         label = "Differential Expression", value = FALSE))), 
br(), 
uiOutput('AnnotationFile')), 
mainPanel(      
    tabsetPanel(id = "MamgedTabs", 
       tabPanel("Source-data", dataTableOutput("sourced")), 
       tabPanel("Annotation-data",dataTableOutput("annotation")) 
      ) 
) 
) 
) 
) 

server.R

#library(gcrma) 
#library(hgu133a.db) 
#library(hgu133acdf) 
#library(hgu133plus2.db) 
#library(hgu133plus2cdf) 
#library(hgu133a2frmavecs) 
#library(hgu133b.db) 
#library(hgu133bcdf) 
#library(hgu219.db) 
#library(hgu219cdf) 
#library(hgu95a.db) 
#library(hgu95acdf) 
#library(org.Hs.eg.db) 
#library(hgu133a2.db) 
#library(hgu133a2cdf) 
#library(hgu95av2.db) 
#library(hgu95av2cdf) 
#library(hgu133plus2cdf) 
#library(affyPLM) 
##library(makecdfenv) 
#library(parallel) 
#library(base) 
#library(S4Vectors) 
#library(IRanges) 
#library(stats4) 
#library(BiocInstaller) 
#library(Biobase) 
#library(BiocGenerics) 
#library(BiocParallel) 
#library(biomaRt) 
#library(Biostrings) 
#library(preprocessCore) 
#library(affyio) 
#library(zlibbioc) 
#library(graphics) 
#library(grDevices) 
#library(methods) 
#library(genefilter) 
#library(stats) 
#library(AnnotationDbi) 
#library(utils) 


## Defining the size of file to be accepted. Here it can accept any size. 
options(shiny.maxRequestSize= -1) 

shinyServer(function(input, output,session) { 
    filenames <- list.files(path = "data", pattern="\\.txt$") 
    names(filenames) <- gsub(pattern = "\\.txt$", "", filenames) 


    ## Dropdown box for chosing and loading annotation file 
    output$AnnotationFile = renderUI({ 
    if(!input$checkbox | (input$checkbox == T && input$radio != 2)){ 
     wellPanel(
     h5("Upload Annotation File"), 
     selectInput('dataset', "Choose platform annotation file", 
        c("Please select a file" = '', filenames), multiple = TRUE)) 
    } 
    }) 
}) 

당신이 server.R에서 보듯이, 내가로드 할 많은 패키지가 필요, 그것은 약간의 시간이 걸립니다. 아래의 코드

output$AnnotationFile = renderUI({ 
    if(!input$checkbox | (input$checkbox == T && input$radio != 2)){ 
     wellPanel(
     h5("Upload Annotation File"), 
     selectInput('dataset', "Choose platform annotation file", 
        c("Please select a file" = '', filenames), multiple = TRUE)) 
    } 
    }) 

는 숨기기 뭔가입니다 보여주는 것입니다 시간이 패키지를로드 할 가지고 있기 때문에, 표시되기까지 다소 시간이 걸리지 만, 때로는 전혀 표시되지 않습니다.

1) 내 응용 프로그램은 로컬에서 올바르게 작동하지만 서버에 배포 할 때이 동작을 보여줍니다. 어떤 이유?

2) 모든 패키지를로드 할 때까지 응용 프로그램이 준비 중이라는 메시지를 주 패널에 표시하려면 어떻게해야합니까?

편집 : 나는 shinyServer() 내부에 메시지를 표시 할 수 있습니다,하지만 그건 (또 ​​다시 모든 패키지를로드합니다) 그러나 내가 표시하고 시작시 모든 패키지를로드 할 각 세션입니다 신청. 즉, shinyServer() 외부에서 진행 메시지를 표시하는 방법

+0

'renderPrint'는 여러분과 여러분의 메시지를 표시하기 위해'print' 메소드를 사용하는 데 유용 할 수 있습니다. –

+0

'shinysky' 패키지에서'busyIndicator'를 사용할 수 있습니다. 더 자세한 정보는 다음을 참고하십시오 : [link] (https://github.com/AnalytixWare/ShinySky) – SBista

답변

1

: 여기 UPDATE 2

30 개 R 패키지, 한 줄에 하나의 텍스트 파일에 읽기 위해 진행률 표시 줄의 정교한 사용하는 것입니다 모든 패키지가로드 될 때까지 ui.R에 모든 패키지를 넣으면됩니다. 그 이유는 ui.Rserver.R 전에 실행되기 때문에 간단합니다. 따라서 모든 패키지를 상단에 넣을 수 있습니다 ui.R. 응용 프로그램이 시작되면, 그것은 응용 프로그램 (ui.R 부분)이 표시됩니다, 예를

당신이 server.R에 패키지를 사용하는 것처럼
#library(gcrma) 
#library(hgu133a.db) 
#library(hgu133acdf) 

shinyUI(fluidPage(
# your code... 
) 
) 

를 들어, 당신이 ui.R 코딩 한 인터페이스를 표시하기 전에 모든 패키지를로드합니다 내부적으로는 모든 패키지를로드 할 것입니다. 사용자가 알지 못할 수도있는 시간이 걸리므로 궁극적으로 응용 프로그램 작업에 혼란을 야기 할 수 있습니다. 이를 피하려면 ui.R 패키지를 사용하는 것이 좋습니다.

1

아마도 진행 표시기 또는 모달 대화 상자가 원하는 것일 수 있습니까? 당신이 당신의 응용 프로그램이 대기 할 경우

# server.R 
options(shiny.maxRequestSize = -1) 
shinyServer(function(input, output, session) { 
    withProgress(message = "Please wait", value = 0, expr = { 
    for (i in 1:30) { 
     source(textConnection(readLines("packages.txt", warn = FALSE)[i])) 
     incProgress(amount = 1/30, detail = paste0("Loading package ", i, "/30")) 
     Sys.sleep(time = 0.1) 
    } 
    }) 

    filenames <- list.files(path = "data", pattern = "\\.txt$") 
    names(filenames) <- gsub(pattern = "\\.txt$", "", filenames) 

    output$AnnotationFile <- renderUI({ 
    if (!input$checkbox | (input$checkbox == T && input$radio != 2)) { 
     wellPanel(
     h5("Upload Annotation File"), 
     selectInput('dataset', "Choose platform annotation file", c("Please select a file" = '', filenames), multiple = TRUE) 
    ) 
    } 
    }) 
}) 
+0

감사합니다.'server.R'에서 observe 나 progress 지시자 안에'library()'를 포함하면 패키지는 로드되지 않았습니다 – AwaitedOne

+0

당신의 노력에 감사하지만 반짝 이는 패키지가'shinyServer (function (input, output, session) {.....}) '을 실행하기 전에로드된다는 것을 알고 있습니다.모든 것이로드 될 때까지 메시지를 표시하지 않습니다. – AwaitedOne

+0

그것은 나를 위해 로컬로 작동합니다. 코드가 작동하지 않습니까? – jsb