scirpy.tl.clonal_expansion
- scirpy.tl.clonal_expansion(adata, *, target_col='clone_id', expanded_in=None, clip_at=3, key_added='clonal_expansion', inplace=True, **kwargs)
Adds a column to
obs
recording which clonotypes are expanded.nan`s in the clonotype column remain `nan
in the output.- Parameters
- adata :
AnnData
|MuData
|DataHandler
Union
[AnnData
,MuData
,DataHandler
] AnnData or MuData object that contains AIRR information.
- target_col :
str
(default:'clone_id'
) Column containing the clontype annoataion
- expanded_in :
str
|None
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.
- clip_at :
int
(default:3
) All clonotypes with more than
clip_at
clones will be summarized into a single category- key_added :
str
(default:'clonal_expansion'
) Key under which the result will be stored in
obs
, ifinplace
isTrue
. 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
) If
True
, 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
MuData
object. if anAnnData
object is passed to the function, this parameter is ignored.
- adata :
- Return type
- Returns
Depending on the value of inplace, adds a column to adata or returns a Series with the clipped count per cell.