| pseudobulk | R Documentation | 
Create a 'SingleCellExperiment' containing pseudo-bulk samples
pseudobulk(
  data,
  group_by,
  ...,
  aggregation_functions = list(counts = "rowSums2", .default = "rowMeans2"),
  col_data = NULL,
  make_colnames = TRUE,
  verbose = TRUE
)
| 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  | 
| ... | named expressions that summarize columns in 'colData()'. Each expression
must produce a value of length 1. The arguments follow the same logic
as  | 
| aggregation_functions | a named list with functions that are used to
aggregate the assays in the  | 
| col_data | additional data with  | 
| make_colnames | a boolean that decides if the column names are the concatenated
values of  | 
| verbose | a boolean that indicates if information about the process are printed Default:  | 
a SingleCellExperiment object
 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.