View source: R/operations_agg_strata.R
| agg_strata | R Documentation |
Use agg_strata() to place sample repertoires into biological comparison
groups, such as treatment arms, tissues, or disease groups.
Use this function after agg_repertoires() when several repertoires should be
analysed as one group. A stratum contains every repertoire with the same
value, or the same combination of values, in schema.
The unit being grouped is a whole repertoire. The function returns a new ImmunData object. The original object is not changed.
agg_strata(idata, schema, prefix = "Strata")
idata |
An ImmunData object with repertoires already defined. Use
|
schema |
A non-empty character vector. One or more repertoire-level
columns that define a stratum. For example, use |
prefix |
A non-empty character string. Prefix for the
automatic stratum labels. The default, |
If schema contains several columns, a separate stratum is created for each
observed combination. For example, c("Tissue", "Therapy") can define
separate blood and tumour strata within each treatment arm.
Calling agg_strata() again replaces the existing strata with groups defined
by the new schema.
A new ImmunData object in which every repertoire belongs to one
stratum. The $strata table lists the strata, their defining biological
values, and their automatic labels. Repertoire definitions and summary
statistics are preserved.
imd_strata_id is an internal identifier and can change when strata are
rebuilt. It is added to the repertoire table and to the underlying chain
annotations. strata_name is stored only in the smaller repertoire and
strata tables.
Calling agg_repertoires() again rebuilds the repertoires, so it removes the
existing strata. Call agg_strata() again after redefining repertoires.
agg_repertoires(), rename_strata(), ImmunData
library(immundata)
library(dplyr)
options(immundata.verbose = FALSE)
# Define sample repertoires using the biological metadata in the test data
idata <- get_test_idata() |>
agg_repertoires(c("Response", "Therapy"))
# Group the sample repertoires into treatment arms
treatment_groups <- idata |>
agg_strata(schema = "Therapy")
treatment_groups$repertoires |>
select(Therapy, Response, imd_strata_id, strata_name) |>
arrange(imd_strata_id)
# Expected result:
# Therapy Response imd_strata_id strata_name
# CAR-T PR 1 Strata1
# ICI FR 2 Strata2
# Each repertoire is now assigned to its treatment stratum. Any additional
# repertoire with the same Therapy value would receive the same stratum ID.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.