% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/main.r
\name{get_celltype_variances}
\alias{get_celltype_variances}
\title{Calculates the variance of cell types across samples.}
\usage{
get_celltype_variances(se, descending = TRUE)
}
\arguments{
\item{se}{An initialized
\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}
object containing CLR-transformed data in the \code{clr} assay}

\item{descending}{Logical (default: \code{TRUE}). If \code{TRUE}, the
returned data frame is sorted by variance in descending order.}
}
\value{
A data frame where each row is a cell type, containing:
\itemize{
\item \code{celltype}: The name of the cell type.
\item \code{avg_clr_abundance}: The mean CLR value for that
cell type across all samples.
\item \code{Variance}: The variance of the CLR values for that
cell type across all samples.
\item \code{cumulative_variance}: Cumulative sum of the variance,
ranked by variance.
\item \code{variance_exp}: The proportion of total variance
explained cumulatively.
}
}
\description{
This function takes the Centered Log-Ratio (CLR) transformed cell type
abundance data from an
\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}
object, calculates the mean CLR abundance and variance for each cell type. It
also calculates the cumulative variance explained by the cell types when
ranked by variance.
}
\examples{
data(example_data)
se <- ecoda(
    data = example_data$Gongsharma_full$cell_counts$authors_HR,
    metadata = example_data$Gongsharma_full$metadata
)

# Calculate variances without plotting, sorted by ascending variance
df_var_asc <- get_celltype_variances(
    se,
    descending = FALSE
)
}
\seealso{
\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment},
\code{\link{plot_varmean}}
}
