This function uses the compare function to compare two adjacency matrices.

network_compare(
  adj_mat_x,
  adj_mat_y,
  comparison_method = "vi",
  weighted = TRUE,
  mode = "undirected",
  diag = TRUE,
  add_colnames = NULL,
  add_rownames = NA,
  ...
)

Arguments

adj_mat_x

a square adjacency matrix. Also supports a sparse matrix from the Matrix package.

adj_mat_y

a square adjacency matrix. Also supports a sparse matrix from the Matrix package.

comparison_method

the network graph comparison method that shall be employed. Options are:

  • comparison_method = "vi": variation of information (VI) metric of Meila (2003) (default). Find details at compare.

  • comparison_method = "nmi": normalized mutual information measure proposed by Danon et al. (2005). Find details at compare.

  • comparison_method = "split.join": split-join distance of can Dongen (2000). Find details at compare.

  • comparison_method = "rand": the Rand index of Rand (1971). Find details at compare.

  • comparison_method = "adjusted.rand": the adjusted Rand index by Hubert and Arabie (1985). Find details at compare.

weighted

This argument specifies whether to create a weighted graph from an adjacency matrix. If it is NULL then an unweighted graph is created and the elements of the adjacency matrix gives the number of edges between the vertices. If it is a character constant then for every non-zero matrix entry an edge is created and the value of the entry is added as an edge attribute named by the weighted argument. If it is TRUE then a weighted graph is created and the name of the edge attribute will be weight. See also details below.

mode

a character value specifying how igraph should interpret the input matrices. Options are:

  • If weighted = NULL:

    • mode = "directed": The graph will be directed and a matrix element gives the number of edges between two vertices.

    • mode = "undirected": This is exactly the same as max, for convenience. Note that it is not checked whether the matrix is symmetric (default).

    • mode = "upper": An undirected graph will be created, only the upper right triangle (including the diagonal) is used for the number of edges.

    • mode = "lower": An undirected graph will be created, only the lower left triangle (including the diagonal) is used for creating the edges.

    • mode = "max": An undirected graph will be created and max(A(i,j), A(j,i)) gives the number of edges.

    • mode = "min": undirected graph will be created with min(A(i,j), A(j,i)) edges between vertex i and j.

    • mode = "plus": undirected graph will be created with A(i,j)+A(j,i) edges between vertex i and j.

  • If the weighted argument is not NULL then the elements of the matrix give the weights of the edges (if they are not zero). The details depend on the value of the mode argument: itemize mode = "directed": The graph will be directed and a matrix element gives the edge weights. mode = "undirected": First we check that the matrix is symmetric. It is an error if not. Then only the upper triangle is used to create a weighted undirected graph (default). mode = "upper": An undirected graph will be created, only the upper right triangle (including the diagonal) is used (for the edge weights). mode = "lower": An undirected graph will be created, only the lower left triangle (including the diagonal) is used for creating the edges. mode = "max": An undirected graph will be created and max(A(i,j), A(j,i)) gives the edge weights. mode = "min": An undirected graph will be created, min(A(i,j), A(j,i)) gives the edge weights. mode = "plus": An undirected graph will be created, A(i,j)+A(j,i) gives the edge weights.

diag

a logical value specifying whether to include the diagonal of the matrix in the calculation. If diag = FALSE then the diagonal first set to zero and then passed along the downstream functions.

add_colnames

a character value specifying whether column names shall be added as vertex attributes. Options are:

  • add_colnames = NULL (default): if present, column names are added as vertex attribute ‘name’.

  • add_colnames = NA: column names will not be added.

  • add_colnames = "": If a character constant is specified then it gives the name of the vertex attribute to add.

add_rownames

a character value specifying whether to add the row names as vertex attributes. Possible values the same as the previous argument. By default row names are not added. If ‘add.rownames’ and ‘add.colnames’ specify the same vertex attribute, then the former is ignored.

...

additional arguments passed on to graph_from_adjacency_matrix.

Value

A real number returned from the respective comparison_method method.

Author

Sergio Vasquez and Hajk-Georg Drost

Examples

##### Compare networks inferred by PPCOR and PIDC ## Import and rescale GENIE3 network # path to GENIE3 output file genie_output <- system.file('beeline_examples/GENIE3/outFile.csv', package = 'edgynode') # import GENIE3 specific output genie_parsed <- genie(genie_output)
#> Warning: The matrix provided as input for genie() was not symmetric.
# rescaling GENIE3 output genie_rescaled <- network_rescale(genie_parsed)
#> Warning: The matrix provided as input for network_rescale() was coerced into symmetric.
## Import and rescale PIDC network # path to PIDC output file pidc_output <- system.file('beeline_examples/PIDC/outFile.txt', package = 'edgynode') # import PIDC specific output pidc_parsed <- pidc(pidc_output)
#> Repairing names...
#> New names: #> * `` -> ...1 #> * `` -> ...2 #> * `` -> ...3 #> * `` -> ...4 #> * `` -> ...5 #> * ...
#Set diagonal values diag(pidc_parsed) <- 1 # rescaling PIDC output pidc_rescaled <- network_rescale(pidc_parsed) ### compare both networks # network_compare(genie_rescaled, pidc_rescaled)