mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 18:57:25 +01:00
analyze: Turn analysis into S3 class
This commit is contained in:
parent
55958e0d85
commit
4792bbaefd
1 changed files with 15 additions and 9 deletions
24
R/analyze.R
24
R/analyze.R
|
|
@ -5,9 +5,10 @@
|
||||||
#' function should accept a number between 0.0 and 1.0 for the current
|
#' function should accept a number between 0.0 and 1.0 for the current
|
||||||
#' progress.
|
#' progress.
|
||||||
#'
|
#'
|
||||||
#' @return A [data.table] with one row for each gene identified by it's ID
|
#' @return An object containing the results of the analysis. It contains a
|
||||||
#' (`gene` column). The additional columns contain the resulting scores per
|
#' [data.table] with one row for each gene identified by it's ID (`gene`
|
||||||
#' method and are named after the method IDs.
|
#' column). The additional columns contain the resulting scores per method
|
||||||
|
#' and are named after the method IDs.
|
||||||
#'
|
#'
|
||||||
#' @export
|
#' @export
|
||||||
analyze <- function(preset, progress = NULL) {
|
analyze <- function(preset, progress = NULL) {
|
||||||
|
|
@ -33,10 +34,10 @@ analyze <- function(preset, progress = NULL) {
|
||||||
"neural" = neural
|
"neural" = neural
|
||||||
)
|
)
|
||||||
|
|
||||||
cached("results", preset, {
|
analysis <- cached("analysis", preset, {
|
||||||
total_progress <- 0.0
|
total_progress <- 0.0
|
||||||
method_count <- length(preset$method_ids)
|
method_count <- length(preset$methods)
|
||||||
results <- data.table(gene = preset$gene_ids)
|
analysis <- data.table(gene = preset$gene_ids)
|
||||||
|
|
||||||
for (method_id in preset$methods) {
|
for (method_id in preset$methods) {
|
||||||
method_progress <- if (!is.null(progress)) {
|
method_progress <- if (!is.null(progress)) {
|
||||||
|
|
@ -48,8 +49,8 @@ analyze <- function(preset, progress = NULL) {
|
||||||
method_results <- methods[[method_id]](preset, method_progress)
|
method_results <- methods[[method_id]](preset, method_progress)
|
||||||
setnames(method_results, "score", method_id)
|
setnames(method_results, "score", method_id)
|
||||||
|
|
||||||
results <- merge(
|
analysis <- merge(
|
||||||
results,
|
analysis,
|
||||||
method_results,
|
method_results,
|
||||||
by = "gene"
|
by = "gene"
|
||||||
)
|
)
|
||||||
|
|
@ -61,6 +62,11 @@ analyze <- function(preset, progress = NULL) {
|
||||||
progress(1.0)
|
progress(1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
results
|
analysis
|
||||||
})
|
})
|
||||||
|
|
||||||
|
structure(
|
||||||
|
analysis,
|
||||||
|
class = c("geposan_analysis", class(analysis))
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue