Add framework for progress information

This commit is contained in:
Elias Projahn 2021-10-19 15:03:10 +02:00
parent 16e83d38a8
commit 37f468658c
6 changed files with 76 additions and 11 deletions

View file

@ -2,7 +2,7 @@
#
# 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) {
proximity <- function(distances, preset, progress = NULL) {
# Prefilter distances by species and gene.
distances <- distances[
species %chin% preset$species_ids & gene %chin% preset$gene_ids
@ -14,5 +14,12 @@ proximity <- function(distances, preset) {
max_distance <- distances[, max(mean_distance)]
distances[, score := 1 - mean_distance / max_distance]
if (!is.null(progress)) {
# We do everything in one go, so it's not possible to report detailed
# progress information. As the method is relatively quick, this should
# not be a problem.
progress(1.0)
}
distances[, .(gene, score)]
}