Skip to contents

Calculate a ranked matrix

Usage

rankedMatrix(object, ...)

# S4 method for matrix
rankedMatrix(
  object,
  MARGIN = 2L,
  method = c("increasing", "decreasing", "bidirectional"),
  tiesMethod = c("average", "first", "last", "random", "max", "min")
)

Arguments

object

Object.

MARGIN

integer(1). Direction to apply the function. 1 indicates rows, 2 indicates columns.

method

character(1). Rank the values in increasing, decreasing, or bidirectional order.

tiesMethod

character(1). How ties should be treated. See rank() for details.

...

Additional arguments.

Value

matrix.

Details

Ties are resolved automatically by calculating the average. See the ties.method parameter in rank() for details.

Note

Updated 2021-02-04.

See also

Examples

data(matrix_lfc, package = "AcidTest")
object <- matrix_lfc

## Increasing (negative to positive).
rankedMatrix(object, method = "increasing")
#>        contrast01 contrast02 contrast03 contrast04
#> gene01        1.0        7.0        6.0        8.0
#> gene02        2.0        4.5        8.0        6.0
#> gene03        3.0        2.0        2.0        1.0
#> gene04        4.5        1.0        4.5        7.0
#> gene05        4.5        6.0        3.0        4.5
#> gene06        6.0        4.5        4.5        2.0
#> gene07        7.0        8.0        7.0        4.5
#> gene08        8.0        3.0        1.0        3.0

## Decreasing (positive to negative).
rankedMatrix(object, method = "decreasing")
#>        contrast01 contrast02 contrast03 contrast04
#> gene01        8.0        2.0        3.0        1.0
#> gene02        7.0        4.5        1.0        3.0
#> gene03        6.0        7.0        7.0        8.0
#> gene04        4.5        8.0        4.5        2.0
#> gene05        4.5        3.0        6.0        4.5
#> gene06        3.0        4.5        4.5        7.0
#> gene07        2.0        1.0        2.0        4.5
#> gene08        1.0        6.0        8.0        6.0

## Bidirectional.
rankedMatrix(object, method = "bidirectional")
#>        contrast01 contrast02 contrast03 contrast04
#> gene01       -2.0        4.0        3.0        5.0
#> gene02       -1.0        1.5        5.0        3.0
#> gene03        0.0       -1.0       -1.0       -2.0
#> gene04        1.5       -2.0        1.5        4.0
#> gene05        1.5        3.0        0.0        1.5
#> gene06        3.0        1.5        1.5       -1.0
#> gene07        4.0        5.0        4.0        1.5
#> gene08        5.0        0.0       -2.0        0.0