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
- adata :
dict
|AnnData
Union
[dict
,AnnData
] AnnData object to work on.
- groupby :
str
str
Group by this column from
obs
. For instance, “sample” or “diagnosis”.- target_col :
str
str
(default:'has_ir'
) Column on which to compute the abundance. Defaults to
has_ir
which computes the number of all cells that have a T-cell receptor.- normalize :
None
|str
|bool
Union
[None
,str
,bool
] (default:None
) If
True
, 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 :
int
|None
Optional
[int
] (default:None
) Only plot the first
max_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 : {‘count’, ‘alphabetical’} |
Sequence
[str
]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 before
max_cols
is applied.- **kwargs
Additional arguments passed to
scirpy.pl.base.bar()
.
- adata :
- Return type
- Returns
Axes object