| collapse_counts | R Documentation |
Sums (or averages) the columns of a feature-by-cell count matrix
according to one or more cell-metadata columns. The result is a
feature-by-pseudobulk matrix where each column pools all cells that
share the same combination of metadata values (e.g. all cells from a
given donor in a given cluster). The resulting matrix is suitable
for bulk-RNA-seq tools such as DESeq2, edgeR, or limma. See the
pseudobulk vignette for an end-to-end walkthrough.
collapse_counts(
counts_mat,
meta_data,
varnames,
min_cells_per_group = 0,
keep_n = FALSE,
how = c("sum", "mean")[1]
)
counts_mat |
Counts matrix. Rows are features (genes), columns
are cells. Sparse ( |
meta_data |
data.frame of cell metadata. Must have one row per
column of |
varnames |
Character vector of column names in |
min_cells_per_group |
Drop pseudobulks containing fewer than
this many cells. Default |
keep_n |
If |
how |
|
A list with two elements:
counts_mat - feature-by-pseudobulk numeric matrix.
meta_data - data.frame with one row per pseudobulk
containing the columns named in varnames (and N if
keep_n = TRUE).
pseudobulk_deseq2(), compute_hash()
m <- matrix(sample.int(8, 100*500, replace=TRUE), nrow=100, ncol=500)
rownames(m) <- paste0("G", 1:100)
colnames(m) <- paste0("C", 1:500)
md1 <- sample(c("a", "b"), 500, replace=TRUE)
md2 <- sample(c("c", "d"), 500, replace=TRUE)
df <- data.frame(md1, md2)
data_collapsed <- collapse_counts(m, df, c("md1", "md2"))
head(data_collapsed$counts_mat)
head(data_collapsed$meta_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.