downsample_immundata: Downsample ImmunData annotations at the repertoire level

View source: R/operations_downsample.R

downsample_immundataR Documentation

Downsample ImmunData annotations at the repertoire level

Description

Downsamples an ImmunData object by selecting barcodes within each repertoire. If repertoire schema is not defined, the entire dataset is treated as one repertoire.

The function uses a single parameter n:

  • If ⁠0 < n < 1⁠, n is treated as a proportion of repertoire size.

  • If n > 1, n is treated as an absolute target count.

  • If n == 1, an error is raised.

Downsampling is barcode-based. For count-based inputs (e.g. bulk), per-barcode counts (imd_n_chains) are trimmed when needed to reach the target.

Usage

downsample_immundata(idata, n, seed = NULL)

Arguments

idata

An ImmunData object.

n

Numeric scalar controlling downsampling amount. See details for interpretation.

seed

Optional integer scalar for reproducible sampling.

Value

A new ImmunData object with downsampled annotations.


immundata documentation built on April 4, 2026, 9:09 a.m.