% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ppi_analysis.R
\name{plot_network}
\alias{plot_network}
\title{Plot a condition-specific protein–protein interaction network with DEG annotations}
\usage{
plot_network(
  g,
  DEG_type,
  result_categories,
  cell_type = "",
  top_hubs = 20,
  show_barplot = FALSE
)
}
\arguments{
\item{g}{An igraph object representing the interaction network.}

\item{DEG_type}{Character string specifying the DEG category to visualize.}

\item{result_categories}{A data.frame containing DEG results with at least
the columns DEG_Type, Gene_Symbols, Male_avg_logFC, and Female_avg_logFC.}

\item{cell_type}{Optional character string used in the plot title.}

\item{top_hubs}{Integer specifying the number of hub genes to highlight.}

\item{show_barplot}{Logical indicating whether hub barplots are displayed.}
}
\value{
A ggplot object representing the network visualization.
}
\description{
Visualizes a gene or protein interaction network for a selected differential
expression category. Nodes are sized by degree centrality, and hub genes can be
optionally annotated with mini barplots showing sex-specific log fold changes.
}
\details{
Nodes represent genes or proteins and edges represent interactions. Node size
reflects degree centrality (number of connections). The top \code{top_hubs}
nodes by degree are labeled. When \code{show_barplot = TRUE}, mini barplots are
overlaid on hub nodes to display sex-specific log fold changes. The visualization
is restricted to the largest connected component of the network.
}
\examples{
# Minimal reproducible example (CRAN-safe)
library(igraph)

# Create a small toy network
g <- make_ring(5)
V(g)$name <- paste0("Gene", 1:5)

# Create minimal DEG table
result_categories <- data.frame(
  DEG_Type = rep("example", 5),
  Gene_Symbols = paste0("Gene", 1:5),
  Male_avg_logFC = runif(5, -1, 1),
  Female_avg_logFC = runif(5, -1, 1)
)

# Run function
plot_network(g, DEG_type = "example", result_categories = result_categories)

}
