diff --git a/R/analyze.R b/R/analyze.R index e443ca0..4fbd2a6 100644 --- a/R/analyze.R +++ b/R/analyze.R @@ -52,7 +52,7 @@ analyze <- function(preset, progress = NULL) { method_results <- methods[[method_id]]( preset, progress = method_progress - ) + )$results setnames(method_results, "score", method_id) diff --git a/R/clusteriness.R b/R/clusteriness.R index d884000..bbbdc75 100644 --- a/R/clusteriness.R +++ b/R/clusteriness.R @@ -65,6 +65,14 @@ clusteriness <- function(preset, progress = NULL) { score } - results[, score := compute(gene), by = 1:nrow(results)] + structure( + list( + results = results[, + score := compute(gene), + by = gene + ] + ), + class = "geposan_method_results" + ) }) } diff --git a/R/correlation.R b/R/correlation.R index 60831a1..45677cf 100644 --- a/R/correlation.R +++ b/R/correlation.R @@ -76,6 +76,14 @@ correlation <- function(preset, progress = NULL) { ] results[, .(gene, score)] + + structure( + list( + results = results[, .(gene, score)], + all_correlations = results + ), + class = "geposan_method_results" + ) } ) } diff --git a/R/neural.R b/R/neural.R index 7e78a2b..f60354c 100644 --- a/R/neural.R +++ b/R/neural.R @@ -120,7 +120,7 @@ neural <- function(preset, progress = NULL, seed = 49641) { colnames(training_matrix) <- NULL training_matrix <- keras::normalize(training_matrix) - keras::fit( + fit <- keras::fit( model, x = training_matrix, y = training_data$score, @@ -142,22 +142,40 @@ neural <- function(preset, progress = NULL, seed = 49641) { progress_buffer <<- progress_buffer + progress_step progress(progress_buffer) } + + list( + training_gene_ids = training_gene_ids, + gene_ids = gene_ids, + model = model, + fit = fit + ) } # Apply the network to all non-training genes first. - apply_network( + network <- apply_network( training_data$gene, gene_ids[!gene_ids %chin% training_data$gene] ) + cross_networks <- NULL + # Apply the network to the training genes leaving out the gene itself. for (training_gene_id in training_data$gene) { - apply_network( + cross_network <- apply_network( training_data[gene != training_gene_id, gene], training_gene_id ) + + cross_networks <- c(cross_networks, cross_network) } - data[, .(gene, score)] + structure( + list( + results = data[, .(gene, score)], + network = network, + cross_networks = cross_networks + ), + class = "geposan_method_results" + ) }) } diff --git a/R/proximity.R b/R/proximity.R index ec9e325..78b24a2 100644 --- a/R/proximity.R +++ b/R/proximity.R @@ -24,6 +24,11 @@ proximity <- function(preset, progress = NULL) { progress(1.0) } - data[, .(gene, score)] + structure( + list( + results = data[, .(gene, score)] + ), + class = "geposan_method_results" + ) }) }