sc_utils.plot_composition¶
- sc_utils.plot_composition(adata: anndata._core.anndata.AnnData, group_by: str, color: str, relative: bool = False, palette: Optional[Collection] = None, plot_numbers: bool = False) matplotlib.axes._axes.Axes [source]¶
Plot composition of clusters or other metadata
Groups cells by one metadata field and plots stacked barplot colored by another metadata field. Common use case is to see which samples contribute to which clusters. Plots horizontally.
- Parameters
adata – Annotated data matrix
group_by – Name of the field to group by on y axis
color – Name of the field to color by
relative – Plot percentage for each cluster if
True
or absolute counts ifFalse
palette – Optional, pass your own palette
plot_numbers – If
True
, plot number of cells next to the bars
- Returns
Matplotlib axes with the plot.