Generate a pseudo-bulk of a SingleCellExperiment by summing counts of all cells from the same sample_var and celltype_var. The SCE is then re-annotated and library sizes calculated based on cell numbers.

pseudobulk_sce(
  sce,
  sample_var = "individual",
  celltype_var = "cluster_celltype",
  assay_name = "counts",
  keep_vars = c("individual", "group", "sex", "age", "PMI", "RIN", "seqdate")
)

Arguments

sce

a SingleCellExperiment object

sample_var

the variable name identifying unique samples

celltype_var

the variable name identifying cell types

assay_name

the assay name for pseudobulking (e.g. "counts")

keep_vars

metadata variables to keep from the SingleCellExperiment

Value

pb_sce a pseudobulk SingleCellExperiment object