% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/main.r
\name{ecoda}
\alias{ecoda}
\title{Create an SummarizedExperiment object from various data types}
\usage{
ecoda(
  data = NULL,
  data_is_freq = FALSE,
  metadata = NULL,
  sample_col = NULL,
  celltype_col = NULL,
  get_pb = FALSE,
  variance_explained = 0.5,
  top_n_hvcs = NULL,
  pseudo_count = 0.5,
  pseudo_frac_min = 2/3,
  add_to = NULL
)
}
\arguments{
\item{data}{The primary input, which can be:
\itemize{
\item A \code{Seurat} object.
\item A \code{SingleCellExperiment} object.
\item A cell type x sample matrix or data frame (counts or frequencies).
}}

\item{data_is_freq}{Logical (default: \code{FALSE}). If \code{TRUE}, the
input \code{data} is treated as relative frequencies (proportions) rather
than raw counts.}

\item{metadata}{A data frame containing sample-level metadata. Required if
\code{data} is a matrix/data frame. If \code{data} is a single-cell object,
metadata is extracted automatically.}

\item{sample_col}{The metadata column name defining unique sample IDs.
Required if \code{data} is a single-cell object.}

\item{celltype_col}{The metadata column name defining cell type annotations.
Required if \code{data} is a single-cell object.}

\item{get_pb}{Logical (default: \code{FALSE}). If \code{TRUE}, calculates and
stores DESeq2-normalized pseudobulk data in \code{metadata(se)$pb}}

\item{variance_explained}{Numeric (default: 0.5). Proportion of variance used
to determine the number of highly variable cell types (HVCs).}

\item{top_n_hvcs}{Integer (optional). If provided, specifies the exact number
of top HVCs to select, overriding \code{variance_explained}.}

\item{pseudo_count}{Numeric (default: 0.5). Used if \code{rep_method =
"counts"}.}

\item{pseudo_frac_min}{Numeric (default: 2/3). The multiplier for the minimum
non-zero value when \code{rep_method = "frac_min"}.}

\item{add_to}{Character string. Should the value be added to \code{"all"}
cells or just the \code{"zeros"}?}
}
\value{
A new
\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}
object.
}
\description{
This is a smart constructor function used to initialize an
\link[SummarizedExperiment:SummarizedExperiment-class]{SummarizedExperiment}
object. It handles the processing of single-cell objects (\code{Seurat} or
\code{SingleCellExperiment}) or raw data frames to extract cell type counts,
calculate sample metadata, and optionally generate DESeq2-normalized
pseudobulk data.
}
\examples{
data(example_data)
Zhang <- example_data$Zhang
counts <- Zhang$cell_counts$authors_LR
freq <- calc_freq(counts)
metadata <- Zhang$metadata

se <- ecoda(data = counts, metadata = metadata)

se <- ecoda(data = freq, metadata = metadata)
}
