mirror of
https://github.com/johrpan/geposan.git
synced 2025-10-26 10:47:25 +01:00
ranking: Add optimization for median
This commit is contained in:
parent
61422a6a06
commit
7d3bedb436
2 changed files with 6 additions and 3 deletions
|
|
@ -24,6 +24,7 @@
|
||||||
#' Available optimization targets are:
|
#' Available optimization targets are:
|
||||||
#'
|
#'
|
||||||
#' - `mean` Mean rank of the reference genes.
|
#' - `mean` Mean rank of the reference genes.
|
||||||
|
#' - `median` Median rank of the reference genes.
|
||||||
#' - `max` First rank of the reference genes.
|
#' - `max` First rank of the reference genes.
|
||||||
#' - `min` Last rank of the reference genes.
|
#' - `min` Last rank of the reference genes.
|
||||||
#'
|
#'
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,8 @@ ranking <- function(analysis, weights) {
|
||||||
#' @param analysis Results from [analyze()] or [ranking()].
|
#' @param analysis Results from [analyze()] or [ranking()].
|
||||||
#' @param methods Methods to include in the score.
|
#' @param methods Methods to include in the score.
|
||||||
#' @param reference_gene_ids IDs of the reference genes.
|
#' @param reference_gene_ids IDs of the reference genes.
|
||||||
#' @param target The optimization target. It may be one of "mean", "min" or
|
#' @param target The optimization target. It may be one of "mean", "median",
|
||||||
#' "max" and results in the respective rank being optimized.
|
#' "min" or "max" and results in the respective rank being optimized.
|
||||||
#'
|
#'
|
||||||
#' @returns Named list pairing method names with their optimal weights. This
|
#' @returns Named list pairing method names with their optimal weights. This
|
||||||
#' can be used as an argument to [ranking()].
|
#' can be used as an argument to [ranking()].
|
||||||
|
|
@ -72,8 +72,10 @@ optimal_weights <- function(analysis, methods, reference_gene_ids,
|
||||||
min(rank)
|
min(rank)
|
||||||
} else if (target == "max") {
|
} else if (target == "max") {
|
||||||
max(rank)
|
max(rank)
|
||||||
} else {
|
} else if (target == "mean") {
|
||||||
mean(rank)
|
mean(rank)
|
||||||
|
} else {
|
||||||
|
median(rank)
|
||||||
}]
|
}]
|
||||||
|
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue