View source: R/operations_agg_receptors.R
| agg_receptors | R Documentation |
agg_receptors() is a low-level function used during AIRR data ingestion. It
decides which sequence rows represent the same biological receptor and adds
package-standard identifiers and counts to the input table.
A receptor can be one chain or a pair of chains from the same cell. The
schema argument defines which sequence features and loci make two receptors
identical.
This function works with a prepared duckplyr table and returns a duckplyr
table. It does not accept or return an ImmunData object. Most analysis
workflows should provide the same arguments to read_repertoires(), which
calls agg_receptors() during import.
agg_receptors(
dataset,
schema,
barcode_col = NULL,
count_col = NULL,
locus_col = NULL,
umi_col = NULL,
verbose = getOption("immundata.verbose", TRUE)
)
dataset |
A duckplyr table containing AIRR sequence data, with one row
per chain or bulk clonotype. It must contain the columns named in |
schema |
Definition of receptor identity. Supply either:
A schema can contain at most two chain entries. Use syntax such as
|
barcode_col |
Name of the column containing cell barcodes. Supply this
for single-cell data. |
count_col |
Name of the column containing non-negative abundance values
in bulk repertoire data. These values are copied to |
locus_col |
Name of the column containing loci such as |
umi_col |
Name of the column containing per-chain UMI or read counts.
It is required when |
verbose |
Whether to print information about the selected processing
mode and loci. Defaults to |
The receptor features are the columns that define the identity of one chain. Two chains with the same values in all feature columns receive the same receptor identity in a single-chain analysis. Common features include V gene, J gene, and CDR3 amino acid sequence.
The function supports three input modes:
Uncounted sequence table: If neither barcode_col nor count_col is
supplied, every input row is treated as one observed chain. A synthetic
barcode is created for each row, and imd_n_chains is set to 1.
Bulk repertoire: If count_col is supplied, every input row receives a
synthetic barcode and its abundance is copied to imd_n_chains.
Single-cell repertoire: If barcode_col is supplied, rows are grouped
by cell. umi_col is required and imd_n_chains is set to 1 for every
retained cell-chain observation.
When one chain is specified in schema, only that locus is retained. If a
cell contains several chains from that locus, the row with the highest value
in umi_col is retained. If the highest values are tied, the first row is
retained.
When two chains are specified, only cells containing both requested loci are
retained. The selected chains are paired by barcode, and both rows receive
the same imd_receptor_id. Cells with incomplete pairs are excluded.
A relaxed pair such as c("IGH", "IGL|IGK") requires IGH and exactly one of
the two alternative light-chain loci. Cells containing both IGL and IGK are
excluded.
Numeric imd_receptor_id values identify receptors within the returned
table. The particular number assigned to a receptor is not a biological
identifier and may change when the data are aggregated again.
A duckplyr table containing the retained input rows and these package-standard columns:
imd_receptor_id: links rows that belong to the same receptor.
imd_barcode: contains the input cell barcode, or a synthetic row-level
barcode for uncounted and bulk data.
imd_chain_id: identifies an individual retained chain row.
imd_n_chains: contains 1 for uncounted and single-cell data, or the
value from count_col for bulk data.
imd_count: initialized to 0; receptor counts are calculated later by
agg_repertoires().
read_repertoires(), make_receptor_schema(), agg_repertoires(),
ImmunData
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.