View source: R/trigraph_from_mat.R
trigraph_from_mat | R Documentation |
Transform two matrices into an igraph object.
trigraph_from_mat(mat1, mat2, weighted = FALSE)
mat1 |
A numeric matrix representing the first subnetwork. Rows should be the shared set of species. |
mat2 |
A numeric matrix representing the second subnetwork. Rows should be the shared set of species. |
weighted |
Logical. Default to FALSE. If TRUE, a weighted measure is provided. |
In this package, a tripartite network contains three groups of nodes (a-nodes,b-nodes,c-nodes) and two subnetworks (P includes the links between a-nodes and b-nodes, Q includes the links between b-nodes and c-nodes). Connector nodes belong to b-nodes.
Please make sure the rows of mat1
and mat2
both represent the groups of connector species,i.e, the b-group species. If both matrices have row names, then the function matches row
names to define connector nodes. Otherwise, row numbers are assigned to row names and matched, which might produce an incorrected network. Within the two matrices (P and Q), columns represents a-group nodes and c-group nodes respectively.
Elements in matrices are non-zero values if two nodes are linked with or without weights, and 0 otherwise.
Return a network of type "igraph".
set.seed(12)
MAT <- build_toy_net(11,22,21,0.2,output_matrices=TRUE)
M <- trigraph_from_mat((MAT[[3]]),MAT[[4]])
M
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.