Title: | Analyze Interconnection Structure of Multilayer Interaction Networks |
---|---|
Description: | In view of the analysis of the structural characteristics of the multilayer network has been complete, however, there is still a lack of a unified operation that can quickly obtain the corresponding characteristics of the multilayer network. To solve this insufficiency, 'ILSM' was designed for supporting calculating such metrics of multilayer networks by functions of this R package. |
Authors: | WeiCheng Sun [aut, cre], Chuan Yan [aut], Yangyang Zhao [aut] |
Maintainer: | WeiCheng Sun <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.3.2 |
Built: | 2024-11-04 06:43:20 UTC |
Source: | CRAN |
Generating a network of three layers. All layers of network contain lay_0
, lay_1
and lay_2
nodes respectively.
build_net(lay_0, lay_1, lay_2, C_lay, asmatrices = FALSE)
build_net(lay_0, lay_1, lay_2, C_lay, asmatrices = FALSE)
lay_0 |
The number of nodes in the first layer. |
lay_1 |
The number of nodes in the second layer. |
lay_2 |
The number of nodes in the third layer. |
C_lay |
The probability of each node interact with the other one. It ranges from 0 to 1. |
asmatrices |
Logical. whether to output the overall adjacency matrix of the network and the corresponding interaction matrix of the respective subnetworks. Defaults to FALSE. |
Return a tripatite network of direction. The network contains three groups of species and interactions within layers, and there is no link among each group of nodes within one layer.
set.seed(12) d <- build_net(11,15,16,0.2) plot(d) set.seed(12) N <- build_net(11,15,16,0.2,asmatrices=FALSE) N
set.seed(12) d <- build_net(11,15,16,0.2) plot(d) set.seed(12) N <- build_net(11,15,16,0.2,asmatrices=FALSE) N
Calculating correlation of interaction degree among subnetworks ("CoID_~").
coid(network.or.subnet_mat1, subnet_mat2 = NULL, weighted = FALSE)
coid(network.or.subnet_mat1, subnet_mat2 = NULL, weighted = FALSE)
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
weighted |
Logical. should elements of matrix be fractional? Default to FALSE. Generally, 'igraph' network represent a spare matrix, so |
weighted
If the weighted
= FALSE, the input for the parameter can be:
network.or.subnet_mat1
: input a 'igraph' of network data independently or input sparse matrix together with subnet_mat2
.
If the weighted
= TRUE, the input for the parameter can be:
network.or.subnet_mat1
: must input matrix(or data.frame) together with subnet_mat2
. the matrix can be sparse matrix and matrix of interaction strength.
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
When the two matrices can have different numbers of rows:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
When the two matrices can have the same numbers of rows:
No matter how the row names of the two matrices are arranged, as long as the row names are exactly the same; But we don't handle matrices with empty row names (the function will give an error).
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
Return a numeric value representing correlation of interaction degree: CoID.
If weighted
= FALSE, the results will show "CoID= ;" and If weighted
= TRUE, the results will show "CoID_weight= ;"
Sauve, A. M., Thébault, E., Pocock, M. J., & Fontaine, C. (2016). How plants connect pollination and herbivory networks and their contribution to community stability. Ecology, 97(4), 908-917.
set.seed(12) d <- build_net(11,15,17,0.2) coid(d) md1<-matrix(sample(c(0,1),110,replace=TRUE),10,11) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) coid(md1,md2) coid(md1,md2,weighted=TRUE) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) coid(md1,md2) mdw1<-matrix(runif(110,0,1),10,11) mdw2<-matrix(runif(120,0,1),10,12) coid(mdw1,mdw2,weighted=TRUE) set.seed(1) mdw1<-matrix(runif(80,0,1),8,10) mdw2<-matrix(runif(120,0,1),10,12) coid(mdw1,mdw2,weighted=TRUE)
set.seed(12) d <- build_net(11,15,17,0.2) coid(d) md1<-matrix(sample(c(0,1),110,replace=TRUE),10,11) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) coid(md1,md2) coid(md1,md2,weighted=TRUE) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) coid(md1,md2) mdw1<-matrix(runif(110,0,1),10,11) mdw2<-matrix(runif(120,0,1),10,12) coid(mdw1,mdw2,weighted=TRUE) set.seed(1) mdw1<-matrix(runif(80,0,1),8,10) mdw2<-matrix(runif(120,0,1),10,12) coid(mdw1,mdw2,weighted=TRUE)
Calculating correlation of interaction similarity for shared species("COis_ ~") in two subnetworks.
cois(network.or.subnet_mat1, subnet_mat2 = NULL, weighted = FALSE)
cois(network.or.subnet_mat1, subnet_mat2 = NULL, weighted = FALSE)
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
weighted |
Logical. should elements of matrix be fractional? Default to FALSE. Generally, 'igraph' network represent a spare matrix, so |
weighted
If the weighted
= FALSE, the input for the parameter can be:
network.or.subnet_mat1
: input a 'igraph' of network data independently or input sparse matrix together with subnet_mat2
.
If the weighted
= TRUE, the input for the parameter can be:
network.or.subnet_mat1
: must input matrix(or data.frame) together with subnet_mat2
. the matrix can be sparse matrix and matrix of interaction strength.
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
When the two matrices can have different numbers of rows:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
When the two matrices can have the same numbers of rows:
No matter how the row names of the two matrices are arranged, as long as the row names are exactly the same; But we don't handle matrices with empty row names (the function will give an error).
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
Return a numeric value representing correlation of interaction similarity for shared species among subnetworks .
If weighted
= FALSE, the results will show "CoIS= ;" and If weighted
= TRUE, the results will show "CoIS_weight= ;"
Sauve, A. M., Thébault, E., Pocock, M. J., & Fontaine, C. (2016). How plants connect pollination and herbivory networks and their contribution to community stability. Ecology, 97(4), 908-917.
set.seed(12) d <- build_net(11,15,17,0.2) cois(d) md1<-matrix(sample(c(0,1),110,replace=TRUE),10,11) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) cois(md1,md2) cois(md1,md2,weighted=TRUE) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) cois(md1,md2) mdw1<-matrix(runif(110,0,1),10,11) mdw2<-matrix(runif(120,0,1),10,12) cois(mdw1,mdw2,weighted=TRUE) set.seed(1) mdw1<-matrix(runif(80,0,1),8,10) mdw2<-matrix(runif(120,0,1),10,12) cois(mdw1,mdw2,weighted=TRUE)
set.seed(12) d <- build_net(11,15,17,0.2) cois(d) md1<-matrix(sample(c(0,1),110,replace=TRUE),10,11) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) cois(md1,md2) cois(md1,md2,weighted=TRUE) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) cois(md1,md2) mdw1<-matrix(runif(110,0,1),10,11) mdw2<-matrix(runif(120,0,1),10,12) cois(mdw1,mdw2,weighted=TRUE) set.seed(1) mdw1<-matrix(runif(80,0,1),8,10) mdw2<-matrix(runif(120,0,1),10,12) cois(mdw1,mdw2,weighted=TRUE)
This function counts degree hub that the proportion of interconnecting species serving as the core node of the network degree.
hc(network.or.subnet_mat1, subnet_mat2 = NULL)
hc(network.or.subnet_mat1, subnet_mat2 = NULL)
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
Print a "hc= ;" and Return a numeric value representing the degree hub of network.
Battiston, F., Nicosia, V. & Latora, V. (2014) Structural measures for multiplex networks. Physical Review E, 89, 032804.
Domínguez-García, V., & Kéfi, S. (2024). The structure and robustness of ecological networks with two interaction types. PLOS Computational Biology, 20(1), e1011770.
Guimera, R. & Amaral, L.A.N. (2005) Cartography of complex networks: modules and universal roles. Journal of Statistical Mechanics: Theory and Experiment, 2005, P02001.
set.seed(15) d <- build_net(11,15,17,0.2) hc(d) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) hc(md1,md2) mdw1<-matrix(sample(c(rep(0,60),runif(60,0,1))),12,10) mdw2<-matrix(sample(c(rep(0,40),runif(80,0,1))),10,12) hc(mdw1,mdw2)
set.seed(15) d <- build_net(11,15,17,0.2) hc(d) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) hc(md1,md2) mdw1<-matrix(sample(c(rep(0,60),runif(60,0,1))),12,10) mdw2<-matrix(sample(c(rep(0,40),runif(80,0,1))),10,12) hc(mdw1,mdw2)
Calculating the number of 48 motifs from a tripartite interaction network.
icmotif_count(network.or.subnet_mat1, subnet_mat2 = NULL)
icmotif_count(network.or.subnet_mat1, subnet_mat2 = NULL)
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
When the two matrices can have different numbers of rows:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
When the two matrices can have the same numbers of rows:
No matter how the row names of the two matrices are arranged, as long as the row names are exactly the same; But we don't handle matrices with empty row names (the function will give an error).
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
Return a numeric vector with the number of 48 motifs: M111, M112, M113, M114, M211, M212, M213, M311, M312, M411, M121_1, M122_1, M122_2, M122_3, M123_1, M123_2, M123_3, M123_4, M123_5, M221_1, M221_2, M221_3, M222_1, M222_2, M222_3, M222_4, M222_5, M222_6, M222_7, M222_8, M222_8, M321_1, M321_2, M321_3, M321_4, M321_5, M131, M132-1, M132-2, M132-3, M132-4, M132-5, M231-1, M231-2, M231-3, M231-4, M231-5, M141.
Pilosof, S., Porter, M. A., Pascual, M., & Kéfi, S. (2017). The multilayer nature of ecological networks. Nature Ecology & Evolution, 1(4), 0101.
Simmons, B. I., Sweering, M. J., Schillinger, M., Dicks, L. V., Sutherland, W. J., & Di Clemente, R. (2019). bmotif: A package for motif analyses of bipartite networks. Methods in Ecology and Evolution, 10(5), 695-701.
set.seed(12) d <- build_net(11,22,21,0.2) m <- icmotif_count(d) m set.seed(12) d <- build_net(11,22,21,0.2,asmatrices=TRUE) MAT<-d icmotif_count(MAT[[3]],MAT[[4]]) md1<-matrix(sample(c(0,1),120,replace=TRUE),8,15) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) icmotif_count(md1,md2) R<-rownames(MAT[[4]])[12] MR<-MAT[[4]][12,] MAT[[4]]<-MAT[[4]][-12,] MAT[[4]]<-rbind(MAT[[4]],MR) rownames(MAT[[4]])[22]<-R icmotif_count(MAT[[3]],MAT[[4]])
set.seed(12) d <- build_net(11,22,21,0.2) m <- icmotif_count(d) m set.seed(12) d <- build_net(11,22,21,0.2,asmatrices=TRUE) MAT<-d icmotif_count(MAT[[3]],MAT[[4]]) md1<-matrix(sample(c(0,1),120,replace=TRUE),8,15) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) icmotif_count(md1,md2) R<-rownames(MAT[[4]])[12] MR<-MAT[[4]][12,] MAT[[4]]<-MAT[[4]][-12,] MAT[[4]]<-rbind(MAT[[4]],MR) rownames(MAT[[4]])[22]<-R icmotif_count(MAT[[3]],MAT[[4]])
Counting the number of 70 roles about interconnecting species in multilayer network motifs.
icmotif_role(network.or.subnet_mat1, subnet_mat2 = NULL)
icmotif_role(network.or.subnet_mat1, subnet_mat2 = NULL)
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
When the two matrices can have different numbers of rows:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
When the two matrices can have the same numbers of rows:
No matter how the row names of the two matrices are arranged, as long as the row names are exactly the same; But we don't handle matrices with empty row names (the function will give an error).
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
Returns a matrix of 70 columns representing the roles of interconnecting species in the motifs. Columns names are Role1, Role2, Role3 ... Role70.
Each row of matrix corresponds to a interconnecting species in the second layer of network. If a interconnecting species is linked to both the second and third level species, the elements in this row are not all zero, otherwise the elements are all zero.
Simmons, B. I., Sweering, M. J., Schillinger, M., Dicks, L. V., Sutherland, W. J., & Di Clemente, R. (2019). bmotif: A package for motif analyses of bipartite networks. Methods in Ecology and Evolution, 10(5), 695-701.
set.seed(12) d <- build_net(11,22,21,0.2) icmotif_role(d) set.seed(12) MAT <- build_net(11,22,21,0.2,asmatrices=TRUE) icmotif_role(MAT[[3]],MAT[[4]]) md1<-matrix(sample(c(0,1),88,replace=TRUE),8,11) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) icmotif_role(md1,md2) R<-rownames(MAT[[4]])[12] MR<-MAT[[4]][12,] MAT[[4]]<-MAT[[4]][-12,] MAT[[4]]<-rbind(MAT[[4]],MR) rownames(MAT[[4]])[22]<-R icmotif_role(MAT[[3]],MAT[[4]])
set.seed(12) d <- build_net(11,22,21,0.2) icmotif_role(d) set.seed(12) MAT <- build_net(11,22,21,0.2,asmatrices=TRUE) icmotif_role(MAT[[3]],MAT[[4]]) md1<-matrix(sample(c(0,1),88,replace=TRUE),8,11) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) icmotif_role(md1,md2) R<-rownames(MAT[[4]])[12] MR<-MAT[[4]][12,] MAT[[4]]<-MAT[[4]][-12,] MAT[[4]]<-rbind(MAT[[4]],MR) rownames(MAT[[4]])[22]<-R icmotif_role(MAT[[3]],MAT[[4]])
Two matrices contain three groups of tropical level species. A multilayer network can be transformed from existing matrices data.
igraph_from_matrices(mat1, mat2, isDirected1 = TRUE, isDirected2 = TRUE)
igraph_from_matrices(mat1, mat2, isDirected1 = TRUE, isDirected2 = TRUE)
mat1 |
A numeric matrix(or data.frame) representing interactions between two groups of species.Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
isDirected1 |
Logical. Whether the interaction between the two groups of species in |
isDirected2 |
Logical. Whether the interaction between the two groups of species in |
mat1 and mat2
The type of inputting is data frame or matrix, please make sure the row of mat1
and mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
When the two matrices can have different numbers of rows:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
When the two matrices can have the same numbers of rows:
No matter how the row names of the two matrices are arranged, as long as the row names are exactly the same; But we don't handle matrices with empty row names (the function will give an error).
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
The columns of mat1
and mat2
could be empty. If empty, the function also defaults to the suggested assignment.
Return a network of type "igraph".
set.seed(12) MAT <- build_net(11,22,21,0.2,asmatrices=TRUE) MAT[[1]] tmat<-t(MAT[[3]]) colnames(tmat)<-NULL igraph_from_matrices(MAT[[3]],MAT[[4]]) M <- igraph_from_matrices(tmat,MAT[[4]]) M
set.seed(12) MAT <- build_net(11,22,21,0.2,asmatrices=TRUE) MAT[[1]] tmat<-t(MAT[[3]]) colnames(tmat)<-NULL igraph_from_matrices(MAT[[3]],MAT[[4]]) M <- igraph_from_matrices(tmat,MAT[[4]]) M
Acquiring each or all of 48 motifs of definition of multilayer network.
Multi_motif( type = c("M111", "M112", "M113", "M114", "M211", "M212", "M213", "M311", "M312", "M411", "M121", "M122-1", "M122-2", "M122-3", "M123-1", "M123-2", "M123-3", "M123-4", "M123-5", "M221-1", "M221-2", "M221-3", "M222-1", "M222-2", "M222-3", "M222-4", "M222-5", "M222-6", "M222-7", "M222-8", "M222-9", "M321-1", "M321-2", "M321-3", "M321-4", "M321-5", "M131", "M132-1", "M132-2", "M132-3", "M132-4", "M132-5", "M231-1", "M231-2", "M231-3", "M231-4", "M231-5", "M141", "all") )
Multi_motif( type = c("M111", "M112", "M113", "M114", "M211", "M212", "M213", "M311", "M312", "M411", "M121", "M122-1", "M122-2", "M122-3", "M123-1", "M123-2", "M123-3", "M123-4", "M123-5", "M221-1", "M221-2", "M221-3", "M222-1", "M222-2", "M222-3", "M222-4", "M222-5", "M222-6", "M222-7", "M222-8", "M222-9", "M321-1", "M321-2", "M321-3", "M321-4", "M321-5", "M131", "M132-1", "M132-2", "M132-3", "M132-4", "M132-5", "M231-1", "M231-2", "M231-3", "M231-4", "M231-5", "M141", "all") )
type |
Character. 49 values representing each and all types of multilayer motifs. |
If type
is one of 48 motifs of definition, function returns a corresponding motif of "igraph".
If type
is "all", function returns a list containing 48 corresponding motifs of "igraph".
type<-c("M111","M112","M113","M114","M211","M212","M213","M311", "M312","M411","M121","M122-1","M122-2","M122-3","M123-1", "M123-2","M123-3","M123-4","M123-5","M221-1","M221-2", "M221-3","M222-1","M222-2","M222-3","M222-4","M222-5", "M222-6","M222-7","M222-8","M222-9","M321-1","M321-2", "M321-3","M321-4","M321-5","M131","M132-1","M132-2", "M132-3","M132-4","M132-5","M231-1","M231-2","M231-3", "M231-4","M231-5","M141") m<-Multi_motif("M222-4") plot(m,main="M222-4") mr <- par(mfrow=c(6,8),mar=c(1,1,3,1)) for(i in 1:48){ plot(Multi_motif("all")[[i]], vertex.size=30, vertex.label=NA, vertex.color="blue",main=type[i]) } par(mr)
type<-c("M111","M112","M113","M114","M211","M212","M213","M311", "M312","M411","M121","M122-1","M122-2","M122-3","M123-1", "M123-2","M123-3","M123-4","M123-5","M221-1","M221-2", "M221-3","M222-1","M222-2","M222-3","M222-4","M222-5", "M222-6","M222-7","M222-8","M222-9","M321-1","M321-2", "M321-3","M321-4","M321-5","M131","M132-1","M132-2", "M132-3","M132-4","M132-5","M231-1","M231-2","M231-3", "M231-4","M231-5","M141") m<-Multi_motif("M222-4") plot(m,main="M222-4") mr <- par(mfrow=c(6,8),mar=c(1,1,3,1)) for(i in 1:48){ plot(Multi_motif("all")[[i]], vertex.size=30, vertex.label=NA, vertex.color="blue",main=type[i]) } par(mr)
The versatility of nodes is revealed by several centrality measures that have now been applied to multilayer networks, such as Degree, Pagerank, Hub, Authority, Katz, Eigenvector, and Closeness centrality.
node_cv( network.or.subnet_mat1, subnet_mat2 = NULL, isDirected1 = TRUE, isDirected2 = TRUE, type = c("degree", "pagerank", "hub", "authority", "katz", "eigenvector", "closeness", "all") )
node_cv( network.or.subnet_mat1, subnet_mat2 = NULL, isDirected1 = TRUE, isDirected2 = TRUE, type = c("degree", "pagerank", "hub", "authority", "katz", "eigenvector", "closeness", "all") )
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
isDirected1 |
Logical. Whether the interaction between the two groups of species in |
isDirected2 |
Logical. Whether the interaction between the two groups of species in |
type |
Character. Including "degree", "pagerank", "hub", "authority", "katz", "eigenvector", "closeness", and "all". |
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
When the two matrices can have different numbers of rows:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
When the two matrices can have the same numbers of rows:
No matter how the row names of the two matrices are arranged, as long as the row names are exactly the same; But we don't handle matrices with empty row names (the function will give an error).
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
type
type
"degree", "pagerank", "hub", "authority", "katz", "eigenvector", and "closeness" correspond to Degree, PageRank, Hub, Authority, Katz, Eigenvector, and Closeness centrality.
type
"all" integrates the above centrality.
Return a data frame with the first row "node" for each node of network representing each species.
If type
is either of "degree", "pagerank", "hub", "authority", "katz", "eigenvector", "closeness", the data frame has two columns, and the second column corresponds to either of "Degree", "Pagerank_versatility",
"Hub_versatility", "Authority_versatility", "Katz_versatility", "Eigenvector_versatility", "Closeness_versatility".
If type
is "all", the data frame has eight columns, and columns form the second to the eighth correspond to "Degree", "Pagerank_versatility",
"Hub_versatility", "Authority_versatility", "Katz_versatility", "Eigenvector_versatility", "Closeness_versatility".
De Domenico, M., Nicosia, V., Arenas, A., & Latora, V. (2015). Structural reducibility of multilayer networks. Nature communications, 6(1), 6864.
De Domenico, M., Solé-Ribalta, A., Omodei, E., Gómez, S., & Arenas, A. (2013). Centrality in interconnected multilayer networks. arXiv preprint arXiv:1311.2906.
De Domenico, M. (2022). Multilayer Networks: Analysis and Visualization. Introduction to muxViz with R. Cham: Springer.
Page, L., Brin, S., Motwani, R., & Winograd, T. (1999). The pagerank citation ranking: Bringing order to the web.
Magnani, M., Micenkova, B., & Rossi, L. (2013). Combinatorial analysis of multiple networks. arXiv preprint arXiv:1303.4986.
set.seed(12) d <- build_net(11,22,21,0.2,asmatrices=TRUE) d node_cv(d[[1]]) MAT<-d tmat<-t(MAT[[3]]) colnames(tmat)<-NULL node_cv(MAT[[3]],MAT[[4]]) node_cv(tmat,MAT[[4]]) node_cv(MAT[[3]],MAT[[4]],type="pagerank") node_cv(MAT[[3]],MAT[[4]],isDirected2=FALSE)
set.seed(12) d <- build_net(11,22,21,0.2,asmatrices=TRUE) d node_cv(d[[1]]) MAT<-d tmat<-t(MAT[[3]]) colnames(tmat)<-NULL node_cv(MAT[[3]],MAT[[4]]) node_cv(tmat,MAT[[4]]) node_cv(MAT[[3]],MAT[[4]],type="pagerank") node_cv(MAT[[3]],MAT[[4]],isDirected2=FALSE)
The null model could be generated according to different matrix scrambling algorithms for interconnection patterns in the multilayer network
null_model( network, number = NULL, null_type = c("subnetwork1", "subnetwork2", "all", "Savue") )
null_model( network, number = NULL, null_type = c("subnetwork1", "subnetwork2", "all", "Savue") )
network |
A multilayer(tripartite) network of 'igraph' class. The network contains three groups of species and interactions within layers without interactions between each group of species. |
number |
A numeric value. The number of null model. Default to NULL representing number 1. |
null_type |
Logical. Four matrix scrambling algorithms. If null_type = NULL, default to "all". |
null_type
For each of the four types of null models, there are corresponding algorithms. The first type, “subnetwork1”, involved scrambling the adjacency matrix of the first and second groups of the multilayer network.
The second type, “subnetwork2”, focused on scrambling the adjacency matrix of the second and third groups.
Comprehensively, the third type, “all”, blended the approaches of the first two to disarrange the entire network's adjacency matrix, achieving a thorough perturbation of the network's structure.
The last type named “Savue” that disarranged inherent structure in terms of the groups of species connected by each interconnecting species of every subnetworks, thus exhibiting different interconnection patterns.
network
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
Return a list contains one or more elements. Each element represent a null model of multilayer network.
Vázquez, D. P., C. J. Melian, N. M. Williams, N. Blüthgen, B. R. Krasnov, and R. Poulin. 2007. Species abundance and asymmetric interaction strength in ecological networks. Oikos 116: 1120-1127.
Sauve, A. M., Thébault, E., Pocock, M. J., & Fontaine, C. (2016). How plants connect pollination and herbivory networks and their contribution to community stability. Ecology, 97(4), 908-917.
set.seed(12) d <- build_net(11,22,21,0.2) set.seed(123) null_model(d) set.seed(123) null_model(d,null_type="subnetwork1") set.seed(123) null_model(d,null_type="Savue") set.seed(123) null_model(d,number=2,null_type="Savue")
set.seed(12) d <- build_net(11,22,21,0.2) set.seed(123) null_model(d) set.seed(123) null_model(d,null_type="subnetwork1") set.seed(123) null_model(d,null_type="Savue") set.seed(123) null_model(d,number=2,null_type="Savue")
Counting participation ratio that the difference in the degree of interconnecting nodes within two subnetworks.
pc(network.or.subnet_mat1, subnet_mat2 = NULL)
pc(network.or.subnet_mat1, subnet_mat2 = NULL)
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
Print a "pc= ;" and Return a numeric value representing difference in the degree of interconnecting nodes within two subnetworks of multialyer network.
Battiston, F., Nicosia, V. & Latora, V. (2014) Structural measures for multiplex networks. Physical Review E, 89, 032804.
Domínguez-García, V., & Kéfi, S. (2024). The structure and robustness of ecological networks with two interaction types. PLOS Computational Biology, 20(1), e1011770.
Guimera, R. & Amaral, L.A.N. (2005) Cartography of complex networks: modules and universal roles. Journal of Statistical Mechanics: Theory and Experiment, 2005, P02001.
set.seed(15) d <- build_net(11,15,17,0.2) pc(d) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) pc(md1,md2) mdw1<-matrix(sample(c(rep(0,60),runif(60,0,1))),12,10) mdw2<-matrix(sample(c(rep(0,40),runif(80,0,1))),10,12) pc(mdw1,mdw2)
set.seed(15) d <- build_net(11,15,17,0.2) pc(d) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) pc(md1,md2) mdw1<-matrix(sample(c(rep(0,60),runif(60,0,1))),12,10) mdw2<-matrix(sample(c(rep(0,40),runif(80,0,1))),10,12) pc(mdw1,mdw2)
Calculating the proportion of species sharing with other species of two subnetworks in intermediate layer.
poc(network.or.subnet_mat1, subnet_mat2 = NULL)
poc(network.or.subnet_mat1, subnet_mat2 = NULL)
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
Print a "poc= ;" and Return a numeric value representing the proportion of sharing species in intermediate layer.
Battiston, F., Nicosia, V. & Latora, V. (2014) Structural measures for multiplex networks. Physical Review E, 89, 032804.
Domínguez-García, V., & Kéfi, S. (2024). The structure and robustness of ecological networks with two interaction types. PLOS Computational Biology, 20(1), e1011770.
Guimera, R. & Amaral, L.A.N. (2005) Cartography of complex networks: modules and universal roles. Journal of Statistical Mechanics: Theory and Experiment, 2005, P02001.
set.seed(15) d <- build_net(11,15,17,0.2) poc(d) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) poc(md1,md2) mdw1<-matrix(sample(c(rep(0,40),runif(60,0,1))),10,10) mdw2<-matrix(sample(c(rep(0,40),runif(80,0,1))),10,12) poc(mdw1,mdw2) mdw1<-matrix(sample(c(rep(0,60),runif(60,0,1))),12,10) mdw2<-matrix(sample(c(rep(0,40),runif(80,0,1))),10,12) poc(mdw1,mdw2)
set.seed(15) d <- build_net(11,15,17,0.2) poc(d) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) poc(md1,md2) mdw1<-matrix(sample(c(rep(0,40),runif(60,0,1))),10,10) mdw2<-matrix(sample(c(rep(0,40),runif(80,0,1))),10,12) poc(mdw1,mdw2) mdw1<-matrix(sample(c(rep(0,60),runif(60,0,1))),12,10) mdw2<-matrix(sample(c(rep(0,40),runif(80,0,1))),10,12) poc(mdw1,mdw2)
A pollinator-plant-herbivore network from Villa-Galaviz et. al. 2020. Journal of Animal Ecology
data(PPH_Coltparkmeadow)
data(PPH_Coltparkmeadow)
A list with "igraph". This is a classical example of multilayer interaction network.
Villa‐Galaviz, E., S. M. Smart, E. L. Clare, S. E. Ward, and J. Memmott. 2021. Differential effects of fertilisers on pollination and parasitoid interaction networks. Journal of animal ecology 90:404-414.
data(PPH_Coltparkmeadow)
data(PPH_Coltparkmeadow)
The average of Similarity of 65 roles of interconnecting species of multilayer network.
role_sim(spe_role_mat)
role_sim(spe_role_mat)
spe_role_mat |
A matrix of 65 columns representing the roles of interconnecting species in the motifs. Columns names are Role1, Role2, Role3 ... Role70. |
spe_role_mat
Should acquire from function motif_role
.
Return a numeric value.
set.seed(12) d <- build_net(11,22,21,0.2) mr <- icmotif_role(d) role_sim(mr) set.seed(1) D <- build_net(11,22,21,0.2) role_sim(icmotif_role(D))
set.seed(12) d <- build_net(11,22,21,0.2) mr <- icmotif_role(d) role_sim(mr) set.seed(1) D <- build_net(11,22,21,0.2) role_sim(icmotif_role(D))
Calculating correlation of interconnecting species generalism among Subnetworks ("general_'~'cor") and correlation between similarities of interconnecing species interaction partners in two subnetworks ("similar_'~'cor").
subnet_cor(network.or.subnet_mat1, subnet_mat2 = NULL, weighted = FALSE)
subnet_cor(network.or.subnet_mat1, subnet_mat2 = NULL, weighted = FALSE)
network.or.subnet_mat1 |
Either a multilayer(tripartite) network of 'igraph' class which contains three groups of species and interactions within layers without interactions between each group of species, or a numeric matrix(or data.frame) representing interactions between two groups of species. Each row and column of matrix represents single species in the second and first groups of the tripartite network respectively. Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. |
subnet_mat2 |
A numeric matrix(or data.frame) representing interactions between two groups of species.
Each row and column of matrix represents single species in the second and third groups of the tripartite network respectively.
Elements of matrix are non-zero numbers if the two groups of species are connected, and 0 otherwise. If |
weighted |
Logical. should elements of matrix be fractional? Default to FALSE. Generally, 'igraph' network represent a spare matrix, so |
weighted
If the weighted
= FALSE, the input for the parameter can be:
network.or.subnet_mat1
: input a 'igraph' of network data independently or input sparse matrix together with subnet_mat2
.
If the weighted
= TRUE, the input for the parameter can be:
network.or.subnet_mat1
: must input matrix(or data.frame) together with subnet_mat2
. the matrix can be sparse matrix and matrix of interaction strength.
network.or.subnet_mat1 and subnet_mat2
There are two types of network.or.subnet_mat1
that can be processed:
(1). Input in a network of type "igraph" alone.
(2). Must be entered as data frame or matrix with subnet_mat2
.
If the type of inputting is data frame or matrix, please make sure the row of network.or.subnet_mat1
and subnet_mat2
correspond with the second group of species that both belong to two subnetworks and interact with other groups of species.
Try to make the rows of both matrices have the same attributes. Or we default:
When the two matrices can have different numbers of rows:
(1). If both matrices have row names, then the function counts all row names to produce two new matrices with the same row names.
(2). If at most one matrix has row names, the function assigns new row names to both matrices on a row-to-row basis (any extra row names are assigned a new value) and then counts all row names to produce two new matrices with the same row names.
When the two matrices can have the same numbers of rows:
No matter how the row names of the two matrices are arranged, as long as the row names are exactly the same; But we don't handle matrices with empty row names (the function will give an error).
The two matrices can have different numbers of rows, but read our default handling carefully to make sure the calculation is accurate when using this function!!!
About a network of type "igraph", It can be obtained from the connection matrices of subnetworks by the function igraph_from_matrices
.
Return a numeric vector of two elements representing correlation of interconnecting species generalism among Subnetworks and correlation between similarities of interconnecing species interaction partners in two subnetworks.
If weighted
= FALSE, the results will show "general_cor= ;similar_cor= ;" and If weighted
= TRUE, the results will show "general_weight_cor= ;similar_weight_cor= ;"
Sauve, A. M., Thébault, E., Pocock, M. J., & Fontaine, C. (2016). How plants connect pollination and herbivory networks and their contribution to community stability. Ecology, 97(4), 908-917.
set.seed(12) d <- build_net(11,15,17,0.2) subnet_cor(d) md1<-matrix(sample(c(0,1),110,replace=TRUE),10,11) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) subnet_cor(md1,md2) subnet_cor(md1,md2,weighted=TRUE) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) subnet_cor(md1,md2) mdw1<-matrix(runif(110,0,1),10,11) mdw2<-matrix(runif(120,0,1),10,12) subnet_cor(mdw1,mdw2,weighted=TRUE) set.seed(1) mdw1<-matrix(runif(80,0,1),8,10) mdw2<-matrix(runif(120,0,1),10,12) subnet_cor(mdw1,mdw2,weighted=TRUE)
set.seed(12) d <- build_net(11,15,17,0.2) subnet_cor(d) md1<-matrix(sample(c(0,1),110,replace=TRUE),10,11) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) subnet_cor(md1,md2) subnet_cor(md1,md2,weighted=TRUE) md1<-matrix(sample(c(0,1),80,replace=TRUE),8,10) md2<-matrix(sample(c(0,1),120,replace=TRUE),10,12) subnet_cor(md1,md2) mdw1<-matrix(runif(110,0,1),10,11) mdw2<-matrix(runif(120,0,1),10,12) subnet_cor(mdw1,mdw2,weighted=TRUE) set.seed(1) mdw1<-matrix(runif(80,0,1),8,10) mdw2<-matrix(runif(120,0,1),10,12) subnet_cor(mdw1,mdw2,weighted=TRUE)