% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/viewNetworkCy.R
\name{viewNetworkCy}
\alias{viewNetworkCy}
\title{Visualize a KEGG-Derived Network in Cytoscape via RCy3}
\usage{
viewNetworkCy(
  network_table,
  name = FALSE,
  category = TRUE,
  style_interaction = FALSE,
  node_compound = "#9DC7DD",
  node_gene = "#9ED17B",
  network_title = "",
  collection_title = ""
)
}
\arguments{
\item{network_table}{A 3-column matrix or data.frame representing the network
(columns: \code{source}, \code{target}, \code{interaction_type}).}

\item{name}{Logical (default \code{FALSE}). If \code{TRUE}, node labels are
converted from KEGG IDs to KEGG-derived names/symbols via \pkg{KEGGREST}.
If \code{FALSE}, node labels remain KEGG IDs and no KEGG REST calls are made.}

\item{category}{Logical. If \code{TRUE}, nodes are coloured by type
(\code{"Compound"}, \code{"KO"}, \code{"Other"}). If \code{FALSE}, all nodes
use a default colour.}

\item{style_interaction}{Logical (default \code{FALSE}). If \code{TRUE}, basic
edge styling is applied based on \code{interaction_type}:
\code{"k_compound:reversible"} edges are drawn with parallel line style, and
\code{"k_compound:irreversible"} edges receive a target arrow. Other
interaction types are displayed with default Cytoscape edge styling.}

\item{node_compound}{Colour for compound nodes (default \code{"#9DC7DD"}).}

\item{node_gene}{Colour for KO/gene nodes (default \code{"#9ED17B"}).}

\item{network_title}{Character. Title of the network in Cytoscape.}

\item{collection_title}{Character. Cytoscape collection name.}
}
\value{
Invisibly returns \code{NULL}. The function acts by side-effect in Cytoscape,
creating a styled network ready for manual or scripted exploration.
}
\description{
Imports a MetaPathNet-style network table (typically from \code{buildKeggNetwork()}
or \code{findShortestPaths()}) into Cytoscape and applies basic visual styling.
Nodes can be coloured by type (compound / KO / other). Node labels can be kept
as KEGG IDs (default) or converted to KEGG-derived names.
}
\details{
Cytoscape (v\eqn{>=}3.9.0) must be running and reachable via \pkg{RCy3}
before calling this function.

Reverse duplicated edges are collapsed for Cytoscape display when they
share the same metabolic interaction type

When \code{name = TRUE}, KEGG IDs are resolved once per node. This can be slow
for large networks and depends on KEGG API response time.
}
\examples{
## 1) Load the precomputed example network; see buildKeggNetwork() for its construction
data(MetaPathNet_example_network)

net_trp_mixed <- MetaPathNet_example_network

## 2) Extract a shortest-path subnetwork (paths_trp_mixed)
source_nodes <- c("K00486", "K00453", "K00463",
                  "K01667", "K01696", "K01610", "K01695")
target_nodes <- c("cpd:C00078", "cpd:C00328", "cpd:C00780",
                  "cpd:C00463", "cpd:C00108", "cpd:C00458", "cpd:C00336")

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
)

\dontrun{
## Requires a running Cytoscape session for network layout and rendering
## Example 1 — Shortest-path subnetwork with KEGG name conversion + interaction styling
## (k_compound:reversible shown as parallel lines; k_compound:irreversible with arrows)
viewNetworkCy(
  network_table     = paths_trp_mixed,
  name              = TRUE,
  category          = TRUE,
  style_interaction = TRUE,
  node_compound     = "#9DC7DD",
  node_gene         = "#9ED17B",
  network_title     = "Trp-immune shortest paths",
  collection_title  = "MetaPathNet_Examples"
)

## Example 2 — Full Trp network without name conversion (faster)
viewNetworkCy(
  network_table     = net_trp_mixed,
  name              = FALSE,
  category          = TRUE,
  style_interaction = FALSE,
  node_compound     = "#9DC7DD",
  node_gene         = "#9ED17B",
  network_title     = "Trp-immune network",
  collection_title  = "MetaPathNet_Examples"
)
}

}
\seealso{
\code{\link{buildKeggNetwork}}, \code{\link{viewNetworkR}},
\code{\link{findShortestPaths}}
}
