% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/taxa_contribution_viz.R
\name{taxa_contribution_bar}
\alias{taxa_contribution_bar}
\title{Stacked bar plot of taxa contributions}
\usage{
taxa_contribution_bar(
  contrib_agg,
  metadata,
  group,
  function_ids = NULL,
  n_functions = 6,
  facet_by = "function",
  show_percentage = TRUE,
  color_theme = "default",
  font_size = 12,
  legend_position = "right",
  custom_title = NULL
)
}
\arguments{
\item{contrib_agg}{A data.frame from \code{\link{aggregate_taxa_contributions}}.}

\item{metadata}{A data.frame containing sample metadata.}

\item{group}{Character. Column name in \code{metadata} for grouping samples.}

\item{function_ids}{Optional character vector of function IDs to plot.
If NULL (default), the top \code{n_functions} by variance are shown.}

\item{n_functions}{Integer. Number of functions to show when
\code{function_ids} is NULL. Default 6.}

\item{facet_by}{Character. Facet by \code{"function"} (default) or
\code{"group"}.}

\item{show_percentage}{Logical. Normalize bars to 100\%? Default TRUE.}

\item{color_theme}{Character. Color theme name, passed to
\code{\link{get_color_theme}}. Default \code{"default"}.}

\item{font_size}{Numeric. Base font size. Default 12.}

\item{legend_position}{Character. Legend position. Default \code{"right"}.}

\item{custom_title}{Optional character string for the plot title.}
}
\value{
A \code{ggplot2} object.
}
\description{
Creates a stacked bar plot showing taxa contributions to predicted
functional abundances, faceted by function or sample group.
}
\examples{
\donttest{
# Synthetic example
agg <- data.frame(
  sample = rep(c("S1", "S2", "S3", "S4"), each = 3),
  function_id = rep(c("K00001", "K00002"), each = 6),
  taxon_label = rep(c("Genus_A", "Genus_B", "Other"), 4),
  contribution = runif(12)
)
metadata <- data.frame(
  sample = c("S1", "S2", "S3", "S4"),
  group = c("Control", "Control", "Treatment", "Treatment")
)
p <- taxa_contribution_bar(agg, metadata, group = "group")
}

}
