diff --git a/R/analyze.R b/R/analyze.R index ea47a65..cf74297 100644 --- a/R/analyze.R +++ b/R/analyze.R @@ -45,9 +45,8 @@ analyze <- function(preset, progress = NULL) { # # A method describes a way to perform a computation on gene distance data # that results in a single score per gene. The function should accept the - # distances data, the preset to apply (see [preset()]) and an optional - # progress function (that may be called with a number between 0.0 and 1.0) - # as its parameters. + # preset to apply (see [preset()]) and an optional progress function (that + # may be called with a number between 0.0 and 1.0) as its parameters. # # The function should return a [data.table] with the following columns: # @@ -62,19 +61,14 @@ analyze <- function(preset, progress = NULL) { total_progress <- 0.0 method_count <- length(preset$method_ids) - results <- data.table(gene = genes$id) + results <- data.table(gene = preset$gene_ids) for (method_id in preset$method_ids) { method_progress <- if (!is.null(progress)) function(p) { progress(total_progress + p / method_count) } - method_results <- methods[[method_id]]( - distances, - preset, - method_progress - ) - + method_results <- methods[[method_id]](preset, method_progress) setnames(method_results, "score", method_id) results <- merge( diff --git a/R/clusteriness.R b/R/clusteriness.R index e8be0d9..91c0154 100644 --- a/R/clusteriness.R +++ b/R/clusteriness.R @@ -36,11 +36,11 @@ clusteriness_priv <- function(data, height = 1000000) { } # Process genes clustering their distance to telomeres. -clusteriness <- function(distances, preset, progress = NULL) { +clusteriness <- function(preset, progress = NULL) { results <- data.table(gene = preset$gene_ids) # Prefilter the input data by species. - distances <- distances[species %chin% preset$species_ids] + distances <- geposan::distances[species %chin% preset$species_ids] # Add an index for quickly accessing data per gene. setkey(distances, gene) diff --git a/R/correlation.R b/R/correlation.R index f6cdac8..a5f9422 100644 --- a/R/correlation.R +++ b/R/correlation.R @@ -1,12 +1,12 @@ # Compute the mean correlation coefficient comparing gene distances with a set # of reference genes. -correlation <- function(distances, preset, progress = NULL) { +correlation <- function(preset, progress = NULL) { species_ids <- preset$species_ids gene_ids <- preset$gene_ids reference_gene_ids <- preset$reference_gene_ids # Prefilter distances by species. - distances <- distances[species %chin% species_ids] + distances <- geposan::distances[species %chin% species_ids] # Tranform data to get species as rows and genes as columns. We construct # columns per species, because it requires fewer iterations, and transpose diff --git a/R/neural.R b/R/neural.R index bb2a3c6..0f7b05e 100644 --- a/R/neural.R +++ b/R/neural.R @@ -1,7 +1,7 @@ # Find genes by training a neural network on reference position data. # # @param seed A seed to get reproducible results. -neural <- function(distances, preset, progress = NULL, seed = 448077) { +neural <- function(preset, progress = NULL, seed = 448077) { species_ids <- preset$species_ids reference_gene_ids <- preset$reference_gene_ids @@ -9,7 +9,7 @@ neural <- function(distances, preset, progress = NULL, seed = 448077) { gene_count <- length(preset$gene_ids) # Prefilter distances by species. - distances <- distances[species %chin% species_ids] + distances <- geposan::distances[species %chin% species_ids] # Input data for the network. This contains the gene ID as an identifier # as well as the per-species gene distances as input variables. diff --git a/R/proximity.R b/R/proximity.R index 35d549f..d3f7b53 100644 --- a/R/proximity.R +++ b/R/proximity.R @@ -2,9 +2,9 @@ # # A score will be given to each gene such that 0.0 corresponds to the maximal # mean distance across all genes and 1.0 corresponds to a distance of 0. -proximity <- function(distances, preset, progress = NULL) { +proximity <- function(preset, progress = NULL) { # Prefilter distances by species and gene. - distances <- distances[ + distances <- geposan::distances[ species %chin% preset$species_ids & gene %chin% preset$gene_ids ]