scirpy.pl.group_abundance#
- scirpy.pl.group_abundance(adata, groupby, target_col='has_ir', *, normalize=None, max_cols=None, sort='count', **kwargs)#
Plots the number of cells per group, split up by a categorical variable.
`Plots the number of cells per group, split up by a categorical variable.
Generates a stacked bar chart with one bar per group. Stacks are colored according to the categorical variable specified in
target_col
.Ignores NaN values.
- Parameters:
groupby (
str
) – Group by this column fromobs
. For instance, “sample” or “diagnosis”.target_col (
str
(default:'has_ir'
)) – Column on which to compute the abundance. Defaults tohas_ir
which computes the number of all cells that have a T-cell receptor.normalize (
Union
[str
,bool
,None
] (default:None
)) – IfTrue
, compute fractions of abundances relative to thegroupby
column rather than reporting abosolute numbers. Alternatively, the name of a column containing a categorical variable can be provided, according to which the values will be normalized.max_cols (
Optional
[int
] (default:None
)) – Only plot the firstmax_cols
columns. If set toNone
(the default) the function will raise aValueError
if attempting to plot more than 100 columns. Set to0
to disable.sort (
Union
[Literal
['count'
,'alphabetical'
],Sequence
[str
]] (default:'count'
)) – How to arrange the dataframe columns. Default is by the category count (“count”). Other options are “alphabetical” or to provide a list of column names. By providing an explicit list, the DataFrame can also be subsetted to specific categories. Sorting (and subsetting) occurs beforemax_cols
is applied.**kwargs – Additional arguments passed to
scirpy.pl.base.bar()
.
- Return type:
- Returns:
Axes object