% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/update_graph_modules.R
\name{update_graph_modules}
\alias{update_graph_modules}
\title{Update module names in an existing graph object}
\usage{
update_graph_modules(
  graph_obj,
  modules,
  old_col = NULL,
  new_col = NULL,
  levels = NULL,
  allow_partial = TRUE
)
}
\arguments{
\item{graph_obj}{A graph object returned by \code{build_graph_*()}.}

\item{modules}{A named vector or a data frame used to rename modules.
The mapping is \code{old_module -> new_module}.}

\item{old_col}{Character. Old-module column name in \code{modules} when
\code{modules} is a data frame. Default \code{NULL} means auto-detect.}

\item{new_col}{Character. New-module column name in \code{modules} when
\code{modules} is a data frame. Default \code{NULL} means auto-detect.}

\item{levels}{Character vector. Optional explicit module order.
If \code{NULL}, order by module size (descending) and place
\code{"Others"} at the end.}

\item{allow_partial}{Logical (default = \code{TRUE}).
If \code{TRUE}, modules without rename rules keep original names.
If \code{FALSE}, all existing modules must be covered by \code{modules}.}
}
\value{
A new graph object with updated module-related node attributes:
  \code{Modularity}, \code{modularity2}, and \code{modularity3}
  (and \code{modularity} if that column exists).
}
\description{
Update module names in an existing graph object
}
\examples{
data(ppi_example)
obj <- build_graph_from_df(
  df              = ppi_example$ppi,
  node_annotation = ppi_example$annotation
)
obj2 <- update_graph_modules(
  graph_obj = obj,
  modules   = c("1" = "ModuleA", "2" = "ModuleB")
)
levels(get_graph_nodes(obj2)$Modularity)
}
