% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/main.r
\name{calculate_pseudobulk}
\alias{calculate_pseudobulk}
\title{Calculate Pseudobulk from Count Matrix}
\usage{
calculate_pseudobulk(count_matrix, sample_ids, min_cells = 10)
}
\arguments{
\item{count_matrix}{A gene x cell count matrix (can be a dense matrix or
sparse Matrix). Gene identifiers should be row names and cell barcodes
should be column names.}

\item{sample_ids}{A vector of sample identifiers, one for each column (cell)
in \code{count_matrix}. The length must equal \code{ncol(count_matrix)}.
Must not contain \code{NA} values.}

\item{min_cells}{Minimum number of cells required per sample (default: 1).
Samples with fewer cells than this threshold will be excluded from the
final pseudobulk matrix.}
}
\value{
A gene x sample pseudobulk count matrix. The columns correspond to
the unique sample IDs, and the rows correspond to the genes.
}
\description{
This function aggregates single-cell count data into a "pseudobulk" matrix by
summing the counts for all cells belonging to the same sample ID. It is
robust to both dense and sparse count matrices. It also includes filtering
logic to exclude samples that do not meet a minimum cell count threshold.
}
\examples{
nrow <- 100
ncol <- 100
vals <- nrow * ncol
mat <- round(matrix(exp(rpois(vals, lambda = 3)), nrow = nrow, ncol = ncol))
rownames(mat) <- paste0("Gene", seq_len(ncol))
colnames(mat) <- paste0("Cell", seq_len(nrow))
ids <- rep(c("Sample1", "Sample2"), each = nrow / 2)
pb <- calculate_pseudobulk(count_matrix = mat, sample_ids = ids)
}
