This function consolidates a list of BCR sequencing results to the level of the individual cell barcodes. Using the samples and ID parameters, the function will add the strings as prefixes to prevent issues with repeated barcodes. The resulting new barcodes will need to match the Seurat or SCE object in order to use, combineExpression(). Unlike combineTCR(), combineBCR produces a column CTstrict of an index of nucleotide sequence and the corresponding V and J genes using clonalCluster().

combineBCR(
  input.data,
  samples = NULL,
  ID = NULL,
  chain = "both",
  sequence = "nt",
  call.related.clones = TRUE,
  group.by = NULL,
  threshold = 0.85,
  cluster.method = "components",
  use.V = TRUE,
  use.J = TRUE,
  removeNA = FALSE,
  removeMulti = FALSE,
  filterMulti = TRUE,
  filterNonproductive = TRUE
)

Arguments

input.data

List of filtered contig annotations or outputs from loadContigs().

samples

A character vector of sample labels. Must be the same length as the input list.

ID

An optional character vector for additional sample identifiers.

chain

The chain to use for clustering when call.related.clones = TRUE. Passed to clonalCluster(). Default is "both".

sequence

The sequence type ("nt" or "aa") to use for clustering. Passed to clonalCluster(). Default is "nt".

Logical. If TRUE, uses clonalCluster() to identify related clones based on sequence similarity. If FALSE, defines clones by the exact V-gene and CDR3 amino acid sequence.

group.by

The column header used for to group clones. If (`NULL“), clusters will be calculated across samples.

threshold

The similarity threshold passed to clonalCluster() if call.related.clones = TRUE. See ?clonalCluster for details.

cluster.method

The clustering algorithm to use. Defaults to "components", which finds connected subgraphs.

use.V

Logical. If TRUE, sequences must share the same V gene to be clustered together.

use.J

Logical. If TRUE, sequences must share the same J gene to be clustered together.

removeNA

This will remove any chain without values.

removeMulti

Logical. If TRUE, removes cells that have more than one distinct heavy or light chain after processing.

filterMulti

Logical. If TRUE, filters multi-chain cells to retain only the most abundant IGH and IGL/IGK chains.

filterNonproductive

Logical. If TRUE, removes non-productive contigs from the analysis.

Value

A list of data frames, where each data frame represents a sample. Each row corresponds to a unique cell barcode, with columns detailing the BCR chains and the assigned clone ID.

Examples

# Data derived from the 10x Genomics intratumoral NSCLC B cells
BCR <- read.csv("https://www.borch.dev/uploads/contigs/b_contigs.csv")
combined <- combineBCR(BCR,
                       samples = "Patient1",
                       threshold = 0.85)