icmotif_role {ILSM} | R Documentation |
Analyzing role of interconnecting node in motifs
Description
Counting the number of 70 roles about interconnecting species in multilayer network motifs.
Usage
icmotif_role(network.or.subnet_mat1, subnet_mat2 = NULL)
Arguments
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 |
Details
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
.
Value
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.
References
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.
Examples
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]])