mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 18:57:25 +01:00
correlation: Score based on best correlation
This commit is contained in:
parent
23bb499d3a
commit
fa49a5a887
2 changed files with 13 additions and 23 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
#' Compute the mean correlation coefficient comparing gene distances with a set
|
#' Score genes based on their correlation with the reference genes.
|
||||||
#' of reference genes.
|
|
||||||
#'
|
#'
|
||||||
#' @return An object of class `geposan_method`.
|
#' @return An object of class `geposan_method`.
|
||||||
#'
|
#'
|
||||||
|
|
@ -66,28 +65,21 @@ correlation <- function() {
|
||||||
|
|
||||||
progress(0.66)
|
progress(0.66)
|
||||||
|
|
||||||
# Compute the final score as the mean of known correlation
|
# Find the highes 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
|
|
||||||
}
|
|
||||||
|
|
||||||
results[,
|
results[,
|
||||||
score := compute_score(as.matrix(.SD)),
|
max_correlation := max(.SD, na.rm = TRUE),
|
||||||
.SDcols = reference_gene_ids,
|
.SDcols = reference_gene_ids,
|
||||||
by = gene
|
by = gene
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Normalize scores.
|
||||||
|
results[,
|
||||||
|
score := (max_correlation - min(max_correlation)) /
|
||||||
|
(max(max_correlation) - min(max_correlation))
|
||||||
|
]
|
||||||
|
|
||||||
|
# Normalize scores.
|
||||||
|
|
||||||
results[, .(gene, score)]
|
results[, .(gene, score)]
|
||||||
|
|
||||||
result(
|
result(
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
% Please edit documentation in R/correlation.R
|
% Please edit documentation in R/correlation.R
|
||||||
\name{correlation}
|
\name{correlation}
|
||||||
\alias{correlation}
|
\alias{correlation}
|
||||||
\title{Compute the mean correlation coefficient comparing gene distances with a set
|
\title{Score genes based on their correlation with the reference genes.}
|
||||||
of reference genes.}
|
|
||||||
\usage{
|
\usage{
|
||||||
correlation()
|
correlation()
|
||||||
}
|
}
|
||||||
|
|
@ -11,6 +10,5 @@ correlation()
|
||||||
An object of class \code{geposan_method}.
|
An object of class \code{geposan_method}.
|
||||||
}
|
}
|
||||||
\description{
|
\description{
|
||||||
Compute the mean correlation coefficient comparing gene distances with a set
|
Score genes based on their correlation with the reference genes.
|
||||||
of reference genes.
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue