threshold {MetNet} | R Documentation

## Threshold the statistical adjacency matrices

### Description

The function 'threshold' takes as input an 'AdjacencyMatrix' object containing 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"'). It will return this kind of information as a binary matrix in the form of an 'AdjacencyMatrix' object.

### Usage

    threshold(
      am,
      type = c("threshold", "top1", "top2", "mean"),
      args,
      values = c("all", "min", "max")
    )

### Arguments

`am` | 'AdjacencyMatrix' object of 'type' '"statistical"' as created from the function 'statistical'. The object will contain the adjacency matrices in the 'assay' slot.
`type` | 'character', either '"threshold"', '"top1', '"top2' or '"mean"'
`args` | 'list'. Depending on the 'type' arguments the list element will be different. In the case of 'type == "threshold"', 'args' has the entry 'filter' ('character' of length 1). The character vector will specify the kind of filtering applied to the adjacency matrices. Elements in 'filter' will refer to the 'assayNames', e.g. 'list(filter = "pearson_coef > 0.8")' will retain all edges with Pearson correlation coefficients > 0.8. 'list(filter = "pearson_coef > 0.8 & spearman_coef > 0.5")' will retain all edges with Pearson correlation coefficients > 0.8 AND Spearman correlation coefficients > 0.5. 'list(filter = "abs(pearson_coef) > 0.8 & spearman_coef > 0.5")' will retain all edges with Pearson correlation coefficients > 0.8 and < -0.8. In the case of 'type == "top1"', 'type == "top2"', or 'type == "mean"', 'args' has the entry 'n' ('numeric' of length 1), that denotes the number of top ranks written to the consensus matrix.
`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)

### Details

'values' has to be set carefully depending on if the 'AdjacencyMatrix' object 'am' is 'directed' or not.

In the case of 'type == "threshold"', 'args' has the entry 'filter' ('character' of length 1). The character vector will specify the kind of filtering applied to the adjacency matrices. Elements in 'filter' will refer to the 'assayNames', e.g. 'list(filter = "pearson_coef > 0.8")' will retain all edges with Pearson correlation coefficients > 0.8. 'list(filter = "pearson_coef > 0.8 & spearman_coef > 0.5")' will retain all edges with Pearson correlation coefficients > 0.8 AND Spearman correlation coefficients > 0.5. 'list(filter = "abs(pearson_coef) > 0.8 & spearman_coef > 0.5")' will retain all edges with Pearson correlation coefficients > 0.8 and < -0.8.

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 'am' is taken. For 'type = "top2"', the second best (i.e. second lowest) rank in 'am' is taken. For 'type = "mean"', the average rank in 'am' is taken. Subsequently the first 'n' unique ranks are returned.

### Value

'AdjacencyMatrix' object containing a binary adjacency matrix given the links supported by the 'type' and the 'args' (in the slot '"consensus"'. The object will furthermore contain the supplied data input, i.e. all assays from 'am'. The slot 'threshold' is set to 'TRUE'.

### 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()
    am_stat <- statistical(x, model = model)

    ## type = "threshold"
    args <- list(filter = "pearson_coef > 0.95 & spearman_coef > 0.95")
    threshold(am = am_stat, type = "threshold", args = args)

    ## type = "top1"
    args <- list(n = 10)
    threshold(am = am_stat, type = "top1", args = args)

    ## type = "top2"
    threshold(am = am_stat, type = "top2", args = args)

    ## type = "mean"
    threshold(am = am_stat, type = "mean", args = args)

[Package MetNet version 1.12.2 Index]