% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/viewNetworkR.R
\name{viewNetworkR}
\alias{viewNetworkR}
\title{Visualise a KEGG-Based Network Matrix in R}
\usage{
viewNetworkR(
  network_table,
  category = TRUE,
  name = FALSE,
  layout = "randomly",
  node_size = 2,
  node_compound = "#9DC7DD",
  node_gene = "#9ED17B",
  network_title = "MetaPathNet Network"
)
}
\arguments{
\item{network_table}{A network matrix with at least three columns: source, target,
interaction type (e.g. output of \code{buildKeggNetwork()},
\code{buildCrossSpeciesNetwork()}, or \code{findShortestPaths()} with
\code{output = "network_matrix"}).}

\item{category}{Logical. If \code{TRUE}, colour nodes by type
(\code{"compound"}, \code{"KO"}, \code{"contextual"}); if \code{FALSE},
all nodes share the same colour.}

\item{name}{Logical (default \code{FALSE}). If \code{TRUE}, node labels are
retrieved from KEGG (compound names and KO symbols/names) via \pkg{KEGGREST}.
If \code{FALSE}, node labels remain the raw KEGG IDs.}

\item{layout}{Character. Layout algorithm for \pkg{ggraph}
(e.g. \code{"randomly"}, \code{"fr"}, \code{"kk"}).}

\item{node_size}{Numeric. Base size for nodes (and label text) in the plot.}

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

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

\item{network_title}{Character. Optional plot title.}
}
\value{
A \code{ggplot} object.
}
\description{
Plots a KEGG-derived network matrix (e.g. from \code{buildKeggNetwork()} or
\code{findShortestPaths()}) directly in R using \pkg{ggraph}. Nodes can be
coloured by type (compound, KO, contextual) and labelled with KEGG IDs or
KEGG-derived names.
}
\details{
For large networks (> 2000 edges), only the largest connected
component is displayed. If more than ~300 nodes are present, a message
suggests using \code{viewNetworkCy()} for Cytoscape-based visualisation.
When \code{name = TRUE}, KEGG REST queries are issued for each node, which
can be slow for large graphs.
}
\examples{
## Load the precomputed example network; see buildKeggNetwork() for its construction
data(MetaPathNet_example_network)

## Define source and target node sets, then keep only nodes mapped in the network
source_nodes <- c("K00453", "K00463", "K01667")
target_nodes <- c("cpd:C00078", "cpd:C00328", "cpd:C02700")

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

## Extract a shortest-path subnetwork for visualisation
paths_trp <- findShortestPaths(
  network_table      = MetaPathNet_example_network,
  source_nodes       = map_src$mapped_nodes,
  target_nodes       = map_tgt$mapped_nodes,
  mode               = "out",
  output             = "network_matrix",
  name               = FALSE,
  distance_threshold = 6
)

## Visualise the shortest-path subnetwork in R
p_trp <- viewNetworkR(
  network_table = paths_trp,
  category      = TRUE,
  name          = FALSE,
  layout        = "fr",
  node_size     = 5,
  network_title = "Tryptophan shortest-path subnetwork"
)
print(p_trp)

}
\seealso{
\code{\link{viewNetworkCy}}, \code{\link{buildCrossSpeciesNetwork}},
\code{\link{buildKeggNetwork}}, \code{\link{findShortestPaths}}
}
