networkSimplifier: Simplify an input network

Description Usage Arguments Details Value References Examples

View source: R/networkSimplifier.R

Description

Threshold and simplify an input network.

Usage

1
networkSimplifier(sub.graph, cutoff, conservative)

Arguments

sub.graph

An igraph-formatted network.

cutoff

The proportion of interactions a species needs to have won in order to be considered the winner.

conservative

TRUE or FALSE. Whether a tied interaction is set to a bidirectional edge or the edges are removed entirely.

Details

Takes a network and simplifies it according to a specified cutoff/threshold. Specifically, it checks for parallel edges between each species combination. If they exist, it calculates what proportion of interactions are A->B, and what proportion are B->A. If either of these proportions are at or above the cutoff, it sets that edge to 1, and the other edge to 0. If neither proportion is above the threshold, then it either sets both edges to 0, or both 1, depending on whether conservative is set to TRUE or FALSE.

Value

A simplified/thresholded igraph network.

References

Miller, E. T., D. N. Bonter, C. Eldermire, B. G. Freeman, E. I. Greig, L. J. Harmon, C. Lisle, and W. M. Hochachka. 2017. Fighting over food unites the birds of North America in a continental dominance hierarchy. biorxiv https://doi.org/10.1101/104133

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#load in the example data
data(exInput)

#subset to interactions between three species.
three <- c("Red-breasted Nuthatch","Downy Woodpecker","White-breasted Nuthatch")
small <- exInput[exInput$source %in% three & exInput$target %in% three,]

#convert into igraph network
complexNetwork <- igraph::graph.data.frame(small)

#plot to see what it looks like
plot(complexNetwork)

#simplify with a 50% conservative threshold
simpleNetwork <- networkSimplifier(complexNetwork, 0.5, TRUE)

#plot to see what it looks like
plot(simpleNetwork)

eliotmiller/networkTricks documentation built on Oct. 6, 2020, 4:23 p.m.