% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/annotateKoClass.R
\name{annotateKoClass}
\alias{annotateKoClass}
\title{Annotate KO functional class (metabolic vs signalling)}
\usage{
annotateKoClass(
  network_table,
  name = FALSE,
  export_cytoscape = FALSE,
  compound_color = "#9DC7DD",
  metabolic_color = "#9ED17B",
  signaling_color = "#C45745",
  metabolic_signaling_color = "#B57F60",
  other_color = "#D1C2C2",
  network_title = "",
  collection_title = ""
)
}
\arguments{
\item{network_table}{A MetaPathNet-style network with at least two columns:
\code{source} and \code{target}. If a third column is present, it is
interpreted as \code{interaction_type}; otherwise it is set to
\code{NA_character_}.}

\item{name}{Logical. If \code{TRUE}, convert node IDs to KEGG-derived labels
(KO: \code{SYMBOL} preferred, then \code{NAME}; non-KO: cleaned
\code{NAME}). If \code{FALSE} (default), keep original node IDs.}

\item{export_cytoscape}{Logical. If \code{FALSE} (default), return only the
annotation data frame. If \code{TRUE}, also create and style a Cytoscape
network using the annotated node table.}

\item{compound_color}{Hex colour for compound nodes (used only when
\code{export_cytoscape = TRUE}).}

\item{metabolic_color}{Hex colour for KO nodes classified as
\code{"metabolic"} (used only when \code{export_cytoscape = TRUE}).}

\item{signaling_color}{Hex colour for KO nodes classified as
\code{"signaling"} (used only when \code{export_cytoscape = TRUE}).}

\item{metabolic_signaling_color}{Hex colour for KO nodes classified as
\code{"metabolic&signaling"} (used only when
\code{export_cytoscape = TRUE}).}

\item{other_color}{Hex colour for KO nodes whose class cannot be determined
and for non-compound, non-KO nodes (used only when
\code{export_cytoscape = TRUE}).}

\item{network_title}{Character. Cytoscape network title (used only when
\code{export_cytoscape = TRUE}).}

\item{collection_title}{Character. Cytoscape collection title (used only when
\code{export_cytoscape = TRUE}).}
}
\value{
A data frame with columns \code{id}, \code{type}, \code{name}, and
\code{ko_class}. Compound nodes are excluded from the returned table.

If \code{export_cytoscape = TRUE}, the same annotation is also applied to a
Cytoscape network as a side effect, with node colours mapped to
\code{ko_class}; the function invisibly returns the annotation data frame.
}
\description{
Annotates KEGG Orthology (KO) nodes in a MetaPathNet-style network by
pathway context: \code{"metabolic"}, \code{"signaling"}, or
\code{"metabolic&signaling"}. Classification is derived from KEGG BRITE
pathway hierarchy and KO-to-pathway links. The function returns a KO-level
annotation table (compound nodes excluded) and can optionally export a
Cytoscape network with KO class colouring.
}
\details{
Cytoscape (version \strong{>= 3.9.0}) must be open and reachable via
\pkg{RCy3} only when \code{export_cytoscape = TRUE}.

Reverse duplicated edges are collapsed for Cytoscape display when they
share the same metabolic interaction type
KO functional class is derived from the KEGG BRITE pathway hierarchy
(\code{br:br08901}). Pathways under the \code{"Metabolism"} branch are
classified as metabolic, whereas all other linked pathways are treated as
signaling for this annotation workflow.
}
\examples{
## 1) Prepare a mixed human–E. coli tryptophan-focused network
## Human: tryptophan metabolism + selected immune/inflammatory signaling pathways
## Load the precomputed example network; see buildKeggNetwork() for its construction
data(MetaPathNet_example_network)

## Combined host–microbe network
net_trp_mixed <- MetaPathNet_example_network

## 2) Build a shortest-path subnetwork (used here as the input network_table)
source_nodes <- c("K00486", "K00453", "K00463", "K01667", "K01696", "K01695")
target_nodes <- c("cpd:C00078", "cpd:C00328", "cpd:C00780", "cpd:C00463", "cpd:C00108")

map_src <- findMappedNodes(source_nodes, net_trp_mixed)
map_tgt <- findMappedNodes(target_nodes, net_trp_mixed)

paths_trp_mixed <- findShortestPaths(
  network_table      = net_trp_mixed,
  source_nodes       = map_src$mapped_nodes,
  target_nodes       = map_tgt$mapped_nodes,
  mode               = "out",
  output             = "network_matrix",
  name               = FALSE,
  distance_threshold = 6
)

## 3) KO class annotation table (data frame output)
ko_class_df <- annotateKoClass(
  network_table = paths_trp_mixed,
  name          = FALSE
)

}
\seealso{
\code{\link{annotateOrigin}} for host vs bacteria origin, and
\code{\link{viewNetworkCy}} for generic Cytoscape visualisation of
MetaPathNet networks.
}
