correlation: Score based on best correlation

This commit is contained in:
Elias Projahn 2022-01-09 21:32:37 +01:00
parent 23bb499d3a
commit fa49a5a887
2 changed files with 13 additions and 23 deletions

View file

@ -1,5 +1,4 @@
#' Compute the mean correlation coefficient comparing gene distances with a set
#' of reference genes.
#' Score genes based on their correlation with the reference genes.
#'
#' @return An object of class `geposan_method`.
#'
@ -66,28 +65,21 @@ correlation <- function() {
progress(0.66)
# Compute the final score as the mean of known correlation
# scores. Negative correlations will correctly lessen the
# score, which will be clamped to zero as its lower bound.
# Genes with no possible correlations at all will be assumed
# to have a score of 0.0.
compute_score <- function(scores) {
score <- mean(scores, na.rm = TRUE)
if (is.na(score) | score < 0.0) {
score <- 0.0
}
score
}
# Find the highes correlation.
results[,
score := compute_score(as.matrix(.SD)),
max_correlation := max(.SD, na.rm = TRUE),
.SDcols = reference_gene_ids,
by = gene
]
# Normalize scores.
results[,
score := (max_correlation - min(max_correlation)) /
(max(max_correlation) - min(max_correlation))
]
# Normalize scores.
results[, .(gene, score)]
result(

View file

@ -2,8 +2,7 @@
% Please edit documentation in R/correlation.R
\name{correlation}
\alias{correlation}
\title{Compute the mean correlation coefficient comparing gene distances with a set
of reference genes.}
\title{Score genes based on their correlation with the reference genes.}
\usage{
correlation()
}
@ -11,6 +10,5 @@ correlation()
An object of class \code{geposan_method}.
}
\description{
Compute the mean correlation coefficient comparing gene distances with a set
of reference genes.
Score genes based on their correlation with the reference genes.
}