tacco.preprocessing.subsample_annotation¶
- subsample_annotation(adata, annotation_key=None, modification=None, range_factor=1, seed=42)[source]¶
Subsamples the observations to change the annotation fractions.
- Parameters:
adata – An
AnnData
containing categorical annotation to subsample.annotation_key – The .obs key with the categorical annotation. Is determined automatically if possible.
modification – A dict-like mapping the annotation categories to a float giving the fraction of this category to be kept. Unlisted categories are unchanged. Instead of the full name of a category, also unambiguous shortcuts are possible, i.e. the first few letters.
range_factor – A float giving a factor to scale down all categories a priori. A factor larger than 1 (e.g. 2) reduces all category observation and makes values larger than 1 in modification possible without duplicated observations.
seed – The random seed to use
- Returns:
Returns a
Series
with the random recaling factors.