diff --git a/R/analyze.R b/R/analyze.R index 28a5127..d813200 100644 --- a/R/analyze.R +++ b/R/analyze.R @@ -5,10 +5,14 @@ #' function should accept a number between 0.0 and 1.0 for the current #' progress. #' -#' @return An object containing the results of the analysis. It contains a -#' [data.table] with one row for each gene identified by it's ID (`gene` -#' column). The additional columns contain the resulting scores per method -#' and are named after the method IDs. +#' @returns An object containing the results of the analysis with the following +#' items: +#' \describe{ +#' \item{`preset`}{The preset that was used.} +#' \item{`results`}{A [data.table] with one row for each gene identified by +#' it's ID (`gene` column). The additional columns contain the resulting +#' scores per method and are named after the method IDs.} +#' } #' #' @export analyze <- function(preset, progress = NULL) { @@ -34,10 +38,10 @@ analyze <- function(preset, progress = NULL) { "neural" = neural ) - analysis <- cached("analysis", preset, { + results <- cached("analysis", preset, { total_progress <- 0.0 method_count <- length(preset$methods) - analysis <- data.table(gene = preset$gene_ids) + results <- data.table(gene = preset$gene_ids) for (method_id in preset$methods) { method_progress <- if (!is.null(progress)) { @@ -50,7 +54,7 @@ analyze <- function(preset, progress = NULL) { setnames(method_results, "score", method_id) analysis <- merge( - analysis, + results, method_results, by = "gene" ) @@ -62,11 +66,14 @@ analyze <- function(preset, progress = NULL) { progress(1.0) } - analysis + results }) structure( - analysis, - class = c("geposan_analysis", class(analysis)) + list( + preset = preset, + results = results + ), + class = "geposan_analysis" ) } diff --git a/R/ranking.R b/R/ranking.R index e55917d..b87cb42 100644 --- a/R/ranking.R +++ b/R/ranking.R @@ -7,9 +7,9 @@ #' @param weights Named list pairing method names with weighting factors. Only #' methods that are contained within this list will be included. #' -#' @returns A ranking object. The object extends the analysis with additional -#' columns containing the `score` and the `rank` of each gene. It will be -#' ordered by rank. +#' @returns A ranking object. The object extends the analysis result with +#' additional columns containing the `score` and the `rank` of each gene. It +#' will be ordered by rank. #' #' @export ranking <- function(analysis, weights) { @@ -17,7 +17,7 @@ ranking <- function(analysis, weights) { stop("Invalid analyis. Use geposan::analyze().") } - ranking <- copy(analysis) + ranking <- copy(analysis$results) ranking[, score := 0.0] for (method in names(weights)) { diff --git a/man/analyze.Rd b/man/analyze.Rd index bf4c6a9..b528f9f 100644 --- a/man/analyze.Rd +++ b/man/analyze.Rd @@ -14,10 +14,14 @@ function should accept a number between 0.0 and 1.0 for the current progress.} } \value{ -An object containing the results of the analysis. It contains a -\link{data.table} with one row for each gene identified by it's ID (\code{gene} -column). The additional columns contain the resulting scores per method -and are named after the method IDs. +An object containing the results of the analysis with the following +items: +\describe{ +\item{\code{preset}}{The preset that was used.} +\item{\code{results}}{A \link{data.table} with one row for each gene identified by +it's ID (\code{gene} column). The additional columns contain the resulting +scores per method and are named after the method IDs.} +} } \description{ Analyze by applying the specified preset. diff --git a/man/ranking.Rd b/man/ranking.Rd index c32a46d..93c7f39 100644 --- a/man/ranking.Rd +++ b/man/ranking.Rd @@ -13,9 +13,9 @@ ranking(analysis, weights) methods that are contained within this list will be included.} } \value{ -A ranking object. The object extends the analysis with additional -columns containing the \code{score} and the \code{rank} of each gene. It will be -ordered by rank. +A ranking object. The object extends the analysis result with +additional columns containing the \code{score} and the \code{rank} of each gene. It +will be ordered by rank. } \description{ This function takes the result of \code{\link[=analyze]{analyze()}} and creates a score by