% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils_hubgene.R
\name{extract_hub_genes}
\alias{extract_hub_genes}
\title{Extract Hub Genes from Selected Pathways (Enhanced with Leading Edge)}
\usage{
extract_hub_genes(gsea_task, pathway_ids, min_degree = 2, de_df = NULL)
}
\arguments{
\item{gsea_task}{GseaTask object}

\item{pathway_ids}{Character vector of pathway IDs to analyze}

\item{min_degree}{Minimum number of pathways a gene must appear in (default: 2)}

\item{de_df}{Optional differential expression data frame with stat column}
}
\value{
A data frame with columns:
  \item{gene}{Gene symbol}
  \item{degree}{Number of pathways the gene appears in}
  \item{pathways}{Comma-separated list of pathway IDs}
  \item{is_hub}{Logical indicating if gene is a hub (degree >= min_degree)}
  \item{stat}{Statistic value from de_df or geneList}
  \item{pathway_leading_edges}{List column with per-pathway leading edge status}
}
\description{
Extract hub genes with their leading edge status for each pathway.
A gene is considered a hub if it appears in at least min_degree pathways.
}
\examples{
# Load pre-computed GseaRes shipped with the package and pick a task
data(precomputed_gseares, package = "GSEAlens")

gsea_res <- precomputed_gseares
task <- extract_gsea_task(gsea_res, contrast_id = "untrt_vs_trt")

# Pick top 3 enriched pathway IDs from the task result
res_df <- as.data.frame(task$gsea_res)
top_ids <- utils::head(res_df$ID, 3)

# Extract hub genes appearing in >= 2 of these pathways
hubs <- extract_hub_genes(task, top_ids, min_degree = 2)
utils::head(hubs)
}
