Skip to contents

The SimulateExtinctions function, can be used to test how the order of species extinctions, species-dependency on existing interaction strength, and rewiring potential might affect the stability of the network by comparing The extinction history and checking for secondary extinctions.

Usage

SimulateExtinctions(
  Network,
  Method,
  Order = NULL,
  NetworkType = "Trophic",
  clust.method = "cluster_infomap",
  IS = 0,
  Rewiring = FALSE,
  RewiringDist,
  RewiringProb = 0.5,
  verbose = TRUE,
  forceFULL = FALSE
)

Arguments

Network

a network representation as a an adjacency matrix, edgelist, or a network object

Method

a character with the options Mostconnected, Leastconnected and Ordered

Order

a numeric vector indexing order of primary extinctions. For Method = Mostconnected or Leastconnected Order must be NULL. If Order is not NULL, Method is internally forced to be Ordered.

NetworkType

a character with the options Trophic and Mutualistic - is used to calculate secondary extinctions.

clust.method

a character with the options cluster_edge_betweenness, cluster_label_prop or cluster_infomap, defaults to cluster_infomap

IS

either numeric or a named vector of numerics. Identifies the threshold of relative interaction strength which species require to not be considered secondarily extinct (i.e. IS = 0.3 leads to removal of all nodes which lose 70 percent of their interaction strength in the Network argument). If a named vector, names must correspond to vertex names in Network argument.

Rewiring

either a function or a named vector of functions. Signifies how rewiring probabilities are calculated from the RewiringDist argument. If FALSE, no rewiring is carried out.

RewiringDist

a numeric matrix of NxN dimension (N... number of nodes in Network). Contains, for example, phylogenetic or functional trait distances between nodes in Network which are used by the Rewiring argument to calculate rewiring probabilities. If Rewiring == function(x)x, this matrix is expected to contain probabilities of a connection being present between species-pairs.

RewiringProb

a numeric which identifies the threshold at which to assume rewiring potential is met.

verbose

Logical. Whether to report on function progress or not.

forceFULL

Logical. Whether to continue removal of nodes after initial order has been depleted. This will force the simulations to execute extinctions and check for secondary extinctions/new links until the network does not change anylonger.

Value

exports list containing a data frame with the characteristics of the network after every extinction and a network object containing the final network. The resulting data frame contains 11 columns that incorporate the topological index, the secondary extinctions, predation release, and total extinctions of the network in each primary extinction.

Details

When method is Mostconnected, the function takes the network and calculates which node is the most connected of the network, using total degree. Then remove the most connected node, and calculates the the topological indexes of the network and the number of secondary extinctions. This process is repeated until the entire network has gone extinct. When method is Leastconnected, this process prioritises nodes of lowest degree.

When method is Ordered, it takes a network, and extinguishes nodes using a custom order, then it calculates the secondary extinctions and plots the accumulated secondary extinctions.

When NetworkType = Trophic, secondary extinctions only occur for any predator, but not producers. If NetworkType = Mutualistic, secondary extinctions occur for all species in the network.

When clust.method = cluster_edge_betweenness computes the network modularity using cluster_edge_betweenness methods from igraph to detect communities When clust.method = cluster_label_prop computes the network modularity using cluster_label_prop methods from igraph to detect communities When clust.method = cluster_infomap computes the network modularity using cluster_infomap methods from igraph to detect communities, here the number of nb.trials are equal to the network size

Author

Derek Corcoran <derek.corcoran.barrios@gmail.com>

M. Isidora Ávila-Thieme <msavila@uc.cl>

Erik Kusch <erik.kusch@bio.au.dk>

Examples

# Mostconnected example
data("net")
SimulateExtinctions(Network = net, Method = "Mostconnected",
clust.method = "cluster_infomap")
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |======================================================================| 100%
#> Warning: Your network became completely unconnected before all primary extinctions were simulated. This happened at extinction step 4 out of 10
#> $sims
#>   Spp S L          C Link_density Modularity SecExt Pred_release Iso_nodes
#> 1   6 9 7 0.08641975    0.7777778  0.3163265      1            0         1
#> 2   7 7 4 0.08163265    0.5714286  0.0000000      0            2         2
#> 3   5 6 2 0.05555556    0.3333333  0.0000000      1            3         3
#> 4   2 4 0 0.00000000    0.0000000        NaN      1            3         4
#>   AccSecExt NumExt TotalExt
#> 1         1      1        2
#> 2         1      2        3
#> 3         2      3        5
#> 4         3      4        7
#> 
#> $R50
#> [1] 0.3
#> 
#> $R100
#> [1] 0.7
#> 
#> $Network
#>  Network attributes:
#>   vertices = 3 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = TRUE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 0 
#>     missing edges= 0 
#>     non-missing edges= 0 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#> No edge attributes
#> 

#first Ordered example
data("net")
SimulateExtinctions(Network = net, Order = c(1,2,3,4,5,6,7,8,9,10),
Method = "Ordered" , clust.method = "cluster_infomap")
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |======================================================================| 100%
#> Warning: Your network became completely unconnected before all primary extinctions were simulated. This happened at extinction step 4 out of 10
#> $sims
#>   Spp S L         C Link_density Modularity SecExt Pred_release Iso_nodes
#> 1   1 9 9 0.1111111    1.0000000  0.2901235      1            0         0
#> 2   2 7 6 0.1224490    0.8571429  0.0000000      1            0         0
#> 3   3 5 3 0.1200000    0.6000000  0.0000000      2            0         1
#> 4   4 2 1 0.2500000    0.5000000  0.0000000      1            0         0
#>   AccSecExt NumExt TotalExt
#> 1         1      1        2
#> 2         2      2        4
#> 3         4      3        7
#> 4         5      4        9
#> 
#> $R50
#> [1] 0.3
#> 
#> $R100
#> [1] 0.5
#> 
#> $Network
#>  Network attributes:
#>   vertices = 1 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = TRUE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 0 
#>     missing edges= 0 
#>     non-missing edges= 0 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#> No edge attributes
#> 

 #Second Ordered example
data("net")
SimulateExtinctions(Network = net, Order = c(2,8,9),
Method = "Ordered", clust.method = "cluster_infomap")
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |======================================================================| 100%
#> Warning: Primary extinctions of 9 skipped due to their prior extinction as secondary extinctions.
#> $sims
#>   Spp S L          C Link_density Modularity SecExt Pred_release Iso_nodes
#> 1   2 9 8 0.09876543    0.8888889  0.3671875      1            0         0
#> 2   8 7 4 0.08163265    0.5714286  0.3750000      1            0         1
#>   AccSecExt NumExt TotalExt
#> 1         1      1        2
#> 2         2      2        4
#> 
#> $R50
#> [1] 0.3
#> 
#> $R100
#> [1] 0.8
#> 
#> $Network
#>  Network attributes:
#>   vertices = 6 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = TRUE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 4 
#>     missing edges= 0 
#>     non-missing edges= 4 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#>  Edge attribute names: 
#>     weight 
#> 

#Network-Dependency Example
data("net")
SimulateExtinctions(Network = net, Order = c(2,8), IS = 0.3,
Method = "Ordered", clust.method = "cluster_infomap")
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |======================================================================| 100%
#> $sims
#>   Spp S L          C Link_density Modularity SecExt Pred_release Iso_nodes
#> 1   2 9 8 0.09876543    0.8888889  0.3671875      1            1         0
#> 2   8 7 4 0.08163265    0.5714286  0.3750000      1            0         1
#>   AccSecExt NumExt TotalExt
#> 1         1      1        2
#> 2         2      2        4
#> 
#> $R50
#> [1] 0.3
#> 
#> $R100
#> [1] 0.8
#> 
#> $Network
#>  Network attributes:
#>   vertices = 6 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = TRUE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 4 
#>     missing edges= 0 
#>     non-missing edges= 4 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#>  Edge attribute names: 
#>     weight 
#> 

 #Rewiring
data("net")
data(dist)
SimulateExtinctions(Network = net, Order = c(2,8), IS = 0.3,
# assuming an exponential decline in rewiring potential
# as values in RewiringDist increase
Rewiring = function(x){1-pexp(x, rate = 1/0.5)},
RewiringDist = dist, # distance matrix
RewiringProb = 0.2, # low threshold for rewiring potential
Method = "Ordered", clust.method = "cluster_infomap")
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |======================================================================| 100%
#> $sims
#>   Spp S L          C Link_density Modularity SecExt Pred_release Iso_nodes
#> 1   2 9 8 0.09876543    0.8888889  0.3671875      0            0         0
#> 2   8 8 6 0.10714286    0.7500000  0.2777778      0            0         0
#>   AccSecExt NumExt TotalExt
#> 1         0      1        1
#> 2         0      2        2
#> 
#> $R50
#> [1] 0.5
#> 
#> $R100
#> [1] 1
#> 
#> $Network
#>  Network attributes:
#>   vertices = 8 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 9 
#>     missing edges= 0 
#>     non-missing edges= 9 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#>  Edge attribute names: 
#>     weight 
#> 

#Rewiring, assuming dist contains probabilities
#' data("net")
data(dist)
SimulateExtinctions(Network = net, Order = c(2,8), IS = 0.3,
Rewiring = function(x){x}, # no changes to the RewiringDist object means
RewiringDist = dist, RewiringProb = 0.2,
Method = "Ordered", clust.method = "cluster_infomap")
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |===================================                                   |  50%
  |                                                                            
  |======================================================================| 100%
#> $sims
#>   Spp S L          C Link_density Modularity SecExt Pred_release Iso_nodes
#> 1   2 9 8 0.09876543    0.8888889  0.3671875      0            0         0
#> 2   8 8 6 0.10714286    0.7500000  0.2777778      0            0         0
#>   AccSecExt NumExt TotalExt
#> 1         0      1        1
#> 2         0      2        2
#> 
#> $R50
#> [1] 0.5
#> 
#> $R100
#> [1] 1
#> 
#> $Network
#>  Network attributes:
#>   vertices = 8 
#>   directed = TRUE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 8 
#>     missing edges= 0 
#>     non-missing edges= 8 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#>  Edge attribute names: 
#>     weight 
#> 

## mutualistic network example
data(mutual)
# tallying of first-order secondary extinctions only
SimulateExtinctions(Network = mutual, Order = 3, NetworkType = "Mutualistic",
IS = 1, forceFULL = FALSE)
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
#> $sims
#>   Spp S L         C Link_density Modularity SecExt Pred_release Iso_nodes
#> 1   3 9 6 0.1666667    0.6666667  0.6111111      3           NA         0
#>   AccSecExt NumExt TotalExt
#> 1         3      1        4
#> 
#> $R50
#> [1] 0.2
#> 
#> $R100
#> [1] 0.7
#> 
#> $Network
#>  Network attributes:
#>   vertices = 6 
#>   directed = FALSE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 2 
#>     missing edges= 0 
#>     non-missing edges= 2 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#>  Edge attribute names: 
#>     weight 
#> 
# tallying of all secondary extinctions until network contains no
#more potential secondary extinctions
SimulateExtinctions(Network = mutual, Order = 3, NetworkType = "Mutualistic",
IS = 1, forceFULL = TRUE)
#> 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
#> Warning: Primary extinctions of 7, 8, 9, 2, 4, 5, 10 skipped due to their prior extinction as secondary extinctions.
#> $sims
#>   Spp S L         C Link_density Modularity SecExt Pred_release Iso_nodes
#> 1   3 9 6 0.1666667    0.6666667  0.6111111      3           NA         0
#> 2   8 6 2 0.1333333    0.3333333  0.5000000      3           NA         2
#> 3   9 3 1 0.3333333    0.3333333  0.0000000      1           NA         1
#> 4   2 2 1 1.0000000    0.5000000  0.0000000      0           NA         0
#> 5   4 2 1 1.0000000    0.5000000  0.0000000      0           NA         0
#> 6   5 2 1 1.0000000    0.5000000  0.0000000      0           NA         0
#> 7  10 2 1 1.0000000    0.5000000  0.0000000      0           NA         0
#>   AccSecExt NumExt TotalExt
#> 1         3      1        4
#> 2         6      2        8
#> 3         7      3       10
#> 4         7      4       11
#> 5         7      5       12
#> 6         7      6       13
#> 7         7      7       14
#> 
#> $R50
#> [1] 0.2
#> 
#> $R100
#> [1] 0.3
#> 
#> $Network
#>  Network attributes:
#>   vertices = 2 
#>   directed = FALSE 
#>   hyper = FALSE 
#>   loops = FALSE 
#>   multiple = FALSE 
#>   bipartite = FALSE 
#>   total edges= 1 
#>     missing edges= 0 
#>     non-missing edges= 1 
#> 
#>  Vertex attribute names: 
#>     vertex.names 
#> 
#>  Edge attribute names: 
#>     weight 
#>