nichesphere.tl.downsample_class

nichesphere.tl.downsample_class#

nichesphere.tl.downsample_class(data, target_class, factor=6)#

Reduce the number of elements belonging to target_class by a given factor.

Useful when certain cell types are over-represented in the gated singlets data relative to their true in-tissue proportions, before building a background doublet distribution.

Parameters:
  • data (list) – Full list of cell type labels (one entry per cell).

  • target_class (list) – Cell types to downsample.

  • factor (int, default 6) – Reduction factor; the number of target-class elements is divided by this value.

Returns:

Combined list of non-target elements plus the downsampled target elements, in their original relative order.

Return type:

list