mirror of
https://github.com/johrpan/geposanui.git
synced 2025-10-26 19:27:24 +01:00
Reorganize source files and generalize presets
This commit is contained in:
parent
8104e9bd8a
commit
68354bf808
14 changed files with 119 additions and 147 deletions
20
process/proximity.R
Normal file
20
process/proximity.R
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
library(data.table)
|
||||
|
||||
#' 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.
|
||||
process_proximity <- function(distances, gene_ids, preset) {
|
||||
species_count <- length(preset$species_ids)
|
||||
|
||||
# Prefilter distances by species.
|
||||
distances <- distances[species %chin% preset$species_ids]
|
||||
|
||||
# Compute the score as described above.
|
||||
|
||||
distances <- distances[, .(mean_distance = mean(distance)), by = "gene"]
|
||||
max_distance <- distances[, max(mean_distance)]
|
||||
distances[, score := 1 - mean_distance / max_distance]
|
||||
|
||||
distances[, .(gene, score)]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue