scirpy.tl.group_abundance#
- scirpy.tl.group_abundance(adata, groupby, target_col='has_ir', *, airr_mod='airr', airr_key='airr', chain_idx_key='chain_indices', fraction=None, sort='count')#
Summarizes the number/fraction of cells of a certain category by a certain group.
Ignores NaN values.
- Parameters:
adata (
Union[AnnData,MuData,DataHandler]) – AnnData or MuData object that contains AIRR information.groupby (
str) – Group by this column fromobs. E.g, sample, or group.target_col (
str(default:'has_ir')) – Caregorical variable fromobsaccording to which the abundance/fractions will be computed. This defaults to “has_ir”, simply counting the number of cells with a detected IR by group.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.fraction (
None|str|bool(default:None)) – IfTrue, compute fractions of abundances relative to thegroupbycolumn rather than reporting abosolute numbers. Alternatively, a column name can be provided according to that the values will be normalized.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 categories. By providing an explicit list, the DataFrame can also be subsetted to specific categories.
- Return type:
- Returns:
Returns a data frame with the number (or fraction) of cells per group.