threshold {MetNet} | R Documentation

## Threshold the statistical adjacency matrices

### Description

The function 'threshold' takes as input a list of adjacency matrices as returned from the function 'statistical'. Depending on the 'type' argument, 'threshold' will identify the strongest link that are lower or higher a certain threshold ('type = "threshold"') or identify the top 'n' links ('type' either '"top1', '"top2' or '"mean"').

### Usage

    threshold(statistical, type, args, values = c("all", "min", "max"), ...)

### Arguments

`statistical` | 'list' containing adjacency matrices
`type` | 'character', either '"threshold"', '"top1', '"top2' or '"mean"'
`args` | 'list' of arguments, has to contain thresholds for weighted adjacency matrices depending on the statistical model (a named list, where names are identical to 'model's in 'statistical') or a numerical vector of length 1 that denotes the number of top ranks written to the consensus matrix (a named list with entry 'n')
`values` | 'character', take from the adjacency matrix all values ("all"), the minimum of the pairs ("min") or the maximum ("max") a^*_ij = min(a_ij, a_ji) a^*_ij = max(a_ij, a_ji)
`...` | parameters passed to the function 'consensus' in the 'sna' package (only for 'type = "threshold"')

### Details

The entries of 'args' differ depending on the argument 'type'. If 'type = "treshhold"', then 'args' has to contain numeric vector of length 1 with names equal to 'names(statistical)' for each 'model' ('names(statistical)') and the entry 'threshold', a numerical 'vector(1)' to threshold the consensus matrix after using the 'consensus' function from the 'sna' package. Depending on the chosen 'method' in 'consensus', the 'threshold' value of the consensus adjacency matrix should be chosen accordingly to report a connection by different statistical modelss.

When combining the adjacency matrices the 'threshold' value defines if an edge is reported or not. For 'method = "central.graph"' threshold should be set to 1 by default. For other values of 'method', the value should be carefully defined by the user.

If 'type' is equal to '"top1"', '"top2"' or '"mean"', then 'args' has to contain a numeric vector of length 1 that gives the number of top ranks included in the returned adjacency matrix. In this case values that are 0 for the models 'lasso', 'randomForest' and 'bayes' are set to 'NaN'; values from correlation (Pearson and Spearman, including for partial and semipartial correlation) and 'clr' and 'aracne' are taken as they are.

For 'type = "top1"', the best (i.e. lowest) rank in 'statistical' is taken. For 'type = "top2"', the second best (i.e. second lowest) rank in 'statistical' is taken. For 'type = "mean"', the average rank in 'statistical' is taken. Subsequently the first 'n' unique ranks are returned.

### Value

'matrix', binary adjacency matrix given the links supported by the 'type' and the 'args'

### Author(s)

Thomas Naake, thomasnaake@googlemail.com

### Examples

    data("x_test", package = "MetNet")
    x <- x_test[1:10, 3:ncol(x_test)]
    x <- as.matrix(x)
    model <- c("pearson", "spearman")
    args <- list("pearson" = 0.95, "spearman" = 0.95, n = 10)
    l <- statistical(x, model = model)

    ## type = "threshold"
    args <- list("pearson" = 0.95, "spearman" = 0.95, threshold = 1)
    threshold(statistical = l, type = "threshold", args = args)

    ## type = "top1"
    args <- list(n = 10)
    threshold(statistical = l, type = "top1", args = args)

    ## type = "top2"
    threshold(statistical = l, type = "top2", args = args)

    ## type = "mean"
    threshold(statistical = l, type = "mean", args = args)

[Package MetNet version 1.5.3 Index]