% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/networkSimilarity.R
\name{networkSimilarity}
\alias{networkSimilarity}
\title{Compare KEGG-Based Networks via Jaccard Similarity}
\usage{
networkSimilarity(..., type = c("edge", "node"), match_interaction = FALSE)
}
\arguments{
\item{...}{Two or more network matrices, typically generated by
\code{buildKeggNetwork()}. Each must have at least two columns:
\code{source} (column 1) and \code{target} (column 2). When
\code{match_interaction = TRUE}, a third column
\code{interaction_type} is required.}

\item{type}{Character, \code{"edge"} or \code{"node"}. If \code{"node"},
similarity is computed on the set of unique nodes (union of sources
and targets). If \code{"edge"}, similarity is computed on directed
edges (source \eqn{\rightarrow} target).}

\item{match_interaction}{Logical. When \code{type = "edge"} and
\code{match_interaction = FALSE} (default), edges are defined by
\code{source -> target} only. If \code{TRUE}, edges must also share
the same \code{interaction_type} to be considered identical. Ignored
when \code{type = "node"}.}
}
\value{
A numeric similarity matrix with dimensions
\code{length(list(...)) x length(list(...))}. Row and column names are
derived from the argument names in \code{...}. Diagonal entries are 1;
off-diagonal entries are Jaccard indices,
\deqn{J = |A \cap B| / |A \cup B|,}
where \eqn{A} and \eqn{B} are node sets (for \code{type = "node"}) or
edge sets (for \code{type = "edge"}). If both sets are empty, the
similarity is \code{NA_real_}.
}
\description{
Computes pairwise Jaccard similarity between two or more KEGG-derived
networks, either at the node level (unique node sets) or edge level
(directed source–target pairs, optionally including interaction type).
}
\details{
This function is particularly useful for comparing pathways across
organisms or conditions using networks built with \code{buildKeggNetwork()}.
}
\examples{
## 1) Prepare example network subsets
data(MetaPathNet_example_network)

net_example_1 <- MetaPathNet_example_network[seq_len(50), , drop = FALSE]
net_example_2 <- MetaPathNet_example_network[51:100, , drop = FALSE]
net_example_3 <- MetaPathNet_example_network[101:150, , drop = FALSE]
net_example_4 <- MetaPathNet_example_network[151:200, , drop = FALSE]
net_example_5 <- MetaPathNet_example_network[201:250, , drop = FALSE]

## 2) Edge-level similarity (Jaccard on directed edges, ignoring interaction type)
##    This compares overlap in network structure (source-target pairs).
sim_edge_example <- networkSimilarity(
  net_example_1,
  net_example_2,
  net_example_3,
  net_example_4,
  net_example_5,
  type              = "edge",
  match_interaction = FALSE
)

## 3) (Optional) Node-level similarity (Jaccard on unique node sets)
##     This compares overlap in node composition, regardless of how nodes are connected.
sim_node_example <- networkSimilarity(
  net_example_1,
  net_example_2,
  net_example_3,
  net_example_4,
  net_example_5,
  type              = "node",
  match_interaction = FALSE
)

}
\references{
Fuxman Bass JI, Diallo A, Nelson J, Soto JM, Myers CL, Walhout AJ.
Using networks to measure similarity between genes: association index selection.
Nat Methods. 2013;10(12):1169–1176. doi:10.1038/nmeth.2728.
}
\seealso{
\code{\link{buildKeggNetwork}} for network construction,
\code{\link{getPathIDs}} for pathway ID retrieval.
}
