d.rank: Converts values to ranks, then ranks to desirabilities

Description Usage Arguments Details Value Examples

View source: R/d.rank.R

Description

Values are ranked from low to high or high to low, and then the ranks are mapped to a 0-1 scale.

Usage

1
d.rank(x, low.to.high, ties = "min")

Arguments

x

Vector of numeric or integer values.

low.to.high

If TRUE, low ranks have high desirabilities; if FALSE, high ranks have high desirabilities.

ties

Specifies how to deal with ties in the data. The value is passed to the 'ties.method' argument of the rank() function. Default is 'min'. See help(rank) for more information.

Details

If low values of a variable are desirable (e.g. p-values) set the argument low.to.high=TRUE, otherwise low.to.high=FALSE.

If extreme values in either direction are of interest (e.g. fold-changes), take the absolute value of the variable and use low.to.high=FALSE. See the example below.

This function is less flexible than the others but it can be used to compare the desirability approach with rank aggregation methods.

Value

Numeric vector of desirability values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
set.seed(1)
x1 <- rnorm(1000, mean=100, sd =5) # generate data
d <- d.rank(x1, low.to.high=TRUE)

# plot data
hist(x1, breaks=30)
# add line
des.line(x1, "d.rank", des.args=c(low.to.high=TRUE))

x2 <- rnorm(1000, mean=0, sd =5) # positive and negative values
# could be fold-changes, mean differences, or t-statistics
hist(abs(x2), breaks=30)
# add line
des.line(abs(x2), "d.rank", des.args=c(low.to.high=FALSE))

stanlazic/desiR documentation built on April 19, 2021, 11:03 a.m.