scirpy.pl.group_abundance#
- scirpy.pl.group_abundance(adata, groupby, target_col='has_ir', *, airr_mod='airr', airr_key='airr', chain_idx_key='chain_indices', 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 (
AnnData|MuData) – AnnData or MuData object that contains AIRR information.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_irwhich computes the number of all cells that have a T-cell receptor.airr_mod (default:
'airr') – Name of the modality with AIRR information is stored in theMuDataobject. if anAnnDataobject is passed to the function, this parameter is ignored.airr_key (default:
'airr') – Key under which the AIRR information is stored in adata.obsm as an awkward array.chain_idx_key (default:
'chain_indices') – Key under which the chain indices are stored in adata.obsm. If chain indices are not present,index_chains()is run with default parameters.normalize (
None|str|bool(default:None)) – IfTrue, 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 (
None|int(default:None)) – Only plot the firstmax_colscolumns. If set toNone(the default) the function will raise aValueErrorif attempting to plot more than 100 columns. Set to0to 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_colsis applied.**kwargs – Additional arguments passed to
scirpy.pl.base.bar().
- Return type:
- Returns:
Axes object