Skip to content

Commit

Permalink
Improve function documentation and add functions for get/setting spec…
Browse files Browse the repository at this point in the history
…ies and assembly version of a data group, closes #88
  • Loading branch information
nuno-agostinho committed Jun 27, 2016
1 parent 3e2984f commit 831dd76
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 20 deletions.
82 changes: 67 additions & 15 deletions R/begin.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,53 @@ getInclusionLevels <- reactive(getCategoryData()[["Inclusion levels"]])
#' @param sep Character to separate identifiers
getGlobal <- function(..., sep="_") sharedData[[paste(..., sep=sep)]]

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

#' Get the species of a data category
#' @note Needs to be called inside reactive function
#'
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
#'
#' @return Character value with the species
getSpecies <- function(category = getCategory())
getGlobal(category, "species")

#' Get the assembly version of a data category
#' @note Needs to be called inside reactive function
#'
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
#'
#' @return Character value with the assembly version
getAssemblyVersion <- function(category = getCategory())
getGlobal(category, "assemblyVersion")

#' Get groups from a given data type
#' @note Needs to be called inside reactive function
#'
#' @param dataset Character: data set (e.g. "Clinical data")
#' @param category Character: data category (e.g. "Carcinoma 2016")
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
#'
#' @return Matrix with groups of a given dataset
getGroupsFrom <- function(dataset, category = getCategory())
getGlobal(category, dataset, "groups")

#' Get clinical matches from a given data type
#' @param dataset Character: data set (e.g. "Junction quantification")
#' @param category Character: data category (e.g. "Carcinoma 2016")
#' @note Needs to be called inside reactive function
#'
#' @param dataset Character: data set (e.g. "Junction quantification")
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
getClinicalMatchFrom <- function(dataset, category = getCategory())
getGlobal(category, dataset, "clinicalMatch")

Expand Down Expand Up @@ -108,42 +134,68 @@ setActiveDataset <- function(dataset) setGlobal("activeDataset", value=dataset)

#' Set inclusion levels for a given data category
#' @note Needs to be called inside reactive function
#'
#' @param value Data frame or matrix: inclusion levels
#' @param category Character: data category (e.g. "Carcinoma 2016")
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
setInclusionLevels <- function(value, category = getCategory())
sharedData$data[[category]][["Inclusion levels"]] <- value

#' Set groups from a given data type
#' @note Needs to be called inside reactive function
#'
#' @param dataset Character: data set (e.g. "Clinical data")
#' @param groups Matrix: groups of dataset
#' @param category Character: data category (e.g. "Carcinoma 2016")
#' @note Needs to be called inside reactive function
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
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")
#' Set the table of differential analyses of a data category
#' @note Needs to be called inside reactive function
#'
#' @param table Character: differential analyses table
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
setDifferentialAnalyses <- function(table, category = getCategory())
setGlobal(category, "differentialAnalyses", value=table)

#' Set the species of a data category
#' @note Needs to be called inside reactive function
#'
#' @param value Character: species
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
setSpecies <- function(value, category = getCategory())
setGlobal(category, "species", value=value)

#' Set the assembly version of a data category
#' @note Needs to be called inside reactive function
#'
#' @param value Character: assembly version
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
setAssemblyVersion <- function(value, category = getCategory())
setGlobal(category, "assemblyVersion", value=value)

#' Set clinical matches from a given data type
#' @note Needs to be called inside reactive function
#'
#' @param dataset Character: data set (e.g. "Clinical data")
#' @param matches Vector of integers: clinical matches of dataset
#' @param category Character: data category (e.g. "Carcinoma 2016")
#' @param category Character: data category (e.g. "Carcinoma 2016"); by default,
#' it uses the selected data category
setClinicalMatchFrom <- function(dataset, matches, category = getCategory())
setGlobal(category, dataset, "clinicalMatch", value=matches)

#' Create an identifier for a given object
#'
#' @param ... Arguments to identify an object
#'
#' @details To make an object's identifier unique, use the names of the module,
#' To make an object's identifier unique, use the names of the module,
#' submodule, subsubmodule, ... as arguments before passing the name. Check the
#' example.
#'
#' @param ... Arguments to identify an object
#'
#' @return Character with underscores instead of spaces
#'
#' @examples
Expand Down
6 changes: 5 additions & 1 deletion R/data_3_inclusionLevels.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ inclusionLevelsServer <- function(input, output, session) {
startProgress("Reading alternative splicing annotation", divisions = 3)
annot <- readRDS(system.file("extdata", input$annotation,
package = "psichomics"))


# Set species and assembly version
if (grepl("Human", "Human (hg19/GRCh37)")) setSpecies("Human")
if (grepl("hg19", "Human (hg19/GRCh37)")) setAssemblyVersion("hg19")

# Calculate inclusion levels with annotation and junction quantification
updateProgress("Calculating inclusion levels")
junctionQuant <- getJunctionQuantification()
Expand Down
12 changes: 8 additions & 4 deletions R/plots_information.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ infoServer <- function(input, output, session) {
eventPosition <- event[4:(length(event)-1)]
eventPosition <- range(as.numeric(eventPosition))

path <- paste0("lookup/symbol/human/", gene)
info <- queryEnsembl(path, list(expand=1))
species <- tolower(getSpecies())
assembly <- getAssemblyVersion()
path <- paste0("lookup/symbol/", species, "/", gene)
grch37 <- assembly == "hg19"
info <- queryEnsembl(path, list(expand=1), grch37=grch37)

output$transcripts <- renderPlot({
transcripts <- data.frame()
Expand Down Expand Up @@ -99,7 +102,8 @@ infoServer <- function(input, output, session) {

tagList(
h2(info$display_name, tags$small(info$id)),
sprintf("Chromosome %s: %s-%s (%s strand)",
sprintf("Species: %s (assembly %s)", species, assembly),
br(), sprintf("Chromosome %s: %s-%s (%s strand)",
info$seq_region_name,
format(start, big.mark=",", scientific=FALSE),
format(end, big.mark=",", scientific=FALSE),
Expand All @@ -108,7 +112,7 @@ infoServer <- function(input, output, session) {
info$biotype), br(),
tags$a("Ensembl", icon("external-link"), target="_blank",
class="btn btn-link",
href=paste0("http://grch37.ensembl.org/human/",
href=paste0("http://grch37.ensembl.org/", species, "/",
"Gene/Summary?g=", info$id)),
tags$a("UCSC", icon("external-link"), target="_blank",
class="btn btn-link",
Expand Down

0 comments on commit 831dd76

Please sign in to comment.