pseudobulk: Create a 'SingleCellExperiment' containing pseudo-bulk...

View source: R/pseudobulk.R

pseudobulkR Documentation

Create a 'SingleCellExperiment' containing pseudo-bulk samples

Description

Create a 'SingleCellExperiment' containing pseudo-bulk samples

Usage

pseudobulk(
  data,
  group_by,
  ...,
  aggregation_functions = list(counts = "rowSums2", .default = "rowMeans2"),
  col_data = NULL,
  make_colnames = TRUE,
  verbose = TRUE
)

Arguments

data

a 'SingleCellExperiment' or an object of a related class

group_by

an unquoted expression that can refer to columns in the 'colData()'. All observations with the same factor level are aggregated. The argument follows the same logic as dplyr::group_by(). The argument must wrapped using vars().

...

named expressions that summarize columns in 'colData()'. Each expression must produce a value of length 1. The arguments follow the same logic as dplyr::summarize().

aggregation_functions

a named list with functions that are used to aggregate the assays in the data.

col_data

additional data with ncol(data) rows. The group_by and named arguments can refer to the columns of the col_data in addition to the columns in colData(data) (assuming data is a SummarizedExperiment).

make_colnames

a boolean that decides if the column names are the concatenated values of group_by. Default: TRUE

verbose

a boolean that indicates if information about the process are printed Default: TRUE.

Value

a SingleCellExperiment object

Examples

 library(SingleCellExperiment)
 data <- data.frame(sample = sample(c("samp1", "samp2", "samp3"), size = 50, replace = TRUE),
       celltype = sample(c("T cells", "B cells", "Macrophages"), size = 50, replace = TRUE),
       size = rnorm(n = 50, mean = 40, sd = 15))
 Y <- matrix(rnbinom(n = 100 * 50, mu = 3, size = 1/3.1), nrow = 100, ncol = 50)
 sce <- SingleCellExperiment(Y, colData = data)
 aggr_sce <- pseudobulk(sce, group_by = vars(sample, celltype), size = mean(size))
 aggr_sce
 colData(aggr_sce)


const-ae/glmGamPoi documentation built on Feb. 13, 2024, 1:35 a.m.