dep.net: Generates the dependency network from Araujo et al. 2011.

Description Usage Arguments Author(s) Examples

View source: R/dep.net.R

Description

Models and conducts network pruning for a species dependency network calculated as pairwise conditional probabilities.

Usage

1
dep.net(x = "species in cols", zero.na = TRUE, prune = TRUE, diag.zero = TRUE)

Arguments

x

A matrix of species abundances with species in columns.

zero.na

Automatically make NA values zero.

prune

Reduce the size of the network using a confidence interval test.

diag.zero

Set the matrix diagonal (i.e. the trace) to zero.

Author(s)

Matthew K. Lau

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x = "species in cols", zero.na = TRUE, prune = TRUE, 
    diag.zero = TRUE, pos = TRUE) 
{
    out <- matrix(NA, nrow = ncol(x), ncol = ncol(x))
    for (i in 1:ncol(x)) {
        for (j in 1:ncol(x)) {
            if (pos) {
                out[i, j] <- calcDepend(x[, i], x[, j])
            }
            else {
                out[i, j] <- negDepend(x[, i], x[, j])
            }
        }
    }
    if (prune) {
        out.rm <- co.net(x, diag.zero = diag.zero)
        out[out.rm == 0] <- 0
    }
    else {
    }
    if (diag.zero) {
        diag(out) <- 0
    }
    rownames(out) <- colnames(out) <- colnames(x)
    if (zero.na) {
        out[is.na(out)] <- 0
    }
    return(out)
  }

ECGen/ComGenR documentation built on July 23, 2021, 11:44 p.m.