Bar plot of cell compositions
Usage
plotCellComposition(obj, col, width = NULL)
# S4 method for SingleCellExperiment
plotCellComposition(obj, col, width = NULL)
# S4 method for matrix
plotCellComposition(obj, col, width = NULL)
# S4 method for data.frame
plotCellComposition(obj, col, width = NULL)
Arguments
- obj
matrix of [cells] x [samples] or
SingleCellExperiment
fromaggregateToPseudoBulk
- col
array of colors. If missing, use default colors. If
names(col)
is the same asarrayNames(obj)
, then colors will be assigned by assay name#'- width
specify width of bars
Examples
library(muscat)
library(SingleCellExperiment)
data(example_sce)
# create pseudobulk for each sample and cell cluster
pb <- aggregateToPseudoBulk(example_sce,
assay = "counts",
cluster_id = "cluster_id",
sample_id = "sample_id",
verbose = FALSE
)
# show cell composition bar plots
plotCellComposition(pb)
# extract cell counts
df_cellCounts <- cellCounts(pb)
# show cell composition bar plots
plotCellComposition(df_cellCounts)