% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/main.r
\name{plot_varmean}
\alias{plot_varmean}
\title{Generates a Mean-Variance Plot for CLR-transformed Cell Type Data.}
\usage{
plot_varmean(
  se,
  plot_title = "",
  highlight_hvcs = TRUE,
  labels = c("only_hvc", "all", "none"),
  plot_fit_line = FALSE,
  smooth_method = "lm"
)
}
\arguments{
\item{se}{A
\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}
object containing pre-calculated cell type variances in
\code{metadata(se)$celltype_variances} and the HVC list in
\code{metadata(se)$hvcs}}

\item{plot_title}{Character string (default: ""). The title for the plot.}

\item{highlight_hvcs}{Logical (default: \code{TRUE}). If \code{TRUE}, the
points corresponding to the Highly Variable Cell Types (HVCs) stored in the
SummarizedExperiment object are colored red.}

\item{labels}{Character (default: "only_hvc"). Options: "all" (label every
point), "none" (no labels), or "only_hvc" (label only the highly variable
cell types).}

\item{plot_fit_line}{Logical (default: \code{FALSE}). If \code{TRUE}, a
smoothing regression line is added to the plot.}

\item{smooth_method}{Character string (default: "lm"). The smoothing method
to use for the regression line if \code{plot_fit_line} is \code{TRUE}
(e.g., "lm" for linear model, "loess" for local regression).}
}
\value{
A \code{ggplot} object representing the mean-variance plot.
}
\description{
This function visualizes the relationship between the mean
abundance (CLR) and the variance (CLR) for each cell type, which is
typically used to identify Highly Variable Cell Types (HVCs).
}
\details{
If \code{highlight_hvcs} is \code{TRUE}, cell types previously
identified and stored in \code{metadata(se)$hvcs} will be highlighted in
red on the plot.
}
\examples{
data(example_data)
se <- ecoda(
    data = example_data$Gongsharma_full$cell_counts$authors_HR,
    metadata = example_data$Gongsharma_full$metadata
)

# 1. Generate the plot, highlighting HVCs (default)
plot_varmean(se, plot_title = "HVCs on Mean-Variance Plot")

# 2. Generate the plot without highlighting HVCs and add a fit line
plot_varmean(se,
    highlight_hvcs = FALSE,
    plot_fit_line = TRUE,
    smooth_method = "loess"
)
}
\seealso{
\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment},
\code{\link{get_celltype_variances}}
}
