inst/protXploRApp/server/anaDiff.R

output$volcanoplot_rCharts <- renderHighchart({
   
    if (length(which(is.na(Biobase::exprs(rv$current.obj)))) > 0) {
        return()}

     result = tryCatch(
         {
            
    if ("logFC" %in% names(fData(rv$current.obj) )){
        
              df <- data.frame(x=fData(rv$current.obj)$logFC, 
                         y = -log10(fData(rv$current.obj)$P_Value),
                         index = as.character(rownames(rv$current.obj)),
                         stringsAsFactors = FALSE)
        #if (!is.null(input$tooltipInfo)){
        #    df <- cbind(df,fData(rv$current.obj)[input$tooltipInfo])
        #}
        rownames(df) <- rownames(rv$current.obj)
        colnames(df) <- gsub(".", "_", colnames(df), fixed=TRUE)
        names(rv$current.obj@experimentData@other) <- gsub(".", "_", names(rv$current.obj@experimentData@other), fixed=TRUE)
        
        if (ncol(df) > 3){
            colnames(df)[4:ncol(df)] <- 
                paste("tooltip_", colnames(df)[4:ncol(df)], sep="")
        }
        hc_clickFunction <- 
            JS("function(event) {Shiny.onInputChange('eventPointClicked', [this.index]);}")
        #             print("avant 5")
        cond <- c(rv$current.obj@experimentData@other$condition1,
                  rv$current.obj@experimentData@other$condition2)
        diffAnaVolcanoplot_rCharts(df,
                                   threshold_logFC = rv$current.obj@experimentData@other$threshold_logFC,
                                   conditions = cond,
                                   clickFunction=hc_clickFunction) 
    } else {
        # df <- data.frame(x=rv$resAnaDiff$logFC, 
        #                  y = -log10(rv$resAnaDiff$P_Value),
        #                  index = 1:nrow(fData(rv$current.obj)),
        #                  stringsAsFactors = FALSE)
        # if (!is.null(input$tooltipInfo)){
        #     df <- cbind(df,fData(rv$current.obj)[input$tooltipInfo])
        # }
        #  rownames(df) <- rownames(rv$current.obj)
        # colnames(df) <- gsub(".", "_", colnames(df), fixed=TRUE)
        # if (ncol(df) > 3){
        #     colnames(df)[4:ncol(df)] <- 
        #         paste("tooltip_", colnames(df)[4:ncol(df)], sep="")
        # }
        # hc_clickFunction <- 
        #     JS("function(event) {Shiny.onInputChange('eventPointClicked', [this.index]);}")
        # #             print("avant 5")
        # cond <- c(input$condition1, input$condition2)
        # diffAnaVolcanoplot_rCharts(df,
        #                            threshold_logFC = rv$seuilLogFC,
        #                            conditions = cond,
        #                            clickFunction=hc_clickFunction)
        # 
        
    }
         }
         , warning = function(w) {
             shinyjs::info(conditionMessage(w))
         }, error = function(e) {
             shinyjs::info(paste("titi",match.call()[[1]],":",
                                 conditionMessage(e),
                                 sep=" "))
         }, finally = {
            #cleanup-code
         })
    
    
})   
samWieczorek/ProtXploR documentation built on May 30, 2019, 8:16 a.m.