mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 18:57:25 +01:00
proximity: Use median distance by default
This commit is contained in:
parent
99bc6794b9
commit
2fb48be0e3
2 changed files with 25 additions and 11 deletions
|
|
@ -1,39 +0,0 @@
|
|||
#' Score the mean distance of genes to the telomeres across species.
|
||||
#'
|
||||
#' 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.
|
||||
#'
|
||||
#' @return An object of class `geposan_method`.
|
||||
#'
|
||||
#' @export
|
||||
proximity <- function() {
|
||||
method(
|
||||
id = "proximity",
|
||||
name = "Proximity",
|
||||
description = "Proximity to telomeres",
|
||||
function(preset, progress) {
|
||||
species_ids <- preset$species_ids
|
||||
gene_ids <- preset$gene_ids
|
||||
|
||||
cached("proximity", c(species_ids, gene_ids), {
|
||||
# Prefilter distances by species and gene.
|
||||
data <- geposan::distances[
|
||||
species %chin% preset$species_ids &
|
||||
gene %chin% preset$gene_ids
|
||||
]
|
||||
|
||||
# Compute the score as described above.
|
||||
data <- data[, .(mean_distance = mean(distance)), by = "gene"]
|
||||
max_distance <- data[, max(mean_distance)]
|
||||
data[, score := 1 - mean_distance / max_distance]
|
||||
|
||||
progress(1.0)
|
||||
|
||||
result(
|
||||
method = "proximity",
|
||||
scores = data[, .(gene, score)]
|
||||
)
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue