scirpy.tl.group_abundance#
- scirpy.tl.group_abundance(adata, groupby, target_col='has_ir', *, fraction=None, sort='count')#
Summarizes the number/fraction of cells of a certain category by a certain group.
Ignores NaN values.
- Parameters:
groupby (
str
) – Group by this column fromobs
. E.g, sample, or group.target_col (
str
(default:'has_ir'
)) – Caregorical variable fromobs
according 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.fraction (
Union
[str
,bool
,None
] (default:None
)) – IfTrue
, compute fractions of abundances relative to thegroupby
column 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 column names. 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.