Skip to content

Describe one publicness selection rule

Source code

Description

Define a comparison population and inclusive incidence and abundance bounds for vdj_public(). The constructor stores a rule without evaluating data.

Usage

make_public_filter(
  repertoires = NULL,
  strata = NULL,
  incidence_by = c("repertoire", "strata"),
  min_incidence = NULL,
  max_incidence = NULL,
  min_count = NULL,
  max_count = NULL,
  min_proportion = NULL,
  max_proportion = NULL
)

Arguments

repertoires A numeric vector of repertoire IDs, or NULL for all.
strata Numeric strata IDs or existing strata_name labels, or NULL for all. When both selectors are supplied, use their intersection.
incidence_by A character scalar: "repertoire" counts distinct repertoires; "strata" counts existing strata.
min_incidence, max_incidence Non-negative whole-number bounds, or NULL. Without either bound, the minimum is one. An explicit maximum alone imposes no minimum, so zero incidence can pass.
min_count, max_count Numeric count bounds, or NULL.
min_proportion, max_proportion Numeric within-repertoire proportion bounds, or NULL.

Details

Abundance bounds qualify individual receptor occurrences before incidence is counted. Repeated chain/cell abundance values are deduplicated, never summed. For example, max_count = 10, min_incidence = 2 requires qualifying occurrences in two repertoires, allowing larger occurrences elsewhere. min_count = 5, max_incidence = 0 allows observed counts below five. Unknown selectors and empty comparison populations are errors during evaluation. Selectors do not match arbitrary metadata values.

Value

A list describing one rule for vdj_public().

See Also

vdj_public() for strata preparation and applying several rules.

Examples

library("immunarch")

# Count >= 5 in at least one repertoire.
abundant <- make_public_filter(min_count = 5)


idata <- get_test_idata() |>
  agg_repertoires(c("Response", "Therapy"))

vdj_public(idata, abundant, output = "df") |>
  dplyr::select(cdr3_aa, v_call, Therapy, imd_orig_count) |>
  head()
#> # A tibble: 6 × 4
#>   cdr3_aa          v_call      Therapy imd_orig_count
#>   <chr>            <chr>       <chr>            <dbl>
#> 1 ASSPGQGLDTQY     TRBV18*01   ICI                 12
#> 2 SVPGYYNEQF       TRBV29-1*01 ICI                  6
#> 3 ASTVPGQGSLHTDTQY TRBV10-2*01 ICI                  8
#> 4 ASSPGQGLDTQY     TRBV18*01   ICI                 12
#> 5 SVLPEGGELF       TRBV29-1*01 ICI                  5
#> 6 SAPRTDYGYT       TRBV20-1*01 ICI                  8
# At least one occurrence with count <= 10. Larger occurrences are allowed.
low_count <- make_public_filter(max_count = 10)

# No occurrence with count >= 5. Smaller counts are allowed.
below_threshold <- make_public_filter(min_count = 5, max_incidence = 0L)