mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 18:57:25 +01:00
proximity: Remove use_positions
This commit is contained in:
parent
cfc5e7a6bf
commit
7bd63aa6d3
2 changed files with 6 additions and 15 deletions
|
|
@ -33,18 +33,15 @@ analyze <- function(preset, progress = NULL) {
|
||||||
# - `score` Score for the gene between 0.0 and 1.0.
|
# - `score` Score for the gene between 0.0 and 1.0.
|
||||||
methods <- list(
|
methods <- list(
|
||||||
"clusteriness" = clusteriness,
|
"clusteriness" = clusteriness,
|
||||||
"correlation" = correlation,
|
|
||||||
"proximity" = proximity,
|
|
||||||
"neural" = neural,
|
|
||||||
"clusteriness_positions" = function(...) {
|
"clusteriness_positions" = function(...) {
|
||||||
clusteriness(..., use_positions = TRUE)
|
clusteriness(..., use_positions = TRUE)
|
||||||
},
|
},
|
||||||
|
"correlation" = correlation,
|
||||||
"correlation_positions" = function(...) {
|
"correlation_positions" = function(...) {
|
||||||
correlation(..., use_positions = TRUE)
|
correlation(..., use_positions = TRUE)
|
||||||
},
|
},
|
||||||
"proximity_positions" = function(...) {
|
"proximity" = proximity,
|
||||||
proximity(..., use_positions = TRUE)
|
"neural" = neural,
|
||||||
},
|
|
||||||
"neural_positions" = function(...) {
|
"neural_positions" = function(...) {
|
||||||
neural(..., use_positions = TRUE)
|
neural(..., use_positions = TRUE)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,18 @@
|
||||||
#
|
#
|
||||||
# A score will be given to each gene such that 0.0 corresponds to the maximal
|
# 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.
|
# mean distance across all genes and 1.0 corresponds to a distance of 0.
|
||||||
proximity <- function(preset, use_positions = FALSE, progress = NULL) {
|
proximity <- function(preset, progress = NULL) {
|
||||||
species_ids <- preset$species_ids
|
species_ids <- preset$species_ids
|
||||||
gene_ids <- preset$gene_ids
|
gene_ids <- preset$gene_ids
|
||||||
|
|
||||||
cached("proximity", c(species_ids, gene_ids, use_positions), {
|
cached("proximity", c(species_ids, gene_ids), {
|
||||||
# Prefilter distances by species and gene.
|
# Prefilter distances by species and gene.
|
||||||
data <- geposan::distances[
|
data <- geposan::distances[
|
||||||
species %chin% preset$species_ids & gene %chin% preset$gene_ids
|
species %chin% preset$species_ids & gene %chin% preset$gene_ids
|
||||||
]
|
]
|
||||||
|
|
||||||
# Compute the score as described above.
|
# Compute the score as described above.
|
||||||
|
data <- data[, .(mean_distance = mean(distance)), by = "gene"]
|
||||||
data <- if (use_positions) {
|
|
||||||
data[, .(mean_distance = mean(position)), by = "gene"]
|
|
||||||
} else {
|
|
||||||
data[, .(mean_distance = mean(distance)), by = "gene"]
|
|
||||||
}
|
|
||||||
|
|
||||||
max_distance <- data[, max(mean_distance)]
|
max_distance <- data[, max(mean_distance)]
|
||||||
data[, score := 1 - mean_distance / max_distance]
|
data[, score := 1 - mean_distance / max_distance]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue