scirpy.tl.clonal_expansion#
- scirpy.tl.clonal_expansion(adata, *, target_col='clone_id', expanded_in=None, breakpoints=(1, 2), clip_at=None, key_added='clonal_expansion', inplace=True, **kwargs)#
Adds a column to
obsrecording which clonotypes are expanded.nan`s in the clonotype column remain `nanin the output.- Parameters:
adata (
Union[AnnData,MuData,DataHandler]) – AnnData or MuData object that contains AIRR information.target_col (
str(default:'clone_id')) – Column containing the clontype annoataionexpanded_in (
Optional[str] (default:None)) – Calculate clonal expansion within groups. Usually makes sense to set this to the column containing sample annotation. If set to None, a clonotype counts as expanded if there’s any cell of the same clonotype across the entire dataset.breakpoints (
Sequence[int] (default:(1, 2))) –summarize clonotypes with a size smaller or equal than the specified numbers into groups. For instance, if this is (1, 2, 5), there will be four categories:
all clonotypes with a size of 1 (singletons)
all clonotypes with a size of 2
all clonotypes with a size between 3 and 5 (inclusive)
all clonotypes with a size > 5
clip_at (
Optional[int] (default:None)) – This argument is superseded bybreakpointsand is only kept for backwards-compatibility. Specifying a value ofclip_at = Nequals to specifyingbreakpoints = (1, 2, 3, ..., N)Specifying bothclip_atoverridesbreakpoints.key_added (
str(default:'clonal_expansion')) – Key under which the result will be stored inobs, ifinplaceisTrue. When the function is running onMuData, the result will be written to bothmdata.obs["{airr_mod}:{key_added}"]andmdata.mod[airr_mod].obs[key_added].inplace (
bool(default:True)) – IfTrue, a column with the result will be stored inobs. Otherwise the result will be returned.airr_mod – Name of the modality with AIRR information is stored in the
MuDataobject. if anAnnDataobject is passed to the function, this parameter is ignored.
- Return type:
- Returns:
Depending on the value of inplace, adds a column to adata or returns a Series with the clipped count per cell.