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|AnnDataUnion[dict,AnnData] AnnData object to work on.
- groupby :
str Group by this column from
obs. For instance, “sample” or “diagnosis”.- target_col :
str(default:'has_ir') Column on which to compute the abundance. Defaults to
has_irwhich computes the number of all cells that have a T-cell receptor.- normalize :
None|str|boolUnion[None,str,bool] (default:None) If
True, compute fractions of abundances relative to thegroupbycolumn 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|NoneOptional[int] (default:None) Only plot the first
max_colscolumns. If set toNone(the default) the function will raise aValueErrorif attempting to plot more than 100 columns. Set to0to 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_colsis applied.- **kwargs
Additional arguments passed to
scirpy.pl.base.bar().
- adata :
- Return type
- Returns
Axes object