Skip to content

Commit

Permalink
Save differential analyses as global variable, closes #99
Browse files Browse the repository at this point in the history
  • Loading branch information
nuno-agostinho committed Jun 11, 2016
1 parent 2456d7d commit f83a538
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
14 changes: 12 additions & 2 deletions R/begin.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ getInclusionLevels <- reactive(getCategoryData()[["Inclusion levels"]])
#' @param sep Character to separate identifiers
getGlobal <- function(..., sep="_") sharedData[[paste(..., sep=sep)]]

#' Get table of differential analyses
#' @note Needs to be called inside reactive function
#' @param category Character: data category (e.g. "Carcinoma 2016")
#'
#' @return Data frame of differential analyses
getDifferentialAnalyses <- function(category = getCategory())
getGlobal(category, "differentialAnalyses")

#' Get groups from a given data type
#' @note Needs to be called inside reactive function
#' @param dataset Character: data set (e.g. "Clinical data")
Expand Down Expand Up @@ -113,10 +121,12 @@ setInclusionLevels <- function(value, category = getCategory())
setGroupsFrom <- function(dataset, groups, category = getCategory())
setGlobal(category, dataset, "groups", value=groups)

#' Set table of differential analyses
#' @param table Character: differential analyses table
#' @param category Character: data category (e.g. "Carcinoma 2016")
#' @note Needs to be called inside reactive function
setGroupsFrom <- function(dataset, value, category = getCategory())
setAsGlobal(paste(category, dataset, "groups", sep = "_"), value)
setDifferentialAnalyses <- function(table, category = getCategory())
setGlobal(category, "differentialAnalyses", value=table)

#' Set clinical matches from a given data type
#' @note Needs to be called inside reactive function
Expand Down
52 changes: 29 additions & 23 deletions R/plots_differentialAnalysisTable.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,32 +92,38 @@ diffAnalysisTableServer <- function(input, output, session) {
df3 <- cbind(df2, deltaVar, deltaMed)
df4 <- data.frame(data.matrix(df3))
stats <- cbind(Event = rownames(df4), df4)

# Columns to show in statistical table
output$showColumns <- renderUI({
tagList(
hr(),
selectizeInput(ns("columns"), "Show columns", multiple=TRUE,
choices=colnames(stats),
selected=colnames(stats)))
})

# Render statistical table with the selected columns
output$statsTable <- renderDataTable({
cols <- colnames(stats) %in% input$columns
stats[, cols]
}, options=list(pageLength=10, scrollX=TRUE))

output$download <- downloadHandler(
filename = paste(getCategories(),
"Differential splicing analyses"),
content = function(file)
write.table(stats, file, quote=FALSE, row.names=FALSE,
sep="\t")
)
setDifferentialAnalyses(stats)
}
print(Sys.time() - time)
})

observe({
stats <- getDifferentialAnalyses()
if (is.null(stats)) return(NULL)

# Columns to show in statistical table
output$showColumns <- renderUI({
tagList(
hr(),
selectizeInput(ns("columns"), "Show columns", multiple=TRUE,
choices=colnames(stats),
selected=colnames(stats)))
})

# Render statistical table with the selected columns
output$statsTable <- renderDataTable({
cols <- colnames(stats) %in% input$columns
stats[, cols]
}, options=list(pageLength=10, scrollX=TRUE))

output$download <- downloadHandler(
filename = paste(getCategories(),
"Differential splicing analyses"),
content = function(file)
write.table(stats, file, quote=FALSE, row.names=FALSE,
sep="\t")
)
})
}

attr(diffAnalysisTableUI, "loader") <- "plots"
Expand Down

0 comments on commit f83a538

Please sign in to comment.